Re: Custom Window Resize Image
Re: Custom Window Resize Image
- Subject: Re: Custom Window Resize Image
- From: "Mr. Gecko" <email@hidden>
- Date: Sat, 6 Dec 2008 11:04:26 -0600
Thanks, I'm going to share what I did, just incase someone else is
wanting to know how to do this.
- (void)mouseDown:(NSEvent *)theEvent {
// Resize if mouse is in the growbox
isResizing = NSPointInRect([self convertPoint:[theEvent
locationInWindow] fromView:nil], growRect);
}
- (void)mouseDragged:(NSEvent *)theEvent {
// Get window frame to get the current size and position
NSRect frameR = [[self window] frame];
int dX = [theEvent deltaX];
int dY = [theEvent deltaY];
// If resizing than resize
if (isResizing) {
// Limit window size to 90 so the user doesn't bring it down to 0
if (frameR.size.width < 90 && dX < 1)
dX = 0;
if (frameR.size.height < 90 && dY < 1)
dY = 0;
// Resize the window
[[self window] setFrame:NSMakeRect(frameR.origin.x, frameR.origin.y
- dY, frameR.size.width + dX, frameR.size.height + dY) display:YES];
} else {
// Move the window if it isn't resizing
[[self window] setFrameOrigin:NSMakePoint(frameR.origin.x + dX,
frameR.origin.y - dY)];
}
}
- (void)mouseUp:(NSEvent *)theEvent {
// Minimize window if mouse is in minimze button
if (NSPointInRect([self convertPoint:[theEvent locationInWindow]
fromView:nil], minimizeRect)) {
[[self window] miniaturize:self];
}
// Set that were not resizing now that the user mouse isn't clicking
isResizing = NO;
}
On Dec 5, 2008, at 5:39 PM, Ron Fleckner wrote:
Hi Mr. Gecko,
I made a borderless window which I wanted to be resizable, so I put
a copy of resize.png in my app's resources. During startup, I add it
to the bottom right corner of my window, then by implementing mouse
down and mouse dragged, implement my own window resizing mechanism.
It's a little bit of work but the end result works fine. In -
mouseDown, I check if the event is in the grow box region, and set a
BOOL isResizing ivar. In -mouseDragged I check isResizing to see if
I need to resize the window or just let it be moved around.
Ron
On 05/12/2008, at 3:28 PM, Mr. Gecko wrote:
Ok so I've done some looking around more in the documents, would it
be possible to make a button that has a picture of the grow box and
than have it send an action when it's dragged using
NSLeftMouseDraggedMask.
On Dec 4, 2008, at 8:47 PM, Sean McBride wrote:
Ron Fleckner (email@hidden) on 2008-12-04 12:52 AM
said:
Hello, I'm writing a custom window for my application, but I can't
figure out how to make a custom resize image... Any help?
Thanks,
Mr. Gecko
Unless you actually want a 'custom' resize image, you can use the
real
one found at /System/Library/WidgetResources/resize.png
If you wanted to draw the standard grow box, you could use
HIThemeDrawGrowBox(). Relying on that file being at that location
is fragile.
But...
Mr. Gecko (email@hidden) on 2008-12-04 1:01 PM said:
I'm not needing to know how to draw it, I'm needing to know how to
make it functional. so if someone clicks and drags it would
resize the
window.
That's not at all what you asked. :) Perhaps you could clarify? To
change a window's size you can use the setFrame... methods.
Sean
_______________________________________________
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