Changeset 76:65780e0e48e6
- Timestamp:
- 07/28/08 13:49:18
(6 months ago)
- Author:
- Diggory Hardy <diggory.hardy@gmail.com>
- branch:
- default
- Message:
Re-enabled click event passing in the gui to make ButtonWidget? work.
Bugfix (pass void* not class reference).
Change to allow compilation with dmd 1.027 (don't use DefaultData?'s Arg!() template).
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r74 |
r76 |
|
| 107 | 107 | |
|---|
| 108 | 108 | // get fallback name |
|---|
| 109 | | char[]* p = "fallback" in reader.dataset.header.Arg!(char[]); |
|---|
| | 109 | char[]* p = "fallback" in reader.dataset.header._charA; |
|---|
| 110 | 110 | if (p is null) |
|---|
| 111 | 111 | throw new fontException ("No fallback font style specified"); |
|---|
| r75 |
r76 |
|
| 93 | 93 | // Read from the HEADER: |
|---|
| 94 | 94 | // Get the renderer |
|---|
| 95 | | char[]* p = "Renderer" in reader.dataset.header.Arg!(char[]); |
|---|
| | 95 | char[]* p = "Renderer" in reader.dataset.header._charA; |
|---|
| 96 | 96 | if (p is null || *p is null) { |
|---|
| 97 | 97 | logger.warn ("No renderer specified: using \"Simple\""); |
|---|
| … | … | |
| 102 | 102 | |
|---|
| 103 | 103 | // Get which section to use |
|---|
| 104 | | p = "Design" in reader.dataset.header.Arg!(char[]); |
|---|
| | 104 | p = "Design" in reader.dataset.header._charA; |
|---|
| 105 | 105 | if (p is null || *p is null) { |
|---|
| 106 | 106 | logger.warn ("No gui design specified: trying \"Default\""); |
|---|
| r75 |
r76 |
|
| 91 | 91 | if (dg (cast(wdabs)cx, cast(wdabs)cy, b, state)) return; |
|---|
| 92 | 92 | |
|---|
| 93 | | /+ |
|---|
| | 93 | // NOTE: do we need to test if the click was on the gui (and thus child)? |
|---|
| | 94 | IChildWidget widg = child.getWidget (cast(wdabs)cx,cast(wdabs)cy); |
|---|
| | 95 | if (widg !is null) |
|---|
| | 96 | widg.clickEvent (cast(wdabs)cx,cast(wdabs)cy,b,state); |
|---|
| | 97 | /+ FIXME: remove |
|---|
| 94 | 98 | foreach (i,w; windows) { |
|---|
| 95 | 99 | IWidget widg = w.getWidget (cast(wdabs)cx,cast(wdabs)cy); |
|---|
| … | … | |
| 151 | 155 | motionCallbacks[dg.ptr] = dg; |
|---|
| 152 | 156 | } |
|---|
| 153 | | void removeCallbacks (IChildWidget frame) { |
|---|
| 154 | | clickCallbacks.remove(cast(void*) frame); |
|---|
| 155 | | motionCallbacks.remove(cast(void*) frame); |
|---|
| | 157 | void removeCallbacks (void* frame) { |
|---|
| | 158 | clickCallbacks.remove(frame); |
|---|
| | 159 | motionCallbacks.remove(frame); |
|---|
| 156 | 160 | } |
|---|
| 157 | 161 | //END IWidgetManager methods |
|---|
| r75 |
r76 |
|
| 109 | 109 | |
|---|
| 110 | 110 | // User input: |
|---|
| 111 | | /** Add a mouse click callback: delegate will be called for all mouse click events recieved. |
|---|
| | 111 | /** Add a mouse click callback. |
|---|
| | 112 | * |
|---|
| | 113 | * This is a delegate this will be called for all mouse click events recieved by the gui, not |
|---|
| | 114 | * simply all click events on the widget (as clickEvent recieves). |
|---|
| 112 | 115 | * |
|---|
| 113 | 116 | * The delegate should return true if it accepts the event and no further processing is |
|---|
| … | … | |
| 118 | 121 | void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg); |
|---|
| 119 | 122 | |
|---|
| 120 | | /** Add a mouse motion callback: delegate will be called for all motion events recieved. */ |
|---|
| | 123 | /** Add a mouse motion callback: delegate will be called for all motion events recieved by the |
|---|
| | 124 | * gui. */ |
|---|
| 121 | 125 | void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg); |
|---|
| 122 | 126 | |
|---|
| … | … | |
| 124 | 128 | |
|---|
| 125 | 129 | /** Remove all event callbacks on this widget (according to the delegate's .ptr). */ |
|---|
| 126 | | void removeCallbacks (IChildWidget frame); |
|---|
| | 130 | // Note: don't try to pass a reference and cast to void* in the function; it's a different address. |
|---|
| | 131 | void removeCallbacks (void* frame); |
|---|
| 127 | 132 | } |
|---|
| 128 | 133 | |
|---|
| … | … | |
| 237 | 242 | * |
|---|
| 238 | 243 | * Note: use global coordinates (x,y) not coordinates relative to the widget. */ |
|---|
| 239 | | IWidget getWidget (wdim x, wdim y); |
|---|
| | 244 | IChildWidget getWidget (wdim x, wdim y); |
|---|
| 240 | 245 | |
|---|
| 241 | 246 | /** Receive a mouse click event. |
|---|
| r75 |
r76 |
|
| 78 | 78 | /* This method is only called when the location is over this widget; hence for all widgets |
|---|
| 79 | 79 | * without children this method is valid. */ |
|---|
| 80 | | IWidget getWidget (wdim,wdim) { |
|---|
| | 80 | IChildWidget getWidget (wdim,wdim) { |
|---|
| 81 | 81 | return this; |
|---|
| 82 | 82 | } |
|---|
| r75 |
r76 |
|
| 86 | 86 | pushed = false; |
|---|
| 87 | 87 | mgr.requestRedraw; |
|---|
| 88 | | mgr.removeCallbacks (this); |
|---|
| | 88 | mgr.removeCallbacks (cast(void*) this); |
|---|
| 89 | 89 | |
|---|
| 90 | 90 | return true; |
|---|