Frameworks/AIUtilities Framework/Source/AIDockingWindow.m
branchadium-1.5.11
changeset 6016 325e2ab3406f
parent 5997 d88e6711d0e0
equal deleted inserted replaced
6014:fcb71cb71a3d 6016:325e2ab3406f
    35 - (void)windowDidToggleToolbarShown:(id)sender;
    35 - (void)windowDidToggleToolbarShown:(id)sender;
    36 @end
    36 @end
    37 
    37 
    38 @implementation AIDockingWindow
    38 @implementation AIDockingWindow
    39 
    39 
    40 - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
    40 - (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag
    41 {
    41 {
    42 	if ((self = [super initWithContentRect:contentRect styleMask:aStyle backing:bufferingType defer:flag])) {
    42 	if ((self = [super initWithContentRect:contentRect styleMask:style backing:backingStoreType defer:flag])) {
    43 		[self _initDockingWindow];
    43 		[self _initDockingWindow];
    44 	}
    44 	}
    45 
    45 
    46 	return self;
    46 	return self;
    47 }
    47 }
   155 
   155 
   156 //Dock the passed window frame if it's close enough to the screen edges
   156 //Dock the passed window frame if it's close enough to the screen edges
   157 - (NSRect)dockWindowFrame:(NSRect)windowFrame toScreenFrame:(NSRect)screenFrame
   157 - (NSRect)dockWindowFrame:(NSRect)windowFrame toScreenFrame:(NSRect)screenFrame
   158 {
   158 {
   159 	//Left
   159 	//Left
   160 	if (labs(NSMinX(windowFrame) - NSMinX(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   160     if (fabs(NSMinX(windowFrame) - NSMinX(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   161 		windowFrame.origin.x = screenFrame.origin.x;
   161 		windowFrame.origin.x = screenFrame.origin.x;
   162 	}
   162 	}
   163 	
   163 	
   164 	//Bottom
   164 	//Bottom
   165 	if (labs(NSMinY(windowFrame) - NSMinY(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   165     if (fabs(NSMinY(windowFrame) - NSMinY(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   166 		windowFrame.origin.y = screenFrame.origin.y;
   166 		windowFrame.origin.y = screenFrame.origin.y;
   167 	}
   167 	}
   168 	
   168 	
   169 	//Right
   169 	//Right
   170 	if (labs(NSMaxX(windowFrame) - NSMaxX(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   170     if (fabs(NSMaxX(windowFrame) - NSMaxX(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   171 		windowFrame.origin.x -= NSMaxX(windowFrame) - NSMaxX(screenFrame);
   171 		windowFrame.origin.x -= NSMaxX(windowFrame) - NSMaxX(screenFrame);
   172 	}
   172 	}
   173 	
   173 	
   174 	//Top
   174 	//Top
   175 	if (labs(NSMaxY(windowFrame) - NSMaxY(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   175     if (fabs(NSMaxY(windowFrame) - NSMaxY(screenFrame)) < WINDOW_DOCKING_DISTANCE) {
   176 		windowFrame.origin.y -= NSMaxY(windowFrame) - NSMaxY(screenFrame);
   176 		windowFrame.origin.y -= NSMaxY(windowFrame) - NSMaxY(screenFrame);
   177 	}
   177 	}
   178 	
   178 	
   179 	return windowFrame;
   179 	return windowFrame;
   180 }
   180 }