comparison mde/gui/widget/Widget.d @ 41:b3a6ca4516b4

The renderer now controls which parts of the window border allow resizing. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 13 May 2008 12:02:36 +0100
parents 5132301e9ed7
children 1530d9c04d4d
comparison
equal deleted inserted replaced
40:b28d7adc786b 41:b3a6ca4516b4
15 15
16 /// GUI Widget module. 16 /// GUI Widget module.
17 module mde.gui.widget.Widget; 17 module mde.gui.widget.Widget;
18 18
19 public import mde.gui.widget.Ifaces; 19 public import mde.gui.widget.Ifaces;
20 import mde.gui.IGui;
21 import mde.gui.exception; 20 import mde.gui.exception;
21 import mde.gui.renderer.IRenderer;
22 22
23 import tango.io.Stdout; 23 import tango.io.Stdout;
24 24
25 /** An abstract base widget class. 25 /** An abstract base widget class.
26 * 26 *
166 } 166 }
167 167
168 void clickEvent (ushort, ushort, ubyte b, bool state) { 168 void clickEvent (ushort, ushort, ubyte b, bool state) {
169 if (b == 1 && state == true) { 169 if (b == 1 && state == true) {
170 pushed = true; 170 pushed = true;
171 window.gui.requestRedraw; 171 window.requestRedraw;
172 window.gui.addClickCallback (&clickWhileHeld); 172 window.gui.addClickCallback (&clickWhileHeld);
173 window.gui.addMotionCallback (&motionWhileHeld); 173 window.gui.addMotionCallback (&motionWhileHeld);
174 } 174 }
175 } 175 }
176 // Called when a mouse motion/click event occurs while (held == true) 176 // Called when a mouse motion/click event occurs while (held == true)
177 void clickWhileHeld (ushort cx, ushort cy, ubyte b, bool state) { 177 bool clickWhileHeld (ushort cx, ushort cy, ubyte b, bool state) {
178 //NOTE: which button? test
178 if (cx >= x && cx < x+w && cy >= y && cy < y+h) // button event 179 if (cx >= x && cx < x+w && cy >= y && cy < y+h) // button event
179 Stdout ("Button clicked!").newline; 180 Stdout ("Button clicked!").newline;
180 181
181 pushed = false; 182 pushed = false;
182 window.gui.requestRedraw; 183 window.requestRedraw;
183 window.gui.removeCallbacks (cast(void*) this); 184 window.gui.removeCallbacks (cast(void*) this);
185
186 return false;
184 } 187 }
185 void motionWhileHeld (ushort cx, ushort cy) { 188 void motionWhileHeld (ushort cx, ushort cy) {
186 bool oldPushed = pushed; 189 bool oldPushed = pushed;
187 if (cx >= x && cx < x+w && cy >= y && cy < y+h) pushed = true; 190 if (cx >= x && cx < x+w && cy >= y && cy < y+h) pushed = true;
188 else pushed = false; 191 else pushed = false;
189 if (oldPushed != pushed) 192 if (oldPushed != pushed)
190 window.gui.requestRedraw; 193 window.requestRedraw;
191 } 194 }
192 } 195 }
193 //END Widgets 196 //END Widgets