comparison mde/gui/widget/Widget.d @ 130:c5c38eaadb64

Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable. Ifaces.IParentWidget.SIZABILITY controlling parent sizability. TextWidget no longer vertically resizable (since multi-line editing is not supported).
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 17 Jan 2009 16:11:26 +0000
parents ad91de8867a0
children
comparison
equal deleted inserted replaced
129:ad91de8867a0 130:c5c38eaadb64
80 return false; 80 return false;
81 } 81 }
82 //END Load and save 82 //END Load and save
83 83
84 //BEGIN Size and position 84 //BEGIN Size and position
85 override bool isWSizable () { return false; } 85 // default to not resizable
86 override bool isHSizable () { return false; } 86 override bool isWSizable () {
87 return false;
88 }
89 override bool isHSizable () {
90 return false;
91 }
87 92
88 /* Return minimal/fixed size. */ 93 /* Return minimal/fixed size. */
89 override wdim minWidth () { 94 override wdim minWidth () {
90 return mw; 95 return mw;
91 } 96 }
161 mgr.renderer.drawWidgetBack (x,y, w,h); 166 mgr.renderer.drawWidgetBack (x,y, w,h);
162 } 167 }
163 168
164 // Debug function to print size info. Intended to be correct not optimal. 169 // Debug function to print size info. Intended to be correct not optimal.
165 debug override void logWidgetSize () { 170 debug override void logWidgetSize () {
166 logger.trace ("Current size: {,4},{,4}; minimal: {,4},{,4} - {,-50} {}", w,h, this.minWidth, this.minHeight, this, id); 171 logger.trace ("Current size: {,4},{,4}; minimal: {,4},{,4}; sizable: {,5},{,5} - {,-50} {}", this.width, this.height, this.minWidth, this.minHeight, this.isWSizable, this.isHSizable, this, id);
167 } 172 }
168 173
169 protected: 174 protected:
170 /********************************************************************************************** 175 /**********************************************************************************************
171 * Widgets may use W*Check as a utility to check for existance of data. Its use is encouraged, 176 * Widgets may use W*Check as a utility to check for existance of data. Its use is encouraged,
227 232
228 override bool setup (uint n, uint flags) { 233 override bool setup (uint n, uint flags) {
229 debug (mdeWidgets) logger.trace ("AParentWidget.setup"); 234 debug (mdeWidgets) logger.trace ("AParentWidget.setup");
230 bool c = false; 235 bool c = false;
231 foreach (w; subWidgets) { 236 foreach (w; subWidgets) {
232 debug assert (w); 237 debug assert (w, "AParentWidget: w is null");
233 c |= w.setup (n,flags); 238 c |= w.setup (n,flags);
234 } 239 }
235 return c; 240 return c;
236 } 241 }
237 242
266 super (mgr, parent, id); 271 super (mgr, parent, id);
267 } 272 }
268 273
269 override bool setup (uint n, uint flags) { 274 override bool setup (uint n, uint flags) {
270 debug (mdeWidgets) logger.trace ("AParentSingleWidget.setup"); 275 debug (mdeWidgets) logger.trace ("AParentSingleWidget.setup");
271 debug assert (subWidget); 276 debug assert (subWidget, "AParentSingleWidget: subWidget is null");
272 return subWidget.setup (n,flags); 277 return subWidget.setup (n,flags);
273 } 278 }
274 279
275 override bool saveChanges () { 280 override bool saveChanges () {
276 return subWidget.saveChanges; 281 return subWidget.saveChanges;
306 /// Constructor for a completely resizable [blank] widget. 311 /// Constructor for a completely resizable [blank] widget.
307 this (IWidgetManager mgr, IParentWidget parent, widgetID id) { 312 this (IWidgetManager mgr, IParentWidget parent, widgetID id) {
308 super (mgr, parent, id); 313 super (mgr, parent, id);
309 } 314 }
310 315
311 override bool isWSizable () { return true; } 316 override bool isWSizable () {
312 override bool isHSizable () { return true; } 317 return true;
318 }
319 override bool isHSizable () {
320 return true;
321 }
313 } 322 }
314 323
315 /** For pressable buttons. 324 /** For pressable buttons.
316 * 325 *
317 * Overriding classes should implement this() (setting the size), draw() and activated(). */ 326 * Overriding classes should implement this() (setting the size), draw() and activated(). */