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"
24 #include "wx/dcclient.h"
27 #include "wx/statusbr.h"
29 #include "gdk/gdkprivate.h"
30 #include "gdk/gdkkeysyms.h"
34 //-----------------------------------------------------------------------------
35 // documentation on internals
36 //-----------------------------------------------------------------------------
39 I have been asked several times about writing some documentation about
40 the GTK port of wxWindows, especially its internal structures. Obviously,
41 you cannot understand wxGTK without knowing a little about the GTK, but
42 some more information about what the wxWindow, which is the base class
43 for all other window classes, does seems required as well.
45 What does wxWindow do? It contains the common interface for the following
46 jobs of its descendants:
48 1) Define the rudimentary behaviour common to all window classes, such as
49 resizing, intercepting user input (so as to make it possible to use these
50 events for special purposes in a derived class), window names etc.
52 2) Provide the possibility to contain and manage children, if the derived
53 class is allowed to contain children, which holds true for those window
54 classes which do not display a native GTK widget. To name them, these
55 classes are wxPanel, wxScrolledWindow, wxDialog, wxFrame. The MDI frame-
56 work classes are a special case and are handled a bit differently from
57 the rest. The same holds true for the wxNotebook class.
59 3) Provide the possibility to draw into a client area of a window. This,
60 too, only holds true for classes that do not display a native GTK widget
63 4) Provide the entire mechanism for scrolling widgets. This actual inter-
64 face for this is usually in wxScrolledWindow, but the GTK implementation
67 5) A multitude of helper or extra methods for special purposes, such as
68 Drag'n'Drop, managing validators etc.
70 Normally one might expect, that one wxWindows window would always correspond
71 to one GTK widget. Under GTK, there is no such allround widget that has all
72 the functionality. Moreover, the GTK defines a client area as a different
73 widget from the actual widget you are handling. Last but not least some
74 special classes (e.g. wxFrame) handle different categories of widgets and
75 still have the possibility to draw something in the client area.
76 It was therefore required to write a special purpose GTK widget, that would
77 represent a client area in the sense of wxWindows capable to do the jobs
78 2), 3) and 4). I have written this class and it resides in win_gtk.c of
81 All windows must have a widget, with which they interact with other under-
82 lying GTK widgets. It is this widget, e.g. that has to be resized etc and
83 thw wxWindow class has a member variable called m_widget which holds a
84 pointer to this widget. When the window class represents a GTK native widget,
85 this is (in most cases) the only GTK widget the class manages. E.g. the
86 wxStatitText class handles only a GtkLabel widget a pointer to which you
87 can find in m_widget (defined in wxWindow)
89 When the class has a client area for drawing into and for containing children
90 it has to handle the client area widget (of the type GtkMyFixed, defined in
91 win_gtk.c), but there could be any number of widgets, handled by a class
92 The common rule for all windows is only, that the widget that interacts with
93 the rest of GTK must be referenced in m_widget and all other widgets must be
94 children of this widget on the GTK level. The top-most widget, which also
95 represents the client area, must be in the m_wxwindow field and must be of
98 As I said, the window classes that display a GTK native widget only have
99 one widget, so in the case of e.g. the wxButton class m_widget holds a
100 pointer to a GtkButton widget. But windows with client areas (for drawing
101 and children) have a m_widget field that is a pointer to a GtkScrolled-
102 Window and a m_wxwindow field that is pointer to a GtkMyFixed and this
103 one is (in the GTK sense) a child of the GtkScrolledWindow.
105 If the m_wxwindow field is set, then all input to this widget is inter-
106 cepted and sent to the wxWindows class. If not, all input to the widget
107 that gets pointed to by m_widget gets intercepted and sent to the class.
111 //-----------------------------------------------------------------------------
113 //-----------------------------------------------------------------------------
115 #if (GTK_MINOR_VERSION == 1)
116 #if (GTK_MICRO_VERSION >= 3)
117 #define NEW_GTK_DND_CODE
121 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
125 extern wxList wxPendingDelete
;
126 extern wxList wxTopLevelWindows
;
127 extern bool g_blockEventsOnDrag
;
128 static bool g_capturing
= FALSE
;
130 // hack: we need something to pass to gtk_menu_popup, so we store the time of
131 // the last click here
132 static guint32 gs_timeLastClick
= 0;
134 //-----------------------------------------------------------------------------
135 // "expose_event" (of m_wxwindow, not of m_widget)
136 //-----------------------------------------------------------------------------
138 static void gtk_window_expose_callback( GtkWidget
*WXUNUSED(widget
), GdkEventExpose
*gdk_event
, wxWindow
*win
)
140 if (!win
->HasVMT()) return;
141 if (g_blockEventsOnDrag
) return;
143 win
->m_updateRegion
.Union( gdk_event
->area
.x
,
145 gdk_event
->area
.width
,
146 gdk_event
->area
.height
);
148 if (gdk_event
->count
> 0) return;
151 printf( "OnExpose from " );
152 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
153 printf( win->GetClassInfo()->GetClassName() );
157 wxPaintEvent
event( win
->GetId() );
158 event
.SetEventObject( win
);
159 win
->GetEventHandler()->ProcessEvent( event
);
161 win
->m_updateRegion
.Clear();
164 //-----------------------------------------------------------------------------
165 // "draw" (of m_wxwindow, not of m_widget)
166 //-----------------------------------------------------------------------------
168 static void gtk_window_draw_callback( GtkWidget
*WXUNUSED(widget
), GdkRectangle
*rect
, wxWindow
*win
)
170 if (!win
->HasVMT()) return;
171 if (g_blockEventsOnDrag
) return;
173 win
->m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
175 wxPaintEvent
event( win
->GetId() );
176 event
.SetEventObject( win
);
177 win
->GetEventHandler()->ProcessEvent( event
);
179 win
->m_updateRegion
.Clear();
182 //-----------------------------------------------------------------------------
184 //-----------------------------------------------------------------------------
186 static gint
gtk_window_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxWindow
*win
)
188 if (!win
->HasVMT()) return FALSE
;
189 if (g_blockEventsOnDrag
) return FALSE
;
192 printf( "OnKeyPress from " );
193 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
194 printf( win->GetClassInfo()->GetClassName() );
199 switch (gdk_event
->keyval
)
201 case GDK_BackSpace
: key_code
= WXK_BACK
; break;
202 case GDK_Tab
: key_code
= WXK_TAB
; break;
203 case GDK_Linefeed
: key_code
= WXK_RETURN
; break;
204 case GDK_Clear
: key_code
= WXK_CLEAR
; break;
205 case GDK_Return
: key_code
= WXK_RETURN
; break;
206 case GDK_Pause
: key_code
= WXK_PAUSE
; break;
207 case GDK_Scroll_Lock
: key_code
= WXK_SCROLL
; break;
208 case GDK_Escape
: key_code
= WXK_ESCAPE
; break;
209 case GDK_Delete
: key_code
= WXK_DELETE
; break;
210 case GDK_Home
: key_code
= WXK_HOME
; break;
211 case GDK_Left
: key_code
= WXK_LEFT
; break;
212 case GDK_Up
: key_code
= WXK_UP
; break;
213 case GDK_Right
: key_code
= WXK_RIGHT
; break;
214 case GDK_Down
: key_code
= WXK_DOWN
; break;
215 case GDK_Prior
: key_code
= WXK_PRIOR
; break;
216 // case GDK_Page_Up: key_code = WXK_PAGEUP; break;
217 case GDK_Next
: key_code
= WXK_NEXT
; break;
218 // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
219 case GDK_End
: key_code
= WXK_END
; break;
220 case GDK_Begin
: key_code
= WXK_HOME
; break;
221 case GDK_Select
: key_code
= WXK_SELECT
; break;
222 case GDK_Print
: key_code
= WXK_PRINT
; break;
223 case GDK_Execute
: key_code
= WXK_EXECUTE
; break;
224 case GDK_Insert
: key_code
= WXK_INSERT
; break;
225 case GDK_Num_Lock
: key_code
= WXK_NUMLOCK
; break;
226 case GDK_KP_Tab
: key_code
= WXK_TAB
; break;
227 case GDK_KP_Enter
: key_code
= WXK_RETURN
; break;
228 case GDK_KP_Home
: key_code
= WXK_HOME
; break;
229 case GDK_KP_Left
: key_code
= WXK_LEFT
; break;
230 case GDK_KP_Up
: key_code
= WXK_UP
; break;
231 case GDK_KP_Right
: key_code
= WXK_RIGHT
; break;
232 case GDK_KP_Down
: key_code
= WXK_DOWN
; break;
233 case GDK_KP_Prior
: key_code
= WXK_PRIOR
; break;
234 // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
235 case GDK_KP_Next
: key_code
= WXK_NEXT
; break;
236 // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
237 case GDK_KP_End
: key_code
= WXK_END
; break;
238 case GDK_KP_Begin
: key_code
= WXK_HOME
; break;
239 case GDK_KP_Insert
: key_code
= WXK_INSERT
; break;
240 case GDK_KP_Delete
: key_code
= WXK_DELETE
; break;
241 case GDK_KP_Multiply
: key_code
= WXK_MULTIPLY
; break;
242 case GDK_KP_Add
: key_code
= WXK_ADD
; break;
243 case GDK_KP_Separator
: key_code
= WXK_SEPARATOR
; break;
244 case GDK_KP_Subtract
: key_code
= WXK_SUBTRACT
; break;
245 case GDK_KP_Decimal
: key_code
= WXK_DECIMAL
; break;
246 case GDK_KP_Divide
: key_code
= WXK_DIVIDE
; break;
247 case GDK_KP_0
: key_code
= WXK_NUMPAD0
; break;
248 case GDK_KP_1
: key_code
= WXK_NUMPAD1
; break;
249 case GDK_KP_2
: key_code
= WXK_NUMPAD2
; break;
250 case GDK_KP_3
: key_code
= WXK_NUMPAD3
; break;
251 case GDK_KP_4
: key_code
= WXK_NUMPAD4
; break;
252 case GDK_KP_5
: key_code
= WXK_NUMPAD5
; break;
253 case GDK_KP_6
: key_code
= WXK_NUMPAD6
; break;
254 case GDK_KP_7
: key_code
= WXK_NUMPAD7
; break;
255 case GDK_KP_8
: key_code
= WXK_NUMPAD7
; break;
256 case GDK_KP_9
: key_code
= WXK_NUMPAD9
; break;
257 case GDK_F1
: key_code
= WXK_F1
; break;
258 case GDK_F2
: key_code
= WXK_F2
; break;
259 case GDK_F3
: key_code
= WXK_F3
; break;
260 case GDK_F4
: key_code
= WXK_F4
; break;
261 case GDK_F5
: key_code
= WXK_F5
; break;
262 case GDK_F6
: key_code
= WXK_F6
; break;
263 case GDK_F7
: key_code
= WXK_F7
; break;
264 case GDK_F8
: key_code
= WXK_F8
; break;
265 case GDK_F9
: key_code
= WXK_F9
; break;
266 case GDK_F10
: key_code
= WXK_F10
; break;
267 case GDK_F11
: key_code
= WXK_F11
; break;
268 case GDK_F12
: key_code
= WXK_F12
; break;
271 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
272 key_code
= gdk_event
->keyval
;
276 if (!key_code
) return FALSE
;
278 wxKeyEvent
event( wxEVT_CHAR
);
279 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
280 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
281 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
282 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
283 event
.m_keyCode
= key_code
;
286 event
.SetEventObject( win
);
288 bool ret
= win
->GetEventHandler()->ProcessEvent( event
);
292 wxWindow
*ancestor
= win
;
295 int command
= ancestor
->GetAcceleratorTable()->GetCommand( event
);
298 wxCommandEvent
command_event( wxEVT_COMMAND_MENU_SELECTED
, command
);
299 ret
= ancestor
->GetEventHandler()->ProcessEvent( command_event
);
302 ancestor
= ancestor
->GetParent();
308 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
309 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
315 //-----------------------------------------------------------------------------
316 // "button_press_event"
317 //-----------------------------------------------------------------------------
319 static gint
gtk_window_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
321 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return TRUE
;
323 if (g_blockEventsOnDrag
) return TRUE
;
327 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
) && !GTK_WIDGET_HAS_FOCUS (win
->m_wxwindow
) )
329 gtk_widget_grab_focus (win
->m_wxwindow
);
332 printf( "GrabFocus from " );
333 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
334 printf( win->GetClassInfo()->GetClassName() );
341 if (!win
->HasVMT()) return TRUE
;
344 printf( "OnButtonPress from " );
345 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
346 printf( win->GetClassInfo()->GetClassName() );
350 wxEventType event_type
= wxEVT_LEFT_DOWN
;
352 if (gdk_event
->button
== 1)
354 switch (gdk_event
->type
)
356 case GDK_BUTTON_PRESS
: event_type
= wxEVT_LEFT_DOWN
; break;
357 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_LEFT_DCLICK
; break;
361 else if (gdk_event
->button
== 2)
363 switch (gdk_event
->type
)
365 case GDK_BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DOWN
; break;
366 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DCLICK
; break;
370 else if (gdk_event
->button
== 3)
372 switch (gdk_event
->type
)
374 case GDK_BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DOWN
; break;
375 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DCLICK
; break;
380 wxMouseEvent
event( event_type
);
381 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
382 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
383 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
384 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
385 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
386 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
387 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
389 event
.m_x
= (long)gdk_event
->x
;
390 event
.m_y
= (long)gdk_event
->y
;
392 // Some control don't have their own X window and thus cannot get
397 wxNode
*node
= win
->GetChildren()->First();
400 wxWindow
*child
= (wxWindow
*)node
->Data();
401 if ((child
->m_x
<= event
.m_x
) &&
402 (child
->m_y
<= event
.m_y
) &&
403 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
404 (child
->m_y
+child
->m_height
>= event
.m_y
))
407 event
.m_x
-= child
->m_x
;
408 event
.m_y
-= child
->m_y
;
415 event
.SetEventObject( win
);
417 gs_timeLastClick
= gdk_event
->time
;
419 if (win
->GetEventHandler()->ProcessEvent( event
))
420 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "button_press_event" );
425 //-----------------------------------------------------------------------------
426 // "button_release_event"
427 //-----------------------------------------------------------------------------
429 static gint
gtk_window_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
431 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return TRUE
;
433 if (g_blockEventsOnDrag
) return TRUE
;
435 if (!win
->HasVMT()) return TRUE
;
438 printf( "OnButtonRelease from " );
439 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
440 printf( win->GetClassInfo()->GetClassName() );
444 wxEventType event_type
= wxEVT_NULL
;
446 switch (gdk_event
->button
)
448 case 1: event_type
= wxEVT_LEFT_UP
; break;
449 case 2: event_type
= wxEVT_MIDDLE_UP
; break;
450 case 3: event_type
= wxEVT_RIGHT_UP
; break;
453 wxMouseEvent
event( event_type
);
454 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
455 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
456 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
457 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
458 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
459 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
460 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
461 event
.m_x
= (long)gdk_event
->x
;
462 event
.m_y
= (long)gdk_event
->y
;
464 // Some control don't have their own X window and thus cannot get
469 wxNode
*node
= win
->GetChildren()->First();
472 wxWindow
*child
= (wxWindow
*)node
->Data();
473 if ((child
->m_x
<= event
.m_x
) &&
474 (child
->m_y
<= event
.m_y
) &&
475 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
476 (child
->m_y
+child
->m_height
>= event
.m_y
))
479 event
.m_x
-= child
->m_x
;
480 event
.m_y
-= child
->m_y
;
487 event
.SetEventObject( win
);
489 if (win
->GetEventHandler()->ProcessEvent( event
))
490 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "button_release_event" );
495 //-----------------------------------------------------------------------------
496 // "motion_notify_event"
497 //-----------------------------------------------------------------------------
499 static gint
gtk_window_motion_notify_callback( GtkWidget
*widget
, GdkEventMotion
*gdk_event
, wxWindow
*win
)
501 if (!win
->IsOwnGtkWindow( gdk_event
->window
)) return TRUE
;
503 if (g_blockEventsOnDrag
) return TRUE
;
505 if (!win
->HasVMT()) return TRUE
;
508 printf( "OnMotion from " );
509 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
510 printf( win->GetClassInfo()->GetClassName() );
514 wxMouseEvent
event( wxEVT_MOTION
);
515 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
516 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
517 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
518 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
519 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
520 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
521 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
523 event
.m_x
= (long)gdk_event
->x
;
524 event
.m_y
= (long)gdk_event
->y
;
526 // Some control don't have their own X window and thus cannot get
531 wxNode
*node
= win
->GetChildren()->First();
534 wxWindow
*child
= (wxWindow
*)node
->Data();
535 if ((child
->m_x
<= event
.m_x
) &&
536 (child
->m_y
<= event
.m_y
) &&
537 (child
->m_x
+child
->m_width
>= event
.m_x
) &&
538 (child
->m_y
+child
->m_height
>= event
.m_y
))
541 event
.m_x
-= child
->m_x
;
542 event
.m_y
-= child
->m_y
;
549 event
.SetEventObject( win
);
551 if (win
->GetEventHandler()->ProcessEvent( event
))
552 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "motion_notify_event" );
557 //-----------------------------------------------------------------------------
559 //-----------------------------------------------------------------------------
561 static gint
gtk_window_focus_in_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
563 if (g_blockEventsOnDrag
) return TRUE
;
566 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
568 GTK_WIDGET_SET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
570 printf( "SetFocus flag from " );
571 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
572 printf( win->GetClassInfo()->GetClassName() );
578 if (!win
->HasVMT()) return TRUE
;
581 printf( "OnSetFocus from " );
582 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
583 printf( win->GetClassInfo()->GetClassName() );
585 printf( WXSTRINGCAST win->GetLabel() );
589 wxFocusEvent
event( wxEVT_SET_FOCUS
, win
->GetId() );
590 event
.SetEventObject( win
);
592 if (win
->GetEventHandler()->ProcessEvent( event
))
593 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus_in_event" );
598 //-----------------------------------------------------------------------------
600 //-----------------------------------------------------------------------------
602 static gint
gtk_window_focus_out_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
604 if (g_blockEventsOnDrag
) return TRUE
;
607 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
608 GTK_WIDGET_UNSET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
611 if (!win
->HasVMT()) return TRUE
;
614 printf( "OnKillFocus from " );
615 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
616 printf( win->GetClassInfo()->GetClassName() );
620 wxFocusEvent
event( wxEVT_KILL_FOCUS
, win
->GetId() );
621 event
.SetEventObject( win
);
623 if (win
->GetEventHandler()->ProcessEvent( event
))
624 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "focus_out_event" );
629 //-----------------------------------------------------------------------------
630 // "enter_notify_event"
631 //-----------------------------------------------------------------------------
633 static gint
gtk_window_enter_callback( GtkWidget
*widget
, GdkEventCrossing
*gdk_event
, wxWindow
*win
)
635 if (widget
->window
!= gdk_event
->window
) return TRUE
;
637 if (g_blockEventsOnDrag
) return TRUE
;
639 if (!win
->HasVMT()) return TRUE
;
642 printf( "OnEnter from " );
643 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
644 printf( win->GetClassInfo()->GetClassName() );
648 if ((widget
->window
) && (win
->m_cursor
))
649 gdk_window_set_cursor( widget
->window
, win
->m_cursor
->GetCursor() );
651 wxMouseEvent
event( wxEVT_ENTER_WINDOW
);
652 event
.SetEventObject( win
);
654 if (win
->GetEventHandler()->ProcessEvent( event
))
655 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "enter_notify_event" );
660 //-----------------------------------------------------------------------------
661 // "leave_notify_event"
662 //-----------------------------------------------------------------------------
664 static gint
gtk_window_leave_callback( GtkWidget
*widget
, GdkEventCrossing
*gdk_event
, wxWindow
*win
)
666 if (widget
->window
!= gdk_event
->window
) return TRUE
;
668 if (g_blockEventsOnDrag
) return TRUE
;
670 if (!win
->HasVMT()) return TRUE
;
673 printf( "OnLeave from " );
674 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
675 printf( win->GetClassInfo()->GetClassName() );
679 if ((widget
->window
) && (win
->m_cursor
))
680 gdk_window_set_cursor( widget
->window
, wxSTANDARD_CURSOR
->GetCursor() );
682 wxMouseEvent
event( wxEVT_LEAVE_WINDOW
);
683 event
.SetEventObject( win
);
685 if (win
->GetEventHandler()->ProcessEvent( event
))
686 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "leave_notify_event" );
691 //-----------------------------------------------------------------------------
692 // "value_changed" from m_vAdjust
693 //-----------------------------------------------------------------------------
695 static void gtk_window_vscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
697 if (g_blockEventsOnDrag
) return;
700 printf( "OnVScroll from " );
701 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
702 printf( win->GetClassInfo()->GetClassName() );
706 if (!win
->HasVMT()) return;
708 float diff
= win
->m_vAdjust
->value
- win
->m_oldVerticalPos
;
709 if (fabs(diff
) < 0.2) return;
711 wxEventType command
= wxEVT_NULL
;
713 float line_step
= win
->m_vAdjust
->step_increment
;
714 float page_step
= win
->m_vAdjust
->page_increment
;
716 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
717 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
718 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
719 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
720 else command
= wxEVT_SCROLL_THUMBTRACK
;
722 int value
= (int)(win
->m_vAdjust
->value
+0.5);
724 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
725 event
.SetEventObject( win
);
726 win
->GetEventHandler()->ProcessEvent( event
);
729 //-----------------------------------------------------------------------------
730 // "value_changed" from m_hAdjust
731 //-----------------------------------------------------------------------------
733 static void gtk_window_hscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
735 if (g_blockEventsOnDrag
) return;
738 printf( "OnHScroll from " );
739 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
740 printf( win->GetClassInfo()->GetClassName() );
744 if (!win
->HasVMT()) return;
746 float diff
= win
->m_hAdjust
->value
- win
->m_oldHorizontalPos
;
747 if (fabs(diff
) < 0.2) return;
749 wxEventType command
= wxEVT_NULL
;
751 float line_step
= win
->m_hAdjust
->step_increment
;
752 float page_step
= win
->m_hAdjust
->page_increment
;
754 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
755 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
756 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
757 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
758 else command
= wxEVT_SCROLL_THUMBTRACK
;
760 int value
= (int)(win
->m_hAdjust
->value
+0.5);
762 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
763 event
.SetEventObject( win
);
764 win
->GetEventHandler()->ProcessEvent( event
);
767 //-----------------------------------------------------------------------------
768 // "changed" from m_vAdjust
769 //-----------------------------------------------------------------------------
771 static void gtk_window_vscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
773 if (g_blockEventsOnDrag
) return;
776 printf( "OnVScroll change from " );
777 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
778 printf( win->GetClassInfo()->GetClassName() );
782 if (!win
->HasVMT()) return;
784 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
785 int value
= (int)(win
->m_vAdjust
->value
+0.5);
787 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
788 event
.SetEventObject( win
);
789 win
->GetEventHandler()->ProcessEvent( event
);
792 //-----------------------------------------------------------------------------
793 // "changed" from m_hAdjust
794 //-----------------------------------------------------------------------------
796 static void gtk_window_hscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
798 if (g_blockEventsOnDrag
) return;
801 printf( "OnHScroll change from " );
802 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
803 printf( win->GetClassInfo()->GetClassName() );
807 if (!win
->HasVMT()) return;
809 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
810 int value
= (int)(win
->m_hAdjust
->value
+0.5);
812 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
813 event
.SetEventObject( win
);
814 win
->GetEventHandler()->ProcessEvent( event
);
817 //-----------------------------------------------------------------------------
818 // "button_press_event" from scrollbar
819 //-----------------------------------------------------------------------------
821 static gint
gtk_scrollbar_button_press_callback( GtkRange
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
823 if (gdk_event
->window
!= widget
->slider
) return FALSE
;
825 win
->m_isScrolling
= TRUE
;
830 //-----------------------------------------------------------------------------
831 // "button_release_event" from scrollbar
832 //-----------------------------------------------------------------------------
834 static gint
gtk_scrollbar_button_release_callback( GtkRange
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
836 if (gdk_event
->window
!= widget
->slider
) return FALSE
;
838 GtkScrolledWindow
*s_window
= GTK_SCROLLED_WINDOW(win
->m_widget
);
840 if (widget
== GTK_RANGE(s_window
->vscrollbar
))
841 gtk_signal_emit_by_name( GTK_OBJECT(win
->m_hAdjust
), "value_changed" );
843 gtk_signal_emit_by_name( GTK_OBJECT(win
->m_vAdjust
), "value_changed" );
845 win
->m_isScrolling
= FALSE
;
851 #ifdef NEW_GTK_DND_CODE
855 //-----------------------------------------------------------------------------
856 // "drop_data_available_event"
857 //-----------------------------------------------------------------------------
859 static void gtk_window_drop_callback( GtkWidget
*widget
, GdkEventDropDataAvailable
*event
, wxWindow
*win
)
861 if (!win
->HasVMT()) return;
863 if (win
->GetDropTarget())
867 gdk_window_get_pointer( widget
->window
, &x
, &y
, (GdkModifierType
*) NULL
);
869 printf( "Drop data is of type %s.\n", event
->data_type
);
871 win
->GetDropTarget()->OnDrop( x
, y
, (const void*)event
->data
, (size_t)event
->data_numbytes
);
875 g_free (event->dropdataavailable.data);
876 g_free (event->dropdataavailable.data_type);
883 //-----------------------------------------------------------------------------
884 // InsertChild for wxWindow.
885 //-----------------------------------------------------------------------------
887 // Callback for wxWindow. This very strange beast has to be used because
888 // C++ has no virtual methods in a constructor. We have to emulate a
889 // virtual function here as wxNotebook requires a different way to insert
890 // a child in it. I had opted for creating a wxNotebookPage window class
891 // which would have made this superflouus (such in the MDI window system),
892 // but no-one is listening to me...
894 static void wxInsertChildInWindow( wxWindow
* parent
, wxWindow
* child
)
896 gtk_myfixed_put( GTK_MYFIXED(parent
->m_wxwindow
),
897 GTK_WIDGET(child
->m_widget
),
901 gtk_widget_set_usize( GTK_WIDGET(child
->m_widget
),
906 //-----------------------------------------------------------------------------
908 //-----------------------------------------------------------------------------
910 IMPLEMENT_DYNAMIC_CLASS(wxWindow
,wxEvtHandler
)
912 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
913 EVT_SIZE(wxWindow::OnSize
)
914 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
915 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
916 EVT_IDLE(wxWindow::OnIdle
)
921 m_widget
= (GtkWidget
*) NULL
;
922 m_wxwindow
= (GtkWidget
*) NULL
;
923 m_parent
= (wxWindow
*) NULL
;
924 m_children
.DeleteContents( FALSE
);
937 m_eventHandler
= this;
938 m_windowValidator
= (wxValidator
*) NULL
;
942 m_cursor
= (wxCursor
*) NULL
;
943 m_font
= *wxSWISS_FONT
;
945 m_windowName
= "noname";
947 m_constraints
= (wxLayoutConstraints
*) NULL
;
948 m_constraintsInvolvedIn
= (wxList
*) NULL
;
949 m_windowSizer
= (wxSizer
*) NULL
;
950 m_sizerParent
= (wxWindow
*) NULL
;
951 m_autoLayout
= FALSE
;
957 m_hasScrolling
= FALSE
;
958 m_isScrolling
= FALSE
;
959 m_hAdjust
= (GtkAdjustment
*) NULL
;
960 m_vAdjust
= (GtkAdjustment
*) NULL
;
961 m_oldHorizontalPos
= 0.0;
962 m_oldVerticalPos
= 0.0;
967 m_dropTarget
= (wxDropTarget
*) NULL
;
969 m_scrollGC
= (GdkGC
*) NULL
;
970 m_widgetStyle
= (GtkStyle
*) NULL
;
972 m_insertCallback
= wxInsertChildInWindow
;
974 m_clientObject
= (wxClientData
*) NULL
;
978 wxWindow::wxWindow( wxWindow
*parent
, wxWindowID id
,
979 const wxPoint
&pos
, const wxSize
&size
,
980 long style
, const wxString
&name
)
982 m_insertCallback
= wxInsertChildInWindow
;
983 Create( parent
, id
, pos
, size
, style
, name
);
986 bool wxWindow::Create( wxWindow
*parent
, wxWindowID id
,
987 const wxPoint
&pos
, const wxSize
&size
,
988 long style
, const wxString
&name
)
994 PreCreation( parent
, id
, pos
, size
, style
, name
);
996 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
997 m_hasScrolling
= TRUE
;
999 GtkScrolledWindow
*s_window
= GTK_SCROLLED_WINDOW(m_widget
);
1001 gtk_signal_connect( GTK_OBJECT(s_window
->vscrollbar
), "button_press_event",
1002 (GtkSignalFunc
)gtk_scrollbar_button_press_callback
, (gpointer
) this );
1004 gtk_signal_connect( GTK_OBJECT(s_window
->hscrollbar
), "button_press_event",
1005 (GtkSignalFunc
)gtk_scrollbar_button_press_callback
, (gpointer
) this );
1007 gtk_signal_connect( GTK_OBJECT(s_window
->vscrollbar
), "button_release_event",
1008 (GtkSignalFunc
)gtk_scrollbar_button_release_callback
, (gpointer
) this );
1010 gtk_signal_connect( GTK_OBJECT(s_window
->hscrollbar
), "button_release_event",
1011 (GtkSignalFunc
)gtk_scrollbar_button_release_callback
, (gpointer
) this );
1013 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1014 scroll_class
->scrollbar_spacing
= 0;
1016 gtk_scrolled_window_set_policy( s_window
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
1018 m_oldHorizontalPos
= 0.0;
1019 m_oldVerticalPos
= 0.0;
1021 m_hAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->hscrollbar
) );
1022 m_vAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->vscrollbar
) );
1024 gtk_signal_connect( GTK_OBJECT(m_hAdjust
), "value_changed",
1025 (GtkSignalFunc
) gtk_window_hscroll_callback
, (gpointer
) this );
1026 gtk_signal_connect( GTK_OBJECT(m_vAdjust
), "value_changed",
1027 (GtkSignalFunc
) gtk_window_vscroll_callback
, (gpointer
) this );
1029 gtk_signal_connect( GTK_OBJECT(m_hAdjust
), "changed",
1030 (GtkSignalFunc
) gtk_window_hscroll_change_callback
, (gpointer
) this );
1031 gtk_signal_connect(GTK_OBJECT(m_vAdjust
), "changed",
1032 (GtkSignalFunc
) gtk_window_vscroll_change_callback
, (gpointer
) this );
1034 GtkViewport
*viewport
= GTK_VIEWPORT(s_window
->viewport
);
1036 if (m_windowStyle
& wxRAISED_BORDER
)
1038 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_OUT
);
1040 else if (m_windowStyle
& wxSUNKEN_BORDER
)
1042 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_IN
);
1046 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_NONE
);
1049 m_wxwindow
= gtk_myfixed_new();
1051 GTK_WIDGET_UNSET_FLAGS( m_widget
, GTK_CAN_FOCUS
);
1053 if (m_windowStyle
& wxTAB_TRAVERSAL
== wxTAB_TRAVERSAL
)
1054 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
1056 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
1058 gtk_container_add( GTK_CONTAINER(m_widget
), m_wxwindow
);
1060 // shut the viewport up
1061 gtk_viewport_set_hadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
1062 gtk_viewport_set_vadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
1064 // I _really_ don't want scrollbars in the beginning
1065 m_vAdjust
->lower
= 0.0;
1066 m_vAdjust
->upper
= 1.0;
1067 m_vAdjust
->value
= 0.0;
1068 m_vAdjust
->step_increment
= 1.0;
1069 m_vAdjust
->page_increment
= 1.0;
1070 m_vAdjust
->page_size
= 5.0;
1071 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
1072 m_hAdjust
->lower
= 0.0;
1073 m_hAdjust
->upper
= 1.0;
1074 m_hAdjust
->value
= 0.0;
1075 m_hAdjust
->step_increment
= 1.0;
1076 m_hAdjust
->page_increment
= 1.0;
1077 m_hAdjust
->page_size
= 5.0;
1078 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
1080 gtk_widget_show( m_wxwindow
);
1082 if (m_parent
) m_parent
->AddChild( this );
1084 (m_parent
->m_insertCallback
)( m_parent
, this );
1093 wxWindow::~wxWindow()
1097 if (m_dropTarget
) delete m_dropTarget
;
1099 if (m_parent
) m_parent
->RemoveChild( this );
1100 if (m_widget
) Show( FALSE
);
1104 if (m_widgetStyle
) gtk_style_unref( m_widgetStyle
);
1106 if (m_scrollGC
) gdk_gc_unref( m_scrollGC
);
1108 if (m_wxwindow
) gtk_widget_destroy( m_wxwindow
);
1110 if (m_widget
) gtk_widget_destroy( m_widget
);
1112 if (m_cursor
) delete m_cursor
;
1114 DeleteRelatedConstraints();
1117 // This removes any dangling pointers to this window
1118 // in other windows' constraintsInvolvedIn lists.
1119 UnsetConstraints(m_constraints
);
1120 delete m_constraints
;
1121 m_constraints
= (wxLayoutConstraints
*) NULL
;
1125 delete m_windowSizer
;
1126 m_windowSizer
= (wxSizer
*) NULL
;
1128 // If this is a child of a sizer, remove self from parent
1129 if (m_sizerParent
) m_sizerParent
->RemoveChild((wxWindow
*)this);
1131 // Just in case the window has been Closed, but
1132 // we're then deleting immediately: don't leave
1133 // dangling pointers.
1134 wxPendingDelete
.DeleteObject(this);
1136 // Just in case we've loaded a top-level window via
1137 // wxWindow::LoadNativeDialog but we weren't a dialog
1139 wxTopLevelWindows
.DeleteObject(this);
1141 if (m_windowValidator
) delete m_windowValidator
;
1143 if (m_clientObject
) delete m_clientObject
;
1146 void wxWindow::PreCreation( wxWindow
*parent
, wxWindowID id
,
1147 const wxPoint
&pos
, const wxSize
&size
,
1148 long style
, const wxString
&name
)
1150 if (m_needParent
&& (parent
== NULL
))
1151 wxFatalError( "Need complete parent.", name
);
1153 m_widget
= (GtkWidget
*) NULL
;
1154 m_wxwindow
= (GtkWidget
*) NULL
;
1157 m_children
.DeleteContents( FALSE
);
1160 if (m_width
== -1) m_width
= 20;
1162 if (m_height
== -1) m_height
= 20;
1167 if (!m_needParent
) // some reasonable defaults
1171 m_x
= (gdk_screen_width () - m_width
) / 2;
1172 if (m_x
< 10) m_x
= 10;
1176 m_y
= (gdk_screen_height () - m_height
) / 2;
1177 if (m_y
< 10) m_y
= 10;
1188 m_eventHandler
= this;
1194 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
1195 m_font
= *wxSWISS_FONT
;
1196 // m_backgroundColour = wxWHITE;
1197 // m_foregroundColour = wxBLACK;
1198 m_windowStyle
= style
;
1199 m_windowName
= name
;
1201 m_constraints
= (wxLayoutConstraints
*) NULL
;
1202 m_constraintsInvolvedIn
= (wxList
*) NULL
;
1203 m_windowSizer
= (wxSizer
*) NULL
;
1204 m_sizerParent
= (wxWindow
*) NULL
;
1205 m_autoLayout
= FALSE
;
1207 m_hasScrolling
= FALSE
;
1208 m_isScrolling
= FALSE
;
1209 m_hAdjust
= (GtkAdjustment
*) NULL
;
1210 m_vAdjust
= (GtkAdjustment
*) NULL
;
1211 m_oldHorizontalPos
= 0.0;
1212 m_oldVerticalPos
= 0.0;
1217 m_dropTarget
= (wxDropTarget
*) NULL
;
1219 m_windowValidator
= (wxValidator
*) NULL
;
1220 m_scrollGC
= (GdkGC
*) NULL
;
1221 m_widgetStyle
= (GtkStyle
*) NULL
;
1223 m_clientObject
= (wxClientData
*)NULL
;
1224 m_clientData
= NULL
;
1227 void wxWindow::PostCreation()
1231 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "expose_event",
1232 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
1234 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "draw",
1235 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
1238 ConnectWidget( GetConnectWidget() );
1240 if (m_widget
&& m_parent
) gtk_widget_realize( m_widget
);
1242 if (m_wxwindow
) gtk_widget_realize( m_wxwindow
);
1244 SetCursor( *wxSTANDARD_CURSOR
);
1249 void wxWindow::ConnectWidget( GtkWidget
*widget
)
1251 gtk_signal_connect( GTK_OBJECT(widget
), "key_press_event",
1252 GTK_SIGNAL_FUNC(gtk_window_key_press_callback
), (gpointer
)this );
1254 gtk_signal_connect( GTK_OBJECT(widget
), "button_press_event",
1255 GTK_SIGNAL_FUNC(gtk_window_button_press_callback
), (gpointer
)this );
1257 gtk_signal_connect( GTK_OBJECT(widget
), "button_release_event",
1258 GTK_SIGNAL_FUNC(gtk_window_button_release_callback
), (gpointer
)this );
1260 gtk_signal_connect( GTK_OBJECT(widget
), "motion_notify_event",
1261 GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback
), (gpointer
)this );
1263 gtk_signal_connect( GTK_OBJECT(widget
), "focus_in_event",
1264 GTK_SIGNAL_FUNC(gtk_window_focus_in_callback
), (gpointer
)this );
1266 gtk_signal_connect( GTK_OBJECT(widget
), "focus_out_event",
1267 GTK_SIGNAL_FUNC(gtk_window_focus_out_callback
), (gpointer
)this );
1269 gtk_signal_connect( GTK_OBJECT(widget
), "enter_notify_event",
1270 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
1272 gtk_signal_connect( GTK_OBJECT(widget
), "leave_notify_event",
1273 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
1276 bool wxWindow::HasVMT()
1281 bool wxWindow::Close( bool force
)
1283 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1285 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
1286 event
.SetEventObject(this);
1287 event
.SetForce(force
);
1289 return GetEventHandler()->ProcessEvent(event
);
1292 bool wxWindow::Destroy()
1294 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1301 bool wxWindow::DestroyChildren()
1306 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
)
1309 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
)
1312 if (GetChildren()->Member(child
)) delete node
;
1319 void wxWindow::PrepareDC( wxDC
&WXUNUSED(dc
) )
1321 // are we to set fonts here ?
1324 wxPoint
wxWindow::GetClientAreaOrigin() const
1326 return wxPoint(0,0);
1329 void wxWindow::AdjustForParentClientOrigin( int& x
, int& y
, int sizeFlags
)
1331 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
1333 wxPoint
pt(GetParent()->GetClientAreaOrigin());
1339 void wxWindow::SetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
1341 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1342 wxASSERT_MSG( (m_parent
!= NULL
), "wxWindow::SetSize requires parent.\n" );
1344 // Don't do anything for children of wxNotebook
1345 if (m_parent
->m_wxwindow
== NULL
) return;
1347 if (m_resizing
) return; // I don't like recursions
1350 int old_width
= m_width
;
1351 int old_height
= m_height
;
1353 if ((sizeFlags
& wxSIZE_USE_EXISTING
) == wxSIZE_USE_EXISTING
)
1355 if (x
!= -1) m_x
= x
;
1356 if (y
!= -1) m_y
= y
;
1357 if (width
!= -1) m_width
= width
;
1358 if (height
!= -1) m_height
= height
;
1368 if ((sizeFlags
& wxSIZE_AUTO_WIDTH
) == wxSIZE_AUTO_WIDTH
)
1370 if (width
== -1) m_width
= 80;
1373 if ((sizeFlags
& wxSIZE_AUTO_HEIGHT
) == wxSIZE_AUTO_HEIGHT
)
1375 if (height
== -1) m_height
= 26;
1378 if ((m_minWidth
!= -1) && (m_width
< m_minWidth
)) m_width
= m_minWidth
;
1379 if ((m_minHeight
!= -1) && (m_height
< m_minHeight
)) m_height
= m_minHeight
;
1380 if ((m_maxWidth
!= -1) && (m_width
> m_maxWidth
)) m_width
= m_minWidth
;
1381 if ((m_maxHeight
!= -1) && (m_height
> m_maxHeight
)) m_height
= m_minHeight
;
1383 wxPoint
pt( m_parent
->GetClientAreaOrigin() );
1384 gtk_myfixed_move( GTK_MYFIXED(m_parent
->m_wxwindow
), m_widget
, m_x
+pt
.x
, m_y
+pt
.y
);
1386 if ((old_width
!= m_width
) || (old_height
!= m_height
))
1387 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
1391 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
1392 event
.SetEventObject( this );
1393 ProcessEvent( event
);
1398 void wxWindow::SetSize( int width
, int height
)
1400 SetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
);
1403 void wxWindow::Move( int x
, int y
)
1405 SetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
);
1408 void wxWindow::GetSize( int *width
, int *height
) const
1410 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1412 if (width
) (*width
) = m_width
;
1413 if (height
) (*height
) = m_height
;
1416 void wxWindow::SetClientSize( int width
, int height
)
1418 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1422 SetSize( width
, height
);
1429 if (!m_hasScrolling
)
1432 do we have sunken dialogs ?
1434 GtkStyleClass *window_class = m_wxwindow->style->klass;
1436 dw += 2 * window_class->xthickness;
1437 dh += 2 * window_class->ythickness;
1442 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1443 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1445 GtkWidget
*viewport
= scroll_window
->viewport
;
1446 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1448 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1449 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1451 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1452 (m_windowStyle
& wxSUNKEN_BORDER
))
1454 dw
+= 2 * viewport_class
->xthickness
;
1455 dh
+= 2 * viewport_class
->ythickness
;
1458 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1460 dw
+= vscrollbar
->allocation
.width
;
1461 dw
+= scroll_class
->scrollbar_spacing
;
1464 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1466 dh
+= hscrollbar
->allocation
.height
;
1467 dw
+= scroll_class
->scrollbar_spacing
;
1471 SetSize( width
+dw
, height
+dh
);
1475 void wxWindow::GetClientSize( int *width
, int *height
) const
1477 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1481 if (width
) (*width
) = m_width
;
1482 if (height
) (*height
) = m_height
;
1489 if (!m_hasScrolling
)
1492 do we have sunken dialogs ?
1494 GtkStyleClass *window_class = m_wxwindow->style->klass;
1496 dw += 2 * window_class->xthickness;
1497 dh += 2 * window_class->ythickness;
1502 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1503 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1505 GtkWidget
*viewport
= scroll_window
->viewport
;
1506 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1508 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1509 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1511 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1512 (m_windowStyle
& wxSUNKEN_BORDER
))
1514 dw
+= 2 * viewport_class
->xthickness
;
1515 dh
+= 2 * viewport_class
->ythickness
;
1518 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1520 // dw += vscrollbar->allocation.width;
1521 dw
+= 15; // range.slider_width = 11 + 2*2pts edge
1522 dw
+= scroll_class
->scrollbar_spacing
;
1525 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1527 // dh += hscrollbar->allocation.height;
1529 dh
+= scroll_class
->scrollbar_spacing
;
1533 if (width
) (*width
) = m_width
- dw
;
1534 if (height
) (*height
) = m_height
- dh
;
1538 void wxWindow::GetPosition( int *x
, int *y
) const
1540 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1546 void wxWindow::ClientToScreen( int *x
, int *y
)
1548 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1550 GdkWindow
*source
= (GdkWindow
*) NULL
;
1552 source
= m_wxwindow
->window
;
1554 source
= m_widget
->window
;
1558 gdk_window_get_origin( source
, &org_x
, &org_y
);
1562 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1564 org_x
+= m_widget
->allocation
.x
;
1565 org_y
+= m_widget
->allocation
.y
;
1569 wxPoint
pt(GetClientAreaOrigin());
1577 void wxWindow::ScreenToClient( int *x
, int *y
)
1579 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1581 GdkWindow
*source
= (GdkWindow
*) NULL
;
1583 source
= m_wxwindow
->window
;
1585 source
= m_widget
->window
;
1589 gdk_window_get_origin( source
, &org_x
, &org_y
);
1593 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1595 org_x
+= m_widget
->allocation
.x
;
1596 org_y
+= m_widget
->allocation
.y
;
1600 wxPoint
pt(GetClientAreaOrigin());
1608 void wxWindow::Centre( int direction
)
1610 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1619 m_parent
->GetSize( &p_w
, &p_h
);
1620 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (p_w
- m_width
) / 2;
1621 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (p_h
- m_height
) / 2;
1625 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (gdk_screen_width () - m_width
) / 2;
1626 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (gdk_screen_height () - m_height
) / 2;
1632 void wxWindow::Fit()
1634 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1638 wxNode
*node
= GetChildren()->First();
1641 wxWindow
*win
= (wxWindow
*)node
->Data();
1643 win
->GetPosition(&wx
, &wy
);
1644 win
->GetSize(&ww
, &wh
);
1645 if ( wx
+ ww
> maxX
)
1647 if ( wy
+ wh
> maxY
)
1650 node
= node
->Next();
1652 SetClientSize(maxX
+ 5, maxY
+ 10);
1655 void wxWindow::SetSizeHints( int minW
, int minH
, int maxW
, int maxH
, int WXUNUSED(incW
), int WXUNUSED(incH
) )
1657 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1665 void wxWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1667 //if (GetAutoLayout()) Layout();
1670 bool wxWindow::Show( bool show
)
1672 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1675 gtk_widget_show( m_widget
);
1677 gtk_widget_hide( m_widget
);
1682 void wxWindow::Enable( bool enable
)
1684 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1686 m_isEnabled
= enable
;
1687 gtk_widget_set_sensitive( m_widget
, enable
);
1688 if (m_wxwindow
) gtk_widget_set_sensitive( m_wxwindow
, enable
);
1691 int wxWindow::GetCharHeight() const
1693 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1697 wxFAIL_MSG( "invalid font" );
1701 GdkFont
*font
= m_font
.GetInternalFont( 1.0 );
1702 return font
->ascent
+ font
->descent
;
1705 int wxWindow::GetCharWidth() const
1707 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1711 wxFAIL_MSG( "invalid font" );
1715 GdkFont
*font
= m_font
.GetInternalFont( 1.0 );
1716 return gdk_string_width( font
, "H" );
1719 void wxWindow::GetTextExtent( const wxString
& string
, int *x
, int *y
,
1720 int *descent
, int *externalLeading
, const wxFont
*theFont
, bool WXUNUSED(use16
) ) const
1722 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1724 wxFont fontToUse
= m_font
;
1725 if (theFont
) fontToUse
= *theFont
;
1727 if (!fontToUse
.Ok())
1729 wxFAIL_MSG( "invalid font" );
1732 wxASSERT_MSG( (m_font
.Ok()), "invalid font" );
1734 GdkFont
*font
= fontToUse
.GetInternalFont( 1.0 );
1735 if (x
) (*x
) = gdk_string_width( font
, string
);
1736 if (y
) (*y
) = font
->ascent
+ font
->descent
;
1737 if (descent
) (*descent
) = font
->descent
;
1738 if (externalLeading
) (*externalLeading
) = 0; // ??
1741 void wxWindow::MakeModal( bool modal
)
1744 // Disable all other windows
1745 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
1747 wxNode
*node
= wxTopLevelWindows
.First();
1750 wxWindow
*win
= (wxWindow
*)node
->Data();
1752 win
->Enable(!modal
);
1754 node
= node
->Next();
1759 void wxWindow::SetFocus()
1761 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1763 GtkWidget
*connect_widget
= GetConnectWidget();
1766 if (GTK_WIDGET_CAN_FOCUS(connect_widget
) && !GTK_WIDGET_HAS_FOCUS (connect_widget
) )
1768 gtk_widget_grab_focus (connect_widget
);
1773 bool wxWindow::OnClose()
1778 void wxWindow::AddChild( wxWindow
*child
)
1780 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1781 wxASSERT_MSG( (child
!= NULL
), "invalid child" );
1783 m_children
.Append( child
);
1786 wxList
*wxWindow::GetChildren()
1788 return (&m_children
);
1791 void wxWindow::RemoveChild( wxWindow
*child
)
1793 if (GetChildren()) GetChildren()->DeleteObject( child
);
1794 child
->m_parent
= (wxWindow
*) NULL
;
1797 void wxWindow::SetReturnCode( int retCode
)
1799 m_retCode
= retCode
;
1802 int wxWindow::GetReturnCode()
1807 void wxWindow::Raise()
1809 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1811 if (m_widget
) gdk_window_raise( m_widget
->window
);
1814 void wxWindow::Lower()
1816 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1818 if (m_widget
) gdk_window_lower( m_widget
->window
);
1821 wxEvtHandler
*wxWindow::GetEventHandler()
1823 return m_eventHandler
;
1826 void wxWindow::SetEventHandler( wxEvtHandler
*handler
)
1828 m_eventHandler
= handler
;
1831 void wxWindow::PushEventHandler(wxEvtHandler
*handler
)
1833 handler
->SetNextHandler(GetEventHandler());
1834 SetEventHandler(handler
);
1837 wxEvtHandler
*wxWindow::PopEventHandler(bool deleteHandler
)
1839 if (GetEventHandler())
1841 wxEvtHandler
*handlerA
= GetEventHandler();
1842 wxEvtHandler
*handlerB
= handlerA
->GetNextHandler();
1843 handlerA
->SetNextHandler((wxEvtHandler
*) NULL
);
1844 SetEventHandler(handlerB
);
1848 return (wxEvtHandler
*) NULL
;
1854 return (wxEvtHandler
*) NULL
;
1857 wxValidator
*wxWindow::GetValidator()
1859 return m_windowValidator
;
1862 void wxWindow::SetValidator( const wxValidator
& validator
)
1864 if (m_windowValidator
) delete m_windowValidator
;
1865 m_windowValidator
= validator
.Clone();
1866 if (m_windowValidator
) m_windowValidator
->SetWindow(this);
1869 void wxWindow::SetClientObject( wxClientData
*data
)
1871 if (m_clientObject
) delete m_clientObject
;
1872 m_clientObject
= data
;
1875 wxClientData
*wxWindow::GetClientObject()
1877 return m_clientObject
;
1880 void wxWindow::SetClientData( void *data
)
1882 m_clientData
= data
;
1885 void *wxWindow::GetClientData()
1887 return m_clientData
;
1890 bool wxWindow::IsBeingDeleted()
1895 void wxWindow::SetId( wxWindowID id
)
1900 wxWindowID
wxWindow::GetId()
1905 void wxWindow::SetCursor( const wxCursor
&cursor
)
1907 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1909 if (m_cursor
== NULL
)
1911 wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
1912 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
1917 if (*((wxCursor
*)&cursor
) == m_cursor
) return;
1922 *m_cursor
= *wxSTANDARD_CURSOR
;
1925 if ((m_widget
) && (m_widget
->window
))
1926 gdk_window_set_cursor( m_widget
->window
, m_cursor
->GetCursor() );
1928 if ((m_wxwindow
) && (m_wxwindow
->window
))
1929 gdk_window_set_cursor( m_wxwindow
->window
, m_cursor
->GetCursor() );
1932 void wxWindow::Refresh( bool eraseBackground
, const wxRect
*rect
)
1934 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
1936 if (eraseBackground
&& m_wxwindow
&& m_wxwindow
->window
)
1939 gdk_window_clear_area( m_wxwindow
->window
,
1953 GetClientSize( &w
, &h
);
1955 GdkRectangle gdk_rect
;
1959 gdk_rect
.height
= h
;
1960 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1965 GdkRectangle gdk_rect
;
1966 gdk_rect
.x
= rect
->x
;
1967 gdk_rect
.y
= rect
->y
;
1968 gdk_rect
.width
= rect
->width
;
1969 gdk_rect
.height
= rect
->height
;
1972 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1974 gtk_widget_draw( m_widget
, &gdk_rect
);
1978 wxRegion
wxWindow::GetUpdateRegion() const
1980 return m_updateRegion
;
1983 bool wxWindow::IsExposed( int x
, int y
) const
1985 return (m_updateRegion
.Contains( x
, y
) != wxOutRegion
);
1988 bool wxWindow::IsExposed( int x
, int y
, int w
, int h
) const
1990 return (m_updateRegion
.Contains( x
, y
, w
, h
) != wxOutRegion
);
1993 bool wxWindow::IsExposed( const wxPoint
& pt
) const
1995 return (m_updateRegion
.Contains( pt
.x
, pt
.y
) != wxOutRegion
);
1998 bool wxWindow::IsExposed( const wxRect
& rect
) const
2000 return (m_updateRegion
.Contains( rect
.x
, rect
.y
, rect
.width
, rect
.height
) != wxOutRegion
);
2003 void wxWindow::Clear()
2005 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2007 if (m_wxwindow
&& m_wxwindow
->window
) gdk_window_clear( m_wxwindow
->window
);
2010 wxColour
wxWindow::GetBackgroundColour() const
2012 return m_backgroundColour
;
2015 void wxWindow::SetBackgroundColour( const wxColour
&colour
)
2017 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2019 m_backgroundColour
= colour
;
2020 if (!m_backgroundColour
.Ok()) return;
2024 GdkWindow
*window
= m_wxwindow
->window
;
2025 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
2026 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
2027 gdk_window_clear( window
);
2033 wxColour
wxWindow::GetForegroundColour() const
2035 return m_foregroundColour
;
2038 void wxWindow::SetForegroundColour( const wxColour
&colour
)
2040 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2042 m_foregroundColour
= colour
;
2043 if (!m_foregroundColour
.Ok()) return;
2048 GtkStyle
*wxWindow::GetWidgetStyle()
2050 if (m_widgetStyle
) gtk_style_unref( m_widgetStyle
);
2054 gtk_widget_get_style( m_widget
) );
2056 return m_widgetStyle
;
2059 void wxWindow::SetWidgetStyle()
2061 GtkStyle
*style
= GetWidgetStyle();
2063 gdk_font_unref( style
->font
);
2064 style
->font
= gdk_font_ref( m_font
.GetInternalFont( 1.0 ) );
2066 if (m_foregroundColour
.Ok())
2068 m_foregroundColour
.CalcPixel( gdk_window_get_colormap( m_widget
->window
) );
2069 style
->fg
[GTK_STATE_NORMAL
] = *m_foregroundColour
.GetColor();
2070 style
->fg
[GTK_STATE_PRELIGHT
] = *m_foregroundColour
.GetColor();
2071 style
->fg
[GTK_STATE_ACTIVE
] = *m_foregroundColour
.GetColor();
2074 if (m_backgroundColour
.Ok())
2076 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( m_widget
->window
) );
2077 style
->bg
[GTK_STATE_NORMAL
] = *m_backgroundColour
.GetColor();
2078 style
->base
[GTK_STATE_NORMAL
] = *m_backgroundColour
.GetColor();
2079 style
->bg
[GTK_STATE_PRELIGHT
] = *m_backgroundColour
.GetColor();
2080 style
->base
[GTK_STATE_PRELIGHT
] = *m_backgroundColour
.GetColor();
2081 style
->bg
[GTK_STATE_ACTIVE
] = *m_backgroundColour
.GetColor();
2082 style
->base
[GTK_STATE_ACTIVE
] = *m_backgroundColour
.GetColor();
2083 style
->bg
[GTK_STATE_INSENSITIVE
] = *m_backgroundColour
.GetColor();
2084 style
->base
[GTK_STATE_INSENSITIVE
] = *m_backgroundColour
.GetColor();
2088 void wxWindow::ApplyWidgetStyle()
2092 bool wxWindow::Validate()
2094 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, "invalid window" );
2096 wxNode
*node
= GetChildren()->First();
2099 wxWindow
*child
= (wxWindow
*)node
->Data();
2100 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this))
2102 node
= node
->Next();
2107 bool wxWindow::TransferDataToWindow()
2109 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, "invalid window" );
2111 wxNode
*node
= GetChildren()->First();
2114 wxWindow
*child
= (wxWindow
*)node
->Data();
2115 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */
2116 !child
->GetValidator()->TransferToWindow() )
2118 wxMessageBox( _("Application Error"), _("Could not transfer data to window"), wxOK
|wxICON_EXCLAMATION
);
2121 node
= node
->Next();
2126 bool wxWindow::TransferDataFromWindow()
2128 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2130 wxNode
*node
= GetChildren()->First();
2133 wxWindow
*child
= (wxWindow
*)node
->Data();
2134 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
2136 node
= node
->Next();
2141 void wxWindow::SetAcceleratorTable( const wxAcceleratorTable
& accel
)
2143 m_acceleratorTable
= accel
;
2146 void wxWindow::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
2148 TransferDataToWindow();
2151 void wxWindow::InitDialog()
2153 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2155 wxInitDialogEvent
event(GetId());
2156 event
.SetEventObject( this );
2157 GetEventHandler()->ProcessEvent(event
);
2160 static void SetInvokingWindow( wxMenu
*menu
, wxWindow
*win
)
2162 menu
->SetInvokingWindow( win
);
2163 wxNode
*node
= menu
->m_items
.First();
2166 wxMenuItem
*menuitem
= (wxMenuItem
*)node
->Data();
2167 if (menuitem
->IsSubMenu())
2168 SetInvokingWindow( menuitem
->GetSubMenu(), win
);
2169 node
= node
->Next();
2173 bool wxWindow::PopupMenu( wxMenu
*menu
, int WXUNUSED(x
), int WXUNUSED(y
) )
2175 wxCHECK_MSG( m_widget
!= NULL
, FALSE
, "invalid window" );
2177 wxCHECK_MSG( menu
!= NULL
, FALSE
, "invalid popup-menu" );
2179 SetInvokingWindow( menu
, this );
2181 GTK_MENU(menu
->m_menu
),
2182 (GtkWidget
*)NULL
, // parent menu shell
2183 (GtkWidget
*)NULL
, // parent menu item
2184 (GtkMenuPositionFunc
)NULL
,
2185 NULL
, // client data
2186 0, // button used to activate it
2187 0//gs_timeLastClick // the time of activation
2192 void wxWindow::SetDropTarget( wxDropTarget
*dropTarget
)
2194 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2196 GtkWidget
*dnd_widget
= GetConnectWidget();
2198 DisconnectDnDWidget( dnd_widget
);
2200 if (m_dropTarget
) delete m_dropTarget
;
2201 m_dropTarget
= dropTarget
;
2203 ConnectDnDWidget( dnd_widget
);
2206 wxDropTarget
*wxWindow::GetDropTarget() const
2208 return m_dropTarget
;
2211 void wxWindow::ConnectDnDWidget( GtkWidget
*widget
)
2213 if (!m_dropTarget
) return;
2215 m_dropTarget
->RegisterWidget( widget
);
2217 #ifdef NEW_GTK_DND_CODE
2221 gtk_signal_connect( GTK_OBJECT(widget
), "drop_data_available_event",
2222 GTK_SIGNAL_FUNC(gtk_window_drop_callback
), (gpointer
)this );
2228 void wxWindow::DisconnectDnDWidget( GtkWidget
*widget
)
2230 if (!m_dropTarget
) return;
2232 #ifdef NEW_GTK_DND_CODE
2236 gtk_signal_disconnect_by_func( GTK_OBJECT(widget
),
2237 GTK_SIGNAL_FUNC(gtk_window_drop_callback
), (gpointer
)this );
2239 m_dropTarget
->UnregisterWidget( widget
);
2245 GtkWidget
* wxWindow::GetConnectWidget()
2247 GtkWidget
*connect_widget
= m_widget
;
2248 if (m_wxwindow
) connect_widget
= m_wxwindow
;
2250 return connect_widget
;
2253 bool wxWindow::IsOwnGtkWindow( GdkWindow
*window
)
2255 if (m_wxwindow
) return (window
== m_wxwindow
->window
);
2256 return (window
== m_widget
->window
);
2259 void wxWindow::SetFont( const wxFont
&font
)
2261 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2263 if (((wxFont
*)&font
)->Ok())
2266 m_font
= *wxSWISS_FONT
;
2271 wxFont
*wxWindow::GetFont()
2276 void wxWindow::SetWindowStyleFlag( long flag
)
2278 m_windowStyle
= flag
;
2281 long wxWindow::GetWindowStyleFlag() const
2283 return m_windowStyle
;
2286 void wxWindow::CaptureMouse()
2288 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2290 wxCHECK_RET( g_capturing
== FALSE
, "CaptureMouse called twice" );
2292 GtkWidget
*connect_widget
= GetConnectWidget();
2293 gtk_grab_add( connect_widget
);
2294 gdk_pointer_grab ( connect_widget
->window
, FALSE
,
2296 (GDK_BUTTON_PRESS_MASK
|
2297 GDK_BUTTON_RELEASE_MASK
|
2298 GDK_POINTER_MOTION_MASK
),
2299 (GdkWindow
*) NULL
, (GdkCursor
*) NULL
, GDK_CURRENT_TIME
);
2303 void wxWindow::ReleaseMouse()
2305 wxCHECK_RET( m_widget
!= NULL
, "invalid window" );
2307 wxCHECK_RET( g_capturing
== TRUE
, "ReleaseMouse called twice" );
2309 GtkWidget
*connect_widget
= GetConnectWidget();
2310 gtk_grab_remove( connect_widget
);
2311 gdk_pointer_ungrab ( GDK_CURRENT_TIME
);
2312 g_capturing
= FALSE
;
2315 void wxWindow::SetTitle( const wxString
&WXUNUSED(title
) )
2319 wxString
wxWindow::GetTitle() const
2321 return (wxString
&)m_windowName
;
2324 wxString
wxWindow::GetLabel() const
2329 void wxWindow::SetName( const wxString
&name
)
2331 m_windowName
= name
;
2334 wxString
wxWindow::GetName() const
2336 return (wxString
&)m_windowName
;
2339 bool wxWindow::IsShown() const
2344 bool wxWindow::IsRetained()
2349 wxWindow
*wxWindow::FindWindow( long id
)
2351 if (id
== m_windowId
) return this;
2352 wxNode
*node
= m_children
.First();
2355 wxWindow
*child
= (wxWindow
*)node
->Data();
2356 wxWindow
*res
= child
->FindWindow( id
);
2357 if (res
) return res
;
2358 node
= node
->Next();
2360 return (wxWindow
*) NULL
;
2363 wxWindow
*wxWindow::FindWindow( const wxString
& name
)
2365 if (name
== m_windowName
) return this;
2366 wxNode
*node
= m_children
.First();
2369 wxWindow
*child
= (wxWindow
*)node
->Data();
2370 wxWindow
*res
= child
->FindWindow( name
);
2371 if (res
) return res
;
2372 node
= node
->Next();
2374 return (wxWindow
*) NULL
;
2377 void wxWindow::SetScrollbar( int orient
, int pos
, int thumbVisible
,
2378 int range
, bool refresh
)
2380 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2382 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2384 if (!m_wxwindow
) return;
2386 if (orient
== wxHORIZONTAL
)
2388 float fpos
= (float)pos
;
2389 float frange
= (float)range
;
2390 float fthumb
= (float)thumbVisible
;
2392 if ((fabs(frange
-m_hAdjust
->upper
) < 0.2) &&
2393 (fabs(fthumb
-m_hAdjust
->page_size
) < 0.2))
2395 SetScrollPos( orient
, pos
, refresh
);
2399 m_oldHorizontalPos
= fpos
;
2401 m_hAdjust
->lower
= 0.0;
2402 m_hAdjust
->upper
= frange
;
2403 m_hAdjust
->value
= fpos
;
2404 m_hAdjust
->step_increment
= 1.0;
2405 m_hAdjust
->page_increment
= (float)(wxMax(fthumb
,0));
2406 m_hAdjust
->page_size
= fthumb
;
2410 float fpos
= (float)pos
;
2411 float frange
= (float)range
;
2412 float fthumb
= (float)thumbVisible
;
2414 if ((fabs(frange
-m_vAdjust
->upper
) < 0.2) &&
2415 (fabs(fthumb
-m_vAdjust
->page_size
) < 0.2))
2417 SetScrollPos( orient
, pos
, refresh
);
2421 m_oldVerticalPos
= fpos
;
2423 m_vAdjust
->lower
= 0.0;
2424 m_vAdjust
->upper
= frange
;
2425 m_vAdjust
->value
= fpos
;
2426 m_vAdjust
->step_increment
= 1.0;
2427 m_vAdjust
->page_increment
= (float)(wxMax(fthumb
,0));
2428 m_vAdjust
->page_size
= fthumb
;
2431 if (m_wxwindow
->window
)
2433 if (orient
== wxHORIZONTAL
)
2434 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
2436 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
2438 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
2442 void wxWindow::SetScrollPos( int orient
, int pos
, bool WXUNUSED(refresh
) )
2444 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2446 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2448 if (!m_wxwindow
) return;
2450 if (orient
== wxHORIZONTAL
)
2452 float fpos
= (float)pos
;
2453 m_oldHorizontalPos
= fpos
;
2455 if (fabs(fpos
-m_hAdjust
->value
) < 0.2) return;
2456 m_hAdjust
->value
= fpos
;
2460 float fpos
= (float)pos
;
2461 m_oldVerticalPos
= fpos
;
2462 if (fabs(fpos
-m_vAdjust
->value
) < 0.2) return;
2463 m_vAdjust
->value
= fpos
;
2468 if (m_wxwindow
->window
)
2470 if (orient
== wxHORIZONTAL
)
2471 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
2473 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
2478 int wxWindow::GetScrollThumb( int orient
) const
2480 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2482 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2484 if (!m_wxwindow
) return 0;
2486 if (orient
== wxHORIZONTAL
)
2487 return (int)(m_hAdjust
->page_size
+0.5);
2489 return (int)(m_vAdjust
->page_size
+0.5);
2492 int wxWindow::GetScrollPos( int orient
) const
2494 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2496 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2498 if (!m_wxwindow
) return 0;
2500 if (orient
== wxHORIZONTAL
)
2501 return (int)(m_hAdjust
->value
+0.5);
2503 return (int)(m_vAdjust
->value
+0.5);
2506 int wxWindow::GetScrollRange( int orient
) const
2508 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2510 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2512 if (!m_wxwindow
) return 0;
2514 if (orient
== wxHORIZONTAL
)
2515 return (int)(m_hAdjust
->upper
+0.5);
2517 return (int)(m_vAdjust
->upper
+0.5);
2520 void wxWindow::ScrollWindow( int dx
, int dy
, const wxRect
* WXUNUSED(rect
) )
2522 wxASSERT_MSG( (m_widget
!= NULL
), "invalid window" );
2524 wxASSERT_MSG( (m_wxwindow
!= NULL
), "window needs client area" );
2526 if (!m_wxwindow
) return;
2530 GetClientSize( &cw
, &ch
);
2532 int w
= cw
- abs(dx
);
2533 int h
= ch
- abs(dy
);
2534 if ((h
< 0) || (w
< 0))
2541 if (dx
< 0) s_x
= -dx
;
2542 if (dy
< 0) s_y
= -dy
;
2545 if (dx
> 0) d_x
= dx
;
2546 if (dy
> 0) d_y
= dy
;
2550 m_scrollGC
= gdk_gc_new( m_wxwindow
->window
);
2551 gdk_gc_set_exposures( m_scrollGC
, TRUE
);
2554 gdk_window_copy_area( m_wxwindow
->window
, m_scrollGC
, d_x
, d_y
,
2555 m_wxwindow
->window
, s_x
, s_y
, w
, h
);
2558 if (dx
< 0) rect
.x
= cw
+dx
; else rect
.x
= 0;
2559 if (dy
< 0) rect
.y
= ch
+dy
; else rect
.y
= 0;
2560 if (dy
!= 0) rect
.width
= cw
; else rect
.width
= abs(dx
);
2561 if (dx
!= 0) rect
.height
= ch
; else rect
.height
= abs(dy
);
2563 Refresh( TRUE
, &rect
);
2566 //-------------------------------------------------------------------------------------
2568 //-------------------------------------------------------------------------------------
2570 wxLayoutConstraints
*wxWindow::GetConstraints() const
2572 return m_constraints
;
2575 void wxWindow::SetConstraints( wxLayoutConstraints
*constraints
)
2579 UnsetConstraints(m_constraints
);
2580 delete m_constraints
;
2582 m_constraints
= constraints
;
2585 // Make sure other windows know they're part of a 'meaningful relationship'
2586 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
2587 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2588 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
2589 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2590 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
2591 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2592 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
2593 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2594 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
2595 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2596 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
2597 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2598 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
2599 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2600 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
2601 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
2607 void wxWindow::SetAutoLayout( bool autoLayout
)
2609 m_autoLayout
= autoLayout
;
2612 bool wxWindow::GetAutoLayout() const
2614 return m_autoLayout
;
2617 wxSizer
*wxWindow::GetSizer() const
2619 return m_windowSizer
;
2622 void wxWindow::SetSizerParent( wxWindow
*win
)
2624 m_sizerParent
= win
;
2627 wxWindow
*wxWindow::GetSizerParent() const
2629 return m_sizerParent
;
2632 // This removes any dangling pointers to this window
2633 // in other windows' constraintsInvolvedIn lists.
2634 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
2638 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2639 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2640 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2641 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2642 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
2643 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2644 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
2645 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2646 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
2647 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2648 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
2649 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2650 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
2651 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2652 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
2653 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2657 // Back-pointer to other windows we're involved with, so if we delete
2658 // this window, we must delete any constraints we're involved with.
2659 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
2661 if (!m_constraintsInvolvedIn
)
2662 m_constraintsInvolvedIn
= new wxList
;
2663 if (!m_constraintsInvolvedIn
->Member(otherWin
))
2664 m_constraintsInvolvedIn
->Append(otherWin
);
2667 // REMOVE back-pointer to other windows we're involved with.
2668 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
2670 if (m_constraintsInvolvedIn
)
2671 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
2674 // Reset any constraints that mention this window
2675 void wxWindow::DeleteRelatedConstraints()
2677 if (m_constraintsInvolvedIn
)
2679 wxNode
*node
= m_constraintsInvolvedIn
->First();
2682 wxWindow
*win
= (wxWindow
*)node
->Data();
2683 wxNode
*next
= node
->Next();
2684 wxLayoutConstraints
*constr
= win
->GetConstraints();
2686 // Reset any constraints involving this window
2689 constr
->left
.ResetIfWin((wxWindow
*)this);
2690 constr
->top
.ResetIfWin((wxWindow
*)this);
2691 constr
->right
.ResetIfWin((wxWindow
*)this);
2692 constr
->bottom
.ResetIfWin((wxWindow
*)this);
2693 constr
->width
.ResetIfWin((wxWindow
*)this);
2694 constr
->height
.ResetIfWin((wxWindow
*)this);
2695 constr
->centreX
.ResetIfWin((wxWindow
*)this);
2696 constr
->centreY
.ResetIfWin((wxWindow
*)this);
2701 delete m_constraintsInvolvedIn
;
2702 m_constraintsInvolvedIn
= (wxList
*) NULL
;
2706 void wxWindow::SetSizer(wxSizer
*sizer
)
2708 m_windowSizer
= sizer
;
2710 sizer
->SetSizerParent((wxWindow
*)this);
2717 bool wxWindow::Layout()
2719 if (GetConstraints())
2722 GetClientSize(&w
, &h
);
2723 GetConstraints()->width
.SetValue(w
);
2724 GetConstraints()->height
.SetValue(h
);
2727 // If top level (one sizer), evaluate the sizer's constraints.
2731 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
2732 GetSizer()->LayoutPhase1(&noChanges
);
2733 GetSizer()->LayoutPhase2(&noChanges
);
2734 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
2739 // Otherwise, evaluate child constraints
2740 ResetConstraints(); // Mark all constraints as unevaluated
2741 DoPhase(1); // Just one phase need if no sizers involved
2743 SetConstraintSizes(); // Recursively set the real window sizes
2749 // Do a phase of evaluating constraints:
2750 // the default behaviour. wxSizers may do a similar
2751 // thing, but also impose their own 'constraints'
2752 // and order the evaluation differently.
2753 bool wxWindow::LayoutPhase1(int *noChanges
)
2755 wxLayoutConstraints
*constr
= GetConstraints();
2758 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
2764 bool wxWindow::LayoutPhase2(int *noChanges
)
2774 // Do a phase of evaluating child constraints
2775 bool wxWindow::DoPhase(int phase
)
2777 int noIterations
= 0;
2778 int maxIterations
= 500;
2782 while ((noChanges
> 0) && (noIterations
< maxIterations
))
2786 wxNode
*node
= GetChildren()->First();
2789 wxWindow
*child
= (wxWindow
*)node
->Data();
2790 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
2792 wxLayoutConstraints
*constr
= child
->GetConstraints();
2795 if (succeeded
.Member(child
))
2800 int tempNoChanges
= 0;
2801 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
2802 noChanges
+= tempNoChanges
;
2805 succeeded
.Append(child
);
2810 node
= node
->Next();
2817 void wxWindow::ResetConstraints()
2819 wxLayoutConstraints
*constr
= GetConstraints();
2822 constr
->left
.SetDone(FALSE
);
2823 constr
->top
.SetDone(FALSE
);
2824 constr
->right
.SetDone(FALSE
);
2825 constr
->bottom
.SetDone(FALSE
);
2826 constr
->width
.SetDone(FALSE
);
2827 constr
->height
.SetDone(FALSE
);
2828 constr
->centreX
.SetDone(FALSE
);
2829 constr
->centreY
.SetDone(FALSE
);
2831 wxNode
*node
= GetChildren()->First();
2834 wxWindow
*win
= (wxWindow
*)node
->Data();
2835 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2836 win
->ResetConstraints();
2837 node
= node
->Next();
2841 // Need to distinguish between setting the 'fake' size for
2842 // windows and sizers, and setting the real values.
2843 void wxWindow::SetConstraintSizes(bool recurse
)
2845 wxLayoutConstraints
*constr
= GetConstraints();
2846 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
2847 constr
->width
.GetDone() && constr
->height
.GetDone())
2849 int x
= constr
->left
.GetValue();
2850 int y
= constr
->top
.GetValue();
2851 int w
= constr
->width
.GetValue();
2852 int h
= constr
->height
.GetValue();
2854 // If we don't want to resize this window, just move it...
2855 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
2856 (constr
->height
.GetRelationship() != wxAsIs
))
2858 // Calls Layout() recursively. AAAGH. How can we stop that.
2859 // Simply take Layout() out of non-top level OnSizes.
2860 SizerSetSize(x
, y
, w
, h
);
2869 char *windowClass
= this->GetClassInfo()->GetClassName();
2872 if (GetName() == "")
2873 winName
= _("unnamed");
2875 winName
= GetName();
2876 wxDebugMsg(_("Constraint(s) not satisfied for window of type %s, name %s:\n"), (const char *)windowClass
, (const char *)winName
);
2877 if (!constr
->left
.GetDone())
2878 wxDebugMsg(_(" unsatisfied 'left' constraint.\n"));
2879 if (!constr
->right
.GetDone())
2880 wxDebugMsg(_(" unsatisfied 'right' constraint.\n"));
2881 if (!constr
->width
.GetDone())
2882 wxDebugMsg(_(" unsatisfied 'width' constraint.\n"));
2883 if (!constr
->height
.GetDone())
2884 wxDebugMsg(_(" unsatisfied 'height' constraint.\n"));
2885 wxDebugMsg(_("Please check constraints: try adding AsIs() constraints.\n"));
2890 wxNode
*node
= GetChildren()->First();
2893 wxWindow
*win
= (wxWindow
*)node
->Data();
2894 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2895 win
->SetConstraintSizes();
2896 node
= node
->Next();
2901 // This assumes that all sizers are 'on' the same
2902 // window, i.e. the parent of this window.
2903 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
2905 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
2906 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
2910 m_sizerParent
->GetPosition(&xp
, &yp
);
2911 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
2916 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
2920 TransformSizerToActual(&xx
, &yy
);
2921 SetSize(xx
, yy
, w
, h
);
2924 void wxWindow::SizerMove(int x
, int y
)
2928 TransformSizerToActual(&xx
, &yy
);
2932 // Only set the size/position of the constraint (if any)
2933 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
2935 wxLayoutConstraints
*constr
= GetConstraints();
2940 constr
->left
.SetValue(x
);
2941 constr
->left
.SetDone(TRUE
);
2945 constr
->top
.SetValue(y
);
2946 constr
->top
.SetDone(TRUE
);
2950 constr
->width
.SetValue(w
);
2951 constr
->width
.SetDone(TRUE
);
2955 constr
->height
.SetValue(h
);
2956 constr
->height
.SetDone(TRUE
);
2961 void wxWindow::MoveConstraint(int x
, int y
)
2963 wxLayoutConstraints
*constr
= GetConstraints();
2968 constr
->left
.SetValue(x
);
2969 constr
->left
.SetDone(TRUE
);
2973 constr
->top
.SetValue(y
);
2974 constr
->top
.SetDone(TRUE
);
2979 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
2981 wxLayoutConstraints
*constr
= GetConstraints();
2984 *w
= constr
->width
.GetValue();
2985 *h
= constr
->height
.GetValue();
2991 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
2993 wxLayoutConstraints
*constr
= GetConstraints();
2996 *w
= constr
->width
.GetValue();
2997 *h
= constr
->height
.GetValue();
3000 GetClientSize(w
, h
);
3003 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
3005 wxLayoutConstraints
*constr
= GetConstraints();
3008 *x
= constr
->left
.GetValue();
3009 *y
= constr
->top
.GetValue();
3015 bool wxWindow::AcceptsFocus() const
3017 return IsEnabled() && IsShown();
3020 void wxWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
) )