Mercurial > projects > dynamin
comparison dynamin/gui/control.d @ 8:b621b528823d
whenXX methods have to come before the event if switched to template mixins.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Wed, 15 Jul 2009 14:04:55 -0500 |
parents | 4029d5af7542 |
children | ccc108b25a0a |
comparison
equal
deleted
inserted
replaced
7:1311fae1ca9b | 8:b621b528823d |
---|---|
71 Font _font; | 71 Font _font; |
72 Cursor _cursor; | 72 Cursor _cursor; |
73 Container _parent; | 73 Container _parent; |
74 bool _elasticX, _elasticY; | 74 bool _elasticX, _elasticY; |
75 public: | 75 public: |
76 /// This event occurs after the control has been moved. | |
77 Event!() moved; | |
78 /// Override this method in a subclass to handle the Moved event. | |
79 protected void whenMoved(EventArgs e) { } | |
80 | |
81 /// This event occurs after the control has been resized. | |
82 Event!() resized; | |
83 /// Override this method in a subclass to handle the Resized event. | |
84 protected void whenResized(EventArgs e) { } | |
85 | |
86 /// This event occurs after the mouse has entered the control. | |
87 Event!() mouseEntered; | |
88 /// Override this method in a subclass to handle the MouseEntered event. | |
89 protected void whenMouseEntered(EventArgs e) { } | |
90 | |
91 /// This event occurs after the mouse has left the control. | |
92 Event!() mouseLeft; | |
93 /// Override this method in a subclass to handle the MouseLeft event. | |
94 protected void whenMouseLeft(EventArgs e) { } | |
95 | |
96 /// This event occurs after a mouse button is pressed. | |
97 Event!(MouseEventArgs) mouseDown; | |
98 /// Override this method in a subclass to handle the MouseDown event. | |
99 protected void whenMouseDown(MouseEventArgs e) { } | |
100 | |
101 /// This event occurs after a mouse button is released. | |
102 Event!(MouseEventArgs) mouseUp; | |
103 /// Override this method in a subclass to handle the MouseUp event. | |
104 protected void whenMouseUp(MouseEventArgs e) { } | |
105 | |
106 /// This event occurs after the mouse has been moved. | |
107 Event!(MouseEventArgs) mouseMoved; | |
108 /// Override this method in a subclass to handle the MouseMoved event. | |
109 protected void whenMouseMoved(MouseEventArgs e) { } | |
110 | |
111 /// This event occurs after the mouse has been moved. | |
112 Event!(MouseEventArgs) mouseDragged; | |
113 /// Override this method in a subclass to handle the MouseMoved event. | |
114 protected void whenMouseDragged(MouseEventArgs e) { } | |
115 | |
116 /// This event occurs after the mouse wheel has been turned. | |
117 Event!(MouseTurnedEventArgs) mouseTurned; | |
118 /// Override this method in a subclass to handle the MouseTurned event. | |
119 protected void whenMouseTurned(MouseTurnedEventArgs e) { } | |
120 | |
121 /// This event occurs after a key is pressed. | |
122 Event!(KeyEventArgs) keyDown; | |
123 /// Override this method in a subclass to handle the KeyDown event. | |
124 protected void whenKeyDown(KeyEventArgs e) { } | |
125 | |
126 /// This event occurs after a character key is pressed. | |
127 Event!(KeyTypedEventArgs) keyTyped; | |
128 /// Override this method in a subclass to handle the KeyTyped event. | |
129 protected void whenKeyTyped(KeyTypedEventArgs e) { } | |
130 | |
131 /// This event occurs after a key is released. | |
132 Event!(KeyEventArgs) keyUp; | |
133 /// Override this method in a subclass to handle the KeyUp event. | |
134 protected void whenKeyUp(KeyEventArgs e) { } | |
135 | |
136 /// This event occurs when the control needs to be painted. | |
137 Event!(PaintingEventArgs) painting; | |
138 /// Override this method in a subclass to handle the painting event. | |
139 protected void whenPainting(PaintingEventArgs e) { | |
140 e.graphics.source = backColor; | |
141 e.graphics.paint(); | |
142 } | |
143 | |
144 protected void dispatchMouseEntered(EventArgs e) { | 76 protected void dispatchMouseEntered(EventArgs e) { |
145 Cursor.setCurrent(this, _cursor); | 77 Cursor.setCurrent(this, _cursor); |
146 mouseEntered.callHandlers(e); | 78 mouseEntered.callHandlers(e); |
147 mouseEntered.callMainHandler(e); | 79 mouseEntered.callMainHandler(e); |
148 } | 80 } |
179 e.graphics.save(); | 111 e.graphics.save(); |
180 // TODO: every call to a handler should be wrapped in a save/restore | 112 // TODO: every call to a handler should be wrapped in a save/restore |
181 painting.callHandlers(e); | 113 painting.callHandlers(e); |
182 e.graphics.restore(); | 114 e.graphics.restore(); |
183 } | 115 } |
116 | |
117 /// Override this method in a subclass to handle the Moved event. | |
118 protected void whenMoved(EventArgs e) { } | |
119 /// This event occurs after the control has been moved. | |
120 Event!() moved; | |
121 | |
122 /// Override this method in a subclass to handle the Resized event. | |
123 protected void whenResized(EventArgs e) { } | |
124 /// This event occurs after the control has been resized. | |
125 Event!() resized; | |
126 | |
127 /// Override this method in a subclass to handle the MouseEntered event. | |
128 protected void whenMouseEntered(EventArgs e) { } | |
129 /// This event occurs after the mouse has entered the control. | |
130 Event!() mouseEntered; | |
131 | |
132 /// Override this method in a subclass to handle the MouseLeft event. | |
133 protected void whenMouseLeft(EventArgs e) { } | |
134 /// This event occurs after the mouse has left the control. | |
135 Event!() mouseLeft; | |
136 | |
137 /// Override this method in a subclass to handle the MouseDown event. | |
138 protected void whenMouseDown(MouseEventArgs e) { } | |
139 /// This event occurs after a mouse button is pressed. | |
140 Event!(MouseEventArgs) mouseDown; | |
141 | |
142 /// Override this method in a subclass to handle the MouseUp event. | |
143 protected void whenMouseUp(MouseEventArgs e) { } | |
144 /// This event occurs after a mouse button is released. | |
145 Event!(MouseEventArgs) mouseUp; | |
146 | |
147 /// Override this method in a subclass to handle the MouseMoved event. | |
148 protected void whenMouseMoved(MouseEventArgs e) { } | |
149 /// This event occurs after the mouse has been moved. | |
150 Event!(MouseEventArgs) mouseMoved; | |
151 | |
152 /// Override this method in a subclass to handle the MouseMoved event. | |
153 protected void whenMouseDragged(MouseEventArgs e) { } | |
154 /// This event occurs after the mouse has been moved. | |
155 Event!(MouseEventArgs) mouseDragged; | |
156 | |
157 /// Override this method in a subclass to handle the MouseTurned event. | |
158 protected void whenMouseTurned(MouseTurnedEventArgs e) { } | |
159 /// This event occurs after the mouse wheel has been turned. | |
160 Event!(MouseTurnedEventArgs) mouseTurned; | |
161 | |
162 /// Override this method in a subclass to handle the KeyDown event. | |
163 protected void whenKeyDown(KeyEventArgs e) { } | |
164 /// This event occurs after a key is pressed. | |
165 Event!(KeyEventArgs) keyDown; | |
166 | |
167 /// Override this method in a subclass to handle the KeyTyped event. | |
168 protected void whenKeyTyped(KeyTypedEventArgs e) { } | |
169 /// This event occurs after a character key is pressed. | |
170 Event!(KeyTypedEventArgs) keyTyped; | |
171 | |
172 /// Override this method in a subclass to handle the KeyUp event. | |
173 protected void whenKeyUp(KeyEventArgs e) { } | |
174 /// This event occurs after a key is released. | |
175 Event!(KeyEventArgs) keyUp; | |
176 | |
177 /// Override this method in a subclass to handle the painting event. | |
178 protected void whenPainting(PaintingEventArgs e) { | |
179 e.graphics.source = backColor; | |
180 e.graphics.paint(); | |
181 } | |
182 /// This event occurs when the control needs to be painted. | |
183 Event!(PaintingEventArgs) painting; | |
184 | 184 |
185 this() { | 185 this() { |
186 moved = new Event!()(&whenMoved); | 186 moved = new Event!()(&whenMoved); |
187 resized = new Event!()(&whenResized); | 187 resized = new Event!()(&whenResized); |
188 mouseEntered = new Event!()(&whenMouseEntered, &dispatchMouseEntered); | 188 mouseEntered = new Event!()(&whenMouseEntered, &dispatchMouseEntered); |