]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: window.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
5e0aa05a | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/defs.h" | |
17 | #include "wx/window.h" | |
18 | #include "wx/dc.h" | |
19 | #include "wx/frame.h" | |
20 | #include "wx/app.h" | |
21 | #include "wx/layout.h" | |
22 | #include "wx/utils.h" | |
23 | #include "wx/dialog.h" | |
24 | #include "wx/msgdlg.h" | |
25 | #include "wx/dcclient.h" | |
26 | #include "wx/dnd.h" | |
27 | #include "wx/mdi.h" | |
30dea054 | 28 | #include "wx/menu.h" |
53b28675 | 29 | #include "wx/notebook.h" |
d4c99d6f | 30 | #include "wx/statusbr.h" |
1a5a8367 | 31 | #include <wx/intl.h> |
c801d85f KB |
32 | #include "gdk/gdkkeysyms.h" |
33 | #include <math.h> | |
34 | #include "wx/gtk/win_gtk.h" | |
35 | #include "gdk/gdkprivate.h" | |
36 | ||
37 | //----------------------------------------------------------------------------- | |
38 | // data | |
39 | //----------------------------------------------------------------------------- | |
40 | ||
41 | extern wxList wxPendingDelete; | |
42 | extern wxList wxTopLevelWindows; | |
43 | extern bool g_blockEventsOnDrag; | |
44 | ||
45 | //----------------------------------------------------------------------------- | |
46 | // GTK callbacks for wxWindows event system | |
47 | //----------------------------------------------------------------------------- | |
48 | ||
49 | //----------------------------------------------------------------------------- | |
50 | // expose (of m_wxwindow, not of m_widget) | |
51 | ||
52 | void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) | |
53 | { | |
54 | if (!win->HasVMT()) return; | |
55 | if (g_blockEventsOnDrag) return; | |
56 | ||
57 | /* | |
30dea054 | 58 | if (IS_KIND_OF(win,wxStatusBar)) |
d4c99d6f RR |
59 | { |
60 | printf( "OnExpose from " ); | |
c801d85f KB |
61 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) |
62 | printf( win->GetClassInfo()->GetClassName() ); | |
63 | printf( ".\n" ); | |
30dea054 | 64 | |
c801d85f KB |
65 | printf( "x: %d \n", gdk_event->area.x ); |
66 | printf( "y: %d \n", gdk_event->area.y ); | |
67 | printf( "w: %d \n", gdk_event->area.width ); | |
68 | printf( "h: %d \n", gdk_event->area.height ); | |
d4c99d6f | 69 | } |
c801d85f KB |
70 | */ |
71 | ||
72 | win->m_updateRegion.Union( gdk_event->area.x, | |
73 | gdk_event->area.y, | |
5e0aa05a VZ |
74 | gdk_event->area.width, |
75 | gdk_event->area.height ); | |
76 | ||
c801d85f KB |
77 | if (gdk_event->count > 0) return; |
78 | ||
79 | wxPaintEvent event( win->GetId() ); | |
80 | event.SetEventObject( win ); | |
81 | win->ProcessEvent( event ); | |
82 | ||
83 | win->m_updateRegion.Clear(); | |
362c6693 | 84 | } |
c801d85f KB |
85 | |
86 | //----------------------------------------------------------------------------- | |
87 | // draw (of m_wxwindow, not of m_widget) | |
88 | ||
89 | void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) | |
90 | { | |
91 | if (!win->HasVMT()) return; | |
92 | if (g_blockEventsOnDrag) return; | |
93 | ||
94 | /* | |
30dea054 RR |
95 | if (IS_KIND_OF(win,wxStatusBar)) |
96 | { | |
c801d85f KB |
97 | printf( "OnDraw from " ); |
98 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
99 | printf( win->GetClassInfo()->GetClassName() ); | |
100 | printf( ".\n" ); | |
101 | ||
102 | printf( "x: %d \n", rect->x ); | |
103 | printf( "y: %d \n", rect->y ); | |
104 | printf( "w: %d \n", rect->width ); | |
105 | printf( "h: %d \n", rect->height ); | |
30dea054 | 106 | } |
c801d85f KB |
107 | */ |
108 | ||
109 | win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); | |
5e0aa05a | 110 | |
c801d85f KB |
111 | wxPaintEvent event( win->GetId() ); |
112 | event.SetEventObject( win ); | |
113 | win->ProcessEvent( event ); | |
114 | ||
115 | win->m_updateRegion.Clear(); | |
362c6693 | 116 | } |
c801d85f KB |
117 | |
118 | //----------------------------------------------------------------------------- | |
119 | // size | |
33d0b396 RR |
120 | // I don't any longer intercept GTK's internal resize events, except |
121 | // for frames and from within MDI and tabbed windows (client area | |
122 | // size determined internally by GTK, not wxWin). | |
c801d85f KB |
123 | |
124 | /* | |
125 | void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) | |
126 | { | |
127 | if (!win->HasVMT()) return; | |
128 | if (g_blockEventsOnDrag) return; | |
129 | ||
130 | return; | |
131 | ||
132 | if ((win->m_x == alloc->x) && | |
133 | (win->m_y == alloc->y) && | |
134 | (win->m_width == alloc->width) && | |
135 | (win->m_height == alloc->height)) | |
136 | { | |
137 | return; | |
362c6693 | 138 | } |
c801d85f KB |
139 | |
140 | printf( "OnResize from " ); | |
141 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
142 | printf( win->GetClassInfo()->GetClassName() ); | |
143 | printf( " .\n" ); | |
144 | ||
145 | printf( " Old: X: %d Y: %d ", win->m_x, win->m_y ); | |
146 | printf( " W: %d H: %d ", win->m_width, win->m_height ); | |
147 | printf( " .\n" ); | |
148 | ||
149 | printf( " New: X: %d Y: %d ", alloc->x, alloc->y ); | |
150 | printf( " W: %d H: %d ", alloc->width, alloc->height ); | |
151 | printf( " .\n" ); | |
152 | ||
153 | wxSizeEvent event( wxSize( alloc->width, alloc->height), win->GetId() ); | |
154 | event.SetEventObject( win ); | |
155 | win->ProcessEvent( event ); | |
362c6693 | 156 | } |
c801d85f KB |
157 | */ |
158 | ||
159 | //----------------------------------------------------------------------------- | |
160 | // key_press | |
161 | ||
162 | gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gdk_event, wxWindow *win ) | |
163 | { | |
164 | if (!win->HasVMT()) return FALSE; | |
165 | if (g_blockEventsOnDrag) return FALSE; | |
166 | ||
167 | /* | |
168 | printf( "OnKeyPress from " ); | |
169 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
170 | printf( win->GetClassInfo()->GetClassName() ); | |
171 | printf( ".\n" ); | |
172 | */ | |
173 | ||
174 | long key_code = 0; | |
175 | switch (gdk_event->keyval) | |
176 | { | |
5e0aa05a VZ |
177 | case GDK_BackSpace: key_code = WXK_BACK; break; |
178 | case GDK_Tab: key_code = WXK_TAB; break; | |
179 | case GDK_Linefeed: key_code = WXK_RETURN; break; | |
180 | case GDK_Clear: key_code = WXK_CLEAR; break; | |
181 | case GDK_Return: key_code = WXK_RETURN; break; | |
182 | case GDK_Pause: key_code = WXK_PAUSE; break; | |
183 | case GDK_Scroll_Lock: key_code = WXK_SCROLL; break; | |
184 | case GDK_Escape: key_code = WXK_ESCAPE; break; | |
185 | case GDK_Delete: key_code = WXK_DELETE; break; | |
186 | case GDK_Home: key_code = WXK_HOME; break; | |
187 | case GDK_Left: key_code = WXK_LEFT; break; | |
188 | case GDK_Up: key_code = WXK_UP; break; | |
189 | case GDK_Right: key_code = WXK_RIGHT; break; | |
190 | case GDK_Down: key_code = WXK_DOWN; break; | |
191 | case GDK_Prior: key_code = WXK_PRIOR; break; | |
192 | // case GDK_Page_Up: key_code = WXK_PAGEUP; break; | |
193 | case GDK_Next: key_code = WXK_NEXT; break; | |
194 | // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break; | |
195 | case GDK_End: key_code = WXK_END; break; | |
196 | case GDK_Begin: key_code = WXK_HOME; break; | |
197 | case GDK_Select: key_code = WXK_SELECT; break; | |
198 | case GDK_Print: key_code = WXK_PRINT; break; | |
199 | case GDK_Execute: key_code = WXK_EXECUTE; break; | |
200 | case GDK_Insert: key_code = WXK_INSERT; break; | |
201 | case GDK_Num_Lock: key_code = WXK_NUMLOCK; break; | |
202 | case GDK_KP_Tab: key_code = WXK_TAB; break; | |
203 | case GDK_KP_Enter: key_code = WXK_RETURN; break; | |
204 | case GDK_KP_Home: key_code = WXK_HOME; break; | |
205 | case GDK_KP_Left: key_code = WXK_LEFT; break; | |
206 | case GDK_KP_Up: key_code = WXK_UP; break; | |
207 | case GDK_KP_Right: key_code = WXK_RIGHT; break; | |
208 | case GDK_KP_Down: key_code = WXK_DOWN; break; | |
209 | case GDK_KP_Prior: key_code = WXK_PRIOR; break; | |
210 | // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break; | |
211 | case GDK_KP_Next: key_code = WXK_NEXT; break; | |
212 | // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break; | |
213 | case GDK_KP_End: key_code = WXK_END; break; | |
214 | case GDK_KP_Begin: key_code = WXK_HOME; break; | |
215 | case GDK_KP_Insert: key_code = WXK_INSERT; break; | |
216 | case GDK_KP_Delete: key_code = WXK_DELETE; break; | |
217 | case GDK_KP_Multiply: key_code = WXK_MULTIPLY; break; | |
218 | case GDK_KP_Add: key_code = WXK_ADD; break; | |
219 | case GDK_KP_Separator: key_code = WXK_SEPARATOR; break; | |
220 | case GDK_KP_Subtract: key_code = WXK_SUBTRACT; break; | |
221 | case GDK_KP_Decimal: key_code = WXK_DECIMAL; break; | |
222 | case GDK_KP_Divide: key_code = WXK_DIVIDE; break; | |
223 | case GDK_KP_0: key_code = WXK_NUMPAD0; break; | |
224 | case GDK_KP_1: key_code = WXK_NUMPAD1; break; | |
225 | case GDK_KP_2: key_code = WXK_NUMPAD2; break; | |
226 | case GDK_KP_3: key_code = WXK_NUMPAD3; break; | |
227 | case GDK_KP_4: key_code = WXK_NUMPAD4; break; | |
228 | case GDK_KP_5: key_code = WXK_NUMPAD5; break; | |
229 | case GDK_KP_6: key_code = WXK_NUMPAD6; break; | |
230 | case GDK_KP_7: key_code = WXK_NUMPAD7; break; | |
231 | case GDK_KP_8: key_code = WXK_NUMPAD7; break; | |
232 | case GDK_KP_9: key_code = WXK_NUMPAD9; break; | |
233 | case GDK_F1: key_code = WXK_F1; break; | |
234 | case GDK_F2: key_code = WXK_F2; break; | |
235 | case GDK_F3: key_code = WXK_F3; break; | |
236 | case GDK_F4: key_code = WXK_F4; break; | |
237 | case GDK_F5: key_code = WXK_F5; break; | |
238 | case GDK_F6: key_code = WXK_F6; break; | |
239 | case GDK_F7: key_code = WXK_F7; break; | |
240 | case GDK_F8: key_code = WXK_F8; break; | |
241 | case GDK_F9: key_code = WXK_F9; break; | |
242 | case GDK_F10: key_code = WXK_F10; break; | |
243 | case GDK_F11: key_code = WXK_F11; break; | |
244 | case GDK_F12: key_code = WXK_F12; break; | |
c801d85f KB |
245 | default: |
246 | { | |
247 | if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) | |
248 | key_code = gdk_event->keyval; | |
362c6693 RR |
249 | } |
250 | } | |
c801d85f KB |
251 | |
252 | if (!key_code) return FALSE; | |
253 | ||
254 | wxKeyEvent event( wxEVT_CHAR ); | |
255 | event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); | |
256 | event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); | |
257 | event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); | |
258 | event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); | |
259 | event.m_keyCode = key_code; | |
260 | event.m_x = 0; | |
261 | event.m_y = 0; | |
262 | event.SetEventObject( win ); | |
66bd6b93 RR |
263 | |
264 | bool ret = win->ProcessEvent( event ); | |
265 | /* | |
266 | if (ret) printf( "found.\n") ; | |
267 | */ | |
268 | return ret; | |
362c6693 | 269 | } |
c801d85f KB |
270 | |
271 | //----------------------------------------------------------------------------- | |
272 | // button_press | |
273 | ||
903f689b RR |
274 | gint gtk_window_button_press_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win ) |
275 | { | |
276 | if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; | |
277 | ||
e3e65dac | 278 | if (g_blockEventsOnDrag) return TRUE; |
c801d85f KB |
279 | |
280 | if (win->m_wxwindow) | |
281 | { | |
282 | if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) ) | |
283 | { | |
284 | gtk_widget_grab_focus (win->m_wxwindow); | |
285 | ||
286 | /* | |
287 | printf( "GrabFocus from " ); | |
288 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
289 | printf( win->GetClassInfo()->GetClassName() ); | |
290 | printf( ".\n" ); | |
291 | */ | |
292 | ||
362c6693 RR |
293 | } |
294 | } | |
c801d85f | 295 | |
e3e65dac | 296 | if (!win->HasVMT()) return TRUE; |
c801d85f KB |
297 | |
298 | /* | |
299 | printf( "OnButtonPress from " ); | |
300 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
301 | printf( win->GetClassInfo()->GetClassName() ); | |
302 | printf( ".\n" ); | |
303 | */ | |
30dea054 | 304 | |
7798a18e | 305 | wxEventType event_type = wxEVT_LEFT_DOWN; |
c801d85f KB |
306 | |
307 | if (gdk_event->button == 1) | |
308 | { | |
309 | switch (gdk_event->type) | |
310 | { | |
311 | case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break; | |
312 | case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break; | |
313 | default: break; | |
362c6693 | 314 | } |
c801d85f KB |
315 | } |
316 | else if (gdk_event->button == 2) | |
317 | { | |
318 | switch (gdk_event->type) | |
319 | { | |
320 | case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break; | |
321 | case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break; | |
322 | default: break; | |
362c6693 | 323 | } |
c801d85f KB |
324 | } |
325 | else if (gdk_event->button == 3) | |
326 | { | |
327 | switch (gdk_event->type) | |
328 | { | |
329 | case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break; | |
330 | case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break; | |
331 | default: break; | |
362c6693 RR |
332 | } |
333 | } | |
c801d85f KB |
334 | |
335 | wxMouseEvent event( event_type ); | |
336 | event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); | |
337 | event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); | |
338 | event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); | |
339 | event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); | |
340 | event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); | |
341 | event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); | |
342 | event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); | |
343 | ||
344 | event.m_x = (long)gdk_event->x; | |
345 | event.m_y = (long)gdk_event->y; | |
346 | event.SetEventObject( win ); | |
347 | ||
348 | win->ProcessEvent( event ); | |
349 | ||
350 | return TRUE; | |
362c6693 | 351 | } |
c801d85f KB |
352 | |
353 | //----------------------------------------------------------------------------- | |
354 | // button_release | |
355 | ||
903f689b | 356 | gint gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win ) |
c801d85f | 357 | { |
903f689b | 358 | if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; |
e3e65dac | 359 | if (g_blockEventsOnDrag) return TRUE; |
c801d85f | 360 | |
e3e65dac | 361 | if (!win->HasVMT()) return TRUE; |
c801d85f KB |
362 | |
363 | /* | |
364 | printf( "OnButtonRelease from " ); | |
365 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
366 | printf( win->GetClassInfo()->GetClassName() ); | |
367 | printf( ".\n" ); | |
368 | */ | |
369 | ||
7798a18e | 370 | wxEventType event_type = wxEVT_NULL; |
c801d85f KB |
371 | |
372 | switch (gdk_event->button) | |
373 | { | |
374 | case 1: event_type = wxEVT_LEFT_UP; break; | |
375 | case 2: event_type = wxEVT_MIDDLE_UP; break; | |
376 | case 3: event_type = wxEVT_RIGHT_UP; break; | |
362c6693 | 377 | } |
c801d85f KB |
378 | |
379 | wxMouseEvent event( event_type ); | |
380 | event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); | |
381 | event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); | |
382 | event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); | |
383 | event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); | |
384 | event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); | |
385 | event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); | |
386 | event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); | |
387 | event.m_x = (long)gdk_event->x; | |
388 | event.m_y = (long)gdk_event->y; | |
389 | event.SetEventObject( win ); | |
390 | ||
e3e65dac RR |
391 | win->ProcessEvent( event ); |
392 | ||
393 | return TRUE; | |
362c6693 | 394 | } |
c801d85f KB |
395 | |
396 | //----------------------------------------------------------------------------- | |
397 | // motion_notify | |
398 | ||
903f689b | 399 | gint gtk_window_motion_notify_callback( GtkWidget *WXUNUSED(widget), GdkEventMotion *gdk_event, wxWindow *win ) |
c801d85f | 400 | { |
903f689b | 401 | if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; |
e3e65dac | 402 | if (g_blockEventsOnDrag) return TRUE; |
c801d85f | 403 | |
e3e65dac | 404 | if (!win->HasVMT()) return TRUE; |
c801d85f KB |
405 | |
406 | /* | |
407 | printf( "OnMotion from " ); | |
408 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
409 | printf( win->GetClassInfo()->GetClassName() ); | |
410 | printf( ".\n" ); | |
411 | */ | |
412 | ||
413 | wxMouseEvent event( wxEVT_MOTION ); | |
414 | event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); | |
415 | event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); | |
416 | event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); | |
417 | event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); | |
418 | event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); | |
419 | event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); | |
420 | event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); | |
421 | ||
422 | event.m_x = (long)gdk_event->x; | |
423 | event.m_y = (long)gdk_event->y; | |
424 | event.SetEventObject( win ); | |
425 | ||
426 | win->ProcessEvent( event ); | |
427 | ||
e3e65dac | 428 | return TRUE; |
362c6693 | 429 | } |
c801d85f KB |
430 | |
431 | //----------------------------------------------------------------------------- | |
432 | // focus_in | |
433 | ||
401ec7b6 | 434 | gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) |
c801d85f | 435 | { |
e3e65dac | 436 | if (g_blockEventsOnDrag) return TRUE; |
c801d85f KB |
437 | if (win->m_wxwindow) |
438 | { | |
439 | if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) | |
440 | { | |
441 | GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); | |
442 | /* | |
443 | printf( "SetFocus flag from " ); | |
444 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
445 | printf( win->GetClassInfo()->GetClassName() ); | |
446 | printf( ".\n" ); | |
447 | */ | |
362c6693 RR |
448 | } |
449 | } | |
c801d85f | 450 | |
e3e65dac | 451 | if (!win->HasVMT()) return TRUE; |
c801d85f KB |
452 | |
453 | /* | |
454 | printf( "OnSetFocus from " ); | |
455 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
456 | printf( win->GetClassInfo()->GetClassName() ); | |
457 | printf( " " ); | |
458 | printf( WXSTRINGCAST win->GetLabel() ); | |
459 | printf( ".\n" ); | |
460 | */ | |
461 | ||
462 | wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() ); | |
463 | event.SetEventObject( win ); | |
e3e65dac RR |
464 | win->ProcessEvent( event ); |
465 | ||
466 | return TRUE; | |
362c6693 | 467 | } |
c801d85f KB |
468 | |
469 | //----------------------------------------------------------------------------- | |
470 | // focus out | |
471 | ||
401ec7b6 | 472 | gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) |
c801d85f | 473 | { |
e3e65dac | 474 | if (g_blockEventsOnDrag) return TRUE; |
c801d85f KB |
475 | if (win->m_wxwindow) |
476 | { | |
477 | if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) | |
478 | GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS); | |
362c6693 | 479 | } |
c801d85f | 480 | |
e3e65dac | 481 | if (!win->HasVMT()) return TRUE; |
c801d85f KB |
482 | |
483 | /* | |
484 | printf( "OnKillFocus from " ); | |
485 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
486 | printf( win->GetClassInfo()->GetClassName() ); | |
487 | printf( ".\n" ); | |
488 | */ | |
489 | ||
490 | wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() ); | |
491 | event.SetEventObject( win ); | |
e3e65dac RR |
492 | win->ProcessEvent( event ); |
493 | ||
494 | return TRUE; | |
362c6693 | 495 | } |
c801d85f KB |
496 | |
497 | //----------------------------------------------------------------------------- | |
498 | // vertical scroll | |
499 | ||
500 | void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) | |
501 | { | |
502 | if (g_blockEventsOnDrag) return; | |
503 | ||
504 | /* | |
505 | printf( "OnVScroll from " ); | |
506 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
507 | printf( win->GetClassInfo()->GetClassName() ); | |
508 | printf( ".\n" ); | |
509 | */ | |
510 | ||
511 | if (!win->HasVMT()) return; | |
512 | ||
513 | float diff = win->m_vAdjust->value - win->m_oldVerticalPos; | |
514 | if (fabs(diff) < 0.2) return; | |
515 | ||
516 | /* | |
517 | int i = (int)(win->m_oldVerticalPos+0.5); | |
518 | printf( "Old value: %d.\n", i ); | |
519 | i = (int)(win->m_vAdjust->value+0.5); | |
520 | printf( "Sending new value: %d.\n", i ); | |
521 | */ | |
522 | ||
7798a18e | 523 | wxEventType command = wxEVT_NULL; |
c801d85f KB |
524 | |
525 | float line_step = win->m_vAdjust->step_increment; | |
526 | float page_step = win->m_vAdjust->page_increment; | |
527 | ||
528 | if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; | |
529 | else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; | |
530 | else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; | |
531 | else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; | |
532 | else command = wxEVT_SCROLL_THUMBTRACK; | |
533 | ||
534 | int value = (int)(win->m_vAdjust->value+0.5); | |
535 | ||
536 | wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); | |
537 | event.SetEventObject( win ); | |
538 | win->ProcessEvent( event ); | |
362c6693 | 539 | } |
c801d85f KB |
540 | |
541 | //----------------------------------------------------------------------------- | |
542 | // horizontal scroll | |
543 | ||
544 | void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) | |
545 | { | |
546 | if (g_blockEventsOnDrag) return; | |
547 | ||
548 | /* | |
549 | printf( "OnHScroll from " ); | |
550 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
551 | printf( win->GetClassInfo()->GetClassName() ); | |
552 | printf( ".\n" ); | |
553 | */ | |
554 | ||
555 | if (!win->HasVMT()) return; | |
556 | ||
557 | float diff = win->m_hAdjust->value - win->m_oldHorizontalPos; | |
558 | if (fabs(diff) < 0.2) return; | |
559 | ||
560 | /* | |
561 | int i = (int)(win->m_oldHorizontalPos+0.5); | |
562 | printf( "Old value: %d.\n", i ); | |
563 | i = (int)(win->m_hAdjust->value+0.5); | |
564 | printf( "Sending new value: %d.\n", i ); | |
565 | */ | |
566 | ||
7798a18e | 567 | wxEventType command = wxEVT_NULL; |
c801d85f KB |
568 | |
569 | float line_step = win->m_hAdjust->step_increment; | |
570 | float page_step = win->m_hAdjust->page_increment; | |
571 | ||
572 | if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN; | |
573 | else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP; | |
574 | else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN; | |
575 | else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP; | |
576 | else command = wxEVT_SCROLL_THUMBTRACK; | |
577 | ||
578 | int value = (int)(win->m_hAdjust->value+0.5); | |
579 | ||
580 | wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); | |
581 | event.SetEventObject( win ); | |
582 | win->ProcessEvent( event ); | |
362c6693 | 583 | } |
c801d85f KB |
584 | |
585 | //----------------------------------------------------------------------------- | |
586 | // vertical scroll change | |
587 | ||
588 | void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) | |
589 | { | |
590 | if (g_blockEventsOnDrag) return; | |
591 | ||
592 | /* | |
593 | printf( "OnVScroll change from " ); | |
594 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
595 | printf( win->GetClassInfo()->GetClassName() ); | |
596 | printf( ".\n" ); | |
597 | */ | |
598 | ||
599 | if (!win->HasVMT()) return; | |
600 | ||
7798a18e | 601 | wxEventType command = wxEVT_SCROLL_THUMBTRACK; |
c801d85f KB |
602 | int value = (int)(win->m_vAdjust->value+0.5); |
603 | ||
604 | wxScrollEvent event( command, win->GetId(), value, wxVERTICAL ); | |
605 | event.SetEventObject( win ); | |
606 | win->ProcessEvent( event ); | |
362c6693 | 607 | } |
c801d85f KB |
608 | |
609 | //----------------------------------------------------------------------------- | |
610 | // horizontal scroll change | |
611 | ||
612 | void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) | |
613 | { | |
614 | if (g_blockEventsOnDrag) return; | |
615 | ||
616 | /* | |
617 | printf( "OnHScroll change from " ); | |
618 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
619 | printf( win->GetClassInfo()->GetClassName() ); | |
620 | printf( ".\n" ); | |
621 | */ | |
622 | ||
623 | if (!win->HasVMT()) return; | |
624 | ||
7798a18e | 625 | wxEventType command = wxEVT_SCROLL_THUMBTRACK; |
c801d85f KB |
626 | int value = (int)(win->m_hAdjust->value+0.5); |
627 | ||
628 | wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL ); | |
629 | event.SetEventObject( win ); | |
630 | win->ProcessEvent( event ); | |
362c6693 | 631 | } |
c801d85f KB |
632 | |
633 | //----------------------------------------------------------------------------- | |
634 | // drop | |
635 | ||
636 | void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win ) | |
637 | { | |
66bd6b93 RR |
638 | if (!win->HasVMT()) return; |
639 | ||
c801d85f KB |
640 | if (win->GetDropTarget()) |
641 | { | |
642 | int x = 0; | |
643 | int y = 0; | |
644 | gdk_window_get_pointer( widget->window, &x, &y, NULL ); | |
645 | win->GetDropTarget()->Drop( event, x, y ); | |
362c6693 | 646 | } |
c801d85f KB |
647 | |
648 | /* | |
649 | g_free (event->dropdataavailable.data); | |
650 | g_free (event->dropdataavailable.data_type); | |
651 | */ | |
652 | } | |
653 | ||
654 | //----------------------------------------------------------------------------- | |
655 | // destroy | |
656 | ||
657 | bool gtk_window_destroy_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win ) | |
658 | { | |
659 | printf( "OnDestroy from " ); | |
660 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
661 | printf( win->GetClassInfo()->GetClassName() ); | |
662 | printf( ".\n" ); | |
663 | printf( "Goodbye.\n" ); | |
664 | printf( " Robert Roebling.\n" ); | |
665 | ||
666 | return FALSE; | |
362c6693 | 667 | } |
c801d85f KB |
668 | |
669 | //----------------------------------------------------------------------------- | |
670 | // enter | |
671 | ||
401ec7b6 | 672 | bool gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) |
c801d85f | 673 | { |
401ec7b6 | 674 | if (widget->window != gdk_event->window) return TRUE; |
66bd6b93 RR |
675 | if (g_blockEventsOnDrag) return TRUE; |
676 | if (!win->HasVMT()) return TRUE; | |
c801d85f KB |
677 | |
678 | if (widget->window) | |
679 | gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); | |
680 | ||
401ec7b6 RR |
681 | wxMouseEvent event( wxEVT_ENTER_WINDOW ); |
682 | event.SetEventObject( win ); | |
683 | return win->ProcessEvent( event ); | |
362c6693 | 684 | } |
c801d85f KB |
685 | |
686 | //----------------------------------------------------------------------------- | |
687 | // leave | |
688 | ||
401ec7b6 | 689 | bool gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) |
c801d85f | 690 | { |
401ec7b6 | 691 | if (widget->window != gdk_event->window) return TRUE; |
66bd6b93 RR |
692 | if (!win->HasVMT()) return TRUE; |
693 | if (g_blockEventsOnDrag) return TRUE; | |
c801d85f KB |
694 | |
695 | if (widget->window) | |
696 | gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); | |
697 | ||
401ec7b6 RR |
698 | wxMouseEvent event( wxEVT_LEAVE_WINDOW ); |
699 | event.SetEventObject( win ); | |
700 | return win->ProcessEvent( event ); | |
362c6693 | 701 | } |
c801d85f KB |
702 | |
703 | //----------------------------------------------------------------------------- | |
704 | // wxWindow implementation | |
705 | //----------------------------------------------------------------------------- | |
706 | ||
707 | IMPLEMENT_DYNAMIC_CLASS(wxWindow,wxEvtHandler) | |
708 | ||
709 | BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) | |
c801d85f | 710 | EVT_SIZE(wxWindow::OnSize) |
c801d85f KB |
711 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) |
712 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
5e0aa05a | 713 | EVT_IDLE(wxWindow::OnIdle) |
c801d85f KB |
714 | END_EVENT_TABLE() |
715 | ||
716 | wxWindow::wxWindow() | |
717 | { | |
718 | m_widget = NULL; | |
719 | m_wxwindow = NULL; | |
720 | m_parent = NULL; | |
721 | m_children.DeleteContents( FALSE ); | |
722 | m_x = 0; | |
723 | m_y = 0; | |
724 | m_width = 0; | |
725 | m_height = 0; | |
726 | m_retCode = 0; | |
727 | m_eventHandler = this; | |
728 | m_windowValidator = NULL; | |
729 | m_windowId = -1; | |
730 | m_cursor = new wxCursor( wxCURSOR_ARROW ); | |
731 | m_font = *wxSWISS_FONT; | |
732 | m_windowStyle = 0; | |
733 | m_windowName = "noname"; | |
734 | m_constraints = NULL; | |
735 | m_constraintsInvolvedIn = NULL; | |
736 | m_windowSizer = NULL; | |
737 | m_sizerParent = NULL; | |
738 | m_autoLayout = FALSE; | |
739 | m_sizeSet = FALSE; | |
740 | m_hasVMT = FALSE; | |
741 | m_needParent = TRUE; | |
742 | m_hasScrolling = FALSE; | |
743 | m_hAdjust = NULL; | |
744 | m_vAdjust = NULL; | |
745 | m_oldHorizontalPos = 0.0; | |
746 | m_oldVerticalPos = 0.0; | |
747 | m_isShown = FALSE; | |
748 | m_isEnabled = TRUE; | |
749 | m_drawingOffsetX = 0; | |
750 | m_drawingOffsetY = 0; | |
751 | m_pDropTarget = NULL; | |
33d0b396 | 752 | m_resizing = FALSE; |
362c6693 | 753 | } |
c801d85f | 754 | |
debe6624 JS |
755 | bool wxWindow::Create( wxWindow *parent, wxWindowID id, |
756 | const wxPoint &pos, const wxSize &size, | |
6de97a3b | 757 | long style, const wxString &name ) |
c801d85f KB |
758 | { |
759 | m_isShown = FALSE; | |
760 | m_isEnabled = TRUE; | |
761 | m_needParent = TRUE; | |
762 | ||
6de97a3b RR |
763 | m_cursor = NULL; |
764 | ||
c801d85f KB |
765 | PreCreation( parent, id, pos, size, style, name ); |
766 | ||
767 | m_widget = gtk_scrolled_window_new( NULL, NULL ); | |
768 | m_hasScrolling = TRUE; | |
769 | ||
770 | GtkScrolledWindow *s_window; | |
771 | s_window = GTK_SCROLLED_WINDOW(m_widget); | |
772 | ||
773 | GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); | |
774 | scroll_class->scrollbar_spacing = 0; | |
775 | ||
776 | gtk_scrolled_window_set_policy( s_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); | |
777 | ||
778 | m_oldHorizontalPos = 0.0; | |
779 | m_oldVerticalPos = 0.0; | |
780 | ||
781 | m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) ); | |
782 | m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) ); | |
783 | ||
784 | gtk_signal_connect (GTK_OBJECT (m_hAdjust), "value_changed", | |
5e0aa05a | 785 | (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this ); |
c801d85f | 786 | gtk_signal_connect (GTK_OBJECT (m_vAdjust), "value_changed", |
5e0aa05a VZ |
787 | (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this ); |
788 | ||
c801d85f | 789 | gtk_signal_connect (GTK_OBJECT (m_hAdjust), "changed", |
5e0aa05a | 790 | (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this ); |
c801d85f | 791 | gtk_signal_connect (GTK_OBJECT (m_vAdjust), "changed", |
5e0aa05a | 792 | (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this ); |
c801d85f KB |
793 | |
794 | GtkViewport *viewport; | |
795 | viewport = GTK_VIEWPORT(s_window->viewport); | |
796 | ||
797 | if (m_windowStyle & wxRAISED_BORDER) | |
798 | { | |
799 | gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT ); | |
800 | } | |
801 | else if (m_windowStyle & wxSUNKEN_BORDER) | |
802 | { | |
803 | gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_IN ); | |
804 | } | |
805 | else | |
806 | { | |
807 | gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); | |
362c6693 | 808 | } |
c801d85f KB |
809 | |
810 | m_wxwindow = gtk_myfixed_new(); | |
811 | ||
66bd6b93 RR |
812 | if (m_wxwindow) GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); |
813 | ||
c801d85f KB |
814 | if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL) |
815 | GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); | |
816 | else | |
817 | GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); | |
818 | ||
819 | gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); | |
820 | ||
821 | // shut the viewport up | |
822 | gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ); | |
823 | gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ); | |
824 | ||
825 | // I _really_ don't want scrollbars in the beginning | |
826 | m_vAdjust->lower = 0.0; | |
827 | m_vAdjust->upper = 1.0; | |
828 | m_vAdjust->value = 0.0; | |
829 | m_vAdjust->step_increment = 1.0; | |
830 | m_vAdjust->page_increment = 1.0; | |
831 | m_vAdjust->page_size = 5.0; | |
832 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); | |
833 | m_hAdjust->lower = 0.0; | |
834 | m_hAdjust->upper = 1.0; | |
835 | m_hAdjust->value = 0.0; | |
836 | m_hAdjust->step_increment = 1.0; | |
837 | m_hAdjust->page_increment = 1.0; | |
838 | m_hAdjust->page_size = 5.0; | |
839 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); | |
840 | ||
841 | gtk_widget_show( m_wxwindow ); | |
842 | ||
843 | PostCreation(); | |
844 | ||
845 | Show( TRUE ); | |
846 | ||
847 | return TRUE; | |
362c6693 | 848 | } |
c801d85f KB |
849 | |
850 | wxWindow::~wxWindow(void) | |
851 | { | |
852 | m_hasVMT = FALSE; | |
853 | ||
854 | if (m_pDropTarget) delete m_pDropTarget; | |
855 | ||
856 | if (m_parent) m_parent->RemoveChild( this ); | |
857 | if (m_widget) Show( FALSE ); | |
858 | ||
859 | DestroyChildren(); | |
860 | ||
861 | if (m_wxwindow) gtk_widget_destroy( m_wxwindow ); | |
862 | ||
863 | if (m_widget) gtk_widget_destroy( m_widget ); | |
864 | ||
a3622daa | 865 | wxDELETE(m_cursor); |
c801d85f KB |
866 | |
867 | DeleteRelatedConstraints(); | |
868 | if (m_constraints) | |
869 | { | |
870 | // This removes any dangling pointers to this window | |
871 | // in other windows' constraintsInvolvedIn lists. | |
872 | UnsetConstraints(m_constraints); | |
873 | delete m_constraints; | |
874 | m_constraints = NULL; | |
875 | } | |
876 | if (m_windowSizer) | |
877 | { | |
878 | delete m_windowSizer; | |
879 | m_windowSizer = NULL; | |
880 | } | |
881 | // If this is a child of a sizer, remove self from parent | |
6de97a3b | 882 | if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this); |
c801d85f KB |
883 | |
884 | // Just in case the window has been Closed, but | |
885 | // we're then deleting immediately: don't leave | |
886 | // dangling pointers. | |
887 | wxPendingDelete.DeleteObject(this); | |
888 | ||
889 | // Just in case we've loaded a top-level window via | |
890 | // wxWindow::LoadNativeDialog but we weren't a dialog | |
891 | // class | |
892 | wxTopLevelWindows.DeleteObject(this); | |
893 | ||
6de97a3b | 894 | if (m_windowValidator) delete m_windowValidator; |
362c6693 | 895 | } |
c801d85f | 896 | |
debe6624 JS |
897 | void wxWindow::PreCreation( wxWindow *parent, wxWindowID id, |
898 | const wxPoint &pos, const wxSize &size, | |
899 | long style, const wxString &name ) | |
c801d85f KB |
900 | { |
901 | if (m_needParent && (parent == NULL)) | |
1a5a8367 | 902 | wxFatalError( _("Need complete parent."), name ); |
c801d85f KB |
903 | |
904 | m_widget = NULL; | |
905 | m_hasVMT = FALSE; | |
906 | m_parent = parent; | |
907 | m_children.DeleteContents( FALSE ); | |
908 | m_x = (int)pos.x; | |
909 | m_y = (int)pos.y; | |
910 | m_width = size.x; | |
911 | if (m_width == -1) m_width = 20; | |
912 | m_height = size.y; | |
913 | if (m_height == -1) m_height = 20; | |
914 | m_retCode = 0; | |
915 | m_eventHandler = this; | |
c801d85f KB |
916 | m_windowId = id; |
917 | m_sizeSet = FALSE; | |
a3622daa VZ |
918 | if (m_cursor == NULL) |
919 | m_cursor = new wxCursor( wxCURSOR_ARROW ); | |
c801d85f KB |
920 | m_font = *wxSWISS_FONT; |
921 | m_backgroundColour = wxWHITE; | |
922 | m_foregroundColour = wxBLACK; | |
923 | m_windowStyle = style; | |
924 | m_windowName = name; | |
925 | m_constraints = NULL; | |
926 | m_constraintsInvolvedIn = NULL; | |
927 | m_windowSizer = NULL; | |
928 | m_sizerParent = NULL; | |
929 | m_autoLayout = FALSE; | |
930 | m_drawingOffsetX = 0; | |
931 | m_drawingOffsetY = 0; | |
932 | m_pDropTarget = NULL; | |
33d0b396 | 933 | m_resizing = FALSE; |
6de97a3b | 934 | m_windowValidator = NULL; |
c801d85f KB |
935 | } |
936 | ||
937 | void wxWindow::PostCreation(void) | |
938 | { | |
939 | if (m_parent) m_parent->AddChild( this ); | |
940 | ||
941 | // GtkStyle *style = m_widget->style; | |
942 | // style->font = m_font.GetInternalFont( 1.0 ); // destroy old font ? | |
943 | ||
30dea054 | 944 | GtkWidget *connect_widget = GetConnectWidget(); |
c801d85f KB |
945 | |
946 | gtk_object_set_data (GTK_OBJECT (connect_widget), "MyWxWindow", (gpointer)this ); | |
947 | ||
948 | if (m_wxwindow) | |
949 | { | |
950 | gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", | |
951 | GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); | |
952 | ||
953 | gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", | |
954 | GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); | |
362c6693 | 955 | } |
c801d85f KB |
956 | |
957 | /* | |
958 | gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", | |
959 | GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); | |
960 | */ | |
961 | ||
962 | gtk_signal_connect( GTK_OBJECT(connect_widget), "key_press_event", | |
963 | GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); | |
964 | ||
965 | gtk_signal_connect( GTK_OBJECT(connect_widget), "button_press_event", | |
966 | GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); | |
967 | ||
968 | gtk_signal_connect( GTK_OBJECT(connect_widget), "button_release_event", | |
969 | GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); | |
970 | ||
971 | gtk_signal_connect( GTK_OBJECT(connect_widget), "motion_notify_event", | |
972 | GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); | |
973 | ||
974 | gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_in_event", | |
975 | GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); | |
976 | ||
977 | gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event", | |
978 | GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); | |
979 | ||
c801d85f KB |
980 | // Only for cursor handling |
981 | ||
982 | gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event", | |
983 | GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); | |
984 | ||
985 | gtk_signal_connect( GTK_OBJECT(m_widget), "leave_notify_event", | |
986 | GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); | |
987 | ||
988 | if (m_wxwindow) | |
989 | { | |
990 | gtk_signal_connect( GTK_OBJECT(m_wxwindow), "enter_notify_event", | |
991 | GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); | |
992 | ||
993 | gtk_signal_connect( GTK_OBJECT(m_wxwindow), "leave_notify_event", | |
994 | GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); | |
362c6693 | 995 | } |
c801d85f KB |
996 | |
997 | /* | |
998 | // Does destroy ever get called ? | |
999 | ||
1000 | gtk_signal_connect( GTK_OBJECT(m_widget), "destroy_event", | |
1001 | GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this ); | |
1002 | ||
1003 | if (m_wxwindow) | |
1004 | { | |
1005 | gtk_signal_connect( GTK_OBJECT(m_wxwindow), "destroy_event", | |
1006 | GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this ); | |
362c6693 | 1007 | } |
c801d85f KB |
1008 | */ |
1009 | ||
1010 | if (m_widget && m_parent) gtk_widget_realize( m_widget ); | |
1011 | if (m_wxwindow) gtk_widget_realize( m_wxwindow ); | |
1012 | ||
1013 | SetCursor( wxSTANDARD_CURSOR ); | |
1014 | ||
1015 | m_hasVMT = TRUE; | |
362c6693 | 1016 | } |
c801d85f KB |
1017 | |
1018 | bool wxWindow::HasVMT(void) | |
1019 | { | |
1020 | return m_hasVMT; | |
362c6693 | 1021 | } |
c801d85f | 1022 | |
debe6624 | 1023 | bool wxWindow::Close( bool force ) |
c801d85f KB |
1024 | { |
1025 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); | |
1026 | event.SetEventObject(this); | |
1027 | event.SetForce(force); | |
1028 | ||
1029 | return GetEventHandler()->ProcessEvent(event); | |
362c6693 | 1030 | } |
c801d85f KB |
1031 | |
1032 | bool wxWindow::Destroy(void) | |
1033 | { | |
1034 | m_hasVMT = FALSE; | |
1035 | delete this; | |
1036 | return TRUE; | |
362c6693 | 1037 | } |
c801d85f KB |
1038 | |
1039 | bool wxWindow::DestroyChildren(void) | |
1040 | { | |
1041 | if (GetChildren()) | |
1042 | { | |
1043 | wxNode *node; | |
1044 | while ((node = GetChildren()->First()) != (wxNode *)NULL) | |
1045 | { | |
1046 | wxWindow *child; | |
1047 | if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) | |
1048 | { | |
1049 | delete child; | |
5e0aa05a | 1050 | if (GetChildren()->Member(child)) delete node; |
362c6693 RR |
1051 | } |
1052 | } | |
1053 | } | |
c801d85f | 1054 | return TRUE; |
362c6693 | 1055 | } |
c801d85f KB |
1056 | |
1057 | void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) ) | |
1058 | { | |
1059 | // are we to set fonts here ? | |
362c6693 | 1060 | } |
c801d85f KB |
1061 | |
1062 | void wxWindow::ImplementSetSize(void) | |
1063 | { | |
1064 | gtk_widget_set_usize( m_widget, m_width, m_height ); | |
362c6693 | 1065 | } |
c801d85f KB |
1066 | |
1067 | void wxWindow::ImplementSetPosition(void) | |
1068 | { | |
66bd6b93 RR |
1069 | if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog)) |
1070 | { | |
1071 | if ((m_x != -1) || (m_y != -1)) | |
1072 | gtk_widget_set_uposition( m_widget, m_x, m_y ); | |
1073 | return; | |
1074 | } | |
1075 | ||
1a6944fd RR |
1076 | if (!m_parent) |
1077 | { | |
903f689b | 1078 | wxFAIL_MSG( _("wxWindow::SetSize error.\n") ); |
1a6944fd RR |
1079 | return; |
1080 | } | |
1081 | ||
c801d85f KB |
1082 | if ((m_parent) && (m_parent->m_wxwindow)) |
1083 | gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y ); | |
1a6944fd RR |
1084 | |
1085 | // Don't do anything for children of wxNotebook and wxMDIChildFrame | |
362c6693 | 1086 | } |
c801d85f | 1087 | |
debe6624 | 1088 | void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) |
c801d85f | 1089 | { |
33d0b396 RR |
1090 | if (m_resizing) return; // I don't like recursions |
1091 | m_resizing = TRUE; | |
1092 | ||
c801d85f KB |
1093 | int newX = x; |
1094 | int newY = y; | |
1095 | int newW = width; | |
1096 | int newH = height; | |
1097 | ||
1098 | if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) | |
1099 | { | |
1100 | if (newX == -1) newX = m_x; | |
1101 | if (newY == -1) newY = m_y; | |
1102 | if (newW == -1) newW = m_width; | |
1103 | if (newH == -1) newH = m_height; | |
362c6693 | 1104 | } |
c801d85f KB |
1105 | |
1106 | if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) | |
1107 | { | |
1108 | if (newW == -1) newW = 80; | |
362c6693 | 1109 | } |
c801d85f KB |
1110 | |
1111 | if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) | |
1112 | { | |
1113 | if (newH == -1) newH = 26; | |
362c6693 | 1114 | } |
c801d85f KB |
1115 | |
1116 | if ((m_x != newX) || (m_y != newY) || (!m_sizeSet)) | |
1117 | { | |
1118 | m_x = newX; | |
1119 | m_y = newY; | |
1120 | ImplementSetPosition(); | |
362c6693 | 1121 | } |
c801d85f KB |
1122 | if ((m_width != newW) || (m_height != newH) || (!m_sizeSet)) |
1123 | { | |
1124 | m_width = newW; | |
1125 | m_height = newH; | |
1126 | ImplementSetSize(); | |
362c6693 | 1127 | } |
c801d85f KB |
1128 | m_sizeSet = TRUE; |
1129 | ||
1130 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); | |
1131 | event.SetEventObject( this ); | |
1132 | ProcessEvent( event ); | |
33d0b396 RR |
1133 | |
1134 | m_resizing = FALSE; | |
362c6693 | 1135 | } |
c801d85f | 1136 | |
debe6624 | 1137 | void wxWindow::SetSize( int width, int height ) |
c801d85f KB |
1138 | { |
1139 | SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); | |
362c6693 | 1140 | } |
c801d85f | 1141 | |
debe6624 | 1142 | void wxWindow::Move( int x, int y ) |
c801d85f KB |
1143 | { |
1144 | SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); | |
362c6693 | 1145 | } |
c801d85f KB |
1146 | |
1147 | void wxWindow::GetSize( int *width, int *height ) const | |
1148 | { | |
33d0b396 RR |
1149 | if (width) (*width) = m_width; |
1150 | if (height) (*height) = m_height; | |
362c6693 | 1151 | } |
c801d85f | 1152 | |
debe6624 | 1153 | void wxWindow::SetClientSize( int width, int height ) |
c801d85f KB |
1154 | { |
1155 | if (!m_wxwindow) | |
1156 | { | |
1157 | SetSize( width, height ); | |
1158 | } | |
1159 | else | |
1160 | { | |
1161 | int dw = 0; | |
1162 | int dh = 0; | |
1163 | ||
1164 | if (!m_hasScrolling) | |
1165 | { | |
1166 | /* | |
1167 | do we have sunken dialogs ? | |
1168 | ||
1169 | GtkStyleClass *window_class = m_wxwindow->style->klass; | |
1170 | ||
1171 | dw += 2 * window_class->xthickness; | |
1172 | dh += 2 * window_class->ythickness; | |
1173 | */ | |
1174 | } | |
1175 | else | |
1176 | { | |
1177 | GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); | |
1178 | GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); | |
1179 | ||
1180 | GtkWidget *viewport = scroll_window->viewport; | |
1181 | GtkStyleClass *viewport_class = viewport->style->klass; | |
1182 | ||
1183 | GtkWidget *hscrollbar = scroll_window->hscrollbar; | |
1184 | GtkWidget *vscrollbar = scroll_window->vscrollbar; | |
1185 | ||
1186 | if ((m_windowStyle & wxRAISED_BORDER) || | |
1187 | (m_windowStyle & wxSUNKEN_BORDER) | |
5e0aa05a | 1188 | ) |
c801d85f KB |
1189 | { |
1190 | dw += 2 * viewport_class->xthickness; | |
1191 | dh += 2 * viewport_class->ythickness; | |
362c6693 | 1192 | } |
c801d85f KB |
1193 | |
1194 | if (GTK_WIDGET_VISIBLE(vscrollbar)) | |
1195 | { | |
1196 | dw += vscrollbar->allocation.width; | |
1197 | dw += scroll_class->scrollbar_spacing; | |
362c6693 | 1198 | } |
c801d85f KB |
1199 | |
1200 | if (GTK_WIDGET_VISIBLE(hscrollbar)) | |
1201 | { | |
1202 | dh += hscrollbar->allocation.height; | |
1203 | dw += scroll_class->scrollbar_spacing; | |
362c6693 RR |
1204 | } |
1205 | } | |
c801d85f KB |
1206 | |
1207 | SetSize( width+dw, height+dh ); | |
362c6693 RR |
1208 | } |
1209 | } | |
c801d85f KB |
1210 | |
1211 | void wxWindow::GetClientSize( int *width, int *height ) const | |
1212 | { | |
1213 | if (!m_wxwindow) | |
1214 | { | |
1215 | if (width) (*width) = m_width; | |
1216 | if (height) (*height) = m_height; | |
1217 | } | |
1218 | else | |
1219 | { | |
1220 | int dw = 0; | |
1221 | int dh = 0; | |
1222 | ||
1223 | if (!m_hasScrolling) | |
1224 | { | |
1225 | /* | |
1226 | do we have sunken dialogs ? | |
1227 | ||
1228 | GtkStyleClass *window_class = m_wxwindow->style->klass; | |
1229 | ||
1230 | dw += 2 * window_class->xthickness; | |
1231 | dh += 2 * window_class->ythickness; | |
1232 | */ | |
1233 | } | |
1234 | else | |
1235 | { | |
1236 | GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); | |
1237 | GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); | |
1238 | ||
1239 | GtkWidget *viewport = scroll_window->viewport; | |
1240 | GtkStyleClass *viewport_class = viewport->style->klass; | |
1241 | ||
1242 | GtkWidget *hscrollbar = scroll_window->hscrollbar; | |
1243 | GtkWidget *vscrollbar = scroll_window->vscrollbar; | |
1244 | ||
1245 | if ((m_windowStyle & wxRAISED_BORDER) || | |
1246 | (m_windowStyle & wxSUNKEN_BORDER) | |
5e0aa05a | 1247 | ) |
c801d85f KB |
1248 | { |
1249 | dw += 2 * viewport_class->xthickness; | |
1250 | dh += 2 * viewport_class->ythickness; | |
362c6693 | 1251 | } |
c801d85f KB |
1252 | |
1253 | if (GTK_WIDGET_VISIBLE(vscrollbar)) | |
1254 | { | |
1255 | // dw += vscrollbar->allocation.width; | |
1256 | dw += 15; // range.slider_width = 11 + 2*2pts edge | |
1257 | dw += scroll_class->scrollbar_spacing; | |
362c6693 | 1258 | } |
c801d85f KB |
1259 | |
1260 | if (GTK_WIDGET_VISIBLE(hscrollbar)) | |
1261 | { | |
1262 | // dh += hscrollbar->allocation.height; | |
1263 | dh += 15; | |
1264 | dh += scroll_class->scrollbar_spacing; | |
362c6693 RR |
1265 | } |
1266 | } | |
c801d85f KB |
1267 | |
1268 | if (width) (*width) = m_width - dw; | |
1269 | if (height) (*height) = m_height - dh; | |
362c6693 RR |
1270 | } |
1271 | } | |
c801d85f KB |
1272 | |
1273 | void wxWindow::GetPosition( int *x, int *y ) const | |
1274 | { | |
1275 | if (x) (*x) = m_x; | |
1276 | if (y) (*y) = m_y; | |
362c6693 | 1277 | } |
c801d85f KB |
1278 | |
1279 | void wxWindow::ClientToScreen( int *x, int *y ) | |
1280 | { | |
1281 | // Does this look simple ? | |
1282 | ||
1283 | GdkWindow *source = NULL; | |
1284 | if (m_wxwindow) | |
1285 | source = m_wxwindow->window; | |
1286 | else | |
1287 | source = m_widget->window; | |
1288 | ||
1289 | int org_x = 0; | |
1290 | int org_y = 0; | |
1291 | gdk_window_get_origin( source, &org_x, &org_y ); | |
1292 | ||
1293 | if (!m_wxwindow) | |
1294 | { | |
1295 | if (GTK_WIDGET_NO_WINDOW (m_widget)) | |
1296 | { | |
1297 | org_x += m_widget->allocation.x; | |
1298 | org_y += m_widget->allocation.y; | |
362c6693 RR |
1299 | } |
1300 | } | |
c801d85f KB |
1301 | |
1302 | if (x) *x += org_x; | |
1303 | if (y) *y += org_y; | |
362c6693 | 1304 | } |
c801d85f KB |
1305 | |
1306 | void wxWindow::ScreenToClient( int *x, int *y ) | |
1307 | { | |
1308 | GdkWindow *source = NULL; | |
1309 | if (m_wxwindow) | |
1310 | source = m_wxwindow->window; | |
1311 | else | |
1312 | source = m_widget->window; | |
1313 | ||
1314 | int org_x = 0; | |
1315 | int org_y = 0; | |
1316 | gdk_window_get_origin( source, &org_x, &org_y ); | |
1317 | ||
1318 | if (!m_wxwindow) | |
1319 | { | |
1320 | if (GTK_WIDGET_NO_WINDOW (m_widget)) | |
1321 | { | |
1322 | org_x += m_widget->allocation.x; | |
1323 | org_y += m_widget->allocation.y; | |
362c6693 RR |
1324 | } |
1325 | } | |
c801d85f KB |
1326 | |
1327 | if (x) *x -= org_x; | |
1328 | if (y) *y -= org_y; | |
362c6693 | 1329 | } |
c801d85f | 1330 | |
debe6624 | 1331 | void wxWindow::Centre( int direction ) |
c801d85f | 1332 | { |
66bd6b93 | 1333 | if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) |
c801d85f | 1334 | { |
d4c99d6f RR |
1335 | if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; |
1336 | if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; | |
1337 | ImplementSetPosition(); | |
c801d85f KB |
1338 | } |
1339 | else | |
1340 | { | |
1341 | if (m_parent) | |
1342 | { | |
1343 | int p_w = 0; | |
1344 | int p_h = 0; | |
1345 | m_parent->GetSize( &p_w, &p_h ); | |
d4c99d6f RR |
1346 | if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2; |
1347 | if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2; | |
1348 | ImplementSetPosition(); | |
362c6693 | 1349 | } |
c801d85f | 1350 | } |
362c6693 | 1351 | } |
c801d85f KB |
1352 | |
1353 | void wxWindow::Fit(void) | |
1354 | { | |
5e0aa05a VZ |
1355 | int maxX = 0; |
1356 | int maxY = 0; | |
1357 | wxNode *node = GetChildren()->First(); | |
1358 | while ( node ) | |
1359 | { | |
1360 | wxWindow *win = (wxWindow *)node->Data(); | |
1361 | int wx, wy, ww, wh; | |
1362 | win->GetPosition(&wx, &wy); | |
1363 | win->GetSize(&ww, &wh); | |
1364 | if ( wx + ww > maxX ) | |
1365 | maxX = wx + ww; | |
1366 | if ( wy + wh > maxY ) | |
1367 | maxY = wy + wh; | |
1368 | ||
1369 | node = node->Next(); | |
1370 | } | |
47908e25 | 1371 | SetClientSize(maxX + 5, maxY + 10); |
362c6693 | 1372 | } |
c801d85f KB |
1373 | |
1374 | void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) | |
1375 | { | |
da7f8ac4 | 1376 | //if (GetAutoLayout()) Layout(); |
362c6693 | 1377 | } |
c801d85f | 1378 | |
debe6624 | 1379 | bool wxWindow::Show( bool show ) |
c801d85f KB |
1380 | { |
1381 | if (show) | |
1382 | gtk_widget_show( m_widget ); | |
1383 | else | |
1384 | gtk_widget_hide( m_widget ); | |
1385 | m_isShown = show; | |
1386 | return TRUE; | |
362c6693 | 1387 | } |
c801d85f | 1388 | |
debe6624 | 1389 | void wxWindow::Enable( bool enable ) |
c801d85f KB |
1390 | { |
1391 | m_isEnabled = enable; | |
1392 | gtk_widget_set_sensitive( m_widget, enable ); | |
1393 | if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable ); | |
362c6693 | 1394 | } |
c801d85f | 1395 | |
debe6624 | 1396 | void wxWindow::MakeModal( bool modal ) |
c801d85f KB |
1397 | { |
1398 | return; | |
1399 | // Disable all other windows | |
1400 | if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) | |
1401 | { | |
1402 | wxNode *node = wxTopLevelWindows.First(); | |
1403 | while (node) | |
1404 | { | |
1405 | wxWindow *win = (wxWindow *)node->Data(); | |
1406 | if (win != this) | |
1407 | win->Enable(!modal); | |
1408 | ||
1409 | node = node->Next(); | |
1410 | } | |
1411 | } | |
1412 | } | |
1413 | ||
1414 | void wxWindow::SetFocus(void) | |
1415 | { | |
30dea054 | 1416 | GtkWidget *connect_widget = GetConnectWidget(); |
c801d85f KB |
1417 | if (connect_widget) |
1418 | { | |
1419 | if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) ) | |
1420 | { | |
1421 | gtk_widget_grab_focus (connect_widget); | |
362c6693 RR |
1422 | } |
1423 | } | |
1424 | } | |
c801d85f KB |
1425 | |
1426 | bool wxWindow::OnClose(void) | |
1427 | { | |
c801d85f | 1428 | return TRUE; |
362c6693 | 1429 | } |
c801d85f KB |
1430 | |
1431 | void wxWindow::AddChild( wxWindow *child ) | |
1432 | { | |
1433 | // Addchild is (often) called before the program | |
1434 | // has left the parents constructor so that no | |
1435 | // virtual tables work yet. The approach below | |
1436 | // practically imitates virtual tables, i.e. it | |
1437 | // implements a different AddChild() behaviour | |
1438 | // for wxFrame, wxDialog, wxWindow and | |
1439 | // wxMDIParentFrame. | |
1440 | ||
46dc76ba RR |
1441 | // wxFrame and wxDialog as children aren't placed into the parents |
1442 | ||
d4c99d6f RR |
1443 | if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) && |
1444 | (!IS_KIND_OF(child,wxMDIChildFrame))) | |
46dc76ba RR |
1445 | { |
1446 | m_children.Append( child ); | |
1447 | ||
1448 | if ((child->m_x != -1) && (child->m_y != -1)) | |
1449 | gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y ); | |
1450 | ||
1451 | return; | |
1452 | } | |
1453 | ||
1454 | // In the case of an wxMDIChildFrame descendant, we use the | |
1455 | // client windows's AddChild() | |
1456 | ||
d4c99d6f | 1457 | if (IS_KIND_OF(this,wxMDIParentFrame)) |
c801d85f | 1458 | { |
d4c99d6f | 1459 | if (IS_KIND_OF(child,wxMDIChildFrame)) |
c801d85f KB |
1460 | { |
1461 | wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow(); | |
1462 | if (client) | |
1463 | { | |
1464 | client->AddChild( child ); | |
1465 | return; | |
46dc76ba RR |
1466 | } |
1467 | } | |
1468 | } | |
7f4dc78d | 1469 | |
46dc76ba | 1470 | // wxNotebook is very special, so it has a private AddChild() |
33d0b396 | 1471 | |
d4c99d6f | 1472 | if (IS_KIND_OF(this,wxNotebook)) |
7f4dc78d | 1473 | { |
53b28675 | 1474 | wxNotebook *tab = (wxNotebook*)this; |
7f4dc78d RR |
1475 | tab->AddChild( child ); |
1476 | return; | |
46dc76ba | 1477 | } |
7f4dc78d | 1478 | |
46dc76ba RR |
1479 | // wxFrame has a private AddChild |
1480 | ||
47908e25 | 1481 | if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame)) |
c801d85f | 1482 | { |
46dc76ba RR |
1483 | wxFrame *frame = (wxFrame*)this; |
1484 | frame->AddChild( child ); | |
1485 | return; | |
c801d85f | 1486 | } |
46dc76ba RR |
1487 | |
1488 | // All the rest | |
1489 | ||
1490 | m_children.Append( child ); | |
d4c99d6f RR |
1491 | if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, |
1492 | child->m_x, child->m_y ); | |
e3e65dac | 1493 | |
c801d85f | 1494 | gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); |
362c6693 | 1495 | } |
c801d85f KB |
1496 | |
1497 | wxList *wxWindow::GetChildren(void) | |
1498 | { | |
1499 | return (&m_children); | |
362c6693 | 1500 | } |
c801d85f KB |
1501 | |
1502 | void wxWindow::RemoveChild( wxWindow *child ) | |
1503 | { | |
1504 | if (GetChildren()) | |
1505 | GetChildren()->DeleteObject( child ); | |
1506 | child->m_parent = NULL; | |
362c6693 | 1507 | } |
c801d85f KB |
1508 | |
1509 | void wxWindow::SetReturnCode( int retCode ) | |
1510 | { | |
1511 | m_retCode = retCode; | |
362c6693 | 1512 | } |
c801d85f KB |
1513 | |
1514 | int wxWindow::GetReturnCode(void) | |
1515 | { | |
1516 | return m_retCode; | |
362c6693 | 1517 | } |
c801d85f KB |
1518 | |
1519 | wxWindow *wxWindow::GetParent(void) | |
1520 | { | |
1521 | return m_parent; | |
362c6693 RR |
1522 | } |
1523 | ||
1524 | void wxWindow::Raise(void) | |
1525 | { | |
1526 | if (m_widget) gdk_window_raise( m_widget->window ); | |
1527 | } | |
1528 | ||
1529 | void wxWindow::Lower(void) | |
1530 | { | |
1531 | if (m_widget) gdk_window_lower( m_widget->window ); | |
1532 | } | |
c801d85f KB |
1533 | |
1534 | wxEvtHandler *wxWindow::GetEventHandler(void) | |
1535 | { | |
1536 | return m_eventHandler; | |
362c6693 | 1537 | } |
c801d85f | 1538 | |
86b29a61 | 1539 | void wxWindow::SetEventHandler( wxEvtHandler *handler ) |
c801d85f KB |
1540 | { |
1541 | m_eventHandler = handler; | |
362c6693 | 1542 | } |
c801d85f | 1543 | |
86b29a61 RR |
1544 | void wxWindow::PushEventHandler(wxEvtHandler *handler) |
1545 | { | |
1546 | handler->SetNextHandler(GetEventHandler()); | |
1547 | SetEventHandler(handler); | |
1548 | } | |
1549 | ||
1550 | wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) | |
1551 | { | |
1552 | if ( GetEventHandler() ) | |
1553 | { | |
1554 | wxEvtHandler *handlerA = GetEventHandler(); | |
1555 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
1556 | handlerA->SetNextHandler(NULL); | |
1557 | SetEventHandler(handlerB); | |
1558 | if ( deleteHandler ) | |
1559 | { | |
1560 | delete handlerA; | |
1561 | return NULL; | |
1562 | } | |
1563 | else | |
1564 | return handlerA; | |
1565 | } | |
1566 | else | |
1567 | return NULL; | |
1568 | } | |
1569 | ||
c801d85f KB |
1570 | wxValidator *wxWindow::GetValidator(void) |
1571 | { | |
1572 | return m_windowValidator; | |
362c6693 | 1573 | } |
c801d85f | 1574 | |
6de97a3b | 1575 | void wxWindow::SetValidator( const wxValidator& validator ) |
c801d85f | 1576 | { |
6de97a3b RR |
1577 | if (m_windowValidator) delete m_windowValidator; |
1578 | m_windowValidator = validator.Clone(); | |
1579 | if (m_windowValidator) m_windowValidator->SetWindow(this); | |
362c6693 | 1580 | } |
c801d85f KB |
1581 | |
1582 | bool wxWindow::IsBeingDeleted(void) | |
1583 | { | |
1584 | return FALSE; | |
362c6693 | 1585 | } |
c801d85f KB |
1586 | |
1587 | void wxWindow::SetId( wxWindowID id ) | |
1588 | { | |
1589 | m_windowId = id; | |
362c6693 | 1590 | } |
c801d85f KB |
1591 | |
1592 | wxWindowID wxWindow::GetId(void) | |
1593 | { | |
1594 | return m_windowId; | |
362c6693 | 1595 | } |
c801d85f KB |
1596 | |
1597 | void wxWindow::SetCursor( const wxCursor &cursor ) | |
1598 | { | |
a3622daa VZ |
1599 | wxASSERT(m_cursor != NULL); |
1600 | ||
1601 | if (m_cursor != NULL) | |
1602 | if (*m_cursor == cursor) | |
1603 | return; | |
c801d85f KB |
1604 | (*m_cursor) = cursor; |
1605 | if (m_widget->window) | |
1606 | gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() ); | |
1607 | if (m_wxwindow && m_wxwindow->window) | |
1608 | gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() ); | |
362c6693 | 1609 | } |
c801d85f | 1610 | |
debe6624 | 1611 | void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) |
c801d85f KB |
1612 | { |
1613 | if (eraseBackground && m_wxwindow && m_wxwindow->window) | |
1614 | { | |
1615 | if (rect) | |
1616 | gdk_window_clear_area( m_wxwindow->window, | |
1617 | rect->x, | |
d4c99d6f RR |
1618 | rect->y, |
1619 | rect->width, | |
1620 | rect->height ); | |
c801d85f | 1621 | else |
30dea054 | 1622 | Clear(); |
362c6693 | 1623 | } |
c801d85f KB |
1624 | if (!rect) |
1625 | { | |
1626 | if (m_wxwindow) | |
1627 | { | |
1628 | wxClientDC dc(this); | |
1629 | PrepareDC(dc); | |
1630 | long x = 0; | |
1631 | long y = 0; | |
1632 | dc.GetInternalDeviceOrigin( &x, &y ); | |
1633 | ||
1634 | int w = 0; | |
1635 | int h = 0; | |
1636 | GetClientSize( &w, &h ); | |
1637 | ||
1638 | GdkRectangle gdk_rect; | |
1639 | gdk_rect.x = x; | |
1640 | gdk_rect.y = y; | |
1641 | gdk_rect.width = w; | |
1642 | gdk_rect.height = h; | |
1643 | gtk_widget_draw( m_wxwindow, &gdk_rect ); | |
362c6693 | 1644 | } |
c801d85f KB |
1645 | } |
1646 | else | |
1647 | { | |
1648 | GdkRectangle gdk_rect; | |
1649 | gdk_rect.x = rect->x; | |
1650 | gdk_rect.y = rect->y; | |
1651 | gdk_rect.width = rect->width; | |
1652 | gdk_rect.height = rect->height; | |
d4c99d6f | 1653 | |
c801d85f KB |
1654 | if (m_wxwindow) |
1655 | gtk_widget_draw( m_wxwindow, &gdk_rect ); | |
1656 | else | |
1657 | gtk_widget_draw( m_widget, &gdk_rect ); | |
362c6693 RR |
1658 | } |
1659 | } | |
c801d85f | 1660 | |
debe6624 | 1661 | bool wxWindow::IsExposed( long x, long y ) |
c801d85f KB |
1662 | { |
1663 | return (m_updateRegion.Contains( x, y ) != wxOutRegion ); | |
362c6693 | 1664 | } |
c801d85f | 1665 | |
debe6624 | 1666 | bool wxWindow::IsExposed( long x, long y, long width, long height ) |
c801d85f KB |
1667 | { |
1668 | return (m_updateRegion.Contains( x, y, width, height ) != wxOutRegion ); | |
362c6693 | 1669 | } |
c801d85f KB |
1670 | |
1671 | void wxWindow::Clear(void) | |
1672 | { | |
1673 | if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window ); | |
362c6693 | 1674 | } |
c801d85f KB |
1675 | |
1676 | wxColour wxWindow::GetBackgroundColour(void) const | |
1677 | { | |
1678 | return m_backgroundColour; | |
362c6693 | 1679 | } |
c801d85f KB |
1680 | |
1681 | void wxWindow::SetBackgroundColour( const wxColour &colour ) | |
1682 | { | |
1683 | m_backgroundColour = colour; | |
1684 | if (m_wxwindow) | |
1685 | { | |
1686 | m_backgroundColour.CalcPixel( m_wxwindow->style->colormap ); | |
1687 | gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() ); | |
1688 | gdk_window_clear( m_wxwindow->window ); | |
362c6693 | 1689 | } |
c801d85f | 1690 | // do something ? |
362c6693 | 1691 | } |
c801d85f | 1692 | |
6de97a3b RR |
1693 | wxColour wxWindow::GetForegroundColour(void) const |
1694 | { | |
1695 | return m_foregroundColour; | |
1696 | } | |
1697 | ||
1698 | void wxWindow::SetForegroundColour( const wxColour &colour ) | |
1699 | { | |
1700 | m_foregroundColour = colour; | |
1701 | } | |
1702 | ||
c801d85f KB |
1703 | bool wxWindow::Validate(void) |
1704 | { | |
1705 | wxNode *node = GetChildren()->First(); | |
1706 | while (node) | |
1707 | { | |
1708 | wxWindow *child = (wxWindow *)node->Data(); | |
1709 | if (child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this)) | |
1710 | { return FALSE; } | |
1711 | node = node->Next(); | |
362c6693 | 1712 | } |
c801d85f | 1713 | return TRUE; |
362c6693 | 1714 | } |
c801d85f KB |
1715 | |
1716 | bool wxWindow::TransferDataToWindow(void) | |
1717 | { | |
1718 | wxNode *node = GetChildren()->First(); | |
1719 | while (node) | |
1720 | { | |
1721 | wxWindow *child = (wxWindow *)node->Data(); | |
1722 | if (child->GetValidator() && /* child->GetValidator()->Ok() && */ | |
5e0aa05a | 1723 | !child->GetValidator()->TransferToWindow() ) |
c801d85f | 1724 | { |
1a5a8367 | 1725 | wxMessageBox( _("Application Error"), _("Could not transfer data to window"), wxOK|wxICON_EXCLAMATION ); |
c801d85f | 1726 | return FALSE; |
362c6693 | 1727 | } |
c801d85f | 1728 | node = node->Next(); |
362c6693 | 1729 | } |
c801d85f | 1730 | return TRUE; |
362c6693 | 1731 | } |
c801d85f KB |
1732 | |
1733 | bool wxWindow::TransferDataFromWindow(void) | |
1734 | { | |
1735 | wxNode *node = GetChildren()->First(); | |
1736 | while (node) | |
1737 | { | |
1738 | wxWindow *child = (wxWindow *)node->Data(); | |
1739 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() ) | |
1740 | { return FALSE; } | |
1741 | node = node->Next(); | |
1742 | } | |
1743 | return TRUE; | |
362c6693 | 1744 | } |
c801d85f KB |
1745 | |
1746 | void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) ) | |
1747 | { | |
1748 | TransferDataToWindow(); | |
362c6693 | 1749 | } |
c801d85f KB |
1750 | |
1751 | void wxWindow::InitDialog(void) | |
1752 | { | |
1753 | wxInitDialogEvent event(GetId()); | |
1754 | event.SetEventObject( this ); | |
1755 | GetEventHandler()->ProcessEvent(event); | |
362c6693 | 1756 | } |
c801d85f | 1757 | |
30dea054 RR |
1758 | static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) |
1759 | { | |
1760 | menu->SetInvokingWindow( win ); | |
1761 | wxNode *node = menu->m_items.First(); | |
1762 | while (node) | |
1763 | { | |
1764 | wxMenuItem *menuitem = (wxMenuItem*)node->Data(); | |
1765 | if (menuitem->IsSubMenu()) | |
1766 | SetInvokingWindow( menuitem->GetSubMenu(), win ); | |
1767 | node = node->Next(); | |
362c6693 RR |
1768 | } |
1769 | } | |
30dea054 RR |
1770 | |
1771 | bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) ) | |
1772 | { | |
1773 | SetInvokingWindow( menu, this ); | |
1774 | gtk_menu_popup( GTK_MENU(menu->m_menu), NULL, NULL, NULL, NULL, 0, 0 ); | |
1775 | return TRUE; | |
1776 | } | |
1777 | ||
c801d85f KB |
1778 | void wxWindow::SetDropTarget( wxDropTarget *dropTarget ) |
1779 | { | |
30dea054 | 1780 | GtkWidget *dnd_widget = GetConnectWidget(); |
e3e65dac | 1781 | |
c801d85f KB |
1782 | if (m_pDropTarget) |
1783 | { | |
e3e65dac RR |
1784 | gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget), |
1785 | GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); | |
1786 | ||
1787 | m_pDropTarget->UnregisterWidget( dnd_widget ); | |
c801d85f | 1788 | delete m_pDropTarget; |
362c6693 | 1789 | } |
c801d85f KB |
1790 | m_pDropTarget = dropTarget; |
1791 | if (m_pDropTarget) | |
1792 | { | |
e3e65dac RR |
1793 | m_pDropTarget->RegisterWidget( dnd_widget ); |
1794 | ||
1795 | gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event", | |
1796 | GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this ); | |
362c6693 RR |
1797 | } |
1798 | } | |
c801d85f KB |
1799 | |
1800 | wxDropTarget *wxWindow::GetDropTarget() const | |
1801 | { | |
1802 | return m_pDropTarget; | |
362c6693 | 1803 | } |
c801d85f | 1804 | |
30dea054 | 1805 | GtkWidget* wxWindow::GetConnectWidget(void) |
e3e65dac RR |
1806 | { |
1807 | GtkWidget *connect_widget = m_widget; | |
1808 | if (m_wxwindow) connect_widget = m_wxwindow; | |
1809 | ||
1810 | return connect_widget; | |
1811 | } | |
1812 | ||
903f689b RR |
1813 | bool wxWindow::IsOwnGtkWindow( GdkWindow *window ) |
1814 | { | |
1815 | if (m_wxwindow) return (window == m_wxwindow->window); | |
1816 | return (window == m_widget->window); | |
1817 | } | |
1818 | ||
c801d85f KB |
1819 | void wxWindow::SetFont( const wxFont &font ) |
1820 | { | |
1821 | m_font = font; | |
1822 | /* | |
1823 | create new style | |
1824 | copy old style values to new one | |
1825 | set font in new style | |
1826 | -> takes to many resources | |
1827 | ||
1828 | GtkStyle *style = gtk_style_new(); | |
1829 | ... | |
1830 | */ | |
362c6693 | 1831 | } |
c801d85f KB |
1832 | |
1833 | wxFont *wxWindow::GetFont(void) | |
1834 | { | |
1835 | return &m_font; | |
362c6693 | 1836 | } |
c801d85f KB |
1837 | |
1838 | void wxWindow::SetWindowStyleFlag( long flag ) | |
1839 | { | |
1840 | m_windowStyle = flag; | |
362c6693 | 1841 | } |
c801d85f KB |
1842 | |
1843 | long wxWindow::GetWindowStyleFlag(void) const | |
1844 | { | |
1845 | return m_windowStyle; | |
362c6693 | 1846 | } |
c801d85f KB |
1847 | |
1848 | void wxWindow::CaptureMouse(void) | |
1849 | { | |
30dea054 | 1850 | GtkWidget *connect_widget = GetConnectWidget(); |
c801d85f KB |
1851 | gtk_grab_add( connect_widget ); |
1852 | gdk_pointer_grab ( connect_widget->window, FALSE, | |
1853 | (GdkEventMask) | |
5e0aa05a VZ |
1854 | (GDK_BUTTON_PRESS_MASK | |
1855 | GDK_BUTTON_RELEASE_MASK | | |
1856 | GDK_POINTER_MOTION_MASK), | |
1857 | NULL, NULL, GDK_CURRENT_TIME ); | |
362c6693 | 1858 | } |
c801d85f KB |
1859 | |
1860 | void wxWindow::ReleaseMouse(void) | |
1861 | { | |
30dea054 | 1862 | GtkWidget *connect_widget = GetConnectWidget(); |
c801d85f KB |
1863 | gtk_grab_remove( connect_widget ); |
1864 | gdk_pointer_ungrab ( GDK_CURRENT_TIME ); | |
362c6693 | 1865 | } |
c801d85f KB |
1866 | |
1867 | void wxWindow::SetTitle( const wxString &WXUNUSED(title) ) | |
1868 | { | |
362c6693 | 1869 | } |
c801d85f KB |
1870 | |
1871 | wxString wxWindow::GetTitle(void) const | |
1872 | { | |
1873 | return (wxString&)m_windowName; | |
362c6693 | 1874 | } |
c801d85f KB |
1875 | |
1876 | wxString wxWindow::GetLabel(void) const | |
1877 | { | |
1878 | return GetTitle(); | |
362c6693 | 1879 | } |
c801d85f KB |
1880 | |
1881 | void wxWindow::SetName( const wxString &name ) | |
1882 | { | |
1883 | m_windowName = name; | |
362c6693 | 1884 | } |
c801d85f KB |
1885 | |
1886 | wxString wxWindow::GetName(void) const | |
1887 | { | |
1888 | return (wxString&)m_windowName; | |
362c6693 | 1889 | } |
c801d85f | 1890 | |
7fd1d163 | 1891 | bool wxWindow::IsShown(void) const |
c801d85f KB |
1892 | { |
1893 | return m_isShown; | |
362c6693 | 1894 | } |
c801d85f KB |
1895 | |
1896 | bool wxWindow::IsRetained(void) | |
1897 | { | |
1898 | return FALSE; | |
362c6693 | 1899 | } |
c801d85f | 1900 | |
debe6624 | 1901 | wxWindow *wxWindow::FindWindow( long id ) |
c801d85f KB |
1902 | { |
1903 | if (id == m_windowId) return this; | |
1904 | wxNode *node = m_children.First(); | |
1905 | while (node) | |
1906 | { | |
1907 | wxWindow *child = (wxWindow*)node->Data(); | |
1908 | wxWindow *res = child->FindWindow( id ); | |
1909 | if (res) return res; | |
1910 | node = node->Next(); | |
362c6693 | 1911 | } |
c801d85f | 1912 | return NULL; |
362c6693 | 1913 | } |
c801d85f KB |
1914 | |
1915 | wxWindow *wxWindow::FindWindow( const wxString& name ) | |
1916 | { | |
1917 | if (name == m_windowName) return this; | |
1918 | wxNode *node = m_children.First(); | |
1919 | while (node) | |
1920 | { | |
1921 | wxWindow *child = (wxWindow*)node->Data(); | |
1922 | wxWindow *res = child->FindWindow( name ); | |
1923 | if (res) return res; | |
1924 | node = node->Next(); | |
362c6693 | 1925 | } |
c801d85f | 1926 | return NULL; |
362c6693 | 1927 | } |
c801d85f | 1928 | |
debe6624 JS |
1929 | void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, |
1930 | int range, bool WXUNUSED(refresh) ) | |
c801d85f KB |
1931 | { |
1932 | if (!m_wxwindow) return; | |
1933 | ||
1934 | if (orient == wxHORIZONTAL) | |
1935 | { | |
1936 | float fpos = (float)pos; | |
1937 | m_oldHorizontalPos = fpos; | |
1938 | float frange = (float)range; | |
1939 | float fthumb = (float)thumbVisible; | |
1940 | ||
1941 | if ((fabs(fpos-m_hAdjust->value) < 0.2) && | |
1942 | (fabs(frange-m_hAdjust->upper) < 0.2) && | |
5e0aa05a | 1943 | (fabs(fthumb-m_hAdjust->page_size) < 0.2)) |
c801d85f KB |
1944 | return; |
1945 | ||
1946 | m_hAdjust->lower = 0.0; | |
1947 | m_hAdjust->upper = frange; | |
1948 | m_hAdjust->value = fpos; | |
1949 | m_hAdjust->step_increment = 1.0; | |
1950 | m_hAdjust->page_increment = (float)(wxMax(fthumb-2,0)); | |
1951 | m_hAdjust->page_size = fthumb; | |
1952 | } | |
1953 | else | |
1954 | { | |
1955 | float fpos = (float)pos; | |
1956 | m_oldVerticalPos = fpos; | |
1957 | float frange = (float)range; | |
1958 | float fthumb = (float)thumbVisible; | |
1959 | ||
1960 | if ((fabs(fpos-m_vAdjust->value) < 0.2) && | |
1961 | (fabs(frange-m_vAdjust->upper) < 0.2) && | |
5e0aa05a | 1962 | (fabs(fthumb-m_vAdjust->page_size) < 0.2)) |
c801d85f KB |
1963 | return; |
1964 | ||
1965 | m_vAdjust->lower = 0.0; | |
1966 | m_vAdjust->upper = frange; | |
1967 | m_vAdjust->value = fpos; | |
1968 | m_vAdjust->step_increment = 1.0; | |
1969 | m_vAdjust->page_increment = (float)(wxMax(fthumb-2,0)); | |
1970 | m_vAdjust->page_size = fthumb; | |
362c6693 | 1971 | } |
33d0b396 | 1972 | |
c801d85f | 1973 | if (m_wxwindow->window) |
d4c99d6f | 1974 | { |
c801d85f | 1975 | if (orient == wxHORIZONTAL) |
d4c99d6f RR |
1976 | { |
1977 | /* | |
1978 | m_drawingOffsetX = -16000; | |
1979 | ||
1980 | gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY ); | |
1981 | */ | |
c801d85f | 1982 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); |
d4c99d6f RR |
1983 | } |
1984 | else | |
1985 | { | |
1986 | /* | |
1987 | m_drawingOffsetY = -16000; | |
1988 | ||
1989 | gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY ); | |
1990 | */ | |
c801d85f | 1991 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); |
d4c99d6f | 1992 | } |
c801d85f | 1993 | |
401ec7b6 | 1994 | gtk_widget_set_usize( m_widget, m_width, m_height ); |
362c6693 RR |
1995 | } |
1996 | } | |
c801d85f | 1997 | |
debe6624 | 1998 | void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) |
c801d85f KB |
1999 | { |
2000 | if (!m_wxwindow) return; | |
2001 | ||
2002 | if (orient == wxHORIZONTAL) | |
2003 | { | |
2004 | float fpos = (float)pos; | |
2005 | m_oldHorizontalPos = fpos; | |
2006 | ||
2007 | if (fabs(fpos-m_hAdjust->value) < 0.2) return; | |
2008 | m_hAdjust->value = fpos; | |
2009 | } | |
2010 | else | |
2011 | { | |
2012 | float fpos = (float)pos; | |
2013 | m_oldVerticalPos = fpos; | |
2014 | if (fabs(fpos-m_vAdjust->value) < 0.2) return; | |
2015 | m_vAdjust->value = fpos; | |
362c6693 | 2016 | } |
c801d85f KB |
2017 | |
2018 | if (m_wxwindow->window) | |
2019 | { | |
2020 | if (orient == wxHORIZONTAL) | |
2021 | gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); | |
2022 | else | |
2023 | gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); | |
362c6693 RR |
2024 | } |
2025 | } | |
c801d85f | 2026 | |
debe6624 | 2027 | int wxWindow::GetScrollThumb( int orient ) const |
c801d85f KB |
2028 | { |
2029 | if (!m_wxwindow) return 0; | |
2030 | ||
2031 | if (orient == wxHORIZONTAL) | |
2032 | return (int)(m_hAdjust->page_size+0.5); | |
2033 | else | |
2034 | return (int)(m_vAdjust->page_size+0.5); | |
362c6693 | 2035 | } |
c801d85f | 2036 | |
debe6624 | 2037 | int wxWindow::GetScrollPos( int orient ) const |
c801d85f KB |
2038 | { |
2039 | if (!m_wxwindow) return 0; | |
2040 | ||
2041 | if (orient == wxHORIZONTAL) | |
2042 | return (int)(m_hAdjust->value+0.5); | |
2043 | else | |
2044 | return (int)(m_vAdjust->value+0.5); | |
362c6693 | 2045 | } |
c801d85f | 2046 | |
debe6624 | 2047 | int wxWindow::GetScrollRange( int orient ) const |
c801d85f KB |
2048 | { |
2049 | if (!m_wxwindow) return 0; | |
2050 | ||
2051 | if (orient == wxHORIZONTAL) | |
2052 | return (int)(m_hAdjust->upper+0.5); | |
2053 | else | |
2054 | return (int)(m_vAdjust->upper+0.5); | |
362c6693 | 2055 | } |
c801d85f | 2056 | |
debe6624 | 2057 | void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) |
c801d85f KB |
2058 | { |
2059 | if (!m_wxwindow) return; | |
2060 | ||
d4c99d6f RR |
2061 | bool refresh = FALSE; |
2062 | ||
2063 | if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0)) | |
2064 | { | |
2065 | m_drawingOffsetX = -16000; | |
2066 | m_drawingOffsetY = -16000; | |
2067 | refresh = TRUE; | |
2068 | } | |
2069 | else | |
2070 | { | |
2071 | m_drawingOffsetX += dx; | |
2072 | m_drawingOffsetY += dy; | |
2073 | } | |
c801d85f KB |
2074 | |
2075 | // printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY ); | |
2076 | ||
2077 | gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY ); | |
2078 | ||
d4c99d6f RR |
2079 | if (refresh) Refresh(); |
2080 | ||
c801d85f KB |
2081 | /* |
2082 | The code here is very nifty, but it doesn't work with | |
2083 | overlapping windows... | |
2084 | ||
2085 | int cw = 0; | |
2086 | int ch = 0; | |
2087 | GetClientSize( &cw, &ch ); | |
2088 | ||
2089 | int w = cw - abs(dx); | |
2090 | int h = ch - abs(dy); | |
2091 | if ((h < 0) || (w < 0)) | |
2092 | { | |
2093 | Refresh(); | |
2094 | return; | |
362c6693 | 2095 | } |
c801d85f KB |
2096 | int s_x = 0; |
2097 | int s_y = 0; | |
2098 | if (dx < 0) s_x = -dx; | |
2099 | if (dy < 0) s_y = -dy; | |
2100 | int d_x = 0; | |
2101 | int d_y = 0; | |
2102 | if (dx > 0) d_x = dx; | |
2103 | if (dy > 0) d_y = dy; | |
2104 | gdk_window_copy_area( m_wxwindow->window, m_wxwindow->style->fg_gc[0], d_x, d_y, | |
2105 | m_wxwindow->window, s_x, s_y, w, h ); | |
2106 | ||
2107 | wxRect rect; | |
2108 | if (dx < 0) rect.x = cw+dx; else rect.x = 0; | |
2109 | if (dy < 0) rect.y = ch+dy; else rect.y = 0; | |
2110 | if (dy != 0) rect.width = cw; else rect.width = abs(dx); | |
2111 | if (dx != 0) rect.height = ch; else rect.height = abs(dy); | |
2112 | ||
2113 | Refresh( TRUE, &rect ); | |
2114 | */ | |
362c6693 | 2115 | } |
c801d85f KB |
2116 | |
2117 | void wxWindow::GetDrawingOffset( long *x, long *y ) | |
2118 | { | |
2119 | if (x) *x = m_drawingOffsetX; | |
2120 | if (y) *y = m_drawingOffsetY; | |
362c6693 | 2121 | } |
c801d85f KB |
2122 | |
2123 | //------------------------------------------------------------------------------------- | |
2124 | // Layout | |
2125 | //------------------------------------------------------------------------------------- | |
2126 | ||
2127 | wxLayoutConstraints *wxWindow::GetConstraints(void) const | |
2128 | { | |
2129 | return m_constraints; | |
362c6693 | 2130 | } |
c801d85f KB |
2131 | |
2132 | void wxWindow::SetConstraints( wxLayoutConstraints *constraints ) | |
2133 | { | |
2134 | if (m_constraints) | |
2135 | { | |
2136 | UnsetConstraints(m_constraints); | |
2137 | delete m_constraints; | |
2138 | } | |
2139 | m_constraints = constraints; | |
2140 | if (m_constraints) | |
2141 | { | |
2142 | // Make sure other windows know they're part of a 'meaningful relationship' | |
2143 | if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) | |
2144 | m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2145 | if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) | |
2146 | m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2147 | if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) | |
2148 | m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2149 | if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) | |
2150 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2151 | if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) | |
2152 | m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2153 | if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) | |
2154 | m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2155 | if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) | |
2156 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2157 | if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) | |
2158 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
2159 | } | |
2160 | ; | |
2161 | } | |
2162 | ; | |
2163 | ||
debe6624 | 2164 | void wxWindow::SetAutoLayout( bool autoLayout ) |
c801d85f KB |
2165 | { |
2166 | m_autoLayout = autoLayout; | |
362c6693 | 2167 | } |
c801d85f KB |
2168 | |
2169 | bool wxWindow::GetAutoLayout(void) const | |
2170 | { | |
2171 | return m_autoLayout; | |
362c6693 | 2172 | } |
c801d85f KB |
2173 | |
2174 | wxSizer *wxWindow::GetSizer(void) const | |
2175 | { | |
2176 | return m_windowSizer; | |
362c6693 | 2177 | } |
c801d85f KB |
2178 | |
2179 | void wxWindow::SetSizerParent( wxWindow *win ) | |
2180 | { | |
2181 | m_sizerParent = win; | |
362c6693 | 2182 | } |
c801d85f KB |
2183 | |
2184 | wxWindow *wxWindow::GetSizerParent(void) const | |
2185 | { | |
2186 | return m_sizerParent; | |
362c6693 | 2187 | } |
c801d85f KB |
2188 | |
2189 | // This removes any dangling pointers to this window | |
2190 | // in other windows' constraintsInvolvedIn lists. | |
2191 | void wxWindow::UnsetConstraints(wxLayoutConstraints *c) | |
2192 | { | |
2193 | if (c) | |
2194 | { | |
2195 | if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
2196 | c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2197 | if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
2198 | c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2199 | if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) | |
2200 | c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2201 | if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) | |
2202 | c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2203 | if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) | |
2204 | c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2205 | if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) | |
2206 | c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2207 | if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) | |
2208 | c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2209 | if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) | |
2210 | c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
2211 | } | |
2212 | } | |
2213 | ||
2214 | // Back-pointer to other windows we're involved with, so if we delete | |
2215 | // this window, we must delete any constraints we're involved with. | |
2216 | void wxWindow::AddConstraintReference(wxWindow *otherWin) | |
2217 | { | |
2218 | if (!m_constraintsInvolvedIn) | |
2219 | m_constraintsInvolvedIn = new wxList; | |
2220 | if (!m_constraintsInvolvedIn->Member(otherWin)) | |
2221 | m_constraintsInvolvedIn->Append(otherWin); | |
2222 | } | |
2223 | ||
2224 | // REMOVE back-pointer to other windows we're involved with. | |
2225 | void wxWindow::RemoveConstraintReference(wxWindow *otherWin) | |
2226 | { | |
2227 | if (m_constraintsInvolvedIn) | |
2228 | m_constraintsInvolvedIn->DeleteObject(otherWin); | |
2229 | } | |
2230 | ||
2231 | // Reset any constraints that mention this window | |
2232 | void wxWindow::DeleteRelatedConstraints(void) | |
2233 | { | |
2234 | if (m_constraintsInvolvedIn) | |
2235 | { | |
2236 | wxNode *node = m_constraintsInvolvedIn->First(); | |
2237 | while (node) | |
2238 | { | |
2239 | wxWindow *win = (wxWindow *)node->Data(); | |
2240 | wxNode *next = node->Next(); | |
2241 | wxLayoutConstraints *constr = win->GetConstraints(); | |
2242 | ||
2243 | // Reset any constraints involving this window | |
2244 | if (constr) | |
2245 | { | |
2246 | constr->left.ResetIfWin((wxWindow *)this); | |
2247 | constr->top.ResetIfWin((wxWindow *)this); | |
2248 | constr->right.ResetIfWin((wxWindow *)this); | |
2249 | constr->bottom.ResetIfWin((wxWindow *)this); | |
2250 | constr->width.ResetIfWin((wxWindow *)this); | |
2251 | constr->height.ResetIfWin((wxWindow *)this); | |
2252 | constr->centreX.ResetIfWin((wxWindow *)this); | |
2253 | constr->centreY.ResetIfWin((wxWindow *)this); | |
2254 | } | |
2255 | delete node; | |
2256 | node = next; | |
2257 | } | |
2258 | delete m_constraintsInvolvedIn; | |
2259 | m_constraintsInvolvedIn = NULL; | |
2260 | } | |
2261 | } | |
2262 | ||
2263 | void wxWindow::SetSizer(wxSizer *sizer) | |
2264 | { | |
2265 | m_windowSizer = sizer; | |
2266 | if (sizer) | |
2267 | sizer->SetSizerParent((wxWindow *)this); | |
2268 | } | |
2269 | ||
2270 | /* | |
2271 | * New version | |
2272 | */ | |
2273 | ||
2274 | bool wxWindow::Layout(void) | |
2275 | { | |
2276 | if (GetConstraints()) | |
2277 | { | |
2278 | int w, h; | |
2279 | GetClientSize(&w, &h); | |
2280 | GetConstraints()->width.SetValue(w); | |
2281 | GetConstraints()->height.SetValue(h); | |
2282 | } | |
2283 | ||
2284 | // If top level (one sizer), evaluate the sizer's constraints. | |
2285 | if (GetSizer()) | |
2286 | { | |
2287 | int noChanges; | |
2288 | GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated | |
2289 | GetSizer()->LayoutPhase1(&noChanges); | |
2290 | GetSizer()->LayoutPhase2(&noChanges); | |
2291 | GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes | |
2292 | return TRUE; | |
2293 | } | |
2294 | else | |
2295 | { | |
2296 | // Otherwise, evaluate child constraints | |
2297 | ResetConstraints(); // Mark all constraints as unevaluated | |
2298 | DoPhase(1); // Just one phase need if no sizers involved | |
2299 | DoPhase(2); | |
2300 | SetConstraintSizes(); // Recursively set the real window sizes | |
2301 | } | |
2302 | return TRUE; | |
2303 | } | |
2304 | ||
2305 | ||
2306 | // Do a phase of evaluating constraints: | |
2307 | // the default behaviour. wxSizers may do a similar | |
2308 | // thing, but also impose their own 'constraints' | |
2309 | // and order the evaluation differently. | |
2310 | bool wxWindow::LayoutPhase1(int *noChanges) | |
2311 | { | |
2312 | wxLayoutConstraints *constr = GetConstraints(); | |
2313 | if (constr) | |
2314 | { | |
2315 | return constr->SatisfyConstraints((wxWindow *)this, noChanges); | |
2316 | } | |
2317 | else | |
2318 | return TRUE; | |
2319 | } | |
2320 | ||
2321 | bool wxWindow::LayoutPhase2(int *noChanges) | |
2322 | { | |
2323 | *noChanges = 0; | |
2324 | ||
2325 | // Layout children | |
2326 | DoPhase(1); | |
2327 | DoPhase(2); | |
2328 | return TRUE; | |
2329 | } | |
2330 | ||
2331 | // Do a phase of evaluating child constraints | |
debe6624 | 2332 | bool wxWindow::DoPhase(int phase) |
c801d85f KB |
2333 | { |
2334 | int noIterations = 0; | |
2335 | int maxIterations = 500; | |
2336 | int noChanges = 1; | |
2337 | int noFailures = 0; | |
2338 | wxList succeeded; | |
2339 | while ((noChanges > 0) && (noIterations < maxIterations)) | |
2340 | { | |
2341 | noChanges = 0; | |
2342 | noFailures = 0; | |
2343 | wxNode *node = GetChildren()->First(); | |
2344 | while (node) | |
2345 | { | |
2346 | wxWindow *child = (wxWindow *)node->Data(); | |
2347 | if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) | |
2348 | { | |
2349 | wxLayoutConstraints *constr = child->GetConstraints(); | |
2350 | if (constr) | |
2351 | { | |
2352 | if (succeeded.Member(child)) | |
2353 | { | |
2354 | } | |
2355 | else | |
2356 | { | |
2357 | int tempNoChanges = 0; | |
2358 | bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; | |
2359 | noChanges += tempNoChanges; | |
2360 | if (success) | |
2361 | { | |
2362 | succeeded.Append(child); | |
2363 | } | |
2364 | } | |
2365 | } | |
2366 | } | |
2367 | node = node->Next(); | |
2368 | } | |
2369 | noIterations ++; | |
2370 | } | |
2371 | return TRUE; | |
2372 | } | |
2373 | ||
2374 | void wxWindow::ResetConstraints(void) | |
2375 | { | |
2376 | wxLayoutConstraints *constr = GetConstraints(); | |
2377 | if (constr) | |
2378 | { | |
2379 | constr->left.SetDone(FALSE); | |
2380 | constr->top.SetDone(FALSE); | |
2381 | constr->right.SetDone(FALSE); | |
2382 | constr->bottom.SetDone(FALSE); | |
2383 | constr->width.SetDone(FALSE); | |
2384 | constr->height.SetDone(FALSE); | |
2385 | constr->centreX.SetDone(FALSE); | |
2386 | constr->centreY.SetDone(FALSE); | |
2387 | } | |
2388 | wxNode *node = GetChildren()->First(); | |
2389 | while (node) | |
2390 | { | |
2391 | wxWindow *win = (wxWindow *)node->Data(); | |
2392 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
2393 | win->ResetConstraints(); | |
2394 | node = node->Next(); | |
2395 | } | |
2396 | } | |
2397 | ||
2398 | // Need to distinguish between setting the 'fake' size for | |
2399 | // windows and sizers, and setting the real values. | |
debe6624 | 2400 | void wxWindow::SetConstraintSizes(bool recurse) |
c801d85f KB |
2401 | { |
2402 | wxLayoutConstraints *constr = GetConstraints(); | |
2403 | if (constr && constr->left.GetDone() && constr->right.GetDone() && | |
2404 | constr->width.GetDone() && constr->height.GetDone()) | |
2405 | { | |
2406 | int x = constr->left.GetValue(); | |
2407 | int y = constr->top.GetValue(); | |
2408 | int w = constr->width.GetValue(); | |
2409 | int h = constr->height.GetValue(); | |
2410 | ||
2411 | // If we don't want to resize this window, just move it... | |
2412 | if ((constr->width.GetRelationship() != wxAsIs) || | |
2413 | (constr->height.GetRelationship() != wxAsIs)) | |
2414 | { | |
2415 | // Calls Layout() recursively. AAAGH. How can we stop that. | |
2416 | // Simply take Layout() out of non-top level OnSizes. | |
2417 | SizerSetSize(x, y, w, h); | |
2418 | } | |
2419 | else | |
2420 | { | |
2421 | SizerMove(x, y); | |
2422 | } | |
2423 | } | |
2424 | else if (constr) | |
2425 | { | |
2426 | char *windowClass = this->GetClassInfo()->GetClassName(); | |
2427 | ||
2428 | wxString winName; | |
5e0aa05a | 2429 | if (GetName() == "") |
1a5a8367 | 2430 | winName = _("unnamed"); |
5e0aa05a VZ |
2431 | else |
2432 | winName = GetName(); | |
1a5a8367 | 2433 | wxDebugMsg(_("Constraint(s) not satisfied for window of type %s, name %s:\n"), (const char *)windowClass, (const char *)winName); |
c801d85f | 2434 | if (!constr->left.GetDone()) |
1a5a8367 | 2435 | wxDebugMsg(_(" unsatisfied 'left' constraint.\n")); |
c801d85f | 2436 | if (!constr->right.GetDone()) |
1a5a8367 | 2437 | wxDebugMsg(_(" unsatisfied 'right' constraint.\n")); |
c801d85f | 2438 | if (!constr->width.GetDone()) |
1a5a8367 | 2439 | wxDebugMsg(_(" unsatisfied 'width' constraint.\n")); |
c801d85f | 2440 | if (!constr->height.GetDone()) |
1a5a8367 DP |
2441 | wxDebugMsg(_(" unsatisfied 'height' constraint.\n")); |
2442 | wxDebugMsg(_("Please check constraints: try adding AsIs() constraints.\n")); | |
c801d85f KB |
2443 | } |
2444 | ||
2445 | if (recurse) | |
2446 | { | |
2447 | wxNode *node = GetChildren()->First(); | |
2448 | while (node) | |
2449 | { | |
2450 | wxWindow *win = (wxWindow *)node->Data(); | |
2451 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
2452 | win->SetConstraintSizes(); | |
2453 | node = node->Next(); | |
2454 | } | |
2455 | } | |
2456 | } | |
2457 | ||
2458 | // This assumes that all sizers are 'on' the same | |
2459 | // window, i.e. the parent of this window. | |
2460 | void wxWindow::TransformSizerToActual(int *x, int *y) const | |
2461 | { | |
2462 | if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || | |
5e0aa05a | 2463 | m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) |
c801d85f KB |
2464 | return; |
2465 | ||
2466 | int xp, yp; | |
2467 | m_sizerParent->GetPosition(&xp, &yp); | |
2468 | m_sizerParent->TransformSizerToActual(&xp, &yp); | |
2469 | *x += xp; | |
2470 | *y += yp; | |
2471 | } | |
2472 | ||
debe6624 | 2473 | void wxWindow::SizerSetSize(int x, int y, int w, int h) |
c801d85f | 2474 | { |
5e0aa05a VZ |
2475 | int xx = x; |
2476 | int yy = y; | |
c801d85f KB |
2477 | TransformSizerToActual(&xx, &yy); |
2478 | SetSize(xx, yy, w, h); | |
2479 | } | |
2480 | ||
debe6624 | 2481 | void wxWindow::SizerMove(int x, int y) |
c801d85f | 2482 | { |
5e0aa05a VZ |
2483 | int xx = x; |
2484 | int yy = y; | |
c801d85f KB |
2485 | TransformSizerToActual(&xx, &yy); |
2486 | Move(xx, yy); | |
2487 | } | |
2488 | ||
2489 | // Only set the size/position of the constraint (if any) | |
debe6624 | 2490 | void wxWindow::SetSizeConstraint(int x, int y, int w, int h) |
c801d85f KB |
2491 | { |
2492 | wxLayoutConstraints *constr = GetConstraints(); | |
2493 | if (constr) | |
2494 | { | |
2495 | if (x != -1) | |
2496 | { | |
2497 | constr->left.SetValue(x); | |
2498 | constr->left.SetDone(TRUE); | |
2499 | } | |
2500 | if (y != -1) | |
2501 | { | |
2502 | constr->top.SetValue(y); | |
2503 | constr->top.SetDone(TRUE); | |
2504 | } | |
2505 | if (w != -1) | |
2506 | { | |
2507 | constr->width.SetValue(w); | |
2508 | constr->width.SetDone(TRUE); | |
2509 | } | |
2510 | if (h != -1) | |
2511 | { | |
2512 | constr->height.SetValue(h); | |
2513 | constr->height.SetDone(TRUE); | |
2514 | } | |
2515 | } | |
2516 | } | |
2517 | ||
debe6624 | 2518 | void wxWindow::MoveConstraint(int x, int y) |
c801d85f KB |
2519 | { |
2520 | wxLayoutConstraints *constr = GetConstraints(); | |
2521 | if (constr) | |
2522 | { | |
2523 | if (x != -1) | |
2524 | { | |
2525 | constr->left.SetValue(x); | |
2526 | constr->left.SetDone(TRUE); | |
2527 | } | |
2528 | if (y != -1) | |
2529 | { | |
2530 | constr->top.SetValue(y); | |
2531 | constr->top.SetDone(TRUE); | |
2532 | } | |
2533 | } | |
2534 | } | |
2535 | ||
2536 | void wxWindow::GetSizeConstraint(int *w, int *h) const | |
2537 | { | |
2538 | wxLayoutConstraints *constr = GetConstraints(); | |
2539 | if (constr) | |
2540 | { | |
2541 | *w = constr->width.GetValue(); | |
2542 | *h = constr->height.GetValue(); | |
2543 | } | |
2544 | else | |
2545 | GetSize(w, h); | |
2546 | } | |
2547 | ||
2548 | void wxWindow::GetClientSizeConstraint(int *w, int *h) const | |
2549 | { | |
2550 | wxLayoutConstraints *constr = GetConstraints(); | |
2551 | if (constr) | |
2552 | { | |
2553 | *w = constr->width.GetValue(); | |
2554 | *h = constr->height.GetValue(); | |
2555 | } | |
2556 | else | |
2557 | GetClientSize(w, h); | |
2558 | } | |
2559 | ||
2560 | void wxWindow::GetPositionConstraint(int *x, int *y) const | |
2561 | { | |
2562 | wxLayoutConstraints *constr = GetConstraints(); | |
2563 | if (constr) | |
2564 | { | |
2565 | *x = constr->left.GetValue(); | |
2566 | *y = constr->top.GetValue(); | |
2567 | } | |
2568 | else | |
2569 | GetPosition(x, y); | |
2570 | } | |
2571 | ||
7fd1d163 | 2572 | bool wxWindow::AcceptsFocus() const |
0abbe297 VZ |
2573 | { |
2574 | return IsEnabled() && IsShown(); | |
2575 | } | |
5e0aa05a | 2576 | |
e3e65dac | 2577 | void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) |
5e0aa05a VZ |
2578 | { |
2579 | UpdateWindowUI(); | |
2580 | } |