comparison dynamin/gui/window.d @ 54:3738a2d0bac3

Fix comments and add blank lines.
author Jordan Miner <jminer7@gmail.com>
date Sat, 08 Aug 2009 15:31:24 -0500
parents ad551ec36b75
children c138461bf845
comparison
equal deleted inserted replaced
53:6e33b00595e9 54:3738a2d0bac3
109 } 109 }
110 110
111 /** 111 /**
112 * The different types of borders that a window may have. 112 * The different types of borders that a window may have.
113 * These do not affect whether the window is resizable-- 113 * These do not affect whether the window is resizable--
114 * use Window.Resizable for that. 114 * use Window.resizable for that.
115 */ 115 */
116 enum WindowBorderStyle { 116 enum WindowBorderStyle {
117 /** Specifies that the window has no border around the content area. */ 117 /** Specifies that the window has no border around the content area. */
118 None, 118 None,
119 /** 119 /**
120 * Specifies that the window has a normal border with a title bar, icon, 120 * Specifies that the window has a normal border with a title bar, icon,
121 * and minimize button. 121 * and minimize button.
122 */ 122 */
123 Normal, 123 Normal,
124 /** Specifies that the window has a normal border without a minimize button. */ 124 /**
125 * Specifies that the window has a normal border without a minimize button.
126 */
125 Dialog, 127 Dialog,
126 /** Specifies that the window has the border of a floating tool box. */ 128 /** Specifies that the window has the border of a floating tool box. */
127 Tool 129 Tool
128 } 130 }
129 131
173 _minSize = Size(0, 0); 175 _minSize = Size(0, 0);
174 _maxSize = Size(0, 0); 176 _maxSize = Size(0, 0);
175 _borderStyle = WindowBorderStyle.Normal; 177 _borderStyle = WindowBorderStyle.Normal;
176 recreateHandle(); 178 recreateHandle();
177 } 179 }
180 /// ditto
178 this(string text) { 181 this(string text) {
179 this(); 182 this();
180 this.text = text; 183 this.text = text;
181 } 184 }
182 185
196 _content.elasticY ? 0 : best.height); 199 _content.elasticY ? 0 : best.height);
197 resizable = _content.maxSize != best; // avoid calling elasticX/Y again 200 resizable = _content.maxSize != best; // avoid calling elasticX/Y again
198 _content.size = best; 201 _content.size = best;
199 202
200 } 203 }
204
201 bool ignoreResize; 205 bool ignoreResize;
202 void whenContentResized(EventArgs e) { 206 void whenContentResized(EventArgs e) {
203 if(ignoreResize) 207 if(ignoreResize)
204 return; 208 return;
205 ignoreResize = true; 209 ignoreResize = true;
241 Application.eventThread is null, 245 Application.eventThread is null,
242 "Controls must be accessed and changed only on the event thread. Use invokeNow() from other threads."); 246 "Controls must be accessed and changed only on the event thread. Use invokeNow() from other threads.");
243 return _handle; 247 return _handle;
244 } 248 }
245 249
250 ///
246 bool handleCreated() { return backend_handleCreated; } 251 bool handleCreated() { return backend_handleCreated; }
247 252
253 ///
248 void recreateHandle() { 254 void recreateHandle() {
249 backend_recreateHandle(); 255 backend_recreateHandle();
250 } 256 }
251 257
252 override protected Graphics quickCreateGraphics() { 258 override protected Graphics quickCreateGraphics() {
266 override Point screenToContent(Point pt) { 272 override Point screenToContent(Point pt) {
267 return pt - location; 273 return pt - location;
268 } 274 }
269 override bool topLevel() { return true; } 275 override bool topLevel() { return true; }
270 override Container parent() { return null; } 276 override Container parent() { return null; }
277
271 // TODO: because you should always be able to click a window from 278 // TODO: because you should always be able to click a window from
272 // the taskbar, then show it on taskbar if window has an owner, 279 // the taskbar, then show it on taskbar if window has an owner,
273 // but don't if it does not 280 // but don't if it does not
274 void owner(Window w) { 281 void owner(Window w) {
275 _owner = w; 282 _owner = w;
276 if(!handleCreated) 283 if(!handleCreated)
277 return; 284 return;
278 recreateHandle(); 285 recreateHandle();
279 } 286 }
280 Window owner() { return _owner; } 287 Window owner() { return _owner; }
288
281 alias Control.visible visible; 289 alias Control.visible visible;
282 void visible(bool b) { 290 void visible(bool b) {
283 _visible = b; 291 _visible = b;
284 backend_visible = b; 292 backend_visible = b;
285 } 293 }
348 super.location(pt); 356 super.location(pt);
349 if(!handleCreated) 357 if(!handleCreated)
350 return; 358 return;
351 backend_location = pt; 359 backend_location = pt;
352 } 360 }
361
353 alias Control.size size; 362 alias Control.size size;
354 void size(Size size) { 363 void size(Size size) {
355 super.size(size); 364 super.size(size);
356 _content.size = size - _borderSize; 365 _content.size = size - _borderSize;
357 if(!handleCreated) 366 if(!handleCreated)
358 return; 367 return;
359 backend_size = size; 368 backend_size = size;
360 } 369 }
361 /** 370
362 * Gets the size of the border/frame around this window.
363 */
364 BorderSize borderSize() {
365 return _borderSize;
366 }
367 alias Control.text text; 371 alias Control.text text;
368 void text(string str) { 372 void text(string str) {
369 super.text(str); 373 super.text(str);
370 if(!handleCreated) 374 if(!handleCreated)
371 return; 375 return;
372 backend_text = str; 376 backend_text = str;
377 }
378
379 /**
380 * Gets the size of the border/frame around this window.
381 */
382 BorderSize borderSize() {
383 return _borderSize;
373 } 384 }
374 385
375 /** 386 /**
376 * Moves this window to the specified position relative to 387 * Moves this window to the specified position relative to
377 * the specified control. If no control is specified, the 388 * the specified control. If no control is specified, the