Frameworks/AIUtilities Framework/Source/AIBorderlessWindow.m
branchadium-1.5.11
changeset 6016 325e2ab3406f
parent 5997 d88e6711d0e0
equal deleted inserted replaced
6014:fcb71cb71a3d 6016:325e2ab3406f
    24 - (BOOL)dockWindowFrame:(NSRect *)inFrame toScreenFrame:(NSRect)screenFrame;
    24 - (BOOL)dockWindowFrame:(NSRect *)inFrame toScreenFrame:(NSRect)screenFrame;
    25 @end
    25 @end
    26 
    26 
    27 @implementation AIBorderlessWindow
    27 @implementation AIBorderlessWindow
    28 
    28 
    29 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
    29 - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag
    30 
    30 {
    31     //Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
    31     //Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
    32     //for the styleMask so that the window doesn't have a title bar
    32     //for the styleMask so that the window doesn't have a title bar
    33    if ((self = [super initWithContentRect:contentRect 
    33    if ((self = [super initWithContentRect:contentRect 
    34 							styleMask:NSBorderlessWindowMask
    34 							styleMask:NSBorderlessWindowMask
    35 							  backing:NSBackingStoreBuffered 
    35 							  backing:NSBackingStoreBuffered 
   167 - (BOOL)dockWindowFrame:(NSRect *)inWindowFrame toScreenFrame:(NSRect)inScreenFrame
   167 - (BOOL)dockWindowFrame:(NSRect *)inWindowFrame toScreenFrame:(NSRect)inScreenFrame
   168 {
   168 {
   169 	BOOL	changed = NO;
   169 	BOOL	changed = NO;
   170 	
   170 	
   171 	//Left
   171 	//Left
   172 	if ((labs(NSMinX((*inWindowFrame)) - NSMinX(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   172     if ((fabs(NSMinX((*inWindowFrame)) - NSMinX(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   173 		(*inWindowFrame).origin.x = inScreenFrame.origin.x;
   173 		(*inWindowFrame).origin.x = inScreenFrame.origin.x;
   174 		changed = YES;
   174 		changed = YES;
   175 	}
   175 	}
   176 	
   176 	
   177 	//Bottom
   177 	//Bottom
   178 	if ((labs(NSMinY(*inWindowFrame) - NSMinY(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   178     if ((fabs(NSMinY(*inWindowFrame) - NSMinY(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   179 		(*inWindowFrame).origin.y = inScreenFrame.origin.y;
   179 		(*inWindowFrame).origin.y = inScreenFrame.origin.y;
   180 		changed = YES;
   180 		changed = YES;
   181 	}
   181 	}
   182 	
   182 	
   183 	//Right
   183 	//Right
   184 	if ((labs(NSMaxX(*inWindowFrame) - NSMaxX(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   184     if ((fabs(NSMaxX(*inWindowFrame) - NSMaxX(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   185 		(*inWindowFrame).origin.x -= NSMaxX(*inWindowFrame) - NSMaxX(inScreenFrame);
   185 		(*inWindowFrame).origin.x -= NSMaxX(*inWindowFrame) - NSMaxX(inScreenFrame);
   186 		changed = YES;
   186 		changed = YES;
   187 	}
   187 	}
   188 	
   188 	
   189 	//Top
   189 	//Top
   190 	if ((labs(NSMaxY(*inWindowFrame) - NSMaxY(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   190     if ((fabs(NSMaxY(*inWindowFrame) - NSMaxY(inScreenFrame)) < BORDERLESS_WINDOW_DOCKING_DISTANCE)) {
   191 		(*inWindowFrame).origin.y -= NSMaxY(*inWindowFrame) - NSMaxY(inScreenFrame);
   191 		(*inWindowFrame).origin.y -= NSMaxY(*inWindowFrame) - NSMaxY(inScreenFrame);
   192 		changed = YES;
   192 		changed = YES;
   193 	}
   193 	}
   194 	
   194 	
   195 	return changed;
   195 	return changed;