comparison mde/gui/widget/AChildWidget.d @ 176:d5d5fe04ca6c

Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 12 Sep 2009 09:14:43 +0200
parents 1cbde9807293
children af40e9679436
comparison
equal deleted inserted replaced
175:1cbde9807293 176:d5d5fe04ca6c
23 23
24 public import mde.gui.widget.Ifaces; 24 public import mde.gui.widget.Ifaces;
25 import mde.content.IContent; 25 import mde.content.IContent;
26 import mde.gui.exception; 26 import mde.gui.exception;
27 27
28 debug { 28 import tango.util.log.Log : Log, Logger;
29 import tango.util.log.Log : Log, Logger; 29 private Logger logger;
30 private Logger logger; 30 static this () {
31 static this () { 31 logger = Log.getLogger ("mde.gui.widget.AChildWidget");
32 logger = Log.getLogger ("mde.gui.widget.AChildWidget");
33 }
34 } 32 }
35 33
36 /****************************************************************************** 34 /******************************************************************************
37 * An abstract base widget class for IChildWidgets. 35 * An abstract base widget class for IChildWidgets.
38 * 36 *
98 } 96 }
99 97
100 /* Set size: minimal size is (mw,mh). Note that both resizable and fixed widgets should allow 98 /* Set size: minimal size is (mw,mh). Note that both resizable and fixed widgets should allow
101 * enlarging, so in both cases this is a correct implementation. */ 99 * enlarging, so in both cases this is a correct implementation. */
102 override void setWidth (wdim nw, int) { 100 override void setWidth (wdim nw, int) {
103 debug if (nw < mw) logger.warn ("Widget width set below minimal size"); 101 debug if (nw < mw) logger.warn ("Widget width set below minimal size ({}: {})", id, this);
104 w = (nw >= mw ? nw : mw); 102 w = (nw >= mw ? nw : mw);
105 } 103 }
106 override void setHeight (wdim nh, int) { 104 override void setHeight (wdim nh, int) {
107 debug if (nh < mh) logger.warn ("Widget height set below minimal size"); 105 debug if (nh < mh) logger.warn ("Widget height set below minimal size ({}: {})", id, this);
108 h = (nh >= mh ? nh : mh); 106 h = (nh >= mh ? nh : mh);
109 } 107 }
110 108
111 override void setPosition (wdim nx, wdim ny) { 109 override void setPosition (wdim nx, wdim ny) {
112 x = nx; 110 x = nx;
211 * mgr.requestRedraw could be hooked in directly if the prototype changed. */ 209 * mgr.requestRedraw could be hooked in directly if the prototype changed. */
212 void contentRedraw (IContent) { 210 void contentRedraw (IContent) {
213 mgr.requestRedraw; 211 mgr.requestRedraw;
214 } 212 }
215 213
214 /** TODO: in progess - design of invariants
215 *
216 * Ideally this wants to be called after minXChange has finished, but not
217 * before/during. minXChange is called in 2 cases:
218 * recursively from a child
219 * from a change of content (setContent, keyEvent, content callbacks) - these can all be public
220 *
221 * So minXChange should not be public. At least the draw() method should be
222 * public so the invariant gets called often. The only protection that can
223 * be used for minXChange is package, however there's compiler bugs
224 * preventing package functions from being virtual! */
216 invariant { 225 invariant {
226 scope (failure)
227 logger.warn ("invariant failed ({}: {}; parent is {})", id, this, parent);
228 /+ FIXME - see comment above
217 assert (w >= mw); 229 assert (w >= mw);
218 assert (h >= mh); 230 assert (h >= mh); +/
219 } 231 }
220 232
221 IWidgetManager mgr; // the enclosing window 233 IWidgetManager mgr; // the enclosing window
222 IParentWidget parent; // the parent widget 234 IParentWidget parent; // the parent widget
223 wdim x, y; // position 235 wdim x, y; // position