Re: Resizable Borderless Window
Re: Resizable Borderless Window
- Subject: Re: Resizable Borderless Window
- From: Jan Hülsmann <email@hidden>
- Date: Sat, 28 Feb 2004 14:15:15 +0100
Am 24.02.2004 um 02:02 schrieb Darkshadow:
Also, two issues with the resizing:
I do all in mouseDown and mouseDragged, resizing bahaves OK with the
code below.
HTH,
--Jan--
- (void)mouseDown:(NSEvent *)theEvent
{
/* get themouse location in local coordinates */
initialMouseLocation = [theEvent locationInWindow];
if( initialMouseLocation.x >= ([self frame].size.width - 15) &&
initialMouseLocation.y <= 15 )
{
isResizeOperation= YES;
initialWindowFrame= [self frame];
}
else
{
isResizeOperation= NO;
}
}
- (void)mouseDragged:(NSEvent *)theEvent
{
if(isResizeOperation) // resize the window
{
/* get the current local mouse location via the global
coordinates,
this ensures we get the right coordinates in case the resizing
of the window is not following fast enough */
NSPoint currentLocation = [self convertBaseToScreen:[self
mouseLocationOutsideOfEventStream]];
currentLocation.x -= initialWindowFrame.origin.x;
currentLocation.y -= initialWindowFrame.origin.y;
float deltaX= currentLocation.x - initialMouseLocation.x;
NSRect newFrame= initialWindowFrame;
newFrame.size.width= initialWindowFrame.size.width + deltaX;
/* your min-size goes here,
you can do something like this: */
if( newFrame.size.width < 100 )
newFrame.size.width= 100;
/* set the height according to the windows aspect-ratio */
newFrame.size.height= newFrame.size.width / [self
aspectRatio].width * [self aspectRatio].height;
float deltaY= newFrame.size.height -
initialWindowFrame.size.height;
newFrame.origin.x= initialWindowFrame.origin.x;
newFrame.origin.y= initialWindowFrame.origin.y - deltaY;
[self setFrame:newFrame display:YES];
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.