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