1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "window.h"
16 #include "wx/window.h"
20 #include "wx/layout.h"
22 #include "wx/dialog.h"
23 #include "wx/msgdlg.h"
25 #if wxUSE_DRAG_AND_DROP
30 #include "wx/tooltip.h"
34 #include "wx/statusbr.h"
36 #include "wx/settings.h"
43 #include "gdk/gdkprivate.h"
44 #include "gdk/gdkkeysyms.h"
45 #include "wx/gtk/win_gtk.h"
47 //-----------------------------------------------------------------------------
48 // documentation on internals
49 //-----------------------------------------------------------------------------
52 I have been asked several times about writing some documentation about
53 the GTK port of wxWindows, especially its internal structures. Obviously,
54 you cannot understand wxGTK without knowing a little about the GTK, but
55 some more information about what the wxWindow, which is the base class
56 for all other window classes, does seems required as well.
58 What does wxWindow do? It contains the common interface for the following
59 jobs of its descendants:
61 1) Define the rudimentary behaviour common to all window classes, such as
62 resizing, intercepting user input (so as to make it possible to use these
63 events for special purposes in a derived class), window names etc.
65 2) Provide the possibility to contain and manage children, if the derived
66 class is allowed to contain children, which holds true for those window
67 classes which do not display a native GTK widget. To name them, these
68 classes are wxPanel, wxScrolledWindow, wxDialog, wxFrame. The MDI frame-
69 work classes are a special case and are handled a bit differently from
70 the rest. The same holds true for the wxNotebook class.
72 3) Provide the possibility to draw into a client area of a window. This,
73 too, only holds true for classes that do not display a native GTK widget
76 4) Provide the entire mechanism for scrolling widgets. This actual inter-
77 face for this is usually in wxScrolledWindow, but the GTK implementation
80 5) A multitude of helper or extra methods for special purposes, such as
81 Drag'n'Drop, managing validators etc.
83 Normally one might expect, that one wxWindows window would always correspond
84 to one GTK widget. Under GTK, there is no such allround widget that has all
85 the functionality. Moreover, the GTK defines a client area as a different
86 widget from the actual widget you are handling. Last but not least some
87 special classes (e.g. wxFrame) handle different categories of widgets and
88 still have the possibility to draw something in the client area.
89 It was therefore required to write a special purpose GTK widget, that would
90 represent a client area in the sense of wxWindows capable to do the jobs
91 2), 3) and 4). I have written this class and it resides in win_gtk.c of
94 All windows must have a widget, with which they interact with other under-
95 lying GTK widgets. It is this widget, e.g. that has to be resized etc and
96 thw wxWindow class has a member variable called m_widget which holds a
97 pointer to this widget. When the window class represents a GTK native widget,
98 this is (in most cases) the only GTK widget the class manages. E.g. the
99 wxStatitText class handles only a GtkLabel widget a pointer to which you
100 can find in m_widget (defined in wxWindow)
102 When the class has a client area for drawing into and for containing children
103 it has to handle the client area widget (of the type GtkMyFixed, defined in
104 win_gtk.c), but there could be any number of widgets, handled by a class
105 The common rule for all windows is only, that the widget that interacts with
106 the rest of GTK must be referenced in m_widget and all other widgets must be
107 children of this widget on the GTK level. The top-most widget, which also
108 represents the client area, must be in the m_wxwindow field and must be of
111 As I said, the window classes that display a GTK native widget only have
112 one widget, so in the case of e.g. the wxButton class m_widget holds a
113 pointer to a GtkButton widget. But windows with client areas (for drawing
114 and children) have a m_widget field that is a pointer to a GtkScrolled-
115 Window and a m_wxwindow field that is pointer to a GtkMyFixed and this
116 one is (in the GTK sense) a child of the GtkScrolledWindow.
118 If the m_wxwindow field is set, then all input to this widget is inter-
119 cepted and sent to the wxWindows class. If not, all input to the widget
120 that gets pointed to by m_widget gets intercepted and sent to the class.
124 //-----------------------------------------------------------------------------
126 //-----------------------------------------------------------------------------
128 extern wxList wxPendingDelete
;
129 extern bool g_blockEventsOnDrag
;
130 extern bool g_blockEventsOnScroll
;
131 static bool g_capturing
= FALSE
;
132 static wxWindow
*g_focusWindow
= (wxWindow
*) NULL
;
134 /* hack: we need something to pass to gtk_menu_popup, so we store the time of
135 the last click here */
136 static guint32 gs_timeLastClick
= 0;
138 #if (GTK_MINOR_VERSION > 0)
140 //-----------------------------------------------------------------------------
141 // local code (see below)
142 //-----------------------------------------------------------------------------
144 static void draw_frame( GtkWidget
*widget
, wxWindow
*win
)
146 if (!win
->HasVMT()) return;
151 if (win
->m_hasScrolling
)
153 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(widget
);
154 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget
)->klass
);
157 GtkWidget *hscrollbar = scroll_window->hscrollbar;
158 GtkWidget *vscrollbar = scroll_window->vscrollbar;
160 we use this instead: range.slider_width = 11 + 2*2pts edge
163 if (scroll_window
->vscrollbar_visible
)
165 dw
+= 15; /* dw += vscrollbar->allocation.width; */
166 dw
+= scroll_class
->scrollbar_spacing
;
169 if (scroll_window
->hscrollbar_visible
)
171 dh
+= 15; /* dh += hscrollbar->allocation.height; */
172 dw
+= scroll_class
->scrollbar_spacing
;
178 if (GTK_WIDGET_NO_WINDOW (widget
))
180 dx
+= widget
->allocation
.x
;
181 dy
+= widget
->allocation
.y
;
184 if (win
->m_windowStyle
& wxRAISED_BORDER
)
186 gtk_draw_shadow( widget
->style
,
191 win
->m_width
-dw
, win
->m_height
-dh
);
195 if (win
->m_windowStyle
& wxSUNKEN_BORDER
)
197 gtk_draw_shadow( widget
->style
,
202 win
->m_width
-dw
, win
->m_height
-dh
);
207 //-----------------------------------------------------------------------------
208 // "expose_event" of m_widget
209 //-----------------------------------------------------------------------------
211 static void gtk_window_own_expose_callback( GtkWidget
*widget
, GdkEventExpose
*gdk_event
, wxWindow
*win
)
213 if (gdk_event
->count
> 0) return;
214 draw_frame( widget
, win
);
217 //-----------------------------------------------------------------------------
218 // "draw" of m_wxwindow
219 //-----------------------------------------------------------------------------
221 static void gtk_window_own_draw_callback( GtkWidget
*widget
, GdkRectangle
*WXUNUSED(rect
), wxWindow
*win
)
223 draw_frame( widget
, win
);
228 //-----------------------------------------------------------------------------
229 // "expose_event" of m_wxwindow
230 //-----------------------------------------------------------------------------
232 static void gtk_window_expose_callback( GtkWidget
*WXUNUSED(widget
), GdkEventExpose
*gdk_event
, wxWindow
*win
)
234 if (!win
->HasVMT()) return;
236 win
->m_updateRegion
.Union( gdk_event
->area
.x
,
238 gdk_event
->area
.width
,
239 gdk_event
->area
.height
);
241 if (gdk_event
->count
> 0) return;
244 printf( "OnExpose from " );
245 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
246 printf( win->GetClassInfo()->GetClassName() );
250 wxPaintEvent
event( win
->GetId() );
251 event
.SetEventObject( win
);
252 win
->GetEventHandler()->ProcessEvent( event
);
254 win
->m_updateRegion
.Clear();
257 //-----------------------------------------------------------------------------
258 // "draw" of m_wxwindow
259 //-----------------------------------------------------------------------------
261 static void gtk_window_draw_callback( GtkWidget
*WXUNUSED(widget
), GdkRectangle
*rect
, wxWindow
*win
)
263 if (!win
->HasVMT()) return;
265 win
->m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
267 wxPaintEvent
event( win
->GetId() );
268 event
.SetEventObject( win
);
269 win
->GetEventHandler()->ProcessEvent( event
);
271 win
->m_updateRegion
.Clear();
274 //-----------------------------------------------------------------------------
275 // "key_press_event" from any window
276 //-----------------------------------------------------------------------------
278 static gint
gtk_window_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxWindow
*win
)
280 if (!win
->HasVMT()) return FALSE
;
281 if (g_blockEventsOnDrag
) return FALSE
;
284 wxPrintf( _T("OnKeyPress from ") );
285 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
286 wxPrintf( win->GetClassInfo()->GetClassName() );
287 wxPrintf( _T(".\n") );
290 switch (gdk_event
->keyval
)
292 case GDK_BackSpace
: key_code
= WXK_BACK
; break;
293 case GDK_ISO_Left_Tab
:
295 case GDK_Tab
: key_code
= WXK_TAB
; break;
296 case GDK_Linefeed
: key_code
= WXK_RETURN
; break;
297 case GDK_Clear
: key_code
= WXK_CLEAR
; break;
298 case GDK_Return
: key_code
= WXK_RETURN
; break;
299 case GDK_Pause
: key_code
= WXK_PAUSE
; break;
300 case GDK_Scroll_Lock
: key_code
= WXK_SCROLL
; break;
301 case GDK_Escape
: key_code
= WXK_ESCAPE
; break;
302 case GDK_Delete
: key_code
= WXK_DELETE
; break;
303 case GDK_Home
: key_code
= WXK_HOME
; break;
304 case GDK_Left
: key_code
= WXK_LEFT
; break;
305 case GDK_Up
: key_code
= WXK_UP
; break;
306 case GDK_Right
: key_code
= WXK_RIGHT
; break;
307 case GDK_Down
: key_code
= WXK_DOWN
; break;
308 case GDK_Prior
: key_code
= WXK_PRIOR
; break;
309 // case GDK_Page_Up: key_code = WXK_PAGEUP; break;
310 case GDK_Next
: key_code
= WXK_NEXT
; break;
311 // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
312 case GDK_End
: key_code
= WXK_END
; break;
313 case GDK_Begin
: key_code
= WXK_HOME
; break;
314 case GDK_Select
: key_code
= WXK_SELECT
; break;
315 case GDK_Print
: key_code
= WXK_PRINT
; break;
316 case GDK_Execute
: key_code
= WXK_EXECUTE
; break;
317 case GDK_Insert
: key_code
= WXK_INSERT
; break;
318 case GDK_Num_Lock
: key_code
= WXK_NUMLOCK
; break;
319 case GDK_KP_Enter
: key_code
= WXK_RETURN
; break;
320 case GDK_KP_Home
: key_code
= WXK_HOME
; break;
321 case GDK_KP_Left
: key_code
= WXK_LEFT
; break;
322 case GDK_KP_Up
: key_code
= WXK_UP
; break;
323 case GDK_KP_Right
: key_code
= WXK_RIGHT
; break;
324 case GDK_KP_Down
: key_code
= WXK_DOWN
; break;
325 case GDK_KP_Prior
: key_code
= WXK_PRIOR
; break;
326 // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
327 case GDK_KP_Next
: key_code
= WXK_NEXT
; break;
328 // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
329 case GDK_KP_End
: key_code
= WXK_END
; break;
330 case GDK_KP_Begin
: key_code
= WXK_HOME
; break;
331 case GDK_KP_Insert
: key_code
= WXK_INSERT
; break;
332 case GDK_KP_Delete
: key_code
= WXK_DELETE
; break;
333 case GDK_KP_Multiply
: key_code
= WXK_MULTIPLY
; break;
334 case GDK_KP_Add
: key_code
= WXK_ADD
; break;
335 case GDK_KP_Separator
: key_code
= WXK_SEPARATOR
; break;
336 case GDK_KP_Subtract
: key_code
= WXK_SUBTRACT
; break;
337 case GDK_KP_Decimal
: key_code
= WXK_DECIMAL
; break;
338 case GDK_KP_Divide
: key_code
= WXK_DIVIDE
; break;
339 case GDK_KP_0
: key_code
= WXK_NUMPAD0
; break;
340 case GDK_KP_1
: key_code
= WXK_NUMPAD1
; break;
341 case GDK_KP_2
: key_code
= WXK_NUMPAD2
; break;
342 case GDK_KP_3
: key_code
= WXK_NUMPAD3
; break;
343 case GDK_KP_4
: key_code
= WXK_NUMPAD4
; break;
344 case GDK_KP_5
: key_code
= WXK_NUMPAD5
; break;
345 case GDK_KP_6
: key_code
= WXK_NUMPAD6
; break;
346 case GDK_KP_7
: key_code
= WXK_NUMPAD7
; break;
347 case GDK_KP_8
: key_code
= WXK_NUMPAD7
; break;
348 case GDK_KP_9
: key_code
= WXK_NUMPAD9
; break;
349 case GDK_F1
: key_code
= WXK_F1
; break;
350 case GDK_F2
: key_code
= WXK_F2
; break;
351 case GDK_F3
: key_code
= WXK_F3
; break;
352 case GDK_F4
: key_code
= WXK_F4
; break;
353 case GDK_F5
: key_code
= WXK_F5
; break;
354 case GDK_F6
: key_code
= WXK_F6
; break;
355 case GDK_F7
: key_code
= WXK_F7
; break;
356 case GDK_F8
: key_code
= WXK_F8
; break;
357 case GDK_F9
: key_code
= WXK_F9
; break;
358 case GDK_F10
: key_code
= WXK_F10
; break;
359 case GDK_F11
: key_code
= WXK_F11
; break;
360 case GDK_F12
: key_code
= WXK_F12
; break;
363 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
364 key_code
= gdk_event
->keyval
;
368 if (!key_code
) return FALSE
;
370 wxKeyEvent
event( wxEVT_KEY_DOWN
);
371 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
372 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
373 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
374 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
375 event
.m_keyCode
= key_code
;
378 event
.SetEventObject( win
);
380 bool ret
= win
->GetEventHandler()->ProcessEvent( event
);
384 wxWindow
*ancestor
= win
;
387 int command
= ancestor
->GetAcceleratorTable()->GetCommand( event
);
390 wxCommandEvent
command_event( wxEVT_COMMAND_MENU_SELECTED
, command
);
391 ret
= ancestor
->GetEventHandler()->ProcessEvent( command_event
);
394 ancestor
= ancestor
->GetParent();
398 // win is a control: tab can be propagated up
400 ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
)) &&
401 ((win
->m_windowStyle
& wxTE_PROCESS_TAB
) == 0))
403 wxNavigationKeyEvent new_event
;
404 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
405 new_event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
406 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
407 new_event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) );
408 new_event
.SetCurrentFocus( win
);
409 ret
= win
->GetEventHandler()->ProcessEvent( new_event
);
413 (gdk_event
->keyval
== GDK_Escape
) )
415 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
416 new_event
.SetEventObject( win
);
417 ret
= win
->GetEventHandler()->ProcessEvent( new_event
);
421 Damn, I forgot why this didn't work, but it didn't work.
423 // win is a panel: up can be propagated to the panel
424 if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
425 (gdk_event->keyval == GDK_Up))
427 win->m_parent->SetFocus();
431 // win is a panel: left/right can be propagated to the panel
432 if ((!ret) && (win->m_wxwindow) &&
433 ((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) ||
434 (gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down)))
436 wxNavigationKeyEvent new_event;
437 new_event.SetDirection( (gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Down) );
438 new_event.SetCurrentFocus( win );
439 ret = win->GetEventHandler()->ProcessEvent( new_event );
445 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
452 //-----------------------------------------------------------------------------
453 // "key_release_event" from any window
454 //-----------------------------------------------------------------------------
456 static gint
gtk_window_key_release_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxWindow
*win
)
458 if (!win
->HasVMT()) return FALSE
;
459 if (g_blockEventsOnDrag
) return FALSE
;
462 printf( "OnKeyRelease from " );
463 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
464 printf( win->GetClassInfo()->GetClassName() );
469 switch (gdk_event
->keyval
)
471 case GDK_BackSpace
: key_code
= WXK_BACK
; break;
472 case GDK_ISO_Left_Tab
:
474 case GDK_Tab
: key_code
= WXK_TAB
; break;
475 case GDK_Linefeed
: key_code
= WXK_RETURN
; break;
476 case GDK_Clear
: key_code
= WXK_CLEAR
; break;
477 case GDK_Return
: key_code
= WXK_RETURN
; break;
478 case GDK_Pause
: key_code
= WXK_PAUSE
; break;
479 case GDK_Scroll_Lock
: key_code
= WXK_SCROLL
; break;
480 case GDK_Escape
: key_code
= WXK_ESCAPE
; break;
481 case GDK_Delete
: key_code
= WXK_DELETE
; break;
482 case GDK_Home
: key_code
= WXK_HOME
; break;
483 case GDK_Left
: key_code
= WXK_LEFT
; break;
484 case GDK_Up
: key_code
= WXK_UP
; break;
485 case GDK_Right
: key_code
= WXK_RIGHT
; break;
486 case GDK_Down
: key_code
= WXK_DOWN
; break;
487 case GDK_Prior
: key_code
= WXK_PRIOR
; break;
488 // case GDK_Page_Up: key_code = WXK_PAGEUP; break;
489 case GDK_Next
: key_code
= WXK_NEXT
; break;
490 // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
491 case GDK_End
: key_code
= WXK_END
; break;
492 case GDK_Begin
: key_code
= WXK_HOME
; break;
493 case GDK_Select
: key_code
= WXK_SELECT
; break;
494 case GDK_Print
: key_code
= WXK_PRINT
; break;
495 case GDK_Execute
: key_code
= WXK_EXECUTE
; break;
496 case GDK_Insert
: key_code
= WXK_INSERT
; break;
497 case GDK_Num_Lock
: key_code
= WXK_NUMLOCK
; break;
498 case GDK_KP_Enter
: key_code
= WXK_RETURN
; break;
499 case GDK_KP_Home
: key_code
= WXK_HOME
; break;
500 case GDK_KP_Left
: key_code
= WXK_LEFT
; break;
501 case GDK_KP_Up
: key_code
= WXK_UP
; break;
502 case GDK_KP_Right
: key_code
= WXK_RIGHT
; break;
503 case GDK_KP_Down
: key_code
= WXK_DOWN
; break;
504 case GDK_KP_Prior
: key_code
= WXK_PRIOR
; break;
505 // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
506 case GDK_KP_Next
: key_code
= WXK_NEXT
; break;
507 // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
508 case GDK_KP_End
: key_code
= WXK_END
; break;
509 case GDK_KP_Begin
: key_code
= WXK_HOME
; break;
510 case GDK_KP_Insert
: key_code
= WXK_INSERT
; break;
511 case GDK_KP_Delete
: key_code
= WXK_DELETE
; break;
512 case GDK_KP_Multiply
: key_code
= WXK_MULTIPLY
; break;
513 case GDK_KP_Add
: key_code
= WXK_ADD
; break;
514 case GDK_KP_Separator
: key_code
= WXK_SEPARATOR
; break;
515 case GDK_KP_Subtract
: key_code
= WXK_SUBTRACT
; break;
516 case GDK_KP_Decimal
: key_code
= WXK_DECIMAL
; break;
517 case GDK_KP_Divide
: key_code
= WXK_DIVIDE
; break;
518 case GDK_KP_0
: key_code
= WXK_NUMPAD0
; break;
519 case GDK_KP_1
: key_code
= WXK_NUMPAD1
; break;
520 case GDK_KP_2
: key_code
= WXK_NUMPAD2
; break;
521 case GDK_KP_3
: key_code
= WXK_NUMPAD3
; break;
522 case GDK_KP_4
: key_code
= WXK_NUMPAD4
; break;
523 case GDK_KP_5
: key_code
= WXK_NUMPAD5
; break;
524 case GDK_KP_6
: key_code
= WXK_NUMPAD6
; break;
525 case GDK_KP_7
: key_code
= WXK_NUMPAD7
; break;
526 case GDK_KP_8
: key_code
= WXK_NUMPAD7
; break;
527 case GDK_KP_9
: key_code
= WXK_NUMPAD9
; break;
528 case GDK_F1
: key_code
= WXK_F1
; break;
529 case GDK_F2
: key_code
= WXK_F2
; break;
530 case GDK_F3
: key_code
= WXK_F3
; break;
531 case GDK_F4
: key_code
= WXK_F4
; break;
532 case GDK_F5
: key_code
= WXK_F5
; break;
533 case GDK_F6
: key_code
= WXK_F6
; break;
534 case GDK_F7
: key_code
= WXK_F7
; break;
535 case GDK_F8
: key_code
= WXK_F8
; break;
536 case GDK_F9
: key_code
= WXK_F9
; break;
537 case GDK_F10
: key_code
= WXK_F10
; break;
538 case GDK_F11
: key_code
= WXK_F11
; break;
539 case GDK_F12
: key_code
= WXK_F12
; break;
542 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
543 key_code
= gdk_event
->keyval
;
547 if (!key_code
) return FALSE
;
549 wxKeyEvent
event( wxEVT_KEY_UP
);
550 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
551 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
552 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
553 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
554 event
.m_keyCode
= key_code
;
557 event
.SetEventObject( win
);
559 if (win
->GetEventHandler()->ProcessEvent( event
))
561 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_release_event" );
568 //-----------------------------------------------------------------------------
569 // "button_press_event"
570 //-----------------------------------------------------------------------------
572 static gint
gtk_window_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
575 wxPrintf( _T("1) OnButtonPress from ") );
576 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
577 wxPrintf( win->GetClassInfo()->GetClassName() );
578 wxPrintf( _T(".\n") );
581 if (!win
->HasVMT()) return FALSE
;
582 if (g_blockEventsOnDrag
) return TRUE
;
583 if (g_blockEventsOnScroll
) return TRUE
;
585 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return FALSE
;
589 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
) && !GTK_WIDGET_HAS_FOCUS (win
->m_wxwindow
) )
591 gtk_widget_grab_focus (win
->m_wxwindow
);
594 wxPrintf( _T("GrabFocus from ") );
595 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
596 wxPrintf( win->GetClassInfo()->GetClassName() );
597 wxPrintf( _T(".\n") );
604 wxPrintf( _T("No GrabFocus from ") );
605 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
606 wxPrintf( win->GetClassInfo()->GetClassName() );
607 if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
608 wxPrintf( _T(" because it already has") );
609 wxPrintf( _T(".\n") );
615 wxPrintf( _T("2) OnButtonPress from ") );
616 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
617 wxPrintf( win->GetClassInfo()->GetClassName() );
618 wxPrintf( _T(".\n") );
621 wxEventType event_type
= wxEVT_LEFT_DOWN
;
623 if (gdk_event
->button
== 1)
625 switch (gdk_event
->type
)
627 case GDK_BUTTON_PRESS
: event_type
= wxEVT_LEFT_DOWN
; break;
628 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_LEFT_DCLICK
; break;
632 else if (gdk_event
->button
== 2)
634 switch (gdk_event
->type
)
636 case GDK_BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DOWN
; break;
637 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DCLICK
; break;
641 else if (gdk_event
->button
== 3)
643 switch (gdk_event
->type
)
645 case GDK_BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DOWN
; break;
646 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DCLICK
; break;
651 wxMouseEvent
event( event_type
);
652 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
653 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
654 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
655 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
656 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
657 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
658 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
660 event
.m_x
= (long)gdk_event
->x
;
661 event
.m_y
= (long)gdk_event
->y
;
663 // Some control don't have their own X window and thus cannot get
668 wxNode
*node
= win
->GetChildren().First();
671 wxWindow
*child
= (wxWindow
*)node
->Data();
673 if (child
->m_isStaticBox
)
675 // wxStaticBox is transparent in the box itself
678 int xx1
= child
->m_x
;
679 int yy1
= child
->m_y
;
680 int xx2
= child
->m_x
+ child
->m_width
;
681 int yy2
= child
->m_x
+ child
->m_height
;
684 if (((x
>= xx1
) && (x
<= xx1
+10) && (y
>= yy1
) && (y
<= yy2
)) ||
686 ((x
>= xx2
-10) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy2
)) ||
688 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy1
+10)) ||
690 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy2
-1) && (y
<= yy2
)))
693 event
.m_x
-= child
->m_x
;
694 event
.m_y
-= child
->m_y
;
701 if ((child
->m_wxwindow
== (GtkWidget
*) NULL
) &&
702 (child
->m_x
<= event
.m_x
) &&
703 (child
->m_y
<= event
.m_y
) &&
704 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
705 (child
->m_y
+child
->m_height
>= event
.m_y
))
708 event
.m_x
-= child
->m_x
;
709 event
.m_y
-= child
->m_y
;
717 event
.SetEventObject( win
);
719 gs_timeLastClick
= gdk_event
->time
;
721 if (win
->GetEventHandler()->ProcessEvent( event
))
723 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "button_press_event" );
730 //-----------------------------------------------------------------------------
731 // "button_release_event"
732 //-----------------------------------------------------------------------------
734 static gint
gtk_window_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
736 if (!win
->HasVMT()) return FALSE
;
737 if (g_blockEventsOnDrag
) return FALSE
;
738 if (g_blockEventsOnScroll
) return FALSE
;
740 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return FALSE
;
743 printf( "OnButtonRelease from " );
744 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
745 printf( win->GetClassInfo()->GetClassName() );
749 wxEventType event_type
= wxEVT_NULL
;
751 switch (gdk_event
->button
)
753 case 1: event_type
= wxEVT_LEFT_UP
; break;
754 case 2: event_type
= wxEVT_MIDDLE_UP
; break;
755 case 3: event_type
= wxEVT_RIGHT_UP
; break;
758 wxMouseEvent
event( event_type
);
759 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
760 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
761 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
762 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
763 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
764 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
765 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
766 event
.m_x
= (long)gdk_event
->x
;
767 event
.m_y
= (long)gdk_event
->y
;
769 // Some control don't have their own X window and thus cannot get
774 wxNode
*node
= win
->GetChildren().First();
777 wxWindow
*child
= (wxWindow
*)node
->Data();
779 if (child
->m_isStaticBox
)
781 // wxStaticBox is transparent in the box itself
784 int xx1
= child
->m_x
;
785 int yy1
= child
->m_y
;
786 int xx2
= child
->m_x
+ child
->m_width
;
787 int yy2
= child
->m_x
+ child
->m_height
;
790 if (((x
>= xx1
) && (x
<= xx1
+10) && (y
>= yy1
) && (y
<= yy2
)) ||
792 ((x
>= xx2
-10) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy2
)) ||
794 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy1
+10)) ||
796 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy2
-1) && (y
<= yy2
)))
799 event
.m_x
-= child
->m_x
;
800 event
.m_y
-= child
->m_y
;
807 if ((child
->m_wxwindow
== (GtkWidget
*) NULL
) &&
808 (child
->m_x
<= event
.m_x
) &&
809 (child
->m_y
<= event
.m_y
) &&
810 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
811 (child
->m_y
+child
->m_height
>= event
.m_y
))
814 event
.m_x
-= child
->m_x
;
815 event
.m_y
-= child
->m_y
;
823 event
.SetEventObject( win
);
825 if (win
->GetEventHandler()->ProcessEvent( event
))
827 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "button_release_event" );
834 //-----------------------------------------------------------------------------
835 // "motion_notify_event"
836 //-----------------------------------------------------------------------------
838 static gint
gtk_window_motion_notify_callback( GtkWidget
*widget
, GdkEventMotion
*gdk_event
, wxWindow
*win
)
840 if (!win
->HasVMT()) return FALSE
;
841 if (g_blockEventsOnDrag
) return FALSE
;
842 if (g_blockEventsOnScroll
) return FALSE
;
844 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return FALSE
;
846 if (gdk_event
->is_hint
)
850 GdkModifierType state
;
851 gdk_window_get_pointer(gdk_event
->window
, &x
, &y
, &state
);
854 gdk_event
->state
= state
;
858 printf( "OnMotion from " );
859 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
860 printf( win->GetClassInfo()->GetClassName() );
864 wxMouseEvent
event( wxEVT_MOTION
);
865 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
866 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
867 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
868 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
869 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
870 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
871 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
873 event
.m_x
= (long)gdk_event
->x
;
874 event
.m_y
= (long)gdk_event
->y
;
876 // Some control don't have their own X window and thus cannot get
881 wxNode
*node
= win
->GetChildren().First();
884 wxWindow
*child
= (wxWindow
*)node
->Data();
886 if (child
->m_isStaticBox
)
888 // wxStaticBox is transparent in the box itself
891 int xx1
= child
->m_x
;
892 int yy1
= child
->m_y
;
893 int xx2
= child
->m_x
+ child
->m_width
;
894 int yy2
= child
->m_x
+ child
->m_height
;
897 if (((x
>= xx1
) && (x
<= xx1
+10) && (y
>= yy1
) && (y
<= yy2
)) ||
899 ((x
>= xx2
-10) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy2
)) ||
901 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy1
) && (y
<= yy1
+10)) ||
903 ((x
>= xx1
) && (x
<= xx2
) && (y
>= yy2
-1) && (y
<= yy2
)))
906 event
.m_x
-= child
->m_x
;
907 event
.m_y
-= child
->m_y
;
914 if ((child
->m_wxwindow
== (GtkWidget
*) NULL
) &&
915 (child
->m_x
<= event
.m_x
) &&
916 (child
->m_y
<= event
.m_y
) &&
917 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
918 (child
->m_y
+child
->m_height
>= event
.m_y
))
921 event
.m_x
-= child
->m_x
;
922 event
.m_y
-= child
->m_y
;
930 event
.SetEventObject( win
);
932 if (win
->GetEventHandler()->ProcessEvent( event
))
934 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "motion_notify_event" );
941 //-----------------------------------------------------------------------------
943 //-----------------------------------------------------------------------------
945 static gint
gtk_window_focus_in_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
947 if (!win
->HasVMT()) return FALSE
;
948 if (g_blockEventsOnDrag
) return FALSE
;
954 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
956 GTK_WIDGET_SET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
958 printf( "SetFocus flag from " );
959 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
960 printf( win->GetClassInfo()->GetClassName() );
968 wxPrintf( _T("OnSetFocus from ") );
969 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
970 wxPrintf( win->GetClassInfo()->GetClassName() );
972 wxPrintf( win->GetLabel() );
973 wxPrintf( _T(".\n") );
976 wxFocusEvent
event( wxEVT_SET_FOCUS
, win
->GetId() );
977 event
.SetEventObject( win
);
979 if (win
->GetEventHandler()->ProcessEvent( event
))
981 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus_in_event" );
988 //-----------------------------------------------------------------------------
990 //-----------------------------------------------------------------------------
992 static gint
gtk_window_focus_out_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
994 if (!win
->HasVMT()) return FALSE
;
995 if (g_blockEventsOnDrag
) return FALSE
;
999 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
1000 GTK_WIDGET_UNSET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
1004 wxPrintf( _T("OnKillFocus from ") );
1005 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1006 wxPrintf( win->GetClassInfo()->GetClassName() );
1007 wxPrintf( _T(" ") );
1008 wxPrintf( win->GetLabel() );
1009 wxPrintf( _T(".\n") );
1012 wxFocusEvent
event( wxEVT_KILL_FOCUS
, win
->GetId() );
1013 event
.SetEventObject( win
);
1015 if (win
->GetEventHandler()->ProcessEvent( event
))
1017 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus_out_event" );
1024 //-----------------------------------------------------------------------------
1025 // "enter_notify_event"
1026 //-----------------------------------------------------------------------------
1028 static gint
gtk_window_enter_callback( GtkWidget
*widget
, GdkEventCrossing
*gdk_event
, wxWindow
*win
)
1030 if (!win
->HasVMT()) return FALSE
;
1031 if (g_blockEventsOnDrag
) return FALSE
;
1033 if (widget
->window
!= gdk_event
->window
) return FALSE
;
1035 if ((widget
->window
) && (win
->m_cursor
))
1036 gdk_window_set_cursor( widget
->window
, win
->m_cursor
->GetCursor() );
1039 printf( "OnEnter from " );
1040 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1041 printf( win->GetClassInfo()->GetClassName() );
1045 wxMouseEvent
event( wxEVT_ENTER_WINDOW
);
1046 event
.SetEventObject( win
);
1050 GdkModifierType state
= (GdkModifierType
)0;
1052 gdk_window_get_pointer( widget
->window
, &x
, &y
, &state
);
1054 event
.m_shiftDown
= (state
& GDK_SHIFT_MASK
);
1055 event
.m_controlDown
= (state
& GDK_CONTROL_MASK
);
1056 event
.m_altDown
= (state
& GDK_MOD1_MASK
);
1057 event
.m_metaDown
= (state
& GDK_MOD2_MASK
);
1058 event
.m_leftDown
= (state
& GDK_BUTTON1_MASK
);
1059 event
.m_middleDown
= (state
& GDK_BUTTON2_MASK
);
1060 event
.m_rightDown
= (state
& GDK_BUTTON3_MASK
);
1062 event
.m_x
= (long)x
;
1063 event
.m_y
= (long)y
;
1065 if (win
->GetEventHandler()->ProcessEvent( event
))
1067 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "enter_notify_event" );
1074 //-----------------------------------------------------------------------------
1075 // "leave_notify_event"
1076 //-----------------------------------------------------------------------------
1078 static gint
gtk_window_leave_callback( GtkWidget
*widget
, GdkEventCrossing
*gdk_event
, wxWindow
*win
)
1080 if (!win
->HasVMT()) return FALSE
;
1081 if (g_blockEventsOnDrag
) return FALSE
;
1083 if (widget
->window
!= gdk_event
->window
) return FALSE
;
1085 if ((widget
->window
) && (win
->m_cursor
))
1086 gdk_window_set_cursor( widget
->window
, wxSTANDARD_CURSOR
->GetCursor() );
1089 printf( "OnLeave from " );
1090 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1091 printf( win->GetClassInfo()->GetClassName() );
1095 wxMouseEvent
event( wxEVT_LEAVE_WINDOW
);
1096 event
.SetEventObject( win
);
1100 GdkModifierType state
= (GdkModifierType
)0;
1102 gdk_window_get_pointer( widget
->window
, &x
, &y
, &state
);
1104 event
.m_shiftDown
= (state
& GDK_SHIFT_MASK
);
1105 event
.m_controlDown
= (state
& GDK_CONTROL_MASK
);
1106 event
.m_altDown
= (state
& GDK_MOD1_MASK
);
1107 event
.m_metaDown
= (state
& GDK_MOD2_MASK
);
1108 event
.m_leftDown
= (state
& GDK_BUTTON1_MASK
);
1109 event
.m_middleDown
= (state
& GDK_BUTTON2_MASK
);
1110 event
.m_rightDown
= (state
& GDK_BUTTON3_MASK
);
1112 event
.m_x
= (long)x
;
1113 event
.m_y
= (long)y
;
1115 if (win
->GetEventHandler()->ProcessEvent( event
))
1117 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "leave_notify_event" );
1124 //-----------------------------------------------------------------------------
1125 // "value_changed" from m_vAdjust
1126 //-----------------------------------------------------------------------------
1128 static void gtk_window_vscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
1130 if (g_blockEventsOnDrag
) return;
1133 printf( "OnVScroll from " );
1134 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1135 printf( win->GetClassInfo()->GetClassName() );
1139 if (!win
->HasVMT()) return;
1141 float diff
= win
->m_vAdjust
->value
- win
->m_oldVerticalPos
;
1142 if (fabs(diff
) < 0.2) return;
1143 win
->m_oldVerticalPos
= win
->m_vAdjust
->value
;
1145 wxEventType command
= wxEVT_NULL
;
1147 float line_step
= win
->m_vAdjust
->step_increment
;
1148 float page_step
= win
->m_vAdjust
->page_increment
;
1150 if (win
->m_isScrolling
)
1152 command
= wxEVT_SCROLL_THUMBTRACK
;
1156 if (fabs(win
->m_vAdjust
->value
-win
->m_vAdjust
->lower
) < 0.2) command
= wxEVT_SCROLL_BOTTOM
;
1157 else if (fabs(win
->m_vAdjust
->value
-win
->m_vAdjust
->upper
) < 0.2) command
= wxEVT_SCROLL_TOP
;
1158 else if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
1159 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
1160 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
1161 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
1162 else command
= wxEVT_SCROLL_THUMBTRACK
;
1165 int value
= (int)(win
->m_vAdjust
->value
+0.5);
1167 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
1168 event
.SetEventObject( win
);
1169 win
->GetEventHandler()->ProcessEvent( event
);
1172 //-----------------------------------------------------------------------------
1173 // "value_changed" from m_hAdjust
1174 //-----------------------------------------------------------------------------
1176 static void gtk_window_hscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
1178 if (g_blockEventsOnDrag
) return;
1181 printf( "OnHScroll from " );
1182 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1183 printf( win->GetClassInfo()->GetClassName() );
1187 if (!win
->HasVMT()) return;
1189 float diff
= win
->m_hAdjust
->value
- win
->m_oldHorizontalPos
;
1190 if (fabs(diff
) < 0.2) return;
1191 win
->m_oldHorizontalPos
= win
->m_hAdjust
->value
;
1193 wxEventType command
= wxEVT_NULL
;
1195 float line_step
= win
->m_hAdjust
->step_increment
;
1196 float page_step
= win
->m_hAdjust
->page_increment
;
1198 if (win
->m_isScrolling
)
1200 command
= wxEVT_SCROLL_THUMBTRACK
;
1204 if (fabs(win
->m_hAdjust
->value
-win
->m_hAdjust
->lower
) < 0.2) command
= wxEVT_SCROLL_BOTTOM
;
1205 else if (fabs(win
->m_hAdjust
->value
-win
->m_hAdjust
->upper
) < 0.2) command
= wxEVT_SCROLL_TOP
;
1206 else if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
1207 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
1208 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
1209 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
1210 else command
= wxEVT_SCROLL_THUMBTRACK
;
1213 int value
= (int)(win
->m_hAdjust
->value
+0.5);
1215 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
1216 event
.SetEventObject( win
);
1217 win
->GetEventHandler()->ProcessEvent( event
);
1220 //-----------------------------------------------------------------------------
1221 // "changed" from m_vAdjust
1222 //-----------------------------------------------------------------------------
1224 static void gtk_window_vscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
1226 if (g_blockEventsOnDrag
) return;
1229 printf( "OnVScroll change from " );
1230 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1231 printf( win->GetClassInfo()->GetClassName() );
1235 if (!win
->HasVMT()) return;
1237 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
1238 int value
= (int)(win
->m_vAdjust
->value
+0.5);
1240 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
1241 event
.SetEventObject( win
);
1242 win
->GetEventHandler()->ProcessEvent( event
);
1245 //-----------------------------------------------------------------------------
1246 // "changed" from m_hAdjust
1247 //-----------------------------------------------------------------------------
1249 static void gtk_window_hscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
1251 if (g_blockEventsOnDrag
) return;
1254 printf( "OnHScroll change from " );
1255 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
1256 printf( win->GetClassInfo()->GetClassName() );
1260 if (!win
->HasVMT()) return;
1262 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
1263 int value
= (int)(win
->m_hAdjust
->value
+0.5);
1265 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
1266 event
.SetEventObject( win
);
1267 win
->GetEventHandler()->ProcessEvent( event
);
1270 //-----------------------------------------------------------------------------
1271 // "button_press_event" from scrollbar
1272 //-----------------------------------------------------------------------------
1274 static gint
gtk_scrollbar_button_press_callback( GtkRange
*WXUNUSED(widget
),
1275 GdkEventButton
*WXUNUSED(gdk_event
),
1278 // don't test here as we can release the mouse while being over
1279 // a different window then the slider
1281 // if (gdk_event->window != widget->slider) return FALSE;
1283 win
->m_isScrolling
= TRUE
;
1284 g_blockEventsOnScroll
= TRUE
;
1289 //-----------------------------------------------------------------------------
1290 // "button_release_event" from scrollbar
1291 //-----------------------------------------------------------------------------
1293 static gint
gtk_scrollbar_button_release_callback( GtkRange
*widget
,
1294 GdkEventButton
*WXUNUSED(gdk_event
),
1298 // don't test here as we can release the mouse while being over
1299 // a different window then the slider
1301 // if (gdk_event->window != widget->slider) return FALSE;
1303 GtkScrolledWindow
*s_window
= GTK_SCROLLED_WINDOW(win
->m_widget
);
1305 if (widget
== GTK_RANGE(s_window
->vscrollbar
))
1306 gtk_signal_emit_by_name( GTK_OBJECT(win
->m_hAdjust
), "value_changed" );
1308 gtk_signal_emit_by_name( GTK_OBJECT(win
->m_vAdjust
), "value_changed" );
1310 win
->m_isScrolling
= FALSE
;
1311 g_blockEventsOnScroll
= FALSE
;
1316 //-----------------------------------------------------------------------------
1317 // "realize" from m_widget
1318 //-----------------------------------------------------------------------------
1320 /* we cannot set colours, fonts and cursors before the widget has
1321 been realized, so we do this directly after realization */
1324 gtk_window_realized_callback( GtkWidget
*widget
, wxWindow
*win
)
1326 if (win
->m_font
!= *wxSWISS_FONT
)
1328 wxFont
font( win
->m_font
);
1329 win
->m_font
= wxNullFont
;
1330 win
->SetFont( font
);
1333 if (win
->m_backgroundColour
!= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
))
1335 wxColour
bg( win
->m_backgroundColour
);
1336 win
->m_backgroundColour
= wxNullColour
;
1337 win
->SetBackgroundColour( bg
);
1340 if (win
->m_foregroundColour
!= *wxBLACK
)
1342 wxColour
fg( win
->m_foregroundColour
);
1343 win
->m_foregroundColour
= wxNullColour
;
1344 win
->SetForegroundColour( fg
);
1350 //-----------------------------------------------------------------------------
1351 // InsertChild for wxWindow.
1352 //-----------------------------------------------------------------------------
1354 /* Callback for wxWindow. This very strange beast has to be used because
1355 * C++ has no virtual methods in a constructor. We have to emulate a
1356 * virtual function here as wxNotebook requires a different way to insert
1357 * a child in it. I had opted for creating a wxNotebookPage window class
1358 * which would have made this superfluous (such in the MDI window system),
1359 * but no-one was listening to me... */
1361 static void wxInsertChildInWindow( wxWindow
* parent
, wxWindow
* child
)
1363 gtk_myfixed_put( GTK_MYFIXED(parent
->m_wxwindow
),
1364 GTK_WIDGET(child
->m_widget
),
1368 gtk_widget_set_usize( GTK_WIDGET(child
->m_widget
),
1372 if (parent
->m_windowStyle
& wxTAB_TRAVERSAL
)
1374 /* we now allow a window to get the focus as long as it
1375 doesn't have any children. */
1376 GTK_WIDGET_UNSET_FLAGS( parent
->m_wxwindow
, GTK_CAN_FOCUS
);
1380 //-----------------------------------------------------------------------------
1382 //-----------------------------------------------------------------------------
1384 wxWindow
* wxGetActiveWindow()
1386 return g_focusWindow
;
1389 //-----------------------------------------------------------------------------
1391 //-----------------------------------------------------------------------------
1393 IMPLEMENT_DYNAMIC_CLASS(wxWindow
,wxEvtHandler
)
1395 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
1396 EVT_SIZE(wxWindow::OnSize
)
1397 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
1398 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
1399 EVT_KEY_DOWN(wxWindow::OnKeyDown
)
1402 void wxWindow::Init()
1406 m_widget
= (GtkWidget
*) NULL
;
1407 m_wxwindow
= (GtkWidget
*) NULL
;
1408 m_parent
= (wxWindow
*) NULL
;
1409 m_children
.DeleteContents( FALSE
);
1422 m_eventHandler
= this;
1423 m_windowValidator
= (wxValidator
*) NULL
;
1427 m_cursor
= (wxCursor
*) NULL
;
1428 m_font
= *wxSWISS_FONT
;
1430 m_windowName
= "noname";
1432 m_constraints
= (wxLayoutConstraints
*) NULL
;
1433 m_constraintsInvolvedIn
= (wxList
*) NULL
;
1434 m_windowSizer
= (wxSizer
*) NULL
;
1435 m_sizerParent
= (wxWindow
*) NULL
;
1436 m_autoLayout
= FALSE
;
1440 m_needParent
= TRUE
;
1442 m_hasScrolling
= FALSE
;
1443 m_isScrolling
= FALSE
;
1444 m_hAdjust
= (GtkAdjustment
*) NULL
;
1445 m_vAdjust
= (GtkAdjustment
*) NULL
;
1446 m_oldHorizontalPos
= 0.0;
1447 m_oldVerticalPos
= 0.0;
1452 #if wxUSE_DRAG_AND_DROP
1453 m_dropTarget
= (wxDropTarget
*) NULL
;
1456 m_scrollGC
= (GdkGC
*) NULL
;
1457 m_widgetStyle
= (GtkStyle
*) NULL
;
1459 m_insertCallback
= wxInsertChildInWindow
;
1461 m_clientObject
= (wxClientData
*) NULL
;
1462 m_clientData
= NULL
;
1464 m_isStaticBox
= FALSE
;
1465 m_acceptsFocus
= FALSE
;
1468 m_toolTip
= (wxToolTip
*) NULL
;
1469 #endif // wxUSE_TOOLTIPS
1472 wxWindow::wxWindow()
1477 wxWindow::wxWindow( wxWindow
*parent
, wxWindowID id
,
1478 const wxPoint
&pos
, const wxSize
&size
,
1479 long style
, const wxString
&name
)
1483 Create( parent
, id
, pos
, size
, style
, name
);
1486 bool wxWindow::Create( wxWindow
*parent
, wxWindowID id
,
1487 const wxPoint
&pos
, const wxSize
&size
,
1488 long style
, const wxString
&name
)
1490 wxASSERT_MSG( m_isWindow
, _T("Init() must have been called before!") );
1492 PreCreation( parent
, id
, pos
, size
, style
, name
);
1494 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
1495 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
1497 GtkScrolledWindow
*s_window
= GTK_SCROLLED_WINDOW(m_widget
);
1499 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1500 scroll_class
->scrollbar_spacing
= 0;
1502 gtk_scrolled_window_set_policy( s_window
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
1504 m_oldHorizontalPos
= 0.0;
1505 m_oldVerticalPos
= 0.0;
1507 m_hAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->hscrollbar
) );
1508 m_vAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->vscrollbar
) );
1510 m_wxwindow
= gtk_myfixed_new();
1511 gtk_widget_show( m_wxwindow
);
1513 gtk_container_add( GTK_CONTAINER(m_widget
), m_wxwindow
);
1515 #if (GTK_MINOR_VERSION > 0)
1516 GtkMyFixed
*myfixed
= GTK_MYFIXED(m_wxwindow
);
1518 if (m_windowStyle
& wxRAISED_BORDER
)
1520 gtk_myfixed_set_shadow_type( myfixed
, GTK_SHADOW_OUT
);
1522 else if (m_windowStyle
& wxSUNKEN_BORDER
)
1524 gtk_myfixed_set_shadow_type( myfixed
, GTK_SHADOW_IN
);
1528 gtk_myfixed_set_shadow_type( myfixed
, GTK_SHADOW_NONE
);
1531 GtkViewport
*viewport
= GTK_VIEWPORT(s_window
->viewport
);
1533 if (m_windowStyle
& wxRAISED_BORDER
)
1535 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_OUT
);
1537 else if (m_windowStyle
& wxSUNKEN_BORDER
)
1539 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_IN
);
1543 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_NONE
);
1547 if (m_windowStyle
& wxTAB_TRAVERSAL
)
1549 /* we now allow a window to get the focus as long as it
1550 doesn't have any children. */
1551 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
1552 m_acceptsFocus
= FALSE
;
1556 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
1557 m_acceptsFocus
= TRUE
;
1560 #if (GTK_MINOR_VERSION == 0)
1561 // shut the viewport up
1562 gtk_viewport_set_hadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
1563 gtk_viewport_set_vadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
1566 // I _really_ don't want scrollbars in the beginning
1567 m_vAdjust
->lower
= 0.0;
1568 m_vAdjust
->upper
= 1.0;
1569 m_vAdjust
->value
= 0.0;
1570 m_vAdjust
->step_increment
= 1.0;
1571 m_vAdjust
->page_increment
= 1.0;
1572 m_vAdjust
->page_size
= 5.0;
1573 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
1574 m_hAdjust
->lower
= 0.0;
1575 m_hAdjust
->upper
= 1.0;
1576 m_hAdjust
->value
= 0.0;
1577 m_hAdjust
->step_increment
= 1.0;
1578 m_hAdjust
->page_increment
= 1.0;
1579 m_hAdjust
->page_size
= 5.0;
1580 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
1582 // these handlers block mouse events to any window during scrolling
1583 // such as motion events and prevent GTK and wxWindows from fighting
1584 // over where the slider should be
1586 gtk_signal_connect( GTK_OBJECT(s_window
->vscrollbar
), "button_press_event",
1587 (GtkSignalFunc
)gtk_scrollbar_button_press_callback
, (gpointer
) this );
1589 gtk_signal_connect( GTK_OBJECT(s_window
->hscrollbar
), "button_press_event",
1590 (GtkSignalFunc
)gtk_scrollbar_button_press_callback
, (gpointer
) this );
1592 gtk_signal_connect( GTK_OBJECT(s_window
->vscrollbar
), "button_release_event",
1593 (GtkSignalFunc
)gtk_scrollbar_button_release_callback
, (gpointer
) this );
1595 gtk_signal_connect( GTK_OBJECT(s_window
->hscrollbar
), "button_release_event",
1596 (GtkSignalFunc
)gtk_scrollbar_button_release_callback
, (gpointer
) this );
1598 // these handlers get notified when screen updates are required either when
1599 // scrolling or when the window size (and therefore scrollbar configuration)
1602 gtk_signal_connect( GTK_OBJECT(m_hAdjust
), "value_changed",
1603 (GtkSignalFunc
) gtk_window_hscroll_callback
, (gpointer
) this );
1604 gtk_signal_connect( GTK_OBJECT(m_vAdjust
), "value_changed",
1605 (GtkSignalFunc
) gtk_window_vscroll_callback
, (gpointer
) this );
1607 gtk_signal_connect( GTK_OBJECT(m_hAdjust
), "changed",
1608 (GtkSignalFunc
) gtk_window_hscroll_change_callback
, (gpointer
) this );
1609 gtk_signal_connect(GTK_OBJECT(m_vAdjust
), "changed",
1610 (GtkSignalFunc
) gtk_window_vscroll_change_callback
, (gpointer
) this );
1612 if (m_parent
) m_parent
->AddChild( this );
1614 (m_parent
->m_insertCallback
)( m_parent
, this );
1623 wxWindow::~wxWindow()
1627 #if wxUSE_DRAG_AND_DROP
1630 delete m_dropTarget
;
1631 m_dropTarget
= (wxDropTarget
*) NULL
;
1639 m_toolTip
= (wxToolTip
*) NULL
;
1641 #endif // wxUSE_TOOLTIPS
1643 if (m_widget
) Show( FALSE
);
1647 if (m_parent
) m_parent
->RemoveChild( this );
1649 if (m_widgetStyle
) gtk_style_unref( m_widgetStyle
);
1651 if (m_scrollGC
) gdk_gc_unref( m_scrollGC
);
1653 if (m_wxwindow
) gtk_widget_destroy( m_wxwindow
);
1655 if (m_widget
) gtk_widget_destroy( m_widget
);
1657 if (m_cursor
) delete m_cursor
;
1659 DeleteRelatedConstraints();
1662 /* This removes any dangling pointers to this window
1663 * in other windows' constraintsInvolvedIn lists. */
1664 UnsetConstraints(m_constraints
);
1665 delete m_constraints
;
1666 m_constraints
= (wxLayoutConstraints
*) NULL
;
1671 delete m_windowSizer
;
1672 m_windowSizer
= (wxSizer
*) NULL
;
1674 /* If this is a child of a sizer, remove self from parent */
1675 if (m_sizerParent
) m_sizerParent
->RemoveChild((wxWindow
*)this);
1677 /* Just in case the window has been Closed, but
1678 * we're then deleting immediately: don't leave
1679 * dangling pointers. */
1680 wxPendingDelete
.DeleteObject(this);
1682 /* Just in case we've loaded a top-level window via
1683 * wxWindow::LoadNativeDialog but we weren't a dialog
1685 wxTopLevelWindows
.DeleteObject(this);
1687 if (m_windowValidator
) delete m_windowValidator
;
1689 if (m_clientObject
) delete m_clientObject
;
1692 void wxWindow::PreCreation( wxWindow
*parent
, wxWindowID id
,
1693 const wxPoint
&pos
, const wxSize
&size
,
1694 long style
, const wxString
&name
)
1696 wxASSERT_MSG( (!m_needParent
) || (parent
), _T("Need complete parent.") );
1698 m_widget
= (GtkWidget
*) NULL
;
1699 m_wxwindow
= (GtkWidget
*) NULL
;
1702 m_children
.DeleteContents( FALSE
);
1705 if (m_width
== -1) m_width
= 20;
1707 if (m_height
== -1) m_height
= 20;
1712 if (!m_needParent
) /* some reasonable defaults */
1716 m_x
= (gdk_screen_width () - m_width
) / 2;
1717 if (m_x
< 10) m_x
= 10;
1721 m_y
= (gdk_screen_height () - m_height
) / 2;
1722 if (m_y
< 10) m_y
= 10;
1733 m_eventHandler
= this;
1735 m_windowId
= id
== -1 ? wxNewId() : id
;
1739 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
1740 m_font
= *wxSWISS_FONT
;
1741 m_backgroundColour
= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
);
1742 m_foregroundColour
= *wxBLACK
;
1743 m_windowStyle
= style
;
1744 m_windowName
= name
;
1746 m_constraints
= (wxLayoutConstraints
*) NULL
;
1747 m_constraintsInvolvedIn
= (wxList
*) NULL
;
1748 m_windowSizer
= (wxSizer
*) NULL
;
1749 m_sizerParent
= (wxWindow
*) NULL
;
1750 m_autoLayout
= FALSE
;
1752 m_hasScrolling
= FALSE
;
1753 m_isScrolling
= FALSE
;
1754 m_hAdjust
= (GtkAdjustment
*) NULL
;
1755 m_vAdjust
= (GtkAdjustment
*) NULL
;
1756 m_oldHorizontalPos
= 0.0;
1757 m_oldVerticalPos
= 0.0;
1762 #if wxUSE_DRAG_AND_DROP
1763 m_dropTarget
= (wxDropTarget
*) NULL
;
1766 m_windowValidator
= (wxValidator
*) NULL
;
1767 m_scrollGC
= (GdkGC
*) NULL
;
1768 m_widgetStyle
= (GtkStyle
*) NULL
;
1770 m_clientObject
= (wxClientData
*)NULL
;
1771 m_clientData
= NULL
;
1773 m_isStaticBox
= FALSE
;
1776 m_toolTip
= (wxToolTip
*) NULL
;
1777 #endif // wxUSE_TOOLTIPS
1780 void wxWindow::PostCreation()
1782 wxASSERT_MSG( (m_widget
!= NULL
), _T("invalid window") );
1786 /* these get reported to wxWindows -> wxPaintEvent */
1787 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "expose_event",
1788 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
1790 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "draw",
1791 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
1793 #if (GTK_MINOR_VERSION > 0)
1794 /* these are called when the "sunken" or "raised" borders are drawn */
1795 gtk_signal_connect( GTK_OBJECT(m_widget
), "expose_event",
1796 GTK_SIGNAL_FUNC(gtk_window_own_expose_callback
), (gpointer
)this );
1798 gtk_signal_connect( GTK_OBJECT(m_widget
), "draw",
1799 GTK_SIGNAL_FUNC(gtk_window_own_draw_callback
), (gpointer
)this );
1803 GtkWidget
*connect_widget
= GetConnectWidget();
1805 ConnectWidget( connect_widget
);
1807 /* we cannot set colours, fonts and cursors before the widget has
1808 been realized, so we do this directly after realization */
1809 gtk_signal_connect( GTK_OBJECT(connect_widget
), "realize",
1810 GTK_SIGNAL_FUNC(gtk_window_realized_callback
), (gpointer
) this );
1815 void wxWindow::ConnectWidget( GtkWidget
*widget
)
1817 gtk_signal_connect( GTK_OBJECT(widget
), "key_press_event",
1818 GTK_SIGNAL_FUNC(gtk_window_key_press_callback
), (gpointer
)this );
1820 gtk_signal_connect( GTK_OBJECT(widget
), "key_release_event",
1821 GTK_SIGNAL_FUNC(gtk_window_key_release_callback
), (gpointer
)this );
1823 gtk_signal_connect( GTK_OBJECT(widget
), "button_press_event",
1824 GTK_SIGNAL_FUNC(gtk_window_button_press_callback
), (gpointer
)this );
1826 gtk_signal_connect( GTK_OBJECT(widget
), "button_release_event",
1827 GTK_SIGNAL_FUNC(gtk_window_button_release_callback
), (gpointer
)this );
1829 gtk_signal_connect( GTK_OBJECT(widget
), "motion_notify_event",
1830 GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback
), (gpointer
)this );
1832 gtk_signal_connect( GTK_OBJECT(widget
), "focus_in_event",
1833 GTK_SIGNAL_FUNC(gtk_window_focus_in_callback
), (gpointer
)this );
1835 gtk_signal_connect( GTK_OBJECT(widget
), "focus_out_event",
1836 GTK_SIGNAL_FUNC(gtk_window_focus_out_callback
), (gpointer
)this );
1838 gtk_signal_connect( GTK_OBJECT(widget
), "enter_notify_event",
1839 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
1841 gtk_signal_connect( GTK_OBJECT(widget
), "leave_notify_event",
1842 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
1845 bool wxWindow::HasVMT()
1850 bool wxWindow::Close( bool force
)
1852 wxASSERT_MSG( (m_widget
!= NULL
), _T("invalid window") );
1854 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
1855 event
.SetEventObject(this);
1856 event
.SetCanVeto(!force
);
1858 /* return FALSE if window wasn't closed because the application vetoed the
1860 return GetEventHandler()->ProcessEvent(event
) && !event
.GetVeto();
1863 bool wxWindow::Destroy()
1865 wxASSERT_MSG( (m_widget
!= NULL
), _T("invalid window") );
1872 bool wxWindow::DestroyChildren()
1875 while ((node
= m_children
.First()) != (wxNode
*)NULL
)
1878 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
)
1881 if (m_children
.Member(child
)) delete node
;
1887 void wxWindow::PrepareDC( wxDC
&WXUNUSED(dc
) )
1889 // are we to set fonts here ?
1892 void wxWindow::DoSetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
1894 wxASSERT_MSG( (m_widget
!= NULL
), _T("invalid window") );
1895 wxASSERT_MSG( (m_parent
!= NULL
), _T("wxWindow::SetSize requires parent.\n") );
1897 if (m_resizing
) return; /* I don't like recursions */
1900 if (m_parent
->m_wxwindow
== NULL
) /* i.e. wxNotebook */
1902 /* don't set the size for children of wxNotebook, just take the values. */
1910 int old_width
= m_width
;
1911 int old_height
= m_height
;
1913 if ((sizeFlags
& wxSIZE_USE_EXISTING
) == wxSIZE_USE_EXISTING
)
1915 if (x
!= -1) m_x
= x
;
1916 if (y
!= -1) m_y
= y
;
1917 if (width
!= -1) m_width
= width
;
1918 if (height
!= -1) m_height
= height
;
1928 if ((sizeFlags
& wxSIZE_AUTO_WIDTH
) == wxSIZE_AUTO_WIDTH
)
1930 if (width
== -1) m_width
= 80;
1933 if ((sizeFlags
& wxSIZE_AUTO_HEIGHT
) == wxSIZE_AUTO_HEIGHT
)
1935 if (height
== -1) m_height
= 26;
1938 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
1939 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
1940 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_maxWidth
;
1941 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_maxHeight
;
1943 if (GTK_WIDGET_HAS_DEFAULT(m_widget
))
1945 /* the default button has a border around it */
1948 gtk_myfixed_move( GTK_MYFIXED(m_parent
->m_wxwindow
), m_widget
, m_x
-border
, m_y
-border
);
1950 gtk_widget_set_usize( m_widget
, m_width
+2*border
, m_height
+2*border
);
1954 gtk_myfixed_move( GTK_MYFIXED(m_parent
->m_wxwindow
), m_widget
, m_x
, m_y
);
1956 if ((old_width
!= m_width
) || (old_height
!= m_height
))
1957 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
1963 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
1964 event
.SetEventObject( this );
1965 GetEventHandler()->ProcessEvent( event
);
1970 void wxWindow::OnInternalIdle()
1975 void wxWindow::GetSize( int *width
, int *height
) const
1977 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
1979 if (width
) (*width
) = m_width
;
1980 if (height
) (*height
) = m_height
;
1983 void wxWindow::DoSetClientSize( int width
, int height
)
1985 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
1989 SetSize( width
, height
);
1996 if (!m_hasScrolling
)
1998 GtkStyleClass
*window_class
= m_wxwindow
->style
->klass
;
2000 if ((m_windowStyle
& wxRAISED_BORDER
) ||
2001 (m_windowStyle
& wxSUNKEN_BORDER
))
2003 dw
+= 2 * window_class
->xthickness
;
2004 dh
+= 2 * window_class
->ythickness
;
2009 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
2010 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
2012 #if (GTK_MINOR_VERSION == 0)
2013 GtkWidget
*viewport
= scroll_window
->viewport
;
2014 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
2016 if ((m_windowStyle
& wxRAISED_BORDER
) ||
2017 (m_windowStyle
& wxSUNKEN_BORDER
))
2019 dw
+= 2 * viewport_class
->xthickness
;
2020 dh
+= 2 * viewport_class
->ythickness
;
2025 GtkWidget *hscrollbar = scroll_window->hscrollbar;
2026 GtkWidget *vscrollbar = scroll_window->vscrollbar;
2028 we use this instead: range.slider_width = 11 + 2*2pts edge
2031 if (scroll_window
->vscrollbar_visible
)
2033 dw
+= 15; /* dw += vscrollbar->allocation.width; */
2034 dw
+= scroll_class
->scrollbar_spacing
;
2037 if (scroll_window
->hscrollbar_visible
)
2039 dh
+= 15; /* dh += hscrollbar->allocation.height; */
2040 dw
+= scroll_class
->scrollbar_spacing
;
2044 SetSize( width
+dw
, height
+dh
);
2048 void wxWindow::GetClientSize( int *width
, int *height
) const
2050 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2054 if (width
) (*width
) = m_width
;
2055 if (height
) (*height
) = m_height
;
2062 if (!m_hasScrolling
)
2064 GtkStyleClass
*window_class
= m_wxwindow
->style
->klass
;
2066 if ((m_windowStyle
& wxRAISED_BORDER
) ||
2067 (m_windowStyle
& wxSUNKEN_BORDER
))
2069 dw
+= 2 * window_class
->xthickness
;
2070 dh
+= 2 * window_class
->ythickness
;
2075 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
2076 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
2078 #if (GTK_MINOR_VERSION == 0)
2079 GtkWidget
*viewport
= scroll_window
->viewport
;
2080 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
2082 if ((m_windowStyle
& wxRAISED_BORDER
) ||
2083 (m_windowStyle
& wxSUNKEN_BORDER
))
2085 dw
+= 2 * viewport_class
->xthickness
;
2086 dh
+= 2 * viewport_class
->ythickness
;
2090 GtkWidget *hscrollbar = scroll_window->hscrollbar;
2091 GtkWidget *vscrollbar = scroll_window->vscrollbar;
2093 we use this instead: range.slider_width = 11 + 2*2pts edge
2096 if (scroll_window
->vscrollbar_visible
)
2098 dw
+= 15; /* dw += vscrollbar->allocation.width; */
2099 dw
+= scroll_class
->scrollbar_spacing
;
2102 if (scroll_window
->hscrollbar_visible
)
2104 dh
+= 15; /* dh += hscrollbar->allocation.height; */
2105 dh
+= scroll_class
->scrollbar_spacing
;
2109 if (width
) (*width
) = m_width
- dw
;
2110 if (height
) (*height
) = m_height
- dh
;
2114 void wxWindow::GetPosition( int *x
, int *y
) const
2116 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2122 void wxWindow::ClientToScreen( int *x
, int *y
)
2124 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2126 if (!m_widget
->window
) return;
2128 GdkWindow
*source
= (GdkWindow
*) NULL
;
2130 source
= m_wxwindow
->window
;
2132 source
= m_widget
->window
;
2136 gdk_window_get_origin( source
, &org_x
, &org_y
);
2140 if (GTK_WIDGET_NO_WINDOW (m_widget
))
2142 org_x
+= m_widget
->allocation
.x
;
2143 org_y
+= m_widget
->allocation
.y
;
2151 void wxWindow::ScreenToClient( int *x
, int *y
)
2153 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2155 if (!m_widget
->window
) return;
2157 GdkWindow
*source
= (GdkWindow
*) NULL
;
2159 source
= m_wxwindow
->window
;
2161 source
= m_widget
->window
;
2165 gdk_window_get_origin( source
, &org_x
, &org_y
);
2169 if (GTK_WIDGET_NO_WINDOW (m_widget
))
2171 org_x
+= m_widget
->allocation
.x
;
2172 org_y
+= m_widget
->allocation
.y
;
2180 void wxWindow::Centre( int direction
)
2182 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2191 m_parent
->GetSize( &p_w
, &p_h
);
2192 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (p_w
- m_width
) / 2;
2193 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (p_h
- m_height
) / 2;
2197 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (gdk_screen_width () - m_width
) / 2;
2198 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (gdk_screen_height () - m_height
) / 2;
2204 void wxWindow::Fit()
2206 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2210 wxNode
*node
= m_children
.First();
2213 wxWindow
*win
= (wxWindow
*)node
->Data();
2215 win
->GetPosition(&wx
, &wy
);
2216 win
->GetSize(&ww
, &wh
);
2217 if (wx
+ ww
> maxX
) maxX
= wx
+ ww
;
2218 if (wy
+ wh
> maxY
) maxY
= wy
+ wh
;
2220 node
= node
->Next();
2223 SetClientSize(maxX
+ 7, maxY
+ 14);
2226 void wxWindow::SetSizeHints( int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
) )
2228 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2236 void wxWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
2238 // if (GetAutoLayout()) Layout();
2241 bool wxWindow::Show( bool show
)
2243 wxCHECK_MSG( (m_widget
!= NULL
), FALSE
, _T("invalid window") );
2245 if (show
== m_isShown
) return TRUE
;
2248 gtk_widget_show( m_widget
);
2250 gtk_widget_hide( m_widget
);
2257 void wxWindow::Enable( bool enable
)
2259 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2261 m_isEnabled
= enable
;
2263 gtk_widget_set_sensitive( m_widget
, enable
);
2264 if (m_wxwindow
) gtk_widget_set_sensitive( m_wxwindow
, enable
);
2267 int wxWindow::GetCharHeight() const
2269 wxCHECK_MSG( (m_widget
!= NULL
), 12, _T("invalid window") );
2271 wxCHECK_MSG( m_font
.Ok(), 12, _T("invalid font") );
2273 GdkFont
*font
= m_font
.GetInternalFont( 1.0 );
2275 return font
->ascent
+ font
->descent
;
2278 int wxWindow::GetCharWidth() const
2280 wxCHECK_MSG( (m_widget
!= NULL
), 8, _T("invalid window") );
2282 wxCHECK_MSG( m_font
.Ok(), 8, _T("invalid font") );
2284 GdkFont
*font
= m_font
.GetInternalFont( 1.0 );
2286 return gdk_string_width( font
, "H" );
2289 void wxWindow::GetTextExtent( const wxString
& string
, int *x
, int *y
,
2290 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool WXUNUSED(use16
) ) const
2292 wxFont fontToUse
= m_font
;
2293 if (theFont
) fontToUse
= *theFont
;
2295 wxCHECK_RET( fontToUse
.Ok(), _T("invalid font") );
2297 GdkFont
*font
= fontToUse
.GetInternalFont( 1.0 );
2298 if (x
) (*x
) = gdk_string_width( font
, string
.mbc_str() );
2299 if (y
) (*y
) = font
->ascent
+ font
->descent
;
2300 if (descent
) (*descent
) = font
->descent
;
2301 if (externalLeading
) (*externalLeading
) = 0; // ??
2304 void wxWindow::MakeModal( bool modal
)
2308 // Disable all other windows
2309 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
2311 wxNode
*node
= wxTopLevelWindows
.First();
2314 wxWindow
*win
= (wxWindow
*)node
->Data();
2315 if (win
!= this) win
->Enable(!modal
);
2317 node
= node
->Next();
2322 void wxWindow::OnKeyDown( wxKeyEvent
&event
)
2324 event
.SetEventType( wxEVT_CHAR
);
2326 if (!GetEventHandler()->ProcessEvent( event
))
2332 void wxWindow::SetFocus()
2334 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2336 GtkWidget
*connect_widget
= GetConnectWidget();
2339 if (GTK_WIDGET_CAN_FOCUS(connect_widget
) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
2341 gtk_widget_grab_focus (connect_widget
);
2343 else if (GTK_IS_CONTAINER(connect_widget
))
2345 gtk_container_focus( GTK_CONTAINER(connect_widget
), GTK_DIR_TAB_FORWARD
);
2353 wxWindow
*wxWindow::FindFocus()
2355 return g_focusWindow
;
2358 bool wxWindow::AcceptsFocus() const
2360 return IsEnabled() && IsShown() && m_acceptsFocus
;
2363 void wxWindow::AddChild( wxWindow
*child
)
2365 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2366 wxCHECK_RET( (child
!= NULL
), _T("invalid child") );
2368 m_children
.Append( child
);
2371 wxWindow
*wxWindow::ReParent( wxWindow
*newParent
)
2373 wxCHECK_MSG( (m_widget
!= NULL
), (wxWindow
*) NULL
, _T("invalid window") );
2375 wxWindow
*oldParent
= GetParent();
2377 if (oldParent
) oldParent
->RemoveChild( this );
2379 gtk_widget_unparent( m_widget
);
2383 newParent
->AddChild( this );
2384 (newParent
->m_insertCallback
)( newParent
, this );
2390 void wxWindow::RemoveChild( wxWindow
*child
)
2392 m_children
.DeleteObject( child
);
2393 child
->m_parent
= (wxWindow
*) NULL
;
2396 void wxWindow::SetReturnCode( int retCode
)
2398 m_retCode
= retCode
;
2401 int wxWindow::GetReturnCode()
2406 void wxWindow::Raise()
2408 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2410 if (!m_widget
->window
) return;
2412 if (m_widget
) gdk_window_raise( m_widget
->window
);
2415 void wxWindow::Lower()
2417 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2419 if (!m_widget
->window
) return;
2421 if (m_widget
) gdk_window_lower( m_widget
->window
);
2424 wxEvtHandler
*wxWindow::GetEventHandler() const
2426 return m_eventHandler
;
2429 void wxWindow::SetEventHandler( wxEvtHandler
*handler
)
2431 m_eventHandler
= handler
;
2434 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
2436 handler
->SetNextHandler(GetEventHandler());
2437 SetEventHandler(handler
);
2440 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
2442 if (GetEventHandler())
2444 wxEvtHandler
*handlerA
= GetEventHandler();
2445 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
2446 handlerA
->SetNextHandler((wxEvtHandler
*) NULL
);
2447 SetEventHandler(handlerB
);
2451 return (wxEvtHandler
*) NULL
;
2457 return (wxEvtHandler
*) NULL
;
2460 wxValidator
*wxWindow::GetValidator()
2462 return m_windowValidator
;
2465 void wxWindow::SetValidator( const wxValidator
& validator
)
2467 if (m_windowValidator
) delete m_windowValidator
;
2468 m_windowValidator
= validator
.Clone();
2469 if (m_windowValidator
) m_windowValidator
->SetWindow(this);
2472 void wxWindow::SetClientObject( wxClientData
*data
)
2474 if (m_clientObject
) delete m_clientObject
;
2475 m_clientObject
= data
;
2478 wxClientData
*wxWindow::GetClientObject()
2480 return m_clientObject
;
2483 void wxWindow::SetClientData( void *data
)
2485 m_clientData
= data
;
2488 void *wxWindow::GetClientData()
2490 return m_clientData
;
2493 bool wxWindow::IsBeingDeleted()
2498 void wxWindow::SetId( wxWindowID id
)
2503 wxWindowID
wxWindow::GetId() const
2508 void wxWindow::SetCursor( const wxCursor
&cursor
)
2510 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2514 if (cursor
== *m_cursor
) return;
2519 *m_cursor
= *wxSTANDARD_CURSOR
;
2522 if (!m_widget
->window
) return;
2524 gdk_window_set_cursor( m_widget
->window
, m_cursor
->GetCursor() );
2526 if ((m_wxwindow
) && (m_wxwindow
->window
))
2527 gdk_window_set_cursor( m_wxwindow
->window
, m_cursor
->GetCursor() );
2530 void wxWindow::WarpPointer( int WXUNUSED(x
), int WXUNUSED(y
) )
2535 void wxWindow::Refresh( bool eraseBackground
, const wxRect
*rect
)
2537 wxCHECK_RET( (m_widget
!= NULL
), _T("invalid window") );
2539 if (!m_widget
->window
) return;
2541 if (eraseBackground
&& m_wxwindow
&& m_wxwindow
->window
)
2545 gdk_window_clear_area( m_wxwindow
->window
,
2547 rect
->width
, rect
->height
);
2551 gdk_window_clear( m_wxwindow
->window
);
2558 gtk_widget_draw( m_wxwindow
, (GdkRectangle
*) NULL
);
2560 gtk_widget_draw( m_widget
, (GdkRectangle
*) NULL
);
2564 GdkRectangle gdk_rect
;
2565 gdk_rect
.x
= rect
->x
;
2566 gdk_rect
.y
= rect
->y
;
2567 gdk_rect
.width
= rect
->width
;
2568 gdk_rect
.height
= rect
->height
;
2571 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
2573 gtk_widget_draw( m_widget
, &gdk_rect
);
2577 wxRegion
wxWindow::GetUpdateRegion() const
2579 return m_updateRegion
;
2582 bool wxWindow::IsExposed( int x
, int y
) const
2584 return (m_updateRegion
.Contains( x
, y
) != wxOutRegion
);
2587 bool wxWindow::IsExposed( int x
, int y
, int w
, int h
) const
2589 return (m_updateRegion
.Contains( x
, y
, w
, h
) != wxOutRegion
);
2592 bool wxWindow::IsExposed( const wxPoint
& pt
) const
2594 return (m_updateRegion
.Contains( pt
.x
, pt
.y
) != wxOutRegion
);
2597 bool wxWindow::IsExposed( const wxRect
& rect
) const
2599 return (m_updateRegion
.Contains( rect
.x
, rect
.y
, rect
.width
, rect
.height
) != wxOutRegion
);
2602 void wxWindow::Clear()
2604 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2606 if (!m_widget
->window
) return;
2608 if (m_wxwindow
&& m_wxwindow
->window
)
2610 gdk_window_clear( m_wxwindow
->window
);
2615 void wxWindow::SetToolTip( const wxString
&tip
)
2619 m_toolTip
->SetTip( tip
);
2623 SetToolTip( new wxToolTip( tip
) );
2626 // setting empty tooltip text does not remove the tooltip any more for
2627 // wxMSW compatibility - use SetToolTip((wxToolTip *)NULL) for this
2630 void wxWindow::SetToolTip( wxToolTip
*tip
)
2634 m_toolTip
->SetTip( (char*) NULL
);
2641 m_toolTip
->Apply( this );
2644 void wxWindow::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
2646 gtk_tooltips_set_tip( tips
, GetConnectWidget(), wxConv_current
->cWX2MB(tip
), (gchar
*) NULL
);
2648 #endif // wxUSE_TOOLTIPS
2650 wxColour
wxWindow::GetBackgroundColour() const
2652 return m_backgroundColour
;
2655 void wxWindow::SetBackgroundColour( const wxColour
&colour
)
2657 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2659 if (m_backgroundColour
== colour
) return;
2661 m_backgroundColour
= colour
;
2662 if (!m_backgroundColour
.Ok()) return;
2664 GtkWidget
*connect_widget
= GetConnectWidget();
2665 if (!connect_widget
->window
) return;
2667 if (m_wxwindow
&& m_wxwindow
->window
)
2669 /* wxMSW doesn't clear the window here. I don't do that
2670 either to provide compatibility. call Clear() to do
2673 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( m_wxwindow
->window
) );
2674 gdk_window_set_background( m_wxwindow
->window
, m_backgroundColour
.GetColor() );
2677 wxColour sysbg
= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
);
2679 if (sysbg
.Red() == colour
.Red() &&
2680 sysbg
.Green() == colour
.Green() &&
2681 sysbg
.Blue() == colour
.Blue())
2683 m_backgroundColour
= wxNullColour
;
2685 m_backgroundColour
= sysbg
;
2693 wxColour
wxWindow::GetForegroundColour() const
2695 return m_foregroundColour
;
2698 void wxWindow::SetForegroundColour( const wxColour
&colour
)
2700 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2702 if (m_foregroundColour
== colour
) return;
2704 m_foregroundColour
= colour
;
2705 if (!m_foregroundColour
.Ok()) return;
2707 if (!m_widget
->window
) return;
2709 wxColour sysbg
= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
);
2710 if (sysbg
.Red() == colour
.Red() &&
2711 sysbg
.Green() == colour
.Green() &&
2712 sysbg
.Blue() == colour
.Blue())
2714 m_backgroundColour
= wxNullColour
;
2716 m_backgroundColour
= sysbg
;
2724 GtkStyle
*wxWindow::GetWidgetStyle()
2726 if (m_widgetStyle
) gtk_style_unref( m_widgetStyle
);
2730 gtk_widget_get_style( m_widget
) );
2732 return m_widgetStyle
;
2735 void wxWindow::SetWidgetStyle()
2737 GtkStyle
*style
= GetWidgetStyle();
2739 gdk_font_unref( style
->font
);
2740 style
->font
= gdk_font_ref( m_font
.GetInternalFont( 1.0 ) );
2742 if (m_foregroundColour
.Ok())
2744 m_foregroundColour
.CalcPixel( gdk_window_get_colormap( m_widget
->window
) );
2745 style
->fg
[GTK_STATE_NORMAL
] = *m_foregroundColour
.GetColor();
2746 style
->fg
[GTK_STATE_PRELIGHT
] = *m_foregroundColour
.GetColor();
2747 style
->fg
[GTK_STATE_ACTIVE
] = *m_foregroundColour
.GetColor();
2750 if (m_backgroundColour
.Ok())
2752 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( m_widget
->window
) );
2753 style
->bg
[GTK_STATE_NORMAL
] = *m_backgroundColour
.GetColor();
2754 style
->base
[GTK_STATE_NORMAL
] = *m_backgroundColour
.GetColor();
2755 style
->bg
[GTK_STATE_PRELIGHT
] = *m_backgroundColour
.GetColor();
2756 style
->base
[GTK_STATE_PRELIGHT
] = *m_backgroundColour
.GetColor();
2757 style
->bg
[GTK_STATE_ACTIVE
] = *m_backgroundColour
.GetColor();
2758 style
->base
[GTK_STATE_ACTIVE
] = *m_backgroundColour
.GetColor();
2759 style
->bg
[GTK_STATE_INSENSITIVE
] = *m_backgroundColour
.GetColor();
2760 style
->base
[GTK_STATE_INSENSITIVE
] = *m_backgroundColour
.GetColor();
2764 void wxWindow::ApplyWidgetStyle()
2768 bool wxWindow::Validate()
2770 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, _T("invalid window") );
2772 wxNode
*node
= m_children
.First();
2775 wxWindow
*child
= (wxWindow
*)node
->Data();
2776 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this))
2780 node
= node
->Next();
2785 bool wxWindow::TransferDataToWindow()
2787 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, _T("invalid window") );
2789 wxNode
*node
= m_children
.First();
2792 wxWindow
*child
= (wxWindow
*)node
->Data();
2793 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */
2794 !child
->GetValidator()->TransferToWindow() )
2796 wxMessageBox( _("Application Error"), _("Could not transfer data to window"), wxOK
|wxICON_EXCLAMATION
);
2799 node
= node
->Next();
2804 bool wxWindow::TransferDataFromWindow()
2806 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, _T("invalid window") );
2808 wxNode
*node
= m_children
.First();
2811 wxWindow
*child
= (wxWindow
*)node
->Data();
2812 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
2816 node
= node
->Next();
2821 void wxWindow::SetAcceleratorTable( const wxAcceleratorTable
& accel
)
2823 m_acceleratorTable
= accel
;
2826 void wxWindow::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2828 TransferDataToWindow();
2831 void wxWindow::InitDialog()
2833 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2835 wxInitDialogEvent
event(GetId());
2836 event
.SetEventObject( this );
2837 GetEventHandler()->ProcessEvent(event
);
2840 static void SetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
2842 menu
->SetInvokingWindow( win
);
2843 wxNode
*node
= menu
->GetItems().First();
2846 wxMenuItem
*menuitem
= (wxMenuItem
*)node
->Data();
2847 if (menuitem
->IsSubMenu())
2849 SetInvokingWindow( menuitem
->GetSubMenu(), win
);
2851 node
= node
->Next();
2855 static gint gs_pop_x
= 0;
2856 static gint gs_pop_y
= 0;
2858 static void pop_pos_callback( GtkMenu
*menu
, gint
*x
, gint
*y
, wxWindow
*win
)
2860 win
->ClientToScreen( &gs_pop_x
, &gs_pop_y
);
2865 bool wxWindow::PopupMenu( wxMenu
*menu
, int x
, int y
)
2867 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, _T("invalid window") );
2869 wxCHECK_MSG( menu
!= NULL
, FALSE
, _T("invalid popup-menu") );
2871 SetInvokingWindow( menu
, this );
2879 GTK_MENU(menu
->m_menu
),
2880 (GtkWidget
*) NULL
, // parent menu shell
2881 (GtkWidget
*) NULL
, // parent menu item
2882 (GtkMenuPositionFunc
) pop_pos_callback
,
2883 (gpointer
) this, // client data
2884 0, // button used to activate it
2885 0 //gs_timeLastClick // the time of activation
2890 #if wxUSE_DRAG_AND_DROP
2892 void wxWindow::SetDropTarget( wxDropTarget
*dropTarget
)
2894 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2896 GtkWidget
*dnd_widget
= GetConnectWidget();
2898 if (m_dropTarget
) m_dropTarget
->UnregisterWidget( dnd_widget
);
2900 if (m_dropTarget
) delete m_dropTarget
;
2901 m_dropTarget
= dropTarget
;
2903 if (m_dropTarget
) m_dropTarget
->RegisterWidget( dnd_widget
);
2906 wxDropTarget
*wxWindow::GetDropTarget() const
2908 return m_dropTarget
;
2913 GtkWidget
* wxWindow::GetConnectWidget()
2915 GtkWidget
*connect_widget
= m_widget
;
2916 if (m_wxwindow
) connect_widget
= m_wxwindow
;
2918 return connect_widget
;
2921 bool wxWindow::IsOwnGtkWindow( GdkWindow
*window
)
2923 if (m_wxwindow
) return (window
== m_wxwindow
->window
);
2924 return (window
== m_widget
->window
);
2927 void wxWindow::SetFont( const wxFont
&font
)
2929 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2931 if (m_font
== font
) return;
2933 if (((wxFont
*)&font
)->Ok())
2936 m_font
= *wxSWISS_FONT
;
2938 wxColour sysbg
= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
);
2939 if (sysbg
.Red() == m_backgroundColour
.Red() &&
2940 sysbg
.Green() == m_backgroundColour
.Green() &&
2941 sysbg
.Blue() == m_backgroundColour
.Blue())
2943 m_backgroundColour
= wxNullColour
;
2945 m_backgroundColour
= sysbg
;
2953 void wxWindow::SetWindowStyleFlag( long flag
)
2955 m_windowStyle
= flag
;
2958 long wxWindow::GetWindowStyleFlag() const
2960 return m_windowStyle
;
2963 void wxWindow::CaptureMouse()
2965 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2967 wxCHECK_RET( g_capturing
== FALSE
, _T("CaptureMouse called twice") );
2969 if (!m_widget
->window
) return;
2971 GtkWidget
*connect_widget
= GetConnectWidget();
2972 gtk_grab_add( connect_widget
);
2973 gdk_pointer_grab( connect_widget
->window
, FALSE
,
2975 (GDK_BUTTON_PRESS_MASK
|
2976 GDK_BUTTON_RELEASE_MASK
|
2977 GDK_POINTER_MOTION_MASK
),
2984 void wxWindow::ReleaseMouse()
2986 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
2988 wxCHECK_RET( g_capturing
== TRUE
, _T("ReleaseMouse called twice") );
2990 if (!m_widget
->window
) return;
2992 GtkWidget
*connect_widget
= GetConnectWidget();
2993 gtk_grab_remove( connect_widget
);
2994 gdk_pointer_ungrab ( GDK_CURRENT_TIME
);
2995 g_capturing
= FALSE
;
2998 void wxWindow::SetTitle( const wxString
&WXUNUSED(title
) )
3002 wxString
wxWindow::GetTitle() const
3004 return (wxString
&)m_windowName
;
3007 wxString
wxWindow::GetLabel() const
3012 void wxWindow::SetName( const wxString
&name
)
3014 m_windowName
= name
;
3017 wxString
wxWindow::GetName() const
3019 return (wxString
&)m_windowName
;
3022 bool wxWindow::IsShown() const
3027 bool wxWindow::IsRetained()
3032 wxWindow
*wxWindow::FindWindow( long id
)
3034 if (id
== m_windowId
) return this;
3035 wxNode
*node
= m_children
.First();
3038 wxWindow
*child
= (wxWindow
*)node
->Data();
3039 wxWindow
*res
= child
->FindWindow( id
);
3040 if (res
) return res
;
3041 node
= node
->Next();
3043 return (wxWindow
*) NULL
;
3046 wxWindow
*wxWindow::FindWindow( const wxString
& name
)
3048 if (name
== m_windowName
) return this;
3049 wxNode
*node
= m_children
.First();
3052 wxWindow
*child
= (wxWindow
*)node
->Data();
3053 wxWindow
*res
= child
->FindWindow( name
);
3054 if (res
) return res
;
3055 node
= node
->Next();
3057 return (wxWindow
*) NULL
;
3060 void wxWindow::SetScrollbar( int orient
, int pos
, int thumbVisible
,
3061 int range
, bool refresh
)
3063 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
3065 wxCHECK_RET( m_wxwindow
!= NULL
, _T("window needs client area for scrolling") );
3067 m_hasScrolling
= TRUE
;
3069 if (orient
== wxHORIZONTAL
)
3071 float fpos
= (float)pos
;
3072 float frange
= (float)range
;
3073 float fthumb
= (float)thumbVisible
;
3074 if (fpos
> frange
-fthumb
) fpos
= frange
-fthumb
;
3075 if (fpos
< 0.0) fpos
= 0.0;
3077 if ((fabs(frange
-m_hAdjust
->upper
) < 0.2) &&
3078 (fabs(fthumb
-m_hAdjust
->page_size
) < 0.2))
3080 SetScrollPos( orient
, pos
, refresh
);
3084 m_oldHorizontalPos
= fpos
;
3086 m_hAdjust
->lower
= 0.0;
3087 m_hAdjust
->upper
= frange
;
3088 m_hAdjust
->value
= fpos
;
3089 m_hAdjust
->step_increment
= 1.0;
3090 m_hAdjust
->page_increment
= (float)(wxMax(fthumb
,0));
3091 m_hAdjust
->page_size
= fthumb
;
3095 float fpos
= (float)pos
;
3096 float frange
= (float)range
;
3097 float fthumb
= (float)thumbVisible
;
3098 if (fpos
> frange
-fthumb
) fpos
= frange
-fthumb
;
3099 if (fpos
< 0.0) fpos
= 0.0;
3101 if ((fabs(frange
-m_vAdjust
->upper
) < 0.2) &&
3102 (fabs(fthumb
-m_vAdjust
->page_size
) < 0.2))
3104 SetScrollPos( orient
, pos
, refresh
);
3108 m_oldVerticalPos
= fpos
;
3110 m_vAdjust
->lower
= 0.0;
3111 m_vAdjust
->upper
= frange
;
3112 m_vAdjust
->value
= fpos
;
3113 m_vAdjust
->step_increment
= 1.0;
3114 m_vAdjust
->page_increment
= (float)(wxMax(fthumb
,0));
3115 m_vAdjust
->page_size
= fthumb
;
3120 if (orient
== wxHORIZONTAL
)
3121 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
3123 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
3125 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
3129 void wxWindow::SetScrollPos( int orient
, int pos
, bool WXUNUSED(refresh
) )
3131 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
3133 wxCHECK_RET( m_wxwindow
!= NULL
, _T("window needs client area for scrolling") );
3135 if (orient
== wxHORIZONTAL
)
3137 float fpos
= (float)pos
;
3138 if (fpos
> m_hAdjust
->upper
- m_hAdjust
->page_size
) fpos
= m_hAdjust
->upper
- m_hAdjust
->page_size
;
3139 if (fpos
< 0.0) fpos
= 0.0;
3140 m_oldHorizontalPos
= fpos
;
3142 if (fabs(fpos
-m_hAdjust
->value
) < 0.2) return;
3143 m_hAdjust
->value
= fpos
;
3147 float fpos
= (float)pos
;
3148 if (fpos
> m_vAdjust
->upper
- m_vAdjust
->page_size
) fpos
= m_vAdjust
->upper
- m_vAdjust
->page_size
;
3149 if (fpos
< 0.0) fpos
= 0.0;
3150 m_oldVerticalPos
= fpos
;
3152 if (fabs(fpos
-m_vAdjust
->value
) < 0.2) return;
3153 m_vAdjust
->value
= fpos
;
3158 if (m_wxwindow
->window
)
3160 if (orient
== wxHORIZONTAL
)
3161 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
3163 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
3168 int wxWindow::GetScrollThumb( int orient
) const
3170 wxCHECK_MSG( m_widget
!= NULL
, 0, _T("invalid window") );
3172 wxCHECK_MSG( m_wxwindow
!= NULL
, 0, _T("window needs client area for scrolling") );
3174 if (orient
== wxHORIZONTAL
)
3175 return (int)(m_hAdjust
->page_size
+0.5);
3177 return (int)(m_vAdjust
->page_size
+0.5);
3180 int wxWindow::GetScrollPos( int orient
) const
3182 wxCHECK_MSG( m_widget
!= NULL
, 0, _T("invalid window") );
3184 wxCHECK_MSG( m_wxwindow
!= NULL
, 0, _T("window needs client area for scrolling") );
3186 if (orient
== wxHORIZONTAL
)
3187 return (int)(m_hAdjust
->value
+0.5);
3189 return (int)(m_vAdjust
->value
+0.5);
3192 int wxWindow::GetScrollRange( int orient
) const
3194 wxCHECK_MSG( m_widget
!= NULL
, 0, _T("invalid window") );
3196 wxCHECK_MSG( m_wxwindow
!= NULL
, 0, _T("window needs client area for scrolling") );
3198 if (orient
== wxHORIZONTAL
)
3199 return (int)(m_hAdjust
->upper
+0.5);
3201 return (int)(m_vAdjust
->upper
+0.5);
3204 void wxWindow::ScrollWindow( int dx
, int dy
, const wxRect
* WXUNUSED(rect
) )
3206 wxCHECK_RET( m_widget
!= NULL
, _T("invalid window") );
3208 wxCHECK_RET( m_wxwindow
!= NULL
, _T("window needs client area for scrolling") );
3210 wxNode
*node
= m_children
.First();
3213 wxWindow
*child
= (wxWindow
*) node
->Data();
3214 child
->Move( child
->m_x
+ dx
, child
->m_y
+ dy
);
3215 node
= node
->Next();
3220 GetClientSize( &cw
, &ch
);
3222 int w
= cw
- abs(dx
);
3223 int h
= ch
- abs(dy
);
3224 if ((h
< 0) || (w
< 0))
3231 if (dx
< 0) s_x
= -dx
;
3232 if (dy
< 0) s_y
= -dy
;
3235 if (dx
> 0) d_x
= dx
;
3236 if (dy
> 0) d_y
= dy
;
3240 m_scrollGC
= gdk_gc_new( m_wxwindow
->window
);
3241 gdk_gc_set_exposures( m_scrollGC
, TRUE
);
3244 gdk_window_copy_area( m_wxwindow
->window
, m_scrollGC
, d_x
, d_y
,
3245 m_wxwindow
->window
, s_x
, s_y
, w
, h
);
3248 if (dx
< 0) rect
.x
= cw
+dx
; else rect
.x
= 0;
3249 if (dy
< 0) rect
.y
= ch
+dy
; else rect
.y
= 0;
3250 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
3251 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
3253 Refresh( TRUE
, &rect
);
3256 //-------------------------------------------------------------------------------------
3258 //-------------------------------------------------------------------------------------
3260 wxLayoutConstraints
*wxWindow::GetConstraints() const
3262 return m_constraints
;
3265 void wxWindow::SetConstraints( wxLayoutConstraints
*constraints
)
3269 UnsetConstraints(m_constraints
);
3270 delete m_constraints
;
3272 m_constraints
= constraints
;
3275 // Make sure other windows know they're part of a 'meaningful relationship'
3276 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
3277 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3278 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
3279 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3280 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
3281 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3282 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
3283 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3284 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
3285 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3286 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
3287 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3288 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
3289 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3290 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
3291 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
3297 void wxWindow::SetAutoLayout( bool autoLayout
)
3299 m_autoLayout
= autoLayout
;
3302 bool wxWindow::GetAutoLayout() const
3304 return m_autoLayout
;
3307 wxSizer
*wxWindow::GetSizer() const
3309 return m_windowSizer
;
3312 void wxWindow::SetSizerParent( wxWindow
*win
)
3314 m_sizerParent
= win
;
3317 wxWindow
*wxWindow::GetSizerParent() const
3319 return m_sizerParent
;
3322 // This removes any dangling pointers to this window
3323 // in other windows' constraintsInvolvedIn lists.
3324 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
3328 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3329 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3330 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
3331 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3332 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
3333 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3334 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
3335 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3336 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
3337 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3338 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
3339 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3340 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
3341 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3342 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
3343 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
3347 // Back-pointer to other windows we're involved with, so if we delete
3348 // this window, we must delete any constraints we're involved with.
3349 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
3351 if (!m_constraintsInvolvedIn
)
3352 m_constraintsInvolvedIn
= new wxList
;
3353 if (!m_constraintsInvolvedIn
->Member(otherWin
))
3354 m_constraintsInvolvedIn
->Append(otherWin
);
3357 // REMOVE back-pointer to other windows we're involved with.
3358 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
3360 if (m_constraintsInvolvedIn
)
3361 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
3364 // Reset any constraints that mention this window
3365 void wxWindow::DeleteRelatedConstraints()
3367 if (m_constraintsInvolvedIn
)
3369 wxNode
*node
= m_constraintsInvolvedIn
->First();
3372 wxWindow
*win
= (wxWindow
*)node
->Data();
3373 wxNode
*next
= node
->Next();
3374 wxLayoutConstraints
*constr
= win
->GetConstraints();
3376 // Reset any constraints involving this window
3379 constr
->left
.ResetIfWin((wxWindow
*)this);
3380 constr
->top
.ResetIfWin((wxWindow
*)this);
3381 constr
->right
.ResetIfWin((wxWindow
*)this);
3382 constr
->bottom
.ResetIfWin((wxWindow
*)this);
3383 constr
->width
.ResetIfWin((wxWindow
*)this);
3384 constr
->height
.ResetIfWin((wxWindow
*)this);
3385 constr
->centreX
.ResetIfWin((wxWindow
*)this);
3386 constr
->centreY
.ResetIfWin((wxWindow
*)this);
3391 delete m_constraintsInvolvedIn
;
3392 m_constraintsInvolvedIn
= (wxList
*) NULL
;
3396 void wxWindow::SetSizer(wxSizer
*sizer
)
3398 m_windowSizer
= sizer
;
3400 sizer
->SetSizerParent((wxWindow
*)this);
3407 bool wxWindow::Layout()
3409 if (GetConstraints())
3412 GetClientSize(&w
, &h
);
3413 GetConstraints()->width
.SetValue(w
);
3414 GetConstraints()->height
.SetValue(h
);
3417 // If top level (one sizer), evaluate the sizer's constraints.
3421 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
3422 GetSizer()->LayoutPhase1(&noChanges
);
3423 GetSizer()->LayoutPhase2(&noChanges
);
3424 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
3429 // Otherwise, evaluate child constraints
3430 ResetConstraints(); // Mark all constraints as unevaluated
3431 DoPhase(1); // Just one phase need if no sizers involved
3433 SetConstraintSizes(); // Recursively set the real window sizes
3439 // Do a phase of evaluating constraints:
3440 // the default behaviour. wxSizers may do a similar
3441 // thing, but also impose their own 'constraints'
3442 // and order the evaluation differently.
3443 bool wxWindow::LayoutPhase1(int *noChanges
)
3445 wxLayoutConstraints
*constr
= GetConstraints();
3448 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
3454 bool wxWindow::LayoutPhase2(int *noChanges
)
3464 // Do a phase of evaluating child constraints
3465 bool wxWindow::DoPhase(int phase
)
3467 int noIterations
= 0;
3468 int maxIterations
= 500;
3472 while ((noChanges
> 0) && (noIterations
< maxIterations
))
3476 wxNode
*node
= m_children
.First();
3479 wxWindow
*child
= (wxWindow
*)node
->Data();
3480 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
3482 wxLayoutConstraints
*constr
= child
->GetConstraints();
3485 if (succeeded
.Member(child
))
3490 int tempNoChanges
= 0;
3491 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
3492 noChanges
+= tempNoChanges
;
3495 succeeded
.Append(child
);
3500 node
= node
->Next();
3507 void wxWindow::ResetConstraints()
3509 wxLayoutConstraints
*constr
= GetConstraints();
3512 constr
->left
.SetDone(FALSE
);
3513 constr
->top
.SetDone(FALSE
);
3514 constr
->right
.SetDone(FALSE
);
3515 constr
->bottom
.SetDone(FALSE
);
3516 constr
->width
.SetDone(FALSE
);
3517 constr
->height
.SetDone(FALSE
);
3518 constr
->centreX
.SetDone(FALSE
);
3519 constr
->centreY
.SetDone(FALSE
);
3521 wxNode
*node
= m_children
.First();
3524 wxWindow
*win
= (wxWindow
*)node
->Data();
3525 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3526 win
->ResetConstraints();
3527 node
= node
->Next();
3531 // Need to distinguish between setting the 'fake' size for
3532 // windows and sizers, and setting the real values.
3533 void wxWindow::SetConstraintSizes(bool recurse
)
3535 wxLayoutConstraints
*constr
= GetConstraints();
3536 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
3537 constr
->width
.GetDone() && constr
->height
.GetDone())
3539 int x
= constr
->left
.GetValue();
3540 int y
= constr
->top
.GetValue();
3541 int w
= constr
->width
.GetValue();
3542 int h
= constr
->height
.GetValue();
3544 // If we don't want to resize this window, just move it...
3545 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
3546 (constr
->height
.GetRelationship() != wxAsIs
))
3548 // Calls Layout() recursively. AAAGH. How can we stop that.
3549 // Simply take Layout() out of non-top level OnSizes.
3550 SizerSetSize(x
, y
, w
, h
);
3559 wxChar
*windowClass
= this->GetClassInfo()->GetClassName();
3562 if (GetName() == _T(""))
3563 winName
= _T("unnamed");
3565 winName
= GetName();
3566 wxLogDebug( _T("Constraint(s) not satisfied for window of type %s, name %s:\n"),
3567 (const wxChar
*)windowClass
,
3568 (const wxChar
*)winName
);
3569 if (!constr
->left
.GetDone()) wxLogDebug( _T(" unsatisfied 'left' constraint.\n") );
3570 if (!constr
->right
.GetDone()) wxLogDebug( _T(" unsatisfied 'right' constraint.\n") );
3571 if (!constr
->width
.GetDone()) wxLogDebug( _T(" unsatisfied 'width' constraint.\n") );
3572 if (!constr
->height
.GetDone()) wxLogDebug( _T(" unsatisfied 'height' constraint.\n") );
3573 wxLogDebug( _T("Please check constraints: try adding AsIs() constraints.\n") );
3578 wxNode
*node
= m_children
.First();
3581 wxWindow
*win
= (wxWindow
*)node
->Data();
3582 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
3583 win
->SetConstraintSizes();
3584 node
= node
->Next();
3589 // This assumes that all sizers are 'on' the same
3590 // window, i.e. the parent of this window.
3591 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
3593 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
3594 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
3598 m_sizerParent
->GetPosition(&xp
, &yp
);
3599 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
3604 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
3608 TransformSizerToActual(&xx
, &yy
);
3609 SetSize(xx
, yy
, w
, h
);
3612 void wxWindow::SizerMove(int x
, int y
)
3616 TransformSizerToActual(&xx
, &yy
);
3620 // Only set the size/position of the constraint (if any)
3621 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
3623 wxLayoutConstraints
*constr
= GetConstraints();
3628 constr
->left
.SetValue(x
);
3629 constr
->left
.SetDone(TRUE
);
3633 constr
->top
.SetValue(y
);
3634 constr
->top
.SetDone(TRUE
);
3638 constr
->width
.SetValue(w
);
3639 constr
->width
.SetDone(TRUE
);
3643 constr
->height
.SetValue(h
);
3644 constr
->height
.SetDone(TRUE
);
3649 void wxWindow::MoveConstraint(int x
, int y
)
3651 wxLayoutConstraints
*constr
= GetConstraints();
3656 constr
->left
.SetValue(x
);
3657 constr
->left
.SetDone(TRUE
);
3661 constr
->top
.SetValue(y
);
3662 constr
->top
.SetDone(TRUE
);
3667 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
3669 wxLayoutConstraints
*constr
= GetConstraints();
3672 *w
= constr
->width
.GetValue();
3673 *h
= constr
->height
.GetValue();
3679 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
3681 wxLayoutConstraints
*constr
= GetConstraints();
3684 *w
= constr
->width
.GetValue();
3685 *h
= constr
->height
.GetValue();
3688 GetClientSize(w
, h
);
3691 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
3693 wxLayoutConstraints
*constr
= GetConstraints();
3696 *x
= constr
->left
.GetValue();
3697 *y
= constr
->top
.GetValue();