• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom NSWindow drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSWindow drawing


  • Subject: Re: Custom NSWindow drawing
  • From: "John C. Randolph" <email@hidden>
  • Date: Sat, 02 Jan 2010 13:14:50 -0800


On Jan 2, 2010, at 10:44 AM, PCWiz wrote:

The only reason I dont want to completely draw the whole window is that resizing is not easily implemented with a custom window.

Sure it is. This is how I did it in the "Core Data Stickies" example:

#import "StickyResizeCornerView.h"

@implementation StickyResizeCornerView

- (void)drawRect:(NSRect)rect
{
NSRect bounds = [self bounds];
[[NSColor brownColor] set];
[NSBezierPath strokeLineFromPoint:NSZeroPoint toPoint:NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))];
}


- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
    return YES;
}

- (void)mouseDragged:(NSEvent *)theEvent
{
	NSWindow *window = [self window];
	NSRect frame = [window frame];
    float newHeight = frame.size.height + [theEvent deltaY];
    float newWidth  = frame.size.width  + [theEvent deltaX];
    NSSize minSize = [window minSize];
    if (newHeight >= minSize.height) {
        frame.size.height = newHeight;
        frame.origin.y -= [theEvent deltaY];
    }
    if (newWidth >= minSize.width)
        frame.size.width = newWidth;
    [window setFrame:frame display:YES];
}


-jcr _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Custom NSWindow drawing (From: John Joyce <email@hidden>)
 >Re: Custom NSWindow drawing (From: PCWiz <email@hidden>)

  • Prev by Date: Re: Saving position in NSTextView
  • Next by Date: Re: Make NSWindow immovable by dragging bottom bar
  • Previous by thread: Re: Custom NSWindow drawing
  • Next by thread: Re: ABPerson initWithVCardRepresentation without addRecord
  • Index(es):
    • Date
    • Thread