Changeset 4956
- Timestamp:
- 10/16/07 17:29:56 (9 months ago)
- Files:
-
- WiredAdditions/trunk/WIWindowController.m (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredAdditions/trunk/WIWindowController.m
r4707 r4956 30 30 #import <WiredAdditions/WIWindowController.h> 31 31 32 static NSMutableDictionary *_WIWindowController_frames; 33 static NSMutableArray *_WIWindowController_windows; 32 #define WIWindowControllerCascadeOffsetX 20.0 33 #define WIWindowControllerCascadeOffsetY 20.0 34 35 36 static NSMutableDictionary *_WIWindowController_frames; 37 static NSMutableArray *_WIWindowController_windows; 38 34 39 35 40 @interface WIWindowController(Private) … … 96 101 - (void)_loadWindowFrame { 97 102 NSScreen *screen; 98 NSString *key, *frame, *previousFrame; 99 NSRect rect, previousRect; 100 NSSize size; 103 NSString *key, *savedFrameString, *cascadedFrameString; 104 NSRect frame, previousFrame, cascadedFrame, savedFrame; 101 105 102 106 if([_WI_windowFrameAutosaveName length] > 0) { 103 107 key = [NSSWF:@"WIWindowController %@ Frame", _WI_windowFrameAutosaveName]; 104 frame= [[NSUserDefaults standardUserDefaults] objectForKey:key];105 size = [[self window] frame].size;106 107 if([ framelength] > 0)108 rect = NSRectFromString(frame);108 savedFrameString = [[NSUserDefaults standardUserDefaults] objectForKey:key]; 109 previousFrame = [[self window] frame]; 110 111 if([savedFrameString length] > 0) 112 savedFrame = NSRectFromString(savedFrameString); 109 113 else 110 rect = [[self window] frame]; 114 savedFrame = previousFrame; 115 116 if([self shouldSaveWindowFrameOriginOnly]) { 117 frame.origin.x = savedFrame.origin.x; 118 frame.origin.y = savedFrame.origin.y + savedFrame.size.height - previousFrame.size.height; 119 frame.size = previousFrame.size; 120 } else { 121 frame = savedFrame; 122 } 111 123 112 124 if(_WI_shouldCascadeWindows) { 113 previousFrame = [_WIWindowController_frames objectForKey:key]; 114 115 if([previousFrame length] > 0) { 116 previousRect = NSRectFromString(previousFrame); 117 rect.origin = previousRect.origin; 125 cascadedFrameString = [_WIWindowController_frames objectForKey:key]; 126 127 if([cascadedFrameString length] > 0) { 128 cascadedFrame = NSRectFromString(cascadedFrameString); 129 130 if([self shouldSaveWindowFrameOriginOnly]) { 131 frame.origin.x = cascadedFrame.origin.x; 132 frame.origin.y = cascadedFrame.origin.y + cascadedFrame.size.height - previousFrame.size.height; 133 } else { 134 frame.origin = cascadedFrame.origin; 135 } 118 136 } 119 137 120 rect.origin.x += 20.0;121 rect.origin.y -= 20.0;122 123 if( rect.origin.x < 0.0 || rect.origin.y < 0.0) {138 frame.origin.x += WIWindowControllerCascadeOffsetX; 139 frame.origin.y -= WIWindowControllerCascadeOffsetY; 140 141 if(frame.origin.x < 0.0 || frame.origin.y < 0.0) { 124 142 screen = [[self window] screen]; 125 143 126 rect.origin.x = 20.0;127 rect.origin.y = [screen frame].size.height - 20.0;144 frame.origin.x = WIWindowControllerCascadeOffsetX; 145 frame.origin.y = [screen frame].size.height - WIWindowControllerCascadeOffsetY; 128 146 } 129 147 } 130 148 131 if([self shouldSaveWindowFrameOriginOnly]) 132 rect.size = size; 133 134 [[self window] setFrame:rect display:NO]; 149 [[self window] setFrame:frame display:NO]; 135 150 136 151 [_WIWindowController_windows addObject:[self window]]; 137 [_WIWindowController_frames setObject:NSStringFromRect( rect) forKey:key];152 [_WIWindowController_frames setObject:NSStringFromRect(frame) forKey:key]; 138 153 } 139 154 } … … 143 158 - (void)_saveWindowFrame { 144 159 NSString *key, *value; 145 NSRect rect;146 147 if([_WI_windowFrameAutosaveName length] > 0) { 148 rect= [[self window] frame];160 NSRect frame; 161 162 if([_WI_windowFrameAutosaveName length] > 0) { 163 frame = [[self window] frame]; 149 164 150 165 if(_WI_shouldCascadeWindows) { 151 rect.origin.x -= 20; 152 rect.origin.y += 20; 153 } 154 155 166 frame.origin.x -= WIWindowControllerCascadeOffsetY; 167 frame.origin.y += WIWindowControllerCascadeOffsetX; 168 } 156 169 157 170 key = [NSSWF:@"WIWindowController %@ Frame", _WI_windowFrameAutosaveName]; 158 value = NSStringFromRect( rect);171 value = NSStringFromRect(frame); 159 172 160 173 [[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
