1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "window.h"
17 #include "wx/window.h"
21 #include "wx/layout.h"
23 #include "wx/dialog.h"
24 #include "wx/msgdlg.h"
25 #include "wx/dcclient.h"
28 #include "wx/notebook.h"
29 #include "gdk/gdkkeysyms.h"
31 #include "wx/gtk/win_gtk.h"
32 #include "gdk/gdkprivate.h"
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 extern wxList wxPendingDelete
;
39 extern wxList wxTopLevelWindows
;
40 extern bool g_blockEventsOnDrag
;
42 //-----------------------------------------------------------------------------
43 // GTK callbacks for wxWindows event system
44 //-----------------------------------------------------------------------------
46 //-----------------------------------------------------------------------------
47 // expose (of m_wxwindow, not of m_widget)
49 void gtk_window_expose_callback( GtkWidget
*WXUNUSED(widget
), GdkEventExpose
*gdk_event
, wxWindow
*win
)
51 if (!win
->HasVMT()) return;
52 if (g_blockEventsOnDrag
) return;
55 printf( "OnExpose from " );
56 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
57 printf( win->GetClassInfo()->GetClassName() );
60 printf( "x: %d \n", gdk_event->area.x );
61 printf( "y: %d \n", gdk_event->area.y );
62 printf( "w: %d \n", gdk_event->area.width );
63 printf( "h: %d \n", gdk_event->area.height );
66 win
->m_updateRegion
.Union( gdk_event
->area
.x
,
68 gdk_event
->area
.width
,
69 gdk_event
->area
.height
);
71 if (gdk_event
->count
> 0) return;
73 wxPaintEvent
event( win
->GetId() );
74 event
.SetEventObject( win
);
75 win
->ProcessEvent( event
);
77 win
->m_updateRegion
.Clear();
80 //-----------------------------------------------------------------------------
81 // draw (of m_wxwindow, not of m_widget)
83 void gtk_window_draw_callback( GtkWidget
*WXUNUSED(widget
), GdkRectangle
*rect
, wxWindow
*win
)
85 if (!win
->HasVMT()) return;
86 if (g_blockEventsOnDrag
) return;
89 printf( "OnDraw from " );
90 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
91 printf( win->GetClassInfo()->GetClassName() );
94 printf( "x: %d \n", rect->x );
95 printf( "y: %d \n", rect->y );
96 printf( "w: %d \n", rect->width );
97 printf( "h: %d \n", rect->height );
100 win
->m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
102 wxPaintEvent
event( win
->GetId() );
103 event
.SetEventObject( win
);
104 win
->ProcessEvent( event
);
106 win
->m_updateRegion
.Clear();
109 //-----------------------------------------------------------------------------
111 // I don't any longer intercept GTK's internal resize events (except frames)
114 void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
116 if (!win->HasVMT()) return;
117 if (g_blockEventsOnDrag) return;
121 if ((win->m_x == alloc->x) &&
122 (win->m_y == alloc->y) &&
123 (win->m_width == alloc->width) &&
124 (win->m_height == alloc->height))
129 printf( "OnResize from " );
130 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
131 printf( win->GetClassInfo()->GetClassName() );
134 printf( " Old: X: %d Y: %d ", win->m_x, win->m_y );
135 printf( " W: %d H: %d ", win->m_width, win->m_height );
138 printf( " New: X: %d Y: %d ", alloc->x, alloc->y );
139 printf( " W: %d H: %d ", alloc->width, alloc->height );
142 wxSizeEvent event( wxSize( alloc->width, alloc->height), win->GetId() );
143 event.SetEventObject( win );
144 win->ProcessEvent( event );
148 //-----------------------------------------------------------------------------
151 gint
gtk_window_key_press_callback( GtkWidget
*WXUNUSED(widget
), GdkEventKey
*gdk_event
, wxWindow
*win
)
153 if (!win
->HasVMT()) return FALSE
;
154 if (g_blockEventsOnDrag
) return FALSE
;
157 printf( "OnKeyPress from " );
158 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
159 printf( win->GetClassInfo()->GetClassName() );
164 switch (gdk_event
->keyval
)
166 case GDK_BackSpace
: key_code
= WXK_BACK
; break;
167 case GDK_Tab
: key_code
= WXK_TAB
; break;
168 case GDK_Linefeed
: key_code
= WXK_RETURN
; break;
169 case GDK_Clear
: key_code
= WXK_CLEAR
; break;
170 case GDK_Return
: key_code
= WXK_RETURN
; break;
171 case GDK_Pause
: key_code
= WXK_PAUSE
; break;
172 case GDK_Scroll_Lock
: key_code
= WXK_SCROLL
; break;
173 case GDK_Escape
: key_code
= WXK_ESCAPE
; break;
174 case GDK_Delete
: key_code
= WXK_DELETE
; break;
175 case GDK_Home
: key_code
= WXK_HOME
; break;
176 case GDK_Left
: key_code
= WXK_LEFT
; break;
177 case GDK_Up
: key_code
= WXK_UP
; break;
178 case GDK_Right
: key_code
= WXK_RIGHT
; break;
179 case GDK_Down
: key_code
= WXK_DOWN
; break;
180 case GDK_Prior
: key_code
= WXK_PRIOR
; break;
181 // case GDK_Page_Up: key_code = WXK_PAGEUP; break;
182 case GDK_Next
: key_code
= WXK_NEXT
; break;
183 // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
184 case GDK_End
: key_code
= WXK_END
; break;
185 case GDK_Begin
: key_code
= WXK_HOME
; break;
186 case GDK_Select
: key_code
= WXK_SELECT
; break;
187 case GDK_Print
: key_code
= WXK_PRINT
; break;
188 case GDK_Execute
: key_code
= WXK_EXECUTE
; break;
189 case GDK_Insert
: key_code
= WXK_INSERT
; break;
190 case GDK_Num_Lock
: key_code
= WXK_NUMLOCK
; break;
191 case GDK_KP_Tab
: key_code
= WXK_TAB
; break;
192 case GDK_KP_Enter
: key_code
= WXK_RETURN
; break;
193 case GDK_KP_Home
: key_code
= WXK_HOME
; break;
194 case GDK_KP_Left
: key_code
= WXK_LEFT
; break;
195 case GDK_KP_Up
: key_code
= WXK_UP
; break;
196 case GDK_KP_Right
: key_code
= WXK_RIGHT
; break;
197 case GDK_KP_Down
: key_code
= WXK_DOWN
; break;
198 case GDK_KP_Prior
: key_code
= WXK_PRIOR
; break;
199 // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
200 case GDK_KP_Next
: key_code
= WXK_NEXT
; break;
201 // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
202 case GDK_KP_End
: key_code
= WXK_END
; break;
203 case GDK_KP_Begin
: key_code
= WXK_HOME
; break;
204 case GDK_KP_Insert
: key_code
= WXK_INSERT
; break;
205 case GDK_KP_Delete
: key_code
= WXK_DELETE
; break;
206 case GDK_KP_Multiply
: key_code
= WXK_MULTIPLY
; break;
207 case GDK_KP_Add
: key_code
= WXK_ADD
; break;
208 case GDK_KP_Separator
: key_code
= WXK_SEPARATOR
; break;
209 case GDK_KP_Subtract
: key_code
= WXK_SUBTRACT
; break;
210 case GDK_KP_Decimal
: key_code
= WXK_DECIMAL
; break;
211 case GDK_KP_Divide
: key_code
= WXK_DIVIDE
; break;
212 case GDK_KP_0
: key_code
= WXK_NUMPAD0
; break;
213 case GDK_KP_1
: key_code
= WXK_NUMPAD1
; break;
214 case GDK_KP_2
: key_code
= WXK_NUMPAD2
; break;
215 case GDK_KP_3
: key_code
= WXK_NUMPAD3
; break;
216 case GDK_KP_4
: key_code
= WXK_NUMPAD4
; break;
217 case GDK_KP_5
: key_code
= WXK_NUMPAD5
; break;
218 case GDK_KP_6
: key_code
= WXK_NUMPAD6
; break;
219 case GDK_KP_7
: key_code
= WXK_NUMPAD7
; break;
220 case GDK_KP_8
: key_code
= WXK_NUMPAD7
; break;
221 case GDK_KP_9
: key_code
= WXK_NUMPAD9
; break;
222 case GDK_F1
: key_code
= WXK_F1
; break;
223 case GDK_F2
: key_code
= WXK_F2
; break;
224 case GDK_F3
: key_code
= WXK_F3
; break;
225 case GDK_F4
: key_code
= WXK_F4
; break;
226 case GDK_F5
: key_code
= WXK_F5
; break;
227 case GDK_F6
: key_code
= WXK_F6
; break;
228 case GDK_F7
: key_code
= WXK_F7
; break;
229 case GDK_F8
: key_code
= WXK_F8
; break;
230 case GDK_F9
: key_code
= WXK_F9
; break;
231 case GDK_F10
: key_code
= WXK_F10
; break;
232 case GDK_F11
: key_code
= WXK_F11
; break;
233 case GDK_F12
: key_code
= WXK_F12
; break;
236 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
237 key_code
= gdk_event
->keyval
;
241 if (!key_code
) return FALSE
;
243 wxKeyEvent
event( wxEVT_CHAR
);
244 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
245 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
246 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
247 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
248 event
.m_keyCode
= key_code
;
251 event
.SetEventObject( win
);
252 return win
->ProcessEvent( event
);
255 //-----------------------------------------------------------------------------
258 gint
gtk_window_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
260 if (widget
->window
!= gdk_event
->window
) return FALSE
;
261 if (g_blockEventsOnDrag
) return FALSE
;
265 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
) && !GTK_WIDGET_HAS_FOCUS (win
->m_wxwindow
) )
267 gtk_widget_grab_focus (win
->m_wxwindow
);
270 printf( "GrabFocus from " );
271 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
272 printf( win->GetClassInfo()->GetClassName() );
279 if (!win
->HasVMT()) return FALSE
;
282 printf( "OnButtonPress from " );
283 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
284 printf( win->GetClassInfo()->GetClassName() );
288 wxEventType event_type
= wxEVT_LEFT_DOWN
;
290 if (gdk_event
->button
== 1)
292 switch (gdk_event
->type
)
294 case GDK_BUTTON_PRESS
: event_type
= wxEVT_LEFT_DOWN
; break;
295 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_LEFT_DCLICK
; break;
299 else if (gdk_event
->button
== 2)
301 switch (gdk_event
->type
)
303 case GDK_BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DOWN
; break;
304 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DCLICK
; break;
308 else if (gdk_event
->button
== 3)
310 switch (gdk_event
->type
)
312 case GDK_BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DOWN
; break;
313 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DCLICK
; break;
318 wxMouseEvent
event( event_type
);
319 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
320 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
321 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
322 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
323 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
324 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
325 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
327 event
.m_x
= (long)gdk_event
->x
;
328 event
.m_y
= (long)gdk_event
->y
;
329 event
.SetEventObject( win
);
331 win
->ProcessEvent( event
);
336 //-----------------------------------------------------------------------------
339 gint
gtk_window_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
341 if (widget
->window
!= gdk_event
->window
) return TRUE
;
343 if (g_blockEventsOnDrag
) return FALSE
;
345 if (!win
->HasVMT()) return FALSE
;
348 printf( "OnButtonRelease from " );
349 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
350 printf( win->GetClassInfo()->GetClassName() );
354 wxEventType event_type
= wxEVT_NULL
;
356 switch (gdk_event
->button
)
358 case 1: event_type
= wxEVT_LEFT_UP
; break;
359 case 2: event_type
= wxEVT_MIDDLE_UP
; break;
360 case 3: event_type
= wxEVT_RIGHT_UP
; break;
363 wxMouseEvent
event( event_type
);
364 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
365 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
366 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
367 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
368 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
369 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
370 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
371 event
.m_x
= (long)gdk_event
->x
;
372 event
.m_y
= (long)gdk_event
->y
;
373 event
.SetEventObject( win
);
375 return win
->ProcessEvent( event
);
378 //-----------------------------------------------------------------------------
381 gint
gtk_window_motion_notify_callback( GtkWidget
*widget
, GdkEventMotion
*gdk_event
, wxWindow
*win
)
383 if (widget
->window
!= gdk_event
->window
) return TRUE
;
385 if (g_blockEventsOnDrag
) return FALSE
;
387 if (!win
->HasVMT()) return FALSE
;
390 printf( "OnMotion from " );
391 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
392 printf( win->GetClassInfo()->GetClassName() );
396 wxMouseEvent
event( wxEVT_MOTION
);
397 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
398 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
399 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
400 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
401 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
402 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
403 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
405 event
.m_x
= (long)gdk_event
->x
;
406 event
.m_y
= (long)gdk_event
->y
;
407 event
.SetEventObject( win
);
409 win
->ProcessEvent( event
);
414 //-----------------------------------------------------------------------------
417 void gtk_window_focus_in_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
419 if (g_blockEventsOnDrag
) return;
422 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
424 GTK_WIDGET_SET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
426 printf( "SetFocus flag from " );
427 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
428 printf( win->GetClassInfo()->GetClassName() );
434 if (!win
->HasVMT()) return;
437 printf( "OnSetFocus from " );
438 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
439 printf( win->GetClassInfo()->GetClassName() );
441 printf( WXSTRINGCAST win->GetLabel() );
445 wxFocusEvent
event( wxEVT_SET_FOCUS
, win
->GetId() );
446 event
.SetEventObject( win
);
447 win
->ProcessEvent( event
);
450 //-----------------------------------------------------------------------------
453 void gtk_window_focus_out_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
455 if (g_blockEventsOnDrag
) return;
458 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
459 GTK_WIDGET_UNSET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
462 if (!win
->HasVMT()) return;
465 printf( "OnKillFocus from " );
466 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
467 printf( win->GetClassInfo()->GetClassName() );
471 wxFocusEvent
event( wxEVT_KILL_FOCUS
, win
->GetId() );
472 event
.SetEventObject( win
);
473 win
->ProcessEvent( event
);
476 //-----------------------------------------------------------------------------
479 void gtk_window_vscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
481 if (g_blockEventsOnDrag
) return;
484 printf( "OnVScroll from " );
485 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
486 printf( win->GetClassInfo()->GetClassName() );
490 if (!win
->HasVMT()) return;
492 float diff
= win
->m_vAdjust
->value
- win
->m_oldVerticalPos
;
493 if (fabs(diff
) < 0.2) return;
496 int i = (int)(win->m_oldVerticalPos+0.5);
497 printf( "Old value: %d.\n", i );
498 i = (int)(win->m_vAdjust->value+0.5);
499 printf( "Sending new value: %d.\n", i );
502 wxEventType command
= wxEVT_NULL
;
504 float line_step
= win
->m_vAdjust
->step_increment
;
505 float page_step
= win
->m_vAdjust
->page_increment
;
507 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
508 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
509 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
510 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
511 else command
= wxEVT_SCROLL_THUMBTRACK
;
513 int value
= (int)(win
->m_vAdjust
->value
+0.5);
515 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
516 event
.SetEventObject( win
);
517 win
->ProcessEvent( event
);
520 //-----------------------------------------------------------------------------
523 void gtk_window_hscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
525 if (g_blockEventsOnDrag
) return;
528 printf( "OnHScroll from " );
529 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
530 printf( win->GetClassInfo()->GetClassName() );
534 if (!win
->HasVMT()) return;
536 float diff
= win
->m_hAdjust
->value
- win
->m_oldHorizontalPos
;
537 if (fabs(diff
) < 0.2) return;
540 int i = (int)(win->m_oldHorizontalPos+0.5);
541 printf( "Old value: %d.\n", i );
542 i = (int)(win->m_hAdjust->value+0.5);
543 printf( "Sending new value: %d.\n", i );
546 wxEventType command
= wxEVT_NULL
;
548 float line_step
= win
->m_hAdjust
->step_increment
;
549 float page_step
= win
->m_hAdjust
->page_increment
;
551 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
552 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
553 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
554 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
555 else command
= wxEVT_SCROLL_THUMBTRACK
;
557 int value
= (int)(win
->m_hAdjust
->value
+0.5);
559 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
560 event
.SetEventObject( win
);
561 win
->ProcessEvent( event
);
564 //-----------------------------------------------------------------------------
565 // vertical scroll change
567 void gtk_window_vscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
569 if (g_blockEventsOnDrag
) return;
572 printf( "OnVScroll change from " );
573 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
574 printf( win->GetClassInfo()->GetClassName() );
578 if (!win
->HasVMT()) return;
580 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
581 int value
= (int)(win
->m_vAdjust
->value
+0.5);
583 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
584 event
.SetEventObject( win
);
585 win
->ProcessEvent( event
);
588 //-----------------------------------------------------------------------------
589 // horizontal scroll change
591 void gtk_window_hscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
593 if (g_blockEventsOnDrag
) return;
596 printf( "OnHScroll change from " );
597 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
598 printf( win->GetClassInfo()->GetClassName() );
602 if (!win
->HasVMT()) return;
604 wxEventType command
= wxEVT_SCROLL_THUMBTRACK
;
605 int value
= (int)(win
->m_hAdjust
->value
+0.5);
607 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
608 event
.SetEventObject( win
);
609 win
->ProcessEvent( event
);
612 //-----------------------------------------------------------------------------
615 void gtk_window_drop_callback( GtkWidget
*widget
, GdkEvent
*event
, wxWindow
*win
)
617 printf( "OnDrop.\n" );
619 if (win
->GetDropTarget())
623 gdk_window_get_pointer( widget
->window
, &x
, &y
, NULL
);
624 win
->GetDropTarget()->Drop( event
, x
, y
);
628 g_free (event->dropdataavailable.data);
629 g_free (event->dropdataavailable.data_type);
633 //-----------------------------------------------------------------------------
636 bool gtk_window_destroy_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
638 printf( "OnDestroy from " );
639 if (win
->GetClassInfo() && win
->GetClassInfo()->GetClassName())
640 printf( win
->GetClassInfo()->GetClassName() );
642 printf( "Goodbye.\n" );
643 printf( " Robert Roebling.\n" );
648 //-----------------------------------------------------------------------------
651 bool gtk_window_enter_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
653 if (g_blockEventsOnDrag
) return FALSE
;
656 gdk_window_set_cursor( widget
->window
, win
->m_cursor
->GetCursor() );
661 //-----------------------------------------------------------------------------
664 bool gtk_window_leave_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*WXUNUSED(win
) )
666 if (g_blockEventsOnDrag
) return FALSE
;
669 gdk_window_set_cursor( widget
->window
, wxSTANDARD_CURSOR
->GetCursor() );
674 //-----------------------------------------------------------------------------
675 // wxWindow implementation
676 //-----------------------------------------------------------------------------
678 IMPLEMENT_DYNAMIC_CLASS(wxWindow
,wxEvtHandler
)
680 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
681 // EVT_CHAR(wxWindow::OnChar)
682 EVT_SIZE(wxWindow::OnSize
)
683 // EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
684 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
685 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
686 // EVT_IDLE(wxWindow::OnIdle)
694 m_children
.DeleteContents( FALSE
);
700 m_eventHandler
= this;
701 m_windowValidator
= NULL
;
703 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
704 m_font
= *wxSWISS_FONT
;
706 m_windowName
= "noname";
707 m_constraints
= NULL
;
708 m_constraintsInvolvedIn
= NULL
;
709 m_windowSizer
= NULL
;
710 m_sizerParent
= NULL
;
711 m_autoLayout
= FALSE
;
715 m_hasScrolling
= FALSE
;
718 m_oldHorizontalPos
= 0.0;
719 m_oldVerticalPos
= 0.0;
722 m_drawingOffsetX
= 0;
723 m_drawingOffsetY
= 0;
724 m_pDropTarget
= NULL
;
727 wxWindow::wxWindow( wxWindow
*parent
, wxWindowID id
,
728 const wxPoint
&pos
, const wxSize
&size
,
729 long style
, const wxString
&name
)
731 Create( parent
, id
, pos
, size
, style
, name
);
734 bool wxWindow::Create( wxWindow
*parent
, wxWindowID id
,
735 const wxPoint
&pos
, const wxSize
&size
,
736 long style
, const wxString
&name
)
742 PreCreation( parent
, id
, pos
, size
, style
, name
);
744 m_widget
= gtk_scrolled_window_new( NULL
, NULL
);
745 m_hasScrolling
= TRUE
;
747 GtkScrolledWindow
*s_window
;
748 s_window
= GTK_SCROLLED_WINDOW(m_widget
);
750 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
751 scroll_class
->scrollbar_spacing
= 0;
753 gtk_scrolled_window_set_policy( s_window
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
755 m_oldHorizontalPos
= 0.0;
756 m_oldVerticalPos
= 0.0;
758 m_hAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->hscrollbar
) );
759 m_vAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->vscrollbar
) );
761 gtk_signal_connect (GTK_OBJECT (m_hAdjust
), "value_changed",
762 (GtkSignalFunc
) gtk_window_hscroll_callback
, (gpointer
) this );
763 gtk_signal_connect (GTK_OBJECT (m_vAdjust
), "value_changed",
764 (GtkSignalFunc
) gtk_window_vscroll_callback
, (gpointer
) this );
766 gtk_signal_connect (GTK_OBJECT (m_hAdjust
), "changed",
767 (GtkSignalFunc
) gtk_window_hscroll_change_callback
, (gpointer
) this );
768 gtk_signal_connect (GTK_OBJECT (m_vAdjust
), "changed",
769 (GtkSignalFunc
) gtk_window_vscroll_change_callback
, (gpointer
) this );
771 GtkViewport
*viewport
;
772 viewport
= GTK_VIEWPORT(s_window
->viewport
);
774 if (m_windowStyle
& wxRAISED_BORDER
)
776 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_OUT
);
778 else if (m_windowStyle
& wxSUNKEN_BORDER
)
780 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_IN
);
784 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_NONE
);
787 m_wxwindow
= gtk_myfixed_new();
789 if (m_windowStyle
& wxTAB_TRAVERSAL
== wxTAB_TRAVERSAL
)
790 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
792 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
794 gtk_container_add( GTK_CONTAINER(m_widget
), m_wxwindow
);
796 // shut the viewport up
797 gtk_viewport_set_hadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
798 gtk_viewport_set_vadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
800 // I _really_ don't want scrollbars in the beginning
801 m_vAdjust
->lower
= 0.0;
802 m_vAdjust
->upper
= 1.0;
803 m_vAdjust
->value
= 0.0;
804 m_vAdjust
->step_increment
= 1.0;
805 m_vAdjust
->page_increment
= 1.0;
806 m_vAdjust
->page_size
= 5.0;
807 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
808 m_hAdjust
->lower
= 0.0;
809 m_hAdjust
->upper
= 1.0;
810 m_hAdjust
->value
= 0.0;
811 m_hAdjust
->step_increment
= 1.0;
812 m_hAdjust
->page_increment
= 1.0;
813 m_hAdjust
->page_size
= 5.0;
814 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
816 gtk_widget_show( m_wxwindow
);
825 wxWindow::~wxWindow(void)
829 if (m_pDropTarget
) delete m_pDropTarget
;
831 if (m_parent
) m_parent
->RemoveChild( this );
832 if (m_widget
) Show( FALSE
);
836 if (m_wxwindow
) gtk_widget_destroy( m_wxwindow
);
838 if (m_widget
) gtk_widget_destroy( m_widget
);
842 DeleteRelatedConstraints();
845 // This removes any dangling pointers to this window
846 // in other windows' constraintsInvolvedIn lists.
847 UnsetConstraints(m_constraints
);
848 delete m_constraints
;
849 m_constraints
= NULL
;
853 delete m_windowSizer
;
854 m_windowSizer
= NULL
;
856 // If this is a child of a sizer, remove self from parent
858 m_sizerParent
->RemoveChild((wxWindow
*)this);
860 // Just in case the window has been Closed, but
861 // we're then deleting immediately: don't leave
862 // dangling pointers.
863 wxPendingDelete
.DeleteObject(this);
865 // Just in case we've loaded a top-level window via
866 // wxWindow::LoadNativeDialog but we weren't a dialog
868 wxTopLevelWindows
.DeleteObject(this);
872 void wxWindow::PreCreation( wxWindow
*parent
, wxWindowID id
,
873 const wxPoint
&pos
, const wxSize
&size
,
874 long style
, const wxString
&name
)
876 if (m_needParent
&& (parent
== NULL
))
877 wxFatalError( "Need complete parent.", name
);
882 m_children
.DeleteContents( FALSE
);
886 if (m_width
== -1) m_width
= 20;
888 if (m_height
== -1) m_height
= 20;
890 m_eventHandler
= this;
891 m_windowValidator
= NULL
;
894 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
895 m_font
= *wxSWISS_FONT
;
896 m_backgroundColour
= wxWHITE
;
897 m_foregroundColour
= wxBLACK
;
898 m_windowStyle
= style
;
900 m_constraints
= NULL
;
901 m_constraintsInvolvedIn
= NULL
;
902 m_windowSizer
= NULL
;
903 m_sizerParent
= NULL
;
904 m_autoLayout
= FALSE
;
905 m_drawingOffsetX
= 0;
906 m_drawingOffsetY
= 0;
907 m_pDropTarget
= NULL
;
910 void wxWindow::PostCreation(void)
912 if (m_parent
) m_parent
->AddChild( this );
914 // GtkStyle *style = m_widget->style;
915 // style->font = m_font.GetInternalFont( 1.0 ); // destroy old font ?
917 GtkWidget
*connect_widget
= m_widget
;
918 if (m_wxwindow
) connect_widget
= m_wxwindow
;
920 gtk_object_set_data (GTK_OBJECT (connect_widget
), "MyWxWindow", (gpointer
)this );
924 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "expose_event",
925 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
927 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "draw",
928 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
932 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
933 GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this );
936 gtk_signal_connect( GTK_OBJECT(connect_widget
), "key_press_event",
937 GTK_SIGNAL_FUNC(gtk_window_key_press_callback
), (gpointer
)this );
939 gtk_signal_connect( GTK_OBJECT(connect_widget
), "button_press_event",
940 GTK_SIGNAL_FUNC(gtk_window_button_press_callback
), (gpointer
)this );
942 gtk_signal_connect( GTK_OBJECT(connect_widget
), "button_release_event",
943 GTK_SIGNAL_FUNC(gtk_window_button_release_callback
), (gpointer
)this );
945 gtk_signal_connect( GTK_OBJECT(connect_widget
), "motion_notify_event",
946 GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback
), (gpointer
)this );
948 gtk_signal_connect( GTK_OBJECT(connect_widget
), "focus_in_event",
949 GTK_SIGNAL_FUNC(gtk_window_focus_in_callback
), (gpointer
)this );
951 gtk_signal_connect( GTK_OBJECT(connect_widget
), "focus_out_event",
952 GTK_SIGNAL_FUNC(gtk_window_focus_out_callback
), (gpointer
)this );
954 gtk_signal_connect( GTK_OBJECT(connect_widget
), "drop_data_available_event",
955 GTK_SIGNAL_FUNC(gtk_window_drop_callback
), (gpointer
)this );
957 // Only for cursor handling
959 gtk_signal_connect( GTK_OBJECT(m_widget
), "enter_notify_event",
960 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
962 gtk_signal_connect( GTK_OBJECT(m_widget
), "leave_notify_event",
963 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
967 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "enter_notify_event",
968 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
970 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "leave_notify_event",
971 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
975 // Does destroy ever get called ?
977 gtk_signal_connect( GTK_OBJECT(m_widget), "destroy_event",
978 GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
982 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "destroy_event",
983 GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
987 if (m_widget
&& m_parent
) gtk_widget_realize( m_widget
);
988 if (m_wxwindow
) gtk_widget_realize( m_wxwindow
);
990 SetCursor( wxSTANDARD_CURSOR
);
995 bool wxWindow::HasVMT(void)
1000 bool wxWindow::Close( bool force
)
1002 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
1003 event
.SetEventObject(this);
1004 event
.SetForce(force
);
1006 return GetEventHandler()->ProcessEvent(event
);
1009 bool wxWindow::Destroy(void)
1016 bool wxWindow::DestroyChildren(void)
1021 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
)
1024 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
)
1027 if (GetChildren()->Member(child
)) delete node
;
1034 void wxWindow::PrepareDC( wxDC
&WXUNUSED(dc
) )
1036 // are we to set fonts here ?
1039 void wxWindow::ImplementSetSize(void)
1041 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
1044 void wxWindow::ImplementSetPosition(void)
1046 if ((m_parent
) && (m_parent
->m_wxwindow
))
1047 gtk_myfixed_move( GTK_MYFIXED(m_parent
->m_wxwindow
), m_widget
, m_x
, m_y
);
1049 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
1052 void wxWindow::SetSize( int x
, int y
, int width
, int height
, int sizeFlags
)
1059 if ((sizeFlags
& wxSIZE_USE_EXISTING
) == wxSIZE_USE_EXISTING
)
1061 if (newX
== -1) newX
= m_x
;
1062 if (newY
== -1) newY
= m_y
;
1063 if (newW
== -1) newW
= m_width
;
1064 if (newH
== -1) newH
= m_height
;
1067 if ((sizeFlags
& wxSIZE_AUTO_WIDTH
) == wxSIZE_AUTO_WIDTH
)
1069 if (newW
== -1) newW
= 80;
1072 if ((sizeFlags
& wxSIZE_AUTO_HEIGHT
) == wxSIZE_AUTO_HEIGHT
)
1074 if (newH
== -1) newH
= 26;
1077 if ((m_x
!= newX
) || (m_y
!= newY
) || (!m_sizeSet
))
1081 ImplementSetPosition();
1083 if ((m_width
!= newW
) || (m_height
!= newH
) || (!m_sizeSet
))
1091 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
1092 event
.SetEventObject( this );
1093 ProcessEvent( event
);
1096 void wxWindow::SetSize( int width
, int height
)
1098 SetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
);
1101 void wxWindow::Move( int x
, int y
)
1103 SetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
);
1106 void wxWindow::GetSize( int *width
, int *height
) const
1109 (*height
) = m_height
;
1112 void wxWindow::SetClientSize( int width
, int height
)
1116 SetSize( width
, height
);
1123 if (!m_hasScrolling
)
1126 do we have sunken dialogs ?
1128 GtkStyleClass *window_class = m_wxwindow->style->klass;
1130 dw += 2 * window_class->xthickness;
1131 dh += 2 * window_class->ythickness;
1136 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1137 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1139 GtkWidget
*viewport
= scroll_window
->viewport
;
1140 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1142 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1143 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1145 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1146 (m_windowStyle
& wxSUNKEN_BORDER
)
1149 dw
+= 2 * viewport_class
->xthickness
;
1150 dh
+= 2 * viewport_class
->ythickness
;
1153 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1155 dw
+= vscrollbar
->allocation
.width
;
1156 dw
+= scroll_class
->scrollbar_spacing
;
1159 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1161 dh
+= hscrollbar
->allocation
.height
;
1162 dw
+= scroll_class
->scrollbar_spacing
;
1166 SetSize( width
+dw
, height
+dh
);
1170 void wxWindow::GetClientSize( int *width
, int *height
) const
1174 if (width
) (*width
) = m_width
;
1175 if (height
) (*height
) = m_height
;
1182 if (!m_hasScrolling
)
1185 do we have sunken dialogs ?
1187 GtkStyleClass *window_class = m_wxwindow->style->klass;
1189 dw += 2 * window_class->xthickness;
1190 dh += 2 * window_class->ythickness;
1195 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1196 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1198 GtkWidget
*viewport
= scroll_window
->viewport
;
1199 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1201 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1202 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1204 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1205 (m_windowStyle
& wxSUNKEN_BORDER
)
1208 dw
+= 2 * viewport_class
->xthickness
;
1209 dh
+= 2 * viewport_class
->ythickness
;
1212 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1214 // dw += vscrollbar->allocation.width;
1215 dw
+= 15; // range.slider_width = 11 + 2*2pts edge
1216 dw
+= scroll_class
->scrollbar_spacing
;
1219 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1221 // dh += hscrollbar->allocation.height;
1223 dh
+= scroll_class
->scrollbar_spacing
;
1227 if (width
) (*width
) = m_width
- dw
;
1228 if (height
) (*height
) = m_height
- dh
;
1232 void wxWindow::GetPosition( int *x
, int *y
) const
1238 void wxWindow::ClientToScreen( int *x
, int *y
)
1240 // Does this look simple ?
1242 GdkWindow
*source
= NULL
;
1244 source
= m_wxwindow
->window
;
1246 source
= m_widget
->window
;
1250 gdk_window_get_origin( source
, &org_x
, &org_y
);
1254 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1256 org_x
+= m_widget
->allocation
.x
;
1257 org_y
+= m_widget
->allocation
.y
;
1265 void wxWindow::ScreenToClient( int *x
, int *y
)
1267 GdkWindow
*source
= NULL
;
1269 source
= m_wxwindow
->window
;
1271 source
= m_widget
->window
;
1275 gdk_window_get_origin( source
, &org_x
, &org_y
);
1279 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1281 org_x
+= m_widget
->allocation
.x
;
1282 org_y
+= m_widget
->allocation
.y
;
1290 void wxWindow::Centre( int direction
)
1294 GetPosition( &x
, &y
);
1295 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
1297 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (gdk_screen_width () - m_width
) / 2;
1298 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (gdk_screen_height () - m_height
) / 2;
1299 gtk_widget_set_uposition( m_widget
, x
, y
);
1307 m_parent
->GetSize( &p_w
, &p_h
);
1308 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (p_w
- m_width
) / 2;
1309 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (p_h
- m_height
) / 2;
1310 gtk_widget_set_uposition( m_widget
, x
, y
);
1315 void wxWindow::Fit(void)
1319 wxNode
*node
= GetChildren()->First();
1322 wxWindow
*win
= (wxWindow
*)node
->Data();
1324 win
->GetPosition(&wx
, &wy
);
1325 win
->GetSize(&ww
, &wh
);
1326 if ( wx
+ ww
> maxX
)
1328 if ( wy
+ wh
> maxY
)
1331 node
= node
->Next();
1333 SetClientSize(maxX
+ 5, maxY
+ 5);
1336 void wxWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1338 //if (GetAutoLayout()) Layout();
1341 bool wxWindow::Show( bool show
)
1344 gtk_widget_show( m_widget
);
1346 gtk_widget_hide( m_widget
);
1351 void wxWindow::Enable( bool enable
)
1353 m_isEnabled
= enable
;
1354 gtk_widget_set_sensitive( m_widget
, enable
);
1355 if (m_wxwindow
) gtk_widget_set_sensitive( m_wxwindow
, enable
);
1358 void wxWindow::MakeModal( bool modal
)
1361 // Disable all other windows
1362 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
1364 wxNode
*node
= wxTopLevelWindows
.First();
1367 wxWindow
*win
= (wxWindow
*)node
->Data();
1369 win
->Enable(!modal
);
1371 node
= node
->Next();
1376 void wxWindow::SetFocus(void)
1378 GtkWidget
*connect_widget
= m_widget
;
1379 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1382 if (GTK_WIDGET_CAN_FOCUS(connect_widget
) && !GTK_WIDGET_HAS_FOCUS (connect_widget
) )
1384 gtk_widget_grab_focus (connect_widget
);
1389 bool wxWindow::OnClose(void)
1391 printf( "OnClose event.\n" );
1395 void wxWindow::AddChild( wxWindow
*child
)
1397 // Addchild is (often) called before the program
1398 // has left the parents constructor so that no
1399 // virtual tables work yet. The approach below
1400 // practically imitates virtual tables, i.e. it
1401 // implements a different AddChild() behaviour
1402 // for wxFrame, wxDialog, wxWindow and
1403 // wxMDIParentFrame.
1405 if (IsKindOf(CLASSINFO(wxMDIParentFrame
)))
1407 if (child
->IsKindOf(CLASSINFO(wxMDIChildFrame
)))
1409 wxMDIClientWindow
*client
= ((wxMDIParentFrame
*)this)->GetClientWindow();
1412 client
->AddChild( child
);
1418 if (IsKindOf(CLASSINFO(wxNotebook
)))
1420 wxNotebook
*tab
= (wxNotebook
*)this;
1421 tab
->AddChild( child
);
1425 m_children
.Append( child
);
1426 if (child
->IsKindOf(CLASSINFO(wxFrame
)) || child
->IsKindOf(CLASSINFO(wxDialog
)))
1428 if ((child
->m_x
!= -1) && (child
->m_y
!= -1))
1429 gtk_widget_set_uposition( child
->m_widget
, child
->m_x
, child
->m_y
);
1434 gtk_myfixed_put( GTK_MYFIXED(m_wxwindow
), child
->m_widget
, child
->m_x
, child
->m_y
);
1436 gtk_widget_set_usize( child
->m_widget
, child
->m_width
, child
->m_height
);
1439 wxList
*wxWindow::GetChildren(void)
1441 return (&m_children
);
1444 void wxWindow::RemoveChild( wxWindow
*child
)
1447 GetChildren()->DeleteObject( child
);
1448 child
->m_parent
= NULL
;
1451 void wxWindow::SetReturnCode( int retCode
)
1453 m_retCode
= retCode
;
1456 int wxWindow::GetReturnCode(void)
1461 wxWindow
*wxWindow::GetParent(void)
1466 wxEvtHandler
*wxWindow::GetEventHandler(void)
1468 return m_eventHandler
;
1471 void wxWindow::SetEventhandler( wxEvtHandler
*handler
)
1473 m_eventHandler
= handler
;
1476 wxValidator
*wxWindow::GetValidator(void)
1478 return m_windowValidator
;
1481 void wxWindow::SetValidator( wxValidator
*validator
)
1483 m_windowValidator
= validator
;
1486 bool wxWindow::IsBeingDeleted(void)
1491 void wxWindow::SetId( wxWindowID id
)
1496 wxWindowID
wxWindow::GetId(void)
1501 void wxWindow::SetCursor( const wxCursor
&cursor
)
1503 if (*m_cursor
== cursor
) return;
1504 (*m_cursor
) = cursor
;
1505 if (m_widget
->window
)
1506 gdk_window_set_cursor( m_widget
->window
, m_cursor
->GetCursor() );
1507 if (m_wxwindow
&& m_wxwindow
->window
)
1508 gdk_window_set_cursor( m_wxwindow
->window
, m_cursor
->GetCursor() );
1511 void wxWindow::Refresh( bool eraseBackground
, const wxRect
*rect
)
1513 if (eraseBackground
&& m_wxwindow
&& m_wxwindow
->window
)
1516 gdk_window_clear_area( m_wxwindow
->window
,
1528 wxClientDC
dc(this);
1532 dc
.GetInternalDeviceOrigin( &x
, &y
);
1536 GetClientSize( &w
, &h
);
1538 GdkRectangle gdk_rect
;
1542 gdk_rect
.height
= h
;
1543 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1548 GdkRectangle gdk_rect
;
1549 gdk_rect
.x
= rect
->x
;
1550 gdk_rect
.y
= rect
->y
;
1551 gdk_rect
.width
= rect
->width
;
1552 gdk_rect
.height
= rect
->height
;
1554 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1556 gtk_widget_draw( m_widget
, &gdk_rect
);
1560 bool wxWindow::IsExposed( long x
, long y
)
1562 return (m_updateRegion
.Contains( x
, y
) != wxOutRegion
);
1565 bool wxWindow::IsExposed( long x
, long y
, long width
, long height
)
1567 return (m_updateRegion
.Contains( x
, y
, width
, height
) != wxOutRegion
);
1570 void wxWindow::Clear(void)
1572 if (m_wxwindow
&& m_wxwindow
->window
) gdk_window_clear( m_wxwindow
->window
);
1575 wxColour
wxWindow::GetBackgroundColour(void) const
1577 return m_backgroundColour
;
1580 void wxWindow::SetBackgroundColour( const wxColour
&colour
)
1582 m_backgroundColour
= colour
;
1585 m_backgroundColour
.CalcPixel( m_wxwindow
->style
->colormap
);
1586 gdk_window_set_background( m_wxwindow
->window
, m_backgroundColour
.GetColor() );
1587 gdk_window_clear( m_wxwindow
->window
);
1592 bool wxWindow::Validate(void)
1594 wxNode
*node
= GetChildren()->First();
1597 wxWindow
*child
= (wxWindow
*)node
->Data();
1598 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this))
1600 node
= node
->Next();
1605 bool wxWindow::TransferDataToWindow(void)
1607 wxNode
*node
= GetChildren()->First();
1610 wxWindow
*child
= (wxWindow
*)node
->Data();
1611 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */
1612 !child
->GetValidator()->TransferToWindow() )
1614 wxMessageBox( "Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
1617 node
= node
->Next();
1622 bool wxWindow::TransferDataFromWindow(void)
1624 wxNode
*node
= GetChildren()->First();
1627 wxWindow
*child
= (wxWindow
*)node
->Data();
1628 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
1630 node
= node
->Next();
1635 void wxWindow::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
1637 TransferDataToWindow();
1640 void wxWindow::InitDialog(void)
1642 wxInitDialogEvent
event(GetId());
1643 event
.SetEventObject( this );
1644 GetEventHandler()->ProcessEvent(event
);
1647 void wxWindow::SetDropTarget( wxDropTarget
*dropTarget
)
1649 GtkWidget
*connect_widget
= m_widget
;
1650 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1653 m_pDropTarget
->UnregisterWidget( connect_widget
);
1654 delete m_pDropTarget
;
1656 m_pDropTarget
= dropTarget
;
1659 m_pDropTarget
->RegisterWidget( connect_widget
);
1663 wxDropTarget
*wxWindow::GetDropTarget() const
1665 return m_pDropTarget
;
1668 void wxWindow::SetFont( const wxFont
&font
)
1673 copy old style values to new one
1674 set font in new style
1675 -> takes to many resources
1677 GtkStyle *style = gtk_style_new();
1682 wxFont
*wxWindow::GetFont(void)
1687 void wxWindow::SetWindowStyleFlag( long flag
)
1689 m_windowStyle
= flag
;
1692 long wxWindow::GetWindowStyleFlag(void) const
1694 return m_windowStyle
;
1697 void wxWindow::CaptureMouse(void)
1699 GtkWidget
*connect_widget
= m_widget
;
1700 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1701 gtk_grab_add( connect_widget
);
1702 gdk_pointer_grab ( connect_widget
->window
, FALSE
,
1704 (GDK_BUTTON_PRESS_MASK
|
1705 GDK_BUTTON_RELEASE_MASK
|
1706 GDK_POINTER_MOTION_MASK
),
1707 NULL
, NULL
, GDK_CURRENT_TIME
);
1710 void wxWindow::ReleaseMouse(void)
1712 GtkWidget
*connect_widget
= m_widget
;
1713 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1714 gtk_grab_remove( connect_widget
);
1715 gdk_pointer_ungrab ( GDK_CURRENT_TIME
);
1718 void wxWindow::SetTitle( const wxString
&WXUNUSED(title
) )
1722 wxString
wxWindow::GetTitle(void) const
1724 return (wxString
&)m_windowName
;
1727 wxString
wxWindow::GetLabel(void) const
1732 void wxWindow::SetName( const wxString
&name
)
1734 m_windowName
= name
;
1737 wxString
wxWindow::GetName(void) const
1739 return (wxString
&)m_windowName
;
1742 bool wxWindow::IsShown(void) const
1747 bool wxWindow::IsRetained(void)
1752 wxWindow
*wxWindow::FindWindow( long id
)
1754 if (id
== m_windowId
) return this;
1755 wxNode
*node
= m_children
.First();
1758 wxWindow
*child
= (wxWindow
*)node
->Data();
1759 wxWindow
*res
= child
->FindWindow( id
);
1760 if (res
) return res
;
1761 node
= node
->Next();
1766 wxWindow
*wxWindow::FindWindow( const wxString
& name
)
1768 if (name
== m_windowName
) return this;
1769 wxNode
*node
= m_children
.First();
1772 wxWindow
*child
= (wxWindow
*)node
->Data();
1773 wxWindow
*res
= child
->FindWindow( name
);
1774 if (res
) return res
;
1775 node
= node
->Next();
1780 void wxWindow::SetScrollbar( int orient
, int pos
, int thumbVisible
,
1781 int range
, bool WXUNUSED(refresh
) )
1783 if (!m_wxwindow
) return;
1785 if (orient
== wxHORIZONTAL
)
1787 float fpos
= (float)pos
;
1788 m_oldHorizontalPos
= fpos
;
1789 float frange
= (float)range
;
1790 float fthumb
= (float)thumbVisible
;
1792 if ((fabs(fpos
-m_hAdjust
->value
) < 0.2) &&
1793 (fabs(frange
-m_hAdjust
->upper
) < 0.2) &&
1794 (fabs(fthumb
-m_hAdjust
->page_size
) < 0.2))
1797 m_hAdjust
->lower
= 0.0;
1798 m_hAdjust
->upper
= frange
;
1799 m_hAdjust
->value
= fpos
;
1800 m_hAdjust
->step_increment
= 1.0;
1801 m_hAdjust
->page_increment
= (float)(wxMax(fthumb
-2,0));
1802 m_hAdjust
->page_size
= fthumb
;
1806 float fpos
= (float)pos
;
1807 m_oldVerticalPos
= fpos
;
1808 float frange
= (float)range
;
1809 float fthumb
= (float)thumbVisible
;
1811 if ((fabs(fpos
-m_vAdjust
->value
) < 0.2) &&
1812 (fabs(frange
-m_vAdjust
->upper
) < 0.2) &&
1813 (fabs(fthumb
-m_vAdjust
->page_size
) < 0.2))
1816 m_vAdjust
->lower
= 0.0;
1817 m_vAdjust
->upper
= frange
;
1818 m_vAdjust
->value
= fpos
;
1819 m_vAdjust
->step_increment
= 1.0;
1820 m_vAdjust
->page_increment
= (float)(wxMax(fthumb
-2,0));
1821 m_vAdjust
->page_size
= fthumb
;
1824 if (m_wxwindow
->window
)
1826 if (orient
== wxHORIZONTAL
)
1827 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
1829 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
1831 // gtk_widget_set_usize( m_widget, m_width, m_height );
1835 void wxWindow::SetScrollPos( int orient
, int pos
, bool WXUNUSED(refresh
) )
1837 if (!m_wxwindow
) return;
1839 if (orient
== wxHORIZONTAL
)
1841 float fpos
= (float)pos
;
1842 m_oldHorizontalPos
= fpos
;
1844 if (fabs(fpos
-m_hAdjust
->value
) < 0.2) return;
1845 m_hAdjust
->value
= fpos
;
1849 float fpos
= (float)pos
;
1850 m_oldVerticalPos
= fpos
;
1851 if (fabs(fpos
-m_vAdjust
->value
) < 0.2) return;
1852 m_vAdjust
->value
= fpos
;
1855 if (m_wxwindow
->window
)
1857 if (orient
== wxHORIZONTAL
)
1858 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
1860 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
1864 int wxWindow::GetScrollThumb( int orient
) const
1866 if (!m_wxwindow
) return 0;
1868 if (orient
== wxHORIZONTAL
)
1869 return (int)(m_hAdjust
->page_size
+0.5);
1871 return (int)(m_vAdjust
->page_size
+0.5);
1874 int wxWindow::GetScrollPos( int orient
) const
1876 if (!m_wxwindow
) return 0;
1878 if (orient
== wxHORIZONTAL
)
1879 return (int)(m_hAdjust
->value
+0.5);
1881 return (int)(m_vAdjust
->value
+0.5);
1884 int wxWindow::GetScrollRange( int orient
) const
1886 if (!m_wxwindow
) return 0;
1888 if (orient
== wxHORIZONTAL
)
1889 return (int)(m_hAdjust
->upper
+0.5);
1891 return (int)(m_vAdjust
->upper
+0.5);
1894 void wxWindow::ScrollWindow( int dx
, int dy
, const wxRect
* WXUNUSED(rect
) )
1896 if (!m_wxwindow
) return;
1898 m_drawingOffsetX
+= dx
;
1899 m_drawingOffsetY
+= dy
;
1901 // printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
1903 gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow
), m_drawingOffsetX
, m_drawingOffsetY
);
1906 The code here is very nifty, but it doesn't work with
1907 overlapping windows...
1911 GetClientSize( &cw, &ch );
1913 int w = cw - abs(dx);
1914 int h = ch - abs(dy);
1915 if ((h < 0) || (w < 0))
1922 if (dx < 0) s_x = -dx;
1923 if (dy < 0) s_y = -dy;
1926 if (dx > 0) d_x = dx;
1927 if (dy > 0) d_y = dy;
1928 gdk_window_copy_area( m_wxwindow->window, m_wxwindow->style->fg_gc[0], d_x, d_y,
1929 m_wxwindow->window, s_x, s_y, w, h );
1932 if (dx < 0) rect.x = cw+dx; else rect.x = 0;
1933 if (dy < 0) rect.y = ch+dy; else rect.y = 0;
1934 if (dy != 0) rect.width = cw; else rect.width = abs(dx);
1935 if (dx != 0) rect.height = ch; else rect.height = abs(dy);
1937 Refresh( TRUE, &rect );
1941 void wxWindow::GetDrawingOffset( long *x
, long *y
)
1943 if (x
) *x
= m_drawingOffsetX
;
1944 if (y
) *y
= m_drawingOffsetY
;
1947 //-------------------------------------------------------------------------------------
1949 //-------------------------------------------------------------------------------------
1951 wxLayoutConstraints
*wxWindow::GetConstraints(void) const
1953 return m_constraints
;
1956 void wxWindow::SetConstraints( wxLayoutConstraints
*constraints
)
1960 UnsetConstraints(m_constraints
);
1961 delete m_constraints
;
1963 m_constraints
= constraints
;
1966 // Make sure other windows know they're part of a 'meaningful relationship'
1967 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
1968 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1969 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
1970 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1971 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
1972 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1973 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
1974 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1975 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
1976 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1977 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
1978 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1979 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
1980 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1981 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
1982 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1988 void wxWindow::SetAutoLayout( bool autoLayout
)
1990 m_autoLayout
= autoLayout
;
1993 bool wxWindow::GetAutoLayout(void) const
1995 return m_autoLayout
;
1998 wxSizer
*wxWindow::GetSizer(void) const
2000 return m_windowSizer
;
2003 void wxWindow::SetSizerParent( wxWindow
*win
)
2005 m_sizerParent
= win
;
2008 wxWindow
*wxWindow::GetSizerParent(void) const
2010 return m_sizerParent
;
2013 // This removes any dangling pointers to this window
2014 // in other windows' constraintsInvolvedIn lists.
2015 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
2019 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2020 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2021 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2022 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2023 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
2024 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2025 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
2026 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2027 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
2028 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2029 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
2030 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2031 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
2032 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2033 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
2034 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2038 // Back-pointer to other windows we're involved with, so if we delete
2039 // this window, we must delete any constraints we're involved with.
2040 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
2042 if (!m_constraintsInvolvedIn
)
2043 m_constraintsInvolvedIn
= new wxList
;
2044 if (!m_constraintsInvolvedIn
->Member(otherWin
))
2045 m_constraintsInvolvedIn
->Append(otherWin
);
2048 // REMOVE back-pointer to other windows we're involved with.
2049 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
2051 if (m_constraintsInvolvedIn
)
2052 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
2055 // Reset any constraints that mention this window
2056 void wxWindow::DeleteRelatedConstraints(void)
2058 if (m_constraintsInvolvedIn
)
2060 wxNode
*node
= m_constraintsInvolvedIn
->First();
2063 wxWindow
*win
= (wxWindow
*)node
->Data();
2064 wxNode
*next
= node
->Next();
2065 wxLayoutConstraints
*constr
= win
->GetConstraints();
2067 // Reset any constraints involving this window
2070 constr
->left
.ResetIfWin((wxWindow
*)this);
2071 constr
->top
.ResetIfWin((wxWindow
*)this);
2072 constr
->right
.ResetIfWin((wxWindow
*)this);
2073 constr
->bottom
.ResetIfWin((wxWindow
*)this);
2074 constr
->width
.ResetIfWin((wxWindow
*)this);
2075 constr
->height
.ResetIfWin((wxWindow
*)this);
2076 constr
->centreX
.ResetIfWin((wxWindow
*)this);
2077 constr
->centreY
.ResetIfWin((wxWindow
*)this);
2082 delete m_constraintsInvolvedIn
;
2083 m_constraintsInvolvedIn
= NULL
;
2087 void wxWindow::SetSizer(wxSizer
*sizer
)
2089 m_windowSizer
= sizer
;
2091 sizer
->SetSizerParent((wxWindow
*)this);
2098 bool wxWindow::Layout(void)
2100 if (GetConstraints())
2103 GetClientSize(&w
, &h
);
2104 GetConstraints()->width
.SetValue(w
);
2105 GetConstraints()->height
.SetValue(h
);
2108 // If top level (one sizer), evaluate the sizer's constraints.
2112 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
2113 GetSizer()->LayoutPhase1(&noChanges
);
2114 GetSizer()->LayoutPhase2(&noChanges
);
2115 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
2120 // Otherwise, evaluate child constraints
2121 ResetConstraints(); // Mark all constraints as unevaluated
2122 DoPhase(1); // Just one phase need if no sizers involved
2124 SetConstraintSizes(); // Recursively set the real window sizes
2130 // Do a phase of evaluating constraints:
2131 // the default behaviour. wxSizers may do a similar
2132 // thing, but also impose their own 'constraints'
2133 // and order the evaluation differently.
2134 bool wxWindow::LayoutPhase1(int *noChanges
)
2136 wxLayoutConstraints
*constr
= GetConstraints();
2139 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
2145 bool wxWindow::LayoutPhase2(int *noChanges
)
2155 // Do a phase of evaluating child constraints
2156 bool wxWindow::DoPhase(int phase
)
2158 int noIterations
= 0;
2159 int maxIterations
= 500;
2163 while ((noChanges
> 0) && (noIterations
< maxIterations
))
2167 wxNode
*node
= GetChildren()->First();
2170 wxWindow
*child
= (wxWindow
*)node
->Data();
2171 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
2173 wxLayoutConstraints
*constr
= child
->GetConstraints();
2176 if (succeeded
.Member(child
))
2181 int tempNoChanges
= 0;
2182 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
2183 noChanges
+= tempNoChanges
;
2186 succeeded
.Append(child
);
2191 node
= node
->Next();
2198 void wxWindow::ResetConstraints(void)
2200 wxLayoutConstraints
*constr
= GetConstraints();
2203 constr
->left
.SetDone(FALSE
);
2204 constr
->top
.SetDone(FALSE
);
2205 constr
->right
.SetDone(FALSE
);
2206 constr
->bottom
.SetDone(FALSE
);
2207 constr
->width
.SetDone(FALSE
);
2208 constr
->height
.SetDone(FALSE
);
2209 constr
->centreX
.SetDone(FALSE
);
2210 constr
->centreY
.SetDone(FALSE
);
2212 wxNode
*node
= GetChildren()->First();
2215 wxWindow
*win
= (wxWindow
*)node
->Data();
2216 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2217 win
->ResetConstraints();
2218 node
= node
->Next();
2222 // Need to distinguish between setting the 'fake' size for
2223 // windows and sizers, and setting the real values.
2224 void wxWindow::SetConstraintSizes(bool recurse
)
2226 wxLayoutConstraints
*constr
= GetConstraints();
2227 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
2228 constr
->width
.GetDone() && constr
->height
.GetDone())
2230 int x
= constr
->left
.GetValue();
2231 int y
= constr
->top
.GetValue();
2232 int w
= constr
->width
.GetValue();
2233 int h
= constr
->height
.GetValue();
2235 // If we don't want to resize this window, just move it...
2236 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
2237 (constr
->height
.GetRelationship() != wxAsIs
))
2239 // Calls Layout() recursively. AAAGH. How can we stop that.
2240 // Simply take Layout() out of non-top level OnSizes.
2241 SizerSetSize(x
, y
, w
, h
);
2250 char *windowClass
= this->GetClassInfo()->GetClassName();
2253 if (GetName() == "")
2254 winName
= "unnamed";
2256 winName
= GetName();
2257 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
2258 if (!constr
->left
.GetDone())
2259 wxDebugMsg(" unsatisfied 'left' constraint.\n");
2260 if (!constr
->right
.GetDone())
2261 wxDebugMsg(" unsatisfied 'right' constraint.\n");
2262 if (!constr
->width
.GetDone())
2263 wxDebugMsg(" unsatisfied 'width' constraint.\n");
2264 if (!constr
->height
.GetDone())
2265 wxDebugMsg(" unsatisfied 'height' constraint.\n");
2266 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
2271 wxNode
*node
= GetChildren()->First();
2274 wxWindow
*win
= (wxWindow
*)node
->Data();
2275 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2276 win
->SetConstraintSizes();
2277 node
= node
->Next();
2282 // This assumes that all sizers are 'on' the same
2283 // window, i.e. the parent of this window.
2284 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
2286 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
2287 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
2291 m_sizerParent
->GetPosition(&xp
, &yp
);
2292 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
2297 void wxWindow::SizerSetSize(int x
, int y
, int w
, int h
)
2301 TransformSizerToActual(&xx
, &yy
);
2302 SetSize(xx
, yy
, w
, h
);
2305 void wxWindow::SizerMove(int x
, int y
)
2309 TransformSizerToActual(&xx
, &yy
);
2313 // Only set the size/position of the constraint (if any)
2314 void wxWindow::SetSizeConstraint(int x
, int y
, int w
, int h
)
2316 wxLayoutConstraints
*constr
= GetConstraints();
2321 constr
->left
.SetValue(x
);
2322 constr
->left
.SetDone(TRUE
);
2326 constr
->top
.SetValue(y
);
2327 constr
->top
.SetDone(TRUE
);
2331 constr
->width
.SetValue(w
);
2332 constr
->width
.SetDone(TRUE
);
2336 constr
->height
.SetValue(h
);
2337 constr
->height
.SetDone(TRUE
);
2342 void wxWindow::MoveConstraint(int x
, int y
)
2344 wxLayoutConstraints
*constr
= GetConstraints();
2349 constr
->left
.SetValue(x
);
2350 constr
->left
.SetDone(TRUE
);
2354 constr
->top
.SetValue(y
);
2355 constr
->top
.SetDone(TRUE
);
2360 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
2362 wxLayoutConstraints
*constr
= GetConstraints();
2365 *w
= constr
->width
.GetValue();
2366 *h
= constr
->height
.GetValue();
2372 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
2374 wxLayoutConstraints
*constr
= GetConstraints();
2377 *w
= constr
->width
.GetValue();
2378 *h
= constr
->height
.GetValue();
2381 GetClientSize(w
, h
);
2384 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
2386 wxLayoutConstraints
*constr
= GetConstraints();
2389 *x
= constr
->left
.GetValue();
2390 *y
= constr
->top
.GetValue();
2396 bool wxWindow::AcceptsFocus() const
2398 return IsEnabled() && IsShown();