/CPView+OffsetCorners.j

http://github.com/rheimbuch/YED · Unknown · 52 lines · 35 code · 17 blank · 0 comment · 0 complexity · 8d6800c9b4736f72669be29484f07e5d MD5 · raw file

  1. @import <AppKit/CPView.j>
  2. @implementation CPView (OffsetCorners)
  3. - (void)offsetFrameTopLeft:(CGPoint)delta
  4. {
  5. var currentFrame = [self frame],
  6. currentLocation = currentFrame.origin;
  7. var newFrame = CGRectMake(currentLocation.x+delta.x , currentLocation.y+delta.y, CGRectGetWidth(currentFrame) - delta.x, CGRectGetHeight(currentFrame) - delta.y);
  8. [self setFrame:newFrame];
  9. [self setNeedsDisplay:YES];
  10. }
  11. - (void)offsetFrameTopRight:(CGPoint)delta
  12. {
  13. var currentFrame = [self frame],
  14. currentLocation = currentFrame.origin;
  15. var newFrame = CGRectMake(currentLocation.x , currentLocation.y+delta.y, CGRectGetWidth(currentFrame) + delta.x, CGRectGetHeight(currentFrame) - delta.y);
  16. [self setFrame:newFrame];
  17. [self setNeedsDisplay:YES];
  18. }
  19. - (void)offsetFrameBottomRight:(CGPoint)delta
  20. {
  21. var currentFrame = [self frame],
  22. currentLocation = currentFrame.origin;
  23. var newFrame = CGRectMake(currentLocation.x , currentLocation.y, CGRectGetWidth(currentFrame) + delta.x, CGRectGetHeight(currentFrame) + delta.y);
  24. [self setFrame:newFrame];
  25. [self setNeedsDisplay:YES];
  26. }
  27. - (void)offsetFrameBottomLeft:(CGPoint)delta
  28. {
  29. var currentFrame = [self frame],
  30. currentLocation = currentFrame.origin;
  31. var newFrame = CGRectMake(currentLocation.x + delta.x , currentLocation.y, CGRectGetWidth(currentFrame) - delta.x, CGRectGetHeight(currentFrame) + delta.y);
  32. [self setFrame:newFrame];
  33. [self setNeedsDisplay:YES];
  34. }
  35. @end