ui/cocoa/MainWindow.m

changeset 1176
87a906a990e3
parent 1174
8b8da1adef7d
equal deleted inserted replaced
1175:1943f7411e50 1176:87a906a990e3
41 41
42 42
43 43
44 @implementation MainWindow 44 @implementation MainWindow
45 45
46 - (MainWindow*)init:(UiObject*)obj withSidebar:(BOOL)hasSidebar withSplitview:(BOOL)hasSplitview{ 46 - (MainWindow*)init:(UiObject*)obj withSidebar:(BOOL)hasSidebar withSplitview:(BOOL)hasSplitview width:(int)width height:(int)height {
47 NSRect frame = NSMakeRect(300, 200, 600, 500); 47 NSRect frame = NSMakeRect(300, 200, width, height);
48 48
49 self = [self initWithContentRect:frame 49 self = [self initWithContentRect:frame
50 styleMask:NSWindowStyleMaskTitled | 50 styleMask:NSWindowStyleMaskTitled |
51 NSWindowStyleMaskResizable | 51 NSWindowStyleMaskResizable |
52 NSWindowStyleMaskClosable | 52 NSWindowStyleMaskClosable |
141 } 141 }
142 142
143 return self; 143 return self;
144 } 144 }
145 145
146 - (void) saveWindowSize {
147 CGSize size = self.frame.size;
148 if(size.width > 0 && size.height > 0) {
149 char width_str[32];
150 char height_str[32];
151 snprintf(width_str, 32, "%d", (int)size.width);
152 snprintf(height_str, 32, "%d", (int)size.height);
153 ui_set_property("ui.window.width", width_str);
154 ui_set_property("ui.window.height", height_str);
155 }
156 }
157
146 - (BOOL) getIsVisible { 158 - (BOOL) getIsVisible {
147 return [self isVisible]; 159 return [self isVisible];
148 } 160 }
149 161
150 - (void) setVisible:(BOOL)visible { 162 - (void) setVisible:(BOOL)visible {
173 // warn about invalid reference counting 185 // warn about invalid reference counting
174 NSLog(@"Error: UiObject %p ref == 0\n", obj); 186 NSLog(@"Error: UiObject %p ref == 0\n", obj);
175 } 187 }
176 188
177 if(obj->ref == 0) { 189 if(obj->ref == 0) {
190 [self saveWindowSize];
178 // this cleans up any widget references from the context 191 // this cleans up any widget references from the context
179 uic_context_prepare_close(obj->ctx); 192 uic_context_prepare_close(obj->ctx);
180
181 [[WindowManager sharedWindowManager] closeWindow:self]; 193 [[WindowManager sharedWindowManager] closeWindow:self];
182 } 194 }
183 } 195 }
184 196
185 - (void) dealloc { 197 - (void) dealloc {

mercurial