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 "gdk/gdkkeysyms.h"
30 #include "wx/gtk/win_gtk.h"
31 #include "gdk/gdkprivate.h"
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 extern wxList wxPendingDelete
;
38 extern wxList wxTopLevelWindows
;
39 extern bool g_blockEventsOnDrag
;
41 //-----------------------------------------------------------------------------
42 // GTK callbacks for wxWindows event system
43 //-----------------------------------------------------------------------------
45 //-----------------------------------------------------------------------------
46 // expose (of m_wxwindow, not of m_widget)
48 void gtk_window_expose_callback( GtkWidget
*WXUNUSED(widget
), GdkEventExpose
*gdk_event
, wxWindow
*win
)
50 if (!win
->HasVMT()) return;
51 if (g_blockEventsOnDrag
) return;
54 printf( "OnExpose from " );
55 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
56 printf( win->GetClassInfo()->GetClassName() );
59 printf( "x: %d \n", gdk_event->area.x );
60 printf( "y: %d \n", gdk_event->area.y );
61 printf( "w: %d \n", gdk_event->area.width );
62 printf( "h: %d \n", gdk_event->area.height );
65 win
->m_updateRegion
.Union( gdk_event
->area
.x
,
67 gdk_event
->area
.width
,
68 gdk_event
->area
.height
);
70 if (gdk_event
->count
> 0) return;
72 wxPaintEvent
event( win
->GetId() );
73 event
.SetEventObject( win
);
74 win
->ProcessEvent( event
);
76 win
->m_updateRegion
.Clear();
79 //-----------------------------------------------------------------------------
80 // draw (of m_wxwindow, not of m_widget)
82 void gtk_window_draw_callback( GtkWidget
*WXUNUSED(widget
), GdkRectangle
*rect
, wxWindow
*win
)
84 if (!win
->HasVMT()) return;
85 if (g_blockEventsOnDrag
) return;
88 printf( "OnDraw from " );
89 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
90 printf( win->GetClassInfo()->GetClassName() );
93 printf( "x: %d \n", rect->x );
94 printf( "y: %d \n", rect->y );
95 printf( "w: %d \n", rect->width );
96 printf( "h: %d \n", rect->height );
99 win
->m_updateRegion
.Union( rect
->x
, rect
->y
, rect
->width
, rect
->height
);
101 wxPaintEvent
event( win
->GetId() );
102 event
.SetEventObject( win
);
103 win
->ProcessEvent( event
);
105 win
->m_updateRegion
.Clear();
108 //-----------------------------------------------------------------------------
110 // I don't any longer intercept GTK's internal resize events (except frames)
113 void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
115 if (!win->HasVMT()) return;
116 if (g_blockEventsOnDrag) return;
120 if ((win->m_x == alloc->x) &&
121 (win->m_y == alloc->y) &&
122 (win->m_width == alloc->width) &&
123 (win->m_height == alloc->height))
128 printf( "OnResize from " );
129 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
130 printf( win->GetClassInfo()->GetClassName() );
133 printf( " Old: X: %d Y: %d ", win->m_x, win->m_y );
134 printf( " W: %d H: %d ", win->m_width, win->m_height );
137 printf( " New: X: %d Y: %d ", alloc->x, alloc->y );
138 printf( " W: %d H: %d ", alloc->width, alloc->height );
141 wxSizeEvent event( wxSize( alloc->width, alloc->height), win->GetId() );
142 event.SetEventObject( win );
143 win->ProcessEvent( event );
147 //-----------------------------------------------------------------------------
150 gint
gtk_window_key_press_callback( GtkWidget
*WXUNUSED(widget
), GdkEventKey
*gdk_event
, wxWindow
*win
)
152 if (!win
->HasVMT()) return FALSE
;
153 if (g_blockEventsOnDrag
) return FALSE
;
156 printf( "OnKeyPress from " );
157 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
158 printf( win->GetClassInfo()->GetClassName() );
163 switch (gdk_event
->keyval
)
165 case GDK_BackSpace
: key_code
= WXK_BACK
; break;
166 case GDK_Tab
: key_code
= WXK_TAB
; break;
167 case GDK_Linefeed
: key_code
= WXK_RETURN
; break;
168 case GDK_Clear
: key_code
= WXK_CLEAR
; break;
169 case GDK_Return
: key_code
= WXK_RETURN
; break;
170 case GDK_Pause
: key_code
= WXK_PAUSE
; break;
171 case GDK_Scroll_Lock
: key_code
= WXK_SCROLL
; break;
172 case GDK_Escape
: key_code
= WXK_ESCAPE
; break;
173 case GDK_Delete
: key_code
= WXK_DELETE
; break;
174 case GDK_Home
: key_code
= WXK_HOME
; break;
175 case GDK_Left
: key_code
= WXK_LEFT
; break;
176 case GDK_Up
: key_code
= WXK_UP
; break;
177 case GDK_Right
: key_code
= WXK_RIGHT
; break;
178 case GDK_Down
: key_code
= WXK_DOWN
; break;
179 case GDK_Prior
: key_code
= WXK_PRIOR
; break;
180 // case GDK_Page_Up: key_code = WXK_PAGEUP; break;
181 case GDK_Next
: key_code
= WXK_NEXT
; break;
182 // case GDK_Page_Down: key_code = WXK_PAGEDOWN; break;
183 case GDK_End
: key_code
= WXK_END
; break;
184 case GDK_Begin
: key_code
= WXK_HOME
; break;
185 case GDK_Select
: key_code
= WXK_SELECT
; break;
186 case GDK_Print
: key_code
= WXK_PRINT
; break;
187 case GDK_Execute
: key_code
= WXK_EXECUTE
; break;
188 case GDK_Insert
: key_code
= WXK_INSERT
; break;
189 case GDK_Num_Lock
: key_code
= WXK_NUMLOCK
; break;
190 case GDK_KP_Tab
: key_code
= WXK_TAB
; break;
191 case GDK_KP_Enter
: key_code
= WXK_RETURN
; break;
192 case GDK_KP_Home
: key_code
= WXK_HOME
; break;
193 case GDK_KP_Left
: key_code
= WXK_LEFT
; break;
194 case GDK_KP_Up
: key_code
= WXK_UP
; break;
195 case GDK_KP_Right
: key_code
= WXK_RIGHT
; break;
196 case GDK_KP_Down
: key_code
= WXK_DOWN
; break;
197 case GDK_KP_Prior
: key_code
= WXK_PRIOR
; break;
198 // case GDK_KP_Page_Up: key_code = WXK_PAGEUP; break;
199 case GDK_KP_Next
: key_code
= WXK_NEXT
; break;
200 // case GDK_KP_Page_Down: key_code = WXK_PAGEDOWN; break;
201 case GDK_KP_End
: key_code
= WXK_END
; break;
202 case GDK_KP_Begin
: key_code
= WXK_HOME
; break;
203 case GDK_KP_Insert
: key_code
= WXK_INSERT
; break;
204 case GDK_KP_Delete
: key_code
= WXK_DELETE
; break;
205 case GDK_KP_Multiply
: key_code
= WXK_MULTIPLY
; break;
206 case GDK_KP_Add
: key_code
= WXK_ADD
; break;
207 case GDK_KP_Separator
: key_code
= WXK_SEPARATOR
; break;
208 case GDK_KP_Subtract
: key_code
= WXK_SUBTRACT
; break;
209 case GDK_KP_Decimal
: key_code
= WXK_DECIMAL
; break;
210 case GDK_KP_Divide
: key_code
= WXK_DIVIDE
; break;
211 case GDK_KP_0
: key_code
= WXK_NUMPAD0
; break;
212 case GDK_KP_1
: key_code
= WXK_NUMPAD1
; break;
213 case GDK_KP_2
: key_code
= WXK_NUMPAD2
; break;
214 case GDK_KP_3
: key_code
= WXK_NUMPAD3
; break;
215 case GDK_KP_4
: key_code
= WXK_NUMPAD4
; break;
216 case GDK_KP_5
: key_code
= WXK_NUMPAD5
; break;
217 case GDK_KP_6
: key_code
= WXK_NUMPAD6
; break;
218 case GDK_KP_7
: key_code
= WXK_NUMPAD7
; break;
219 case GDK_KP_8
: key_code
= WXK_NUMPAD7
; break;
220 case GDK_KP_9
: key_code
= WXK_NUMPAD9
; break;
221 case GDK_F1
: key_code
= WXK_F1
; break;
222 case GDK_F2
: key_code
= WXK_F2
; break;
223 case GDK_F3
: key_code
= WXK_F3
; break;
224 case GDK_F4
: key_code
= WXK_F4
; break;
225 case GDK_F5
: key_code
= WXK_F5
; break;
226 case GDK_F6
: key_code
= WXK_F6
; break;
227 case GDK_F7
: key_code
= WXK_F7
; break;
228 case GDK_F8
: key_code
= WXK_F8
; break;
229 case GDK_F9
: key_code
= WXK_F9
; break;
230 case GDK_F10
: key_code
= WXK_F10
; break;
231 case GDK_F11
: key_code
= WXK_F11
; break;
232 case GDK_F12
: key_code
= WXK_F12
; break;
235 if ((gdk_event
->keyval
>= 0x20) && (gdk_event
->keyval
<= 0xFF))
236 key_code
= gdk_event
->keyval
;
240 if (!key_code
) return FALSE
;
242 wxKeyEvent
event( wxEVT_CHAR
);
243 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
244 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
245 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
246 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
247 event
.m_keyCode
= key_code
;
250 event
.SetEventObject( win
);
251 return win
->ProcessEvent( event
);
254 //-----------------------------------------------------------------------------
257 gint
gtk_window_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
259 if (widget
->window
!= gdk_event
->window
) return FALSE
;
260 if (g_blockEventsOnDrag
) return FALSE
;
264 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
) && !GTK_WIDGET_HAS_FOCUS (win
->m_wxwindow
) )
266 gtk_widget_grab_focus (win
->m_wxwindow
);
269 printf( "GrabFocus from " );
270 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
271 printf( win->GetClassInfo()->GetClassName() );
278 if (!win
->HasVMT()) return FALSE
;
281 printf( "OnButtonPress from " );
282 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
283 printf( win->GetClassInfo()->GetClassName() );
287 WXTYPE event_type
= wxEVT_LEFT_DOWN
;
289 if (gdk_event
->button
== 1)
291 switch (gdk_event
->type
)
293 case GDK_BUTTON_PRESS
: event_type
= wxEVT_LEFT_DOWN
; break;
294 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_LEFT_DCLICK
; break;
298 else if (gdk_event
->button
== 2)
300 switch (gdk_event
->type
)
302 case GDK_BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DOWN
; break;
303 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_MIDDLE_DCLICK
; break;
307 else if (gdk_event
->button
== 3)
309 switch (gdk_event
->type
)
311 case GDK_BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DOWN
; break;
312 case GDK_2BUTTON_PRESS
: event_type
= wxEVT_RIGHT_DCLICK
; break;
317 wxMouseEvent
event( event_type
);
318 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
319 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
320 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
321 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
322 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
323 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
324 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
326 event
.m_x
= (long)gdk_event
->x
;
327 event
.m_y
= (long)gdk_event
->y
;
328 event
.SetEventObject( win
);
330 win
->ProcessEvent( event
);
335 //-----------------------------------------------------------------------------
338 gint
gtk_window_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxWindow
*win
)
340 if (widget
->window
!= gdk_event
->window
) return TRUE
;
342 if (g_blockEventsOnDrag
) return FALSE
;
344 if (!win
->HasVMT()) return FALSE
;
347 printf( "OnButtonRelease from " );
348 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
349 printf( win->GetClassInfo()->GetClassName() );
353 WXTYPE event_type
= 0;
355 switch (gdk_event
->button
)
357 case 1: event_type
= wxEVT_LEFT_UP
; break;
358 case 2: event_type
= wxEVT_MIDDLE_UP
; break;
359 case 3: event_type
= wxEVT_RIGHT_UP
; break;
362 wxMouseEvent
event( event_type
);
363 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
364 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
365 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
366 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
367 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
368 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
369 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
370 event
.m_x
= (long)gdk_event
->x
;
371 event
.m_y
= (long)gdk_event
->y
;
372 event
.SetEventObject( win
);
374 return win
->ProcessEvent( event
);
377 //-----------------------------------------------------------------------------
380 gint
gtk_window_motion_notify_callback( GtkWidget
*widget
, GdkEventMotion
*gdk_event
, wxWindow
*win
)
382 if (widget
->window
!= gdk_event
->window
) return TRUE
;
384 if (g_blockEventsOnDrag
) return FALSE
;
386 if (!win
->HasVMT()) return FALSE
;
389 printf( "OnMotion from " );
390 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
391 printf( win->GetClassInfo()->GetClassName() );
395 wxMouseEvent
event( wxEVT_MOTION
);
396 event
.m_shiftDown
= (gdk_event
->state
& GDK_SHIFT_MASK
);
397 event
.m_controlDown
= (gdk_event
->state
& GDK_CONTROL_MASK
);
398 event
.m_altDown
= (gdk_event
->state
& GDK_MOD1_MASK
);
399 event
.m_metaDown
= (gdk_event
->state
& GDK_MOD2_MASK
);
400 event
.m_leftDown
= (gdk_event
->state
& GDK_BUTTON1_MASK
);
401 event
.m_middleDown
= (gdk_event
->state
& GDK_BUTTON2_MASK
);
402 event
.m_rightDown
= (gdk_event
->state
& GDK_BUTTON3_MASK
);
404 event
.m_x
= (long)gdk_event
->x
;
405 event
.m_y
= (long)gdk_event
->y
;
406 event
.SetEventObject( win
);
408 win
->ProcessEvent( event
);
413 //-----------------------------------------------------------------------------
416 void gtk_window_focus_in_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
418 if (g_blockEventsOnDrag
) return;
421 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
423 GTK_WIDGET_SET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
425 printf( "SetFocus flag from " );
426 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
427 printf( win->GetClassInfo()->GetClassName() );
433 if (!win
->HasVMT()) return;
436 printf( "OnSetFocus from " );
437 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
438 printf( win->GetClassInfo()->GetClassName() );
440 printf( WXSTRINGCAST win->GetLabel() );
444 wxFocusEvent
event( wxEVT_SET_FOCUS
, win
->GetId() );
445 event
.SetEventObject( win
);
446 win
->ProcessEvent( event
);
449 //-----------------------------------------------------------------------------
452 void gtk_window_focus_out_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
454 if (g_blockEventsOnDrag
) return;
457 if (GTK_WIDGET_CAN_FOCUS(win
->m_wxwindow
))
458 GTK_WIDGET_UNSET_FLAGS (win
->m_wxwindow
, GTK_HAS_FOCUS
);
461 if (!win
->HasVMT()) return;
464 printf( "OnKillFocus from " );
465 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
466 printf( win->GetClassInfo()->GetClassName() );
470 wxFocusEvent
event( wxEVT_KILL_FOCUS
, win
->GetId() );
471 event
.SetEventObject( win
);
472 win
->ProcessEvent( event
);
475 //-----------------------------------------------------------------------------
478 void gtk_window_vscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
480 if (g_blockEventsOnDrag
) return;
483 printf( "OnVScroll from " );
484 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
485 printf( win->GetClassInfo()->GetClassName() );
489 if (!win
->HasVMT()) return;
491 float diff
= win
->m_vAdjust
->value
- win
->m_oldVerticalPos
;
492 if (fabs(diff
) < 0.2) return;
495 int i = (int)(win->m_oldVerticalPos+0.5);
496 printf( "Old value: %d.\n", i );
497 i = (int)(win->m_vAdjust->value+0.5);
498 printf( "Sending new value: %d.\n", i );
503 float line_step
= win
->m_vAdjust
->step_increment
;
504 float page_step
= win
->m_vAdjust
->page_increment
;
506 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
507 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
508 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
509 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
510 else command
= wxEVT_SCROLL_THUMBTRACK
;
512 int value
= (int)(win
->m_vAdjust
->value
+0.5);
514 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
515 event
.SetEventObject( win
);
516 win
->ProcessEvent( event
);
519 //-----------------------------------------------------------------------------
522 void gtk_window_hscroll_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
524 if (g_blockEventsOnDrag
) return;
527 printf( "OnHScroll from " );
528 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
529 printf( win->GetClassInfo()->GetClassName() );
533 if (!win
->HasVMT()) return;
535 float diff
= win
->m_hAdjust
->value
- win
->m_oldHorizontalPos
;
536 if (fabs(diff
) < 0.2) return;
539 int i = (int)(win->m_oldHorizontalPos+0.5);
540 printf( "Old value: %d.\n", i );
541 i = (int)(win->m_hAdjust->value+0.5);
542 printf( "Sending new value: %d.\n", i );
547 float line_step
= win
->m_hAdjust
->step_increment
;
548 float page_step
= win
->m_hAdjust
->page_increment
;
550 if (fabs(diff
-line_step
) < 0.2) command
= wxEVT_SCROLL_LINEDOWN
;
551 else if (fabs(diff
+line_step
) < 0.2) command
= wxEVT_SCROLL_LINEUP
;
552 else if (fabs(diff
-page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEDOWN
;
553 else if (fabs(diff
+page_step
) < 0.2) command
= wxEVT_SCROLL_PAGEUP
;
554 else command
= wxEVT_SCROLL_THUMBTRACK
;
556 int value
= (int)(win
->m_hAdjust
->value
+0.5);
558 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
559 event
.SetEventObject( win
);
560 win
->ProcessEvent( event
);
563 //-----------------------------------------------------------------------------
564 // vertical scroll change
566 void gtk_window_vscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
568 if (g_blockEventsOnDrag
) return;
571 printf( "OnVScroll change from " );
572 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
573 printf( win->GetClassInfo()->GetClassName() );
577 if (!win
->HasVMT()) return;
579 int command
= wxEVT_SCROLL_THUMBTRACK
;
580 int value
= (int)(win
->m_vAdjust
->value
+0.5);
582 wxScrollEvent
event( command
, win
->GetId(), value
, wxVERTICAL
);
583 event
.SetEventObject( win
);
584 win
->ProcessEvent( event
);
587 //-----------------------------------------------------------------------------
588 // horizontal scroll change
590 void gtk_window_hscroll_change_callback( GtkWidget
*WXUNUSED(widget
), wxWindow
*win
)
592 if (g_blockEventsOnDrag
) return;
595 printf( "OnHScroll change from " );
596 if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
597 printf( win->GetClassInfo()->GetClassName() );
601 if (!win
->HasVMT()) return;
603 int command
= wxEVT_SCROLL_THUMBTRACK
;
604 int value
= (int)(win
->m_hAdjust
->value
+0.5);
606 wxScrollEvent
event( command
, win
->GetId(), value
, wxHORIZONTAL
);
607 event
.SetEventObject( win
);
608 win
->ProcessEvent( event
);
611 //-----------------------------------------------------------------------------
614 void gtk_window_drop_callback( GtkWidget
*widget
, GdkEvent
*event
, wxWindow
*win
)
616 printf( "OnDrop.\n" );
618 if (win
->GetDropTarget())
622 gdk_window_get_pointer( widget
->window
, &x
, &y
, NULL
);
623 win
->GetDropTarget()->Drop( event
, x
, y
);
627 g_free (event->dropdataavailable.data);
628 g_free (event->dropdataavailable.data_type);
632 //-----------------------------------------------------------------------------
635 bool gtk_window_destroy_callback( GtkWidget
*WXUNUSED(widget
), GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
637 printf( "OnDestroy from " );
638 if (win
->GetClassInfo() && win
->GetClassInfo()->GetClassName())
639 printf( win
->GetClassInfo()->GetClassName() );
641 printf( "Goodbye.\n" );
642 printf( " Robert Roebling.\n" );
647 //-----------------------------------------------------------------------------
650 bool gtk_window_enter_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*win
)
652 if (g_blockEventsOnDrag
) return FALSE
;
655 gdk_window_set_cursor( widget
->window
, win
->m_cursor
->GetCursor() );
660 //-----------------------------------------------------------------------------
663 bool gtk_window_leave_callback( GtkWidget
*widget
, GdkEvent
*WXUNUSED(event
), wxWindow
*WXUNUSED(win
) )
665 if (g_blockEventsOnDrag
) return FALSE
;
668 gdk_window_set_cursor( widget
->window
, wxSTANDARD_CURSOR
->GetCursor() );
673 //-----------------------------------------------------------------------------
674 // wxWindow implementation
675 //-----------------------------------------------------------------------------
677 IMPLEMENT_DYNAMIC_CLASS(wxWindow
,wxEvtHandler
)
679 BEGIN_EVENT_TABLE(wxWindow
, wxEvtHandler
)
680 // EVT_CHAR(wxWindow::OnChar)
681 EVT_SIZE(wxWindow::OnSize
)
682 // EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
683 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
684 EVT_INIT_DIALOG(wxWindow::OnInitDialog
)
685 // EVT_IDLE(wxWindow::OnIdle)
693 m_children
.DeleteContents( FALSE
);
699 m_eventHandler
= this;
700 m_windowValidator
= NULL
;
702 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
703 m_font
= *wxSWISS_FONT
;
705 m_windowName
= "noname";
706 m_constraints
= NULL
;
707 m_constraintsInvolvedIn
= NULL
;
708 m_windowSizer
= NULL
;
709 m_sizerParent
= NULL
;
710 m_autoLayout
= FALSE
;
714 m_hasScrolling
= FALSE
;
717 m_oldHorizontalPos
= 0.0;
718 m_oldVerticalPos
= 0.0;
721 m_drawingOffsetX
= 0;
722 m_drawingOffsetY
= 0;
723 m_pDropTarget
= NULL
;
726 wxWindow::wxWindow( wxWindow
*parent
, const wxWindowID id
,
727 const wxPoint
&pos
, const wxSize
&size
,
728 const long style
, const wxString
&name
)
730 Create( parent
, id
, pos
, size
, style
, name
);
733 bool wxWindow::Create( wxWindow
*parent
, const wxWindowID id
,
734 const wxPoint
&pos
, const wxSize
&size
,
735 const long style
, const wxString
&name
)
741 PreCreation( parent
, id
, pos
, size
, style
, name
);
743 m_widget
= gtk_scrolled_window_new( NULL
, NULL
);
744 m_hasScrolling
= TRUE
;
746 GtkScrolledWindow
*s_window
;
747 s_window
= GTK_SCROLLED_WINDOW(m_widget
);
749 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
750 scroll_class
->scrollbar_spacing
= 0;
752 gtk_scrolled_window_set_policy( s_window
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
754 m_oldHorizontalPos
= 0.0;
755 m_oldVerticalPos
= 0.0;
757 m_hAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->hscrollbar
) );
758 m_vAdjust
= gtk_range_get_adjustment( GTK_RANGE(s_window
->vscrollbar
) );
760 gtk_signal_connect (GTK_OBJECT (m_hAdjust
), "value_changed",
761 (GtkSignalFunc
) gtk_window_hscroll_callback
, (gpointer
) this );
762 gtk_signal_connect (GTK_OBJECT (m_vAdjust
), "value_changed",
763 (GtkSignalFunc
) gtk_window_vscroll_callback
, (gpointer
) this );
765 gtk_signal_connect (GTK_OBJECT (m_hAdjust
), "changed",
766 (GtkSignalFunc
) gtk_window_hscroll_change_callback
, (gpointer
) this );
767 gtk_signal_connect (GTK_OBJECT (m_vAdjust
), "changed",
768 (GtkSignalFunc
) gtk_window_vscroll_change_callback
, (gpointer
) this );
770 GtkViewport
*viewport
;
771 viewport
= GTK_VIEWPORT(s_window
->viewport
);
773 if (m_windowStyle
& wxRAISED_BORDER
)
775 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_OUT
);
777 else if (m_windowStyle
& wxSUNKEN_BORDER
)
779 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_IN
);
783 gtk_viewport_set_shadow_type( viewport
, GTK_SHADOW_NONE
);
786 m_wxwindow
= gtk_myfixed_new();
788 if (m_windowStyle
& wxTAB_TRAVERSAL
== wxTAB_TRAVERSAL
)
789 GTK_WIDGET_UNSET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
791 GTK_WIDGET_SET_FLAGS( m_wxwindow
, GTK_CAN_FOCUS
);
793 gtk_container_add( GTK_CONTAINER(m_widget
), m_wxwindow
);
795 // shut the viewport up
796 gtk_viewport_set_hadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
797 gtk_viewport_set_vadjustment( viewport
, (GtkAdjustment
*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
799 // I _really_ don't want scrollbars in the beginning
800 m_vAdjust
->lower
= 0.0;
801 m_vAdjust
->upper
= 1.0;
802 m_vAdjust
->value
= 0.0;
803 m_vAdjust
->step_increment
= 1.0;
804 m_vAdjust
->page_increment
= 1.0;
805 m_vAdjust
->page_size
= 5.0;
806 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
807 m_hAdjust
->lower
= 0.0;
808 m_hAdjust
->upper
= 1.0;
809 m_hAdjust
->value
= 0.0;
810 m_hAdjust
->step_increment
= 1.0;
811 m_hAdjust
->page_increment
= 1.0;
812 m_hAdjust
->page_size
= 5.0;
813 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
815 gtk_widget_show( m_wxwindow
);
824 wxWindow::~wxWindow(void)
828 if (m_pDropTarget
) delete m_pDropTarget
;
830 if (m_parent
) m_parent
->RemoveChild( this );
831 if (m_widget
) Show( FALSE
);
835 if (m_wxwindow
) gtk_widget_destroy( m_wxwindow
);
837 if (m_widget
) gtk_widget_destroy( m_widget
);
841 DeleteRelatedConstraints();
844 // This removes any dangling pointers to this window
845 // in other windows' constraintsInvolvedIn lists.
846 UnsetConstraints(m_constraints
);
847 delete m_constraints
;
848 m_constraints
= NULL
;
852 delete m_windowSizer
;
853 m_windowSizer
= NULL
;
855 // If this is a child of a sizer, remove self from parent
857 m_sizerParent
->RemoveChild((wxWindow
*)this);
859 // Just in case the window has been Closed, but
860 // we're then deleting immediately: don't leave
861 // dangling pointers.
862 wxPendingDelete
.DeleteObject(this);
864 // Just in case we've loaded a top-level window via
865 // wxWindow::LoadNativeDialog but we weren't a dialog
867 wxTopLevelWindows
.DeleteObject(this);
871 void wxWindow::PreCreation( wxWindow
*parent
, const wxWindowID id
,
872 const wxPoint
&pos
, const wxSize
&size
,
873 const long style
, const wxString
&name
)
875 if (m_needParent
&& (parent
== NULL
))
876 wxFatalError( "Need complete parent.", name
);
881 m_children
.DeleteContents( FALSE
);
885 if (m_width
== -1) m_width
= 20;
887 if (m_height
== -1) m_height
= 20;
889 m_eventHandler
= this;
890 m_windowValidator
= NULL
;
893 m_cursor
= new wxCursor( wxCURSOR_ARROW
);
894 m_font
= *wxSWISS_FONT
;
895 m_backgroundColour
= wxWHITE
;
896 m_foregroundColour
= wxBLACK
;
897 m_windowStyle
= style
;
899 m_constraints
= NULL
;
900 m_constraintsInvolvedIn
= NULL
;
901 m_windowSizer
= NULL
;
902 m_sizerParent
= NULL
;
903 m_autoLayout
= FALSE
;
904 m_drawingOffsetX
= 0;
905 m_drawingOffsetY
= 0;
906 m_pDropTarget
= NULL
;
909 void wxWindow::PostCreation(void)
911 if (m_parent
) m_parent
->AddChild( this );
913 // GtkStyle *style = m_widget->style;
914 // style->font = m_font.GetInternalFont( 1.0 ); // destroy old font ?
916 GtkWidget
*connect_widget
= m_widget
;
917 if (m_wxwindow
) connect_widget
= m_wxwindow
;
919 gtk_object_set_data (GTK_OBJECT (connect_widget
), "MyWxWindow", (gpointer
)this );
923 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "expose_event",
924 GTK_SIGNAL_FUNC(gtk_window_expose_callback
), (gpointer
)this );
926 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "draw",
927 GTK_SIGNAL_FUNC(gtk_window_draw_callback
), (gpointer
)this );
931 gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
932 GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this );
935 gtk_signal_connect( GTK_OBJECT(connect_widget
), "key_press_event",
936 GTK_SIGNAL_FUNC(gtk_window_key_press_callback
), (gpointer
)this );
938 gtk_signal_connect( GTK_OBJECT(connect_widget
), "button_press_event",
939 GTK_SIGNAL_FUNC(gtk_window_button_press_callback
), (gpointer
)this );
941 gtk_signal_connect( GTK_OBJECT(connect_widget
), "button_release_event",
942 GTK_SIGNAL_FUNC(gtk_window_button_release_callback
), (gpointer
)this );
944 gtk_signal_connect( GTK_OBJECT(connect_widget
), "motion_notify_event",
945 GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback
), (gpointer
)this );
947 gtk_signal_connect( GTK_OBJECT(connect_widget
), "focus_in_event",
948 GTK_SIGNAL_FUNC(gtk_window_focus_in_callback
), (gpointer
)this );
950 gtk_signal_connect( GTK_OBJECT(connect_widget
), "focus_out_event",
951 GTK_SIGNAL_FUNC(gtk_window_focus_out_callback
), (gpointer
)this );
953 gtk_signal_connect( GTK_OBJECT(connect_widget
), "drop_data_available_event",
954 GTK_SIGNAL_FUNC(gtk_window_drop_callback
), (gpointer
)this );
956 // Only for cursor handling
958 gtk_signal_connect( GTK_OBJECT(m_widget
), "enter_notify_event",
959 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
961 gtk_signal_connect( GTK_OBJECT(m_widget
), "leave_notify_event",
962 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
966 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "enter_notify_event",
967 GTK_SIGNAL_FUNC(gtk_window_enter_callback
), (gpointer
)this );
969 gtk_signal_connect( GTK_OBJECT(m_wxwindow
), "leave_notify_event",
970 GTK_SIGNAL_FUNC(gtk_window_leave_callback
), (gpointer
)this );
974 // Does destroy ever get called ?
976 gtk_signal_connect( GTK_OBJECT(m_widget), "destroy_event",
977 GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
981 gtk_signal_connect( GTK_OBJECT(m_wxwindow), "destroy_event",
982 GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
986 if (m_widget
&& m_parent
) gtk_widget_realize( m_widget
);
987 if (m_wxwindow
) gtk_widget_realize( m_wxwindow
);
989 SetCursor( wxSTANDARD_CURSOR
);
994 bool wxWindow::HasVMT(void)
999 bool wxWindow::Close( const bool force
)
1001 wxCloseEvent
event(wxEVT_CLOSE_WINDOW
, m_windowId
);
1002 event
.SetEventObject(this);
1003 event
.SetForce(force
);
1005 return GetEventHandler()->ProcessEvent(event
);
1008 bool wxWindow::Destroy(void)
1015 bool wxWindow::DestroyChildren(void)
1020 while ((node
= GetChildren()->First()) != (wxNode
*)NULL
)
1023 if ((child
= (wxWindow
*)node
->Data()) != (wxWindow
*)NULL
)
1026 if (GetChildren()->Member(child
)) delete node
;
1033 void wxWindow::PrepareDC( wxDC
&WXUNUSED(dc
) )
1035 // are we to set fonts here ?
1038 void wxWindow::ImplementSetSize(void)
1040 gtk_widget_set_usize( m_widget
, m_width
, m_height
);
1043 void wxWindow::ImplementSetPosition(void)
1045 if ((m_parent
) && (m_parent
->m_wxwindow
))
1046 gtk_myfixed_move( GTK_MYFIXED(m_parent
->m_wxwindow
), m_widget
, m_x
, m_y
);
1048 gtk_widget_set_uposition( m_widget
, m_x
, m_y
);
1051 void wxWindow::SetSize( const int x
, const int y
, const int width
, const int height
, const int sizeFlags
)
1058 if ((sizeFlags
& wxSIZE_USE_EXISTING
) == wxSIZE_USE_EXISTING
)
1060 if (newX
== -1) newX
= m_x
;
1061 if (newY
== -1) newY
= m_y
;
1062 if (newW
== -1) newW
= m_width
;
1063 if (newH
== -1) newH
= m_height
;
1066 if ((sizeFlags
& wxSIZE_AUTO_WIDTH
) == wxSIZE_AUTO_WIDTH
)
1068 if (newW
== -1) newW
= 80;
1071 if ((sizeFlags
& wxSIZE_AUTO_HEIGHT
) == wxSIZE_AUTO_HEIGHT
)
1073 if (newH
== -1) newH
= 26;
1076 if ((m_x
!= newX
) || (m_y
!= newY
) || (!m_sizeSet
))
1080 ImplementSetPosition();
1082 if ((m_width
!= newW
) || (m_height
!= newH
) || (!m_sizeSet
))
1090 wxSizeEvent
event( wxSize(m_width
,m_height
), GetId() );
1091 event
.SetEventObject( this );
1092 ProcessEvent( event
);
1095 void wxWindow::SetSize( const int width
, const int height
)
1097 SetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
);
1100 void wxWindow::Move( const int x
, const int y
)
1102 SetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
);
1105 void wxWindow::GetSize( int *width
, int *height
) const
1108 (*height
) = m_height
;
1111 void wxWindow::SetClientSize( const int width
, const int height
)
1115 SetSize( width
, height
);
1122 if (!m_hasScrolling
)
1125 do we have sunken dialogs ?
1127 GtkStyleClass *window_class = m_wxwindow->style->klass;
1129 dw += 2 * window_class->xthickness;
1130 dh += 2 * window_class->ythickness;
1135 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1136 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1138 GtkWidget
*viewport
= scroll_window
->viewport
;
1139 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1141 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1142 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1144 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1145 (m_windowStyle
& wxSUNKEN_BORDER
)
1148 dw
+= 2 * viewport_class
->xthickness
;
1149 dh
+= 2 * viewport_class
->ythickness
;
1152 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1154 dw
+= vscrollbar
->allocation
.width
;
1155 dw
+= scroll_class
->scrollbar_spacing
;
1158 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1160 dh
+= hscrollbar
->allocation
.height
;
1161 dw
+= scroll_class
->scrollbar_spacing
;
1165 SetSize( width
+dw
, height
+dh
);
1169 void wxWindow::GetClientSize( int *width
, int *height
) const
1173 if (width
) (*width
) = m_width
;
1174 if (height
) (*height
) = m_height
;
1181 if (!m_hasScrolling
)
1184 do we have sunken dialogs ?
1186 GtkStyleClass *window_class = m_wxwindow->style->klass;
1188 dw += 2 * window_class->xthickness;
1189 dh += 2 * window_class->ythickness;
1194 GtkScrolledWindow
*scroll_window
= GTK_SCROLLED_WINDOW(m_widget
);
1195 GtkScrolledWindowClass
*scroll_class
= GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget
)->klass
);
1197 GtkWidget
*viewport
= scroll_window
->viewport
;
1198 GtkStyleClass
*viewport_class
= viewport
->style
->klass
;
1200 GtkWidget
*hscrollbar
= scroll_window
->hscrollbar
;
1201 GtkWidget
*vscrollbar
= scroll_window
->vscrollbar
;
1203 if ((m_windowStyle
& wxRAISED_BORDER
) ||
1204 (m_windowStyle
& wxSUNKEN_BORDER
)
1207 dw
+= 2 * viewport_class
->xthickness
;
1208 dh
+= 2 * viewport_class
->ythickness
;
1211 if (GTK_WIDGET_VISIBLE(vscrollbar
))
1213 // dw += vscrollbar->allocation.width;
1214 dw
+= 15; // range.slider_width = 11 + 2*2pts edge
1215 dw
+= scroll_class
->scrollbar_spacing
;
1218 if (GTK_WIDGET_VISIBLE(hscrollbar
))
1220 // dh += hscrollbar->allocation.height;
1222 dh
+= scroll_class
->scrollbar_spacing
;
1226 if (width
) (*width
) = m_width
- dw
;
1227 if (height
) (*height
) = m_height
- dh
;
1231 void wxWindow::GetPosition( int *x
, int *y
) const
1237 void wxWindow::ClientToScreen( int *x
, int *y
)
1239 // Does this look simple ?
1241 GdkWindow
*source
= NULL
;
1243 source
= m_wxwindow
->window
;
1245 source
= m_widget
->window
;
1249 gdk_window_get_origin( source
, &org_x
, &org_y
);
1253 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1255 org_x
+= m_widget
->allocation
.x
;
1256 org_y
+= m_widget
->allocation
.y
;
1264 void wxWindow::ScreenToClient( int *x
, int *y
)
1266 GdkWindow
*source
= NULL
;
1268 source
= m_wxwindow
->window
;
1270 source
= m_widget
->window
;
1274 gdk_window_get_origin( source
, &org_x
, &org_y
);
1278 if (GTK_WIDGET_NO_WINDOW (m_widget
))
1280 org_x
+= m_widget
->allocation
.x
;
1281 org_y
+= m_widget
->allocation
.y
;
1289 void wxWindow::Centre( const int direction
)
1293 GetPosition( &x
, &y
);
1294 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
1296 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (gdk_screen_width () - m_width
) / 2;
1297 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (gdk_screen_height () - m_height
) / 2;
1298 gtk_widget_set_uposition( m_widget
, x
, y
);
1306 m_parent
->GetSize( &p_w
, &p_h
);
1307 if (direction
& wxHORIZONTAL
== wxHORIZONTAL
) x
= (p_w
- m_width
) / 2;
1308 if (direction
& wxVERTICAL
== wxVERTICAL
) y
= (p_h
- m_height
) / 2;
1309 gtk_widget_set_uposition( m_widget
, x
, y
);
1314 void wxWindow::Fit(void)
1318 wxNode
*node
= GetChildren()->First();
1321 wxWindow
*win
= (wxWindow
*)node
->Data();
1323 win
->GetPosition(&wx
, &wy
);
1324 win
->GetSize(&ww
, &wh
);
1325 if ( wx
+ ww
> maxX
)
1327 if ( wy
+ wh
> maxY
)
1330 node
= node
->Next();
1332 SetClientSize(maxX
+ 5, maxY
+ 5);
1335 void wxWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1337 if (GetAutoLayout()) Layout();
1340 bool wxWindow::Show( const bool show
)
1343 gtk_widget_show( m_widget
);
1345 gtk_widget_hide( m_widget
);
1350 void wxWindow::Enable( const bool enable
)
1352 m_isEnabled
= enable
;
1353 gtk_widget_set_sensitive( m_widget
, enable
);
1354 if (m_wxwindow
) gtk_widget_set_sensitive( m_wxwindow
, enable
);
1357 void wxWindow::MakeModal( const bool modal
)
1360 // Disable all other windows
1361 if (this->IsKindOf(CLASSINFO(wxDialog
)) || this->IsKindOf(CLASSINFO(wxFrame
)))
1363 wxNode
*node
= wxTopLevelWindows
.First();
1366 wxWindow
*win
= (wxWindow
*)node
->Data();
1368 win
->Enable(!modal
);
1370 node
= node
->Next();
1375 void wxWindow::SetFocus(void)
1377 GtkWidget
*connect_widget
= m_widget
;
1378 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1381 if (GTK_WIDGET_CAN_FOCUS(connect_widget
) && !GTK_WIDGET_HAS_FOCUS (connect_widget
) )
1383 gtk_widget_grab_focus (connect_widget
);
1388 bool wxWindow::OnClose(void)
1390 printf( "OnClose event.\n" );
1394 void wxWindow::AddChild( wxWindow
*child
)
1396 // Addchild is (often) called before the program
1397 // has left the parents constructor so that no
1398 // virtual tables work yet. The approach below
1399 // practically imitates virtual tables, i.e. it
1400 // implements a different AddChild() behaviour
1401 // for wxFrame, wxDialog, wxWindow and
1402 // wxMDIParentFrame.
1404 if (IsKindOf(CLASSINFO(wxMDIParentFrame
)))
1406 if (child
->IsKindOf(CLASSINFO(wxMDIChildFrame
)))
1408 wxMDIClientWindow
*client
= ((wxMDIParentFrame
*)this)->GetClientWindow();
1411 client
->AddChild( child
);
1416 m_children
.Append( child
);
1417 if (child
->IsKindOf(CLASSINFO(wxFrame
)) || child
->IsKindOf(CLASSINFO(wxDialog
)))
1419 if ((child
->m_x
!= -1) && (child
->m_y
!= -1))
1420 gtk_widget_set_uposition( child
->m_widget
, child
->m_x
, child
->m_y
);
1425 gtk_myfixed_put( GTK_MYFIXED(m_wxwindow
), child
->m_widget
, child
->m_x
, child
->m_y
);
1427 gtk_widget_set_usize( child
->m_widget
, child
->m_width
, child
->m_height
);
1430 wxList
*wxWindow::GetChildren(void)
1432 return (&m_children
);
1435 void wxWindow::RemoveChild( wxWindow
*child
)
1438 GetChildren()->DeleteObject( child
);
1439 child
->m_parent
= NULL
;
1442 void wxWindow::SetReturnCode( int retCode
)
1444 m_retCode
= retCode
;
1447 int wxWindow::GetReturnCode(void)
1452 wxWindow
*wxWindow::GetParent(void)
1457 wxEvtHandler
*wxWindow::GetEventHandler(void)
1459 return m_eventHandler
;
1462 void wxWindow::SetEventhandler( wxEvtHandler
*handler
)
1464 m_eventHandler
= handler
;
1467 wxValidator
*wxWindow::GetValidator(void)
1469 return m_windowValidator
;
1472 void wxWindow::SetValidator( wxValidator
*validator
)
1474 m_windowValidator
= validator
;
1477 bool wxWindow::IsBeingDeleted(void)
1482 void wxWindow::SetId( wxWindowID id
)
1487 wxWindowID
wxWindow::GetId(void)
1492 void wxWindow::SetCursor( const wxCursor
&cursor
)
1494 if (*m_cursor
== cursor
) return;
1495 (*m_cursor
) = cursor
;
1496 if (m_widget
->window
)
1497 gdk_window_set_cursor( m_widget
->window
, m_cursor
->GetCursor() );
1498 if (m_wxwindow
&& m_wxwindow
->window
)
1499 gdk_window_set_cursor( m_wxwindow
->window
, m_cursor
->GetCursor() );
1502 void wxWindow::Refresh( const bool eraseBackground
, const wxRect
*rect
)
1504 if (eraseBackground
&& m_wxwindow
&& m_wxwindow
->window
)
1507 gdk_window_clear_area( m_wxwindow
->window
,
1519 wxClientDC
dc(this);
1523 dc
.GetInternalDeviceOrigin( &x
, &y
);
1527 GetClientSize( &w
, &h
);
1529 GdkRectangle gdk_rect
;
1533 gdk_rect
.height
= h
;
1534 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1539 GdkRectangle gdk_rect
;
1540 gdk_rect
.x
= rect
->x
;
1541 gdk_rect
.y
= rect
->y
;
1542 gdk_rect
.width
= rect
->width
;
1543 gdk_rect
.height
= rect
->height
;
1545 gtk_widget_draw( m_wxwindow
, &gdk_rect
);
1547 gtk_widget_draw( m_widget
, &gdk_rect
);
1551 bool wxWindow::IsExposed( const long x
, const long y
)
1553 return (m_updateRegion
.Contains( x
, y
) != wxOutRegion
);
1556 bool wxWindow::IsExposed( const long x
, const long y
, const long width
, const long height
)
1558 return (m_updateRegion
.Contains( x
, y
, width
, height
) != wxOutRegion
);
1561 void wxWindow::Clear(void)
1563 if (m_wxwindow
&& m_wxwindow
->window
) gdk_window_clear( m_wxwindow
->window
);
1566 wxColour
wxWindow::GetBackgroundColour(void) const
1568 return m_backgroundColour
;
1571 void wxWindow::SetBackgroundColour( const wxColour
&colour
)
1573 m_backgroundColour
= colour
;
1576 m_backgroundColour
.CalcPixel( m_wxwindow
->style
->colormap
);
1577 gdk_window_set_background( m_wxwindow
->window
, m_backgroundColour
.GetColor() );
1578 gdk_window_clear( m_wxwindow
->window
);
1583 bool wxWindow::Validate(void)
1585 wxNode
*node
= GetChildren()->First();
1588 wxWindow
*child
= (wxWindow
*)node
->Data();
1589 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->Validate(this))
1591 node
= node
->Next();
1596 bool wxWindow::TransferDataToWindow(void)
1598 wxNode
*node
= GetChildren()->First();
1601 wxWindow
*child
= (wxWindow
*)node
->Data();
1602 if (child
->GetValidator() && /* child->GetValidator()->Ok() && */
1603 !child
->GetValidator()->TransferToWindow() )
1605 wxMessageBox( "Application Error", "Could not transfer data to window", wxOK
|wxICON_EXCLAMATION
);
1608 node
= node
->Next();
1613 bool wxWindow::TransferDataFromWindow(void)
1615 wxNode
*node
= GetChildren()->First();
1618 wxWindow
*child
= (wxWindow
*)node
->Data();
1619 if ( child
->GetValidator() && /* child->GetValidator()->Ok() && */ !child
->GetValidator()->TransferFromWindow() )
1621 node
= node
->Next();
1626 void wxWindow::OnInitDialog( wxInitDialogEvent
&WXUNUSED(event
) )
1628 TransferDataToWindow();
1631 void wxWindow::InitDialog(void)
1633 wxInitDialogEvent
event(GetId());
1634 event
.SetEventObject( this );
1635 GetEventHandler()->ProcessEvent(event
);
1638 void wxWindow::SetDropTarget( wxDropTarget
*dropTarget
)
1640 GtkWidget
*connect_widget
= m_widget
;
1641 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1644 m_pDropTarget
->UnregisterWidget( connect_widget
);
1645 delete m_pDropTarget
;
1647 m_pDropTarget
= dropTarget
;
1650 m_pDropTarget
->RegisterWidget( connect_widget
);
1654 wxDropTarget
*wxWindow::GetDropTarget() const
1656 return m_pDropTarget
;
1659 void wxWindow::SetFont( const wxFont
&font
)
1664 copy old style values to new one
1665 set font in new style
1666 -> takes to many resources
1668 GtkStyle *style = gtk_style_new();
1673 wxFont
*wxWindow::GetFont(void)
1678 void wxWindow::SetWindowStyleFlag( long flag
)
1680 m_windowStyle
= flag
;
1683 long wxWindow::GetWindowStyleFlag(void) const
1685 return m_windowStyle
;
1688 void wxWindow::CaptureMouse(void)
1690 GtkWidget
*connect_widget
= m_widget
;
1691 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1692 gtk_grab_add( connect_widget
);
1693 gdk_pointer_grab ( connect_widget
->window
, FALSE
,
1695 (GDK_BUTTON_PRESS_MASK
|
1696 GDK_BUTTON_RELEASE_MASK
|
1697 GDK_POINTER_MOTION_MASK
),
1698 NULL
, NULL
, GDK_CURRENT_TIME
);
1701 void wxWindow::ReleaseMouse(void)
1703 GtkWidget
*connect_widget
= m_widget
;
1704 if (m_wxwindow
) connect_widget
= m_wxwindow
;
1705 gtk_grab_remove( connect_widget
);
1706 gdk_pointer_ungrab ( GDK_CURRENT_TIME
);
1709 void wxWindow::SetTitle( const wxString
&WXUNUSED(title
) )
1713 wxString
wxWindow::GetTitle(void) const
1715 return (wxString
&)m_windowName
;
1718 wxString
wxWindow::GetLabel(void) const
1723 void wxWindow::SetName( const wxString
&name
)
1725 m_windowName
= name
;
1728 wxString
wxWindow::GetName(void) const
1730 return (wxString
&)m_windowName
;
1733 bool wxWindow::IsShown(void)
1738 bool wxWindow::IsRetained(void)
1743 wxWindow
*wxWindow::FindWindow( const long id
)
1745 if (id
== m_windowId
) return this;
1746 wxNode
*node
= m_children
.First();
1749 wxWindow
*child
= (wxWindow
*)node
->Data();
1750 wxWindow
*res
= child
->FindWindow( id
);
1751 if (res
) return res
;
1752 node
= node
->Next();
1757 wxWindow
*wxWindow::FindWindow( const wxString
& name
)
1759 if (name
== m_windowName
) return this;
1760 wxNode
*node
= m_children
.First();
1763 wxWindow
*child
= (wxWindow
*)node
->Data();
1764 wxWindow
*res
= child
->FindWindow( name
);
1765 if (res
) return res
;
1766 node
= node
->Next();
1771 void wxWindow::SetScrollbar( const int orient
, const int pos
, const int thumbVisible
,
1772 const int range
, const bool WXUNUSED(refresh
) )
1774 if (!m_wxwindow
) return;
1776 if (orient
== wxHORIZONTAL
)
1778 float fpos
= (float)pos
;
1779 m_oldHorizontalPos
= fpos
;
1780 float frange
= (float)range
;
1781 float fthumb
= (float)thumbVisible
;
1783 if ((fabs(fpos
-m_hAdjust
->value
) < 0.2) &&
1784 (fabs(frange
-m_hAdjust
->upper
) < 0.2) &&
1785 (fabs(fthumb
-m_hAdjust
->page_size
) < 0.2))
1788 m_hAdjust
->lower
= 0.0;
1789 m_hAdjust
->upper
= frange
;
1790 m_hAdjust
->value
= fpos
;
1791 m_hAdjust
->step_increment
= 1.0;
1792 m_hAdjust
->page_increment
= (float)(wxMax(fthumb
-2,0));
1793 m_hAdjust
->page_size
= fthumb
;
1797 float fpos
= (float)pos
;
1798 m_oldVerticalPos
= fpos
;
1799 float frange
= (float)range
;
1800 float fthumb
= (float)thumbVisible
;
1802 if ((fabs(fpos
-m_vAdjust
->value
) < 0.2) &&
1803 (fabs(frange
-m_vAdjust
->upper
) < 0.2) &&
1804 (fabs(fthumb
-m_vAdjust
->page_size
) < 0.2))
1807 m_vAdjust
->lower
= 0.0;
1808 m_vAdjust
->upper
= frange
;
1809 m_vAdjust
->value
= fpos
;
1810 m_vAdjust
->step_increment
= 1.0;
1811 m_vAdjust
->page_increment
= (float)(wxMax(fthumb
-2,0));
1812 m_vAdjust
->page_size
= fthumb
;
1815 if (m_wxwindow
->window
)
1817 if (orient
== wxHORIZONTAL
)
1818 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "changed" );
1820 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "changed" );
1822 // gtk_widget_set_usize( m_widget, m_width, m_height );
1826 void wxWindow::SetScrollPos( const int orient
, const int pos
, const bool WXUNUSED(refresh
) )
1828 if (!m_wxwindow
) return;
1830 if (orient
== wxHORIZONTAL
)
1832 float fpos
= (float)pos
;
1833 m_oldHorizontalPos
= fpos
;
1835 if (fabs(fpos
-m_hAdjust
->value
) < 0.2) return;
1836 m_hAdjust
->value
= fpos
;
1840 float fpos
= (float)pos
;
1841 m_oldVerticalPos
= fpos
;
1842 if (fabs(fpos
-m_vAdjust
->value
) < 0.2) return;
1843 m_vAdjust
->value
= fpos
;
1846 if (m_wxwindow
->window
)
1848 if (orient
== wxHORIZONTAL
)
1849 gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust
), "value_changed" );
1851 gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust
), "value_changed" );
1855 int wxWindow::GetScrollThumb( const int orient
) const
1857 if (!m_wxwindow
) return 0;
1859 if (orient
== wxHORIZONTAL
)
1860 return (int)(m_hAdjust
->page_size
+0.5);
1862 return (int)(m_vAdjust
->page_size
+0.5);
1865 int wxWindow::GetScrollPos( const int orient
) const
1867 if (!m_wxwindow
) return 0;
1869 if (orient
== wxHORIZONTAL
)
1870 return (int)(m_hAdjust
->value
+0.5);
1872 return (int)(m_vAdjust
->value
+0.5);
1875 int wxWindow::GetScrollRange( const int orient
) const
1877 if (!m_wxwindow
) return 0;
1879 if (orient
== wxHORIZONTAL
)
1880 return (int)(m_hAdjust
->upper
+0.5);
1882 return (int)(m_vAdjust
->upper
+0.5);
1885 void wxWindow::ScrollWindow( const int dx
, const int dy
, const wxRect
* WXUNUSED(rect
) )
1887 if (!m_wxwindow
) return;
1889 m_drawingOffsetX
+= dx
;
1890 m_drawingOffsetY
+= dy
;
1892 // printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
1894 gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow
), m_drawingOffsetX
, m_drawingOffsetY
);
1897 The code here is very nifty, but it doesn't work with
1898 overlapping windows...
1902 GetClientSize( &cw, &ch );
1904 int w = cw - abs(dx);
1905 int h = ch - abs(dy);
1906 if ((h < 0) || (w < 0))
1913 if (dx < 0) s_x = -dx;
1914 if (dy < 0) s_y = -dy;
1917 if (dx > 0) d_x = dx;
1918 if (dy > 0) d_y = dy;
1919 gdk_window_copy_area( m_wxwindow->window, m_wxwindow->style->fg_gc[0], d_x, d_y,
1920 m_wxwindow->window, s_x, s_y, w, h );
1923 if (dx < 0) rect.x = cw+dx; else rect.x = 0;
1924 if (dy < 0) rect.y = ch+dy; else rect.y = 0;
1925 if (dy != 0) rect.width = cw; else rect.width = abs(dx);
1926 if (dx != 0) rect.height = ch; else rect.height = abs(dy);
1928 Refresh( TRUE, &rect );
1932 void wxWindow::GetDrawingOffset( long *x
, long *y
)
1934 if (x
) *x
= m_drawingOffsetX
;
1935 if (y
) *y
= m_drawingOffsetY
;
1938 //-------------------------------------------------------------------------------------
1940 //-------------------------------------------------------------------------------------
1942 wxLayoutConstraints
*wxWindow::GetConstraints(void) const
1944 return m_constraints
;
1947 void wxWindow::SetConstraints( wxLayoutConstraints
*constraints
)
1951 UnsetConstraints(m_constraints
);
1952 delete m_constraints
;
1954 m_constraints
= constraints
;
1957 // Make sure other windows know they're part of a 'meaningful relationship'
1958 if (m_constraints
->left
.GetOtherWindow() && (m_constraints
->left
.GetOtherWindow() != this))
1959 m_constraints
->left
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1960 if (m_constraints
->top
.GetOtherWindow() && (m_constraints
->top
.GetOtherWindow() != this))
1961 m_constraints
->top
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1962 if (m_constraints
->right
.GetOtherWindow() && (m_constraints
->right
.GetOtherWindow() != this))
1963 m_constraints
->right
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1964 if (m_constraints
->bottom
.GetOtherWindow() && (m_constraints
->bottom
.GetOtherWindow() != this))
1965 m_constraints
->bottom
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1966 if (m_constraints
->width
.GetOtherWindow() && (m_constraints
->width
.GetOtherWindow() != this))
1967 m_constraints
->width
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1968 if (m_constraints
->height
.GetOtherWindow() && (m_constraints
->height
.GetOtherWindow() != this))
1969 m_constraints
->height
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1970 if (m_constraints
->centreX
.GetOtherWindow() && (m_constraints
->centreX
.GetOtherWindow() != this))
1971 m_constraints
->centreX
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1972 if (m_constraints
->centreY
.GetOtherWindow() && (m_constraints
->centreY
.GetOtherWindow() != this))
1973 m_constraints
->centreY
.GetOtherWindow()->AddConstraintReference((wxWindow
*)this);
1979 void wxWindow::SetAutoLayout( const bool autoLayout
)
1981 m_autoLayout
= autoLayout
;
1984 bool wxWindow::GetAutoLayout(void) const
1986 return m_autoLayout
;
1989 wxSizer
*wxWindow::GetSizer(void) const
1991 return m_windowSizer
;
1994 void wxWindow::SetSizerParent( wxWindow
*win
)
1996 m_sizerParent
= win
;
1999 wxWindow
*wxWindow::GetSizerParent(void) const
2001 return m_sizerParent
;
2004 // This removes any dangling pointers to this window
2005 // in other windows' constraintsInvolvedIn lists.
2006 void wxWindow::UnsetConstraints(wxLayoutConstraints
*c
)
2010 if (c
->left
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2011 c
->left
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2012 if (c
->top
.GetOtherWindow() && (c
->top
.GetOtherWindow() != this))
2013 c
->top
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2014 if (c
->right
.GetOtherWindow() && (c
->right
.GetOtherWindow() != this))
2015 c
->right
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2016 if (c
->bottom
.GetOtherWindow() && (c
->bottom
.GetOtherWindow() != this))
2017 c
->bottom
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2018 if (c
->width
.GetOtherWindow() && (c
->width
.GetOtherWindow() != this))
2019 c
->width
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2020 if (c
->height
.GetOtherWindow() && (c
->height
.GetOtherWindow() != this))
2021 c
->height
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2022 if (c
->centreX
.GetOtherWindow() && (c
->centreX
.GetOtherWindow() != this))
2023 c
->centreX
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2024 if (c
->centreY
.GetOtherWindow() && (c
->centreY
.GetOtherWindow() != this))
2025 c
->centreY
.GetOtherWindow()->RemoveConstraintReference((wxWindow
*)this);
2029 // Back-pointer to other windows we're involved with, so if we delete
2030 // this window, we must delete any constraints we're involved with.
2031 void wxWindow::AddConstraintReference(wxWindow
*otherWin
)
2033 if (!m_constraintsInvolvedIn
)
2034 m_constraintsInvolvedIn
= new wxList
;
2035 if (!m_constraintsInvolvedIn
->Member(otherWin
))
2036 m_constraintsInvolvedIn
->Append(otherWin
);
2039 // REMOVE back-pointer to other windows we're involved with.
2040 void wxWindow::RemoveConstraintReference(wxWindow
*otherWin
)
2042 if (m_constraintsInvolvedIn
)
2043 m_constraintsInvolvedIn
->DeleteObject(otherWin
);
2046 // Reset any constraints that mention this window
2047 void wxWindow::DeleteRelatedConstraints(void)
2049 if (m_constraintsInvolvedIn
)
2051 wxNode
*node
= m_constraintsInvolvedIn
->First();
2054 wxWindow
*win
= (wxWindow
*)node
->Data();
2055 wxNode
*next
= node
->Next();
2056 wxLayoutConstraints
*constr
= win
->GetConstraints();
2058 // Reset any constraints involving this window
2061 constr
->left
.ResetIfWin((wxWindow
*)this);
2062 constr
->top
.ResetIfWin((wxWindow
*)this);
2063 constr
->right
.ResetIfWin((wxWindow
*)this);
2064 constr
->bottom
.ResetIfWin((wxWindow
*)this);
2065 constr
->width
.ResetIfWin((wxWindow
*)this);
2066 constr
->height
.ResetIfWin((wxWindow
*)this);
2067 constr
->centreX
.ResetIfWin((wxWindow
*)this);
2068 constr
->centreY
.ResetIfWin((wxWindow
*)this);
2073 delete m_constraintsInvolvedIn
;
2074 m_constraintsInvolvedIn
= NULL
;
2078 void wxWindow::SetSizer(wxSizer
*sizer
)
2080 m_windowSizer
= sizer
;
2082 sizer
->SetSizerParent((wxWindow
*)this);
2089 bool wxWindow::Layout(void)
2091 if (GetConstraints())
2094 GetClientSize(&w
, &h
);
2095 GetConstraints()->width
.SetValue(w
);
2096 GetConstraints()->height
.SetValue(h
);
2099 // If top level (one sizer), evaluate the sizer's constraints.
2103 GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
2104 GetSizer()->LayoutPhase1(&noChanges
);
2105 GetSizer()->LayoutPhase2(&noChanges
);
2106 GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
2111 // Otherwise, evaluate child constraints
2112 ResetConstraints(); // Mark all constraints as unevaluated
2113 DoPhase(1); // Just one phase need if no sizers involved
2115 SetConstraintSizes(); // Recursively set the real window sizes
2121 // Do a phase of evaluating constraints:
2122 // the default behaviour. wxSizers may do a similar
2123 // thing, but also impose their own 'constraints'
2124 // and order the evaluation differently.
2125 bool wxWindow::LayoutPhase1(int *noChanges
)
2127 wxLayoutConstraints
*constr
= GetConstraints();
2130 return constr
->SatisfyConstraints((wxWindow
*)this, noChanges
);
2136 bool wxWindow::LayoutPhase2(int *noChanges
)
2146 // Do a phase of evaluating child constraints
2147 bool wxWindow::DoPhase(const int phase
)
2149 int noIterations
= 0;
2150 int maxIterations
= 500;
2154 while ((noChanges
> 0) && (noIterations
< maxIterations
))
2158 wxNode
*node
= GetChildren()->First();
2161 wxWindow
*child
= (wxWindow
*)node
->Data();
2162 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) && !child
->IsKindOf(CLASSINFO(wxDialog
)))
2164 wxLayoutConstraints
*constr
= child
->GetConstraints();
2167 if (succeeded
.Member(child
))
2172 int tempNoChanges
= 0;
2173 bool success
= ( (phase
== 1) ? child
->LayoutPhase1(&tempNoChanges
) : child
->LayoutPhase2(&tempNoChanges
) ) ;
2174 noChanges
+= tempNoChanges
;
2177 succeeded
.Append(child
);
2182 node
= node
->Next();
2189 void wxWindow::ResetConstraints(void)
2191 wxLayoutConstraints
*constr
= GetConstraints();
2194 constr
->left
.SetDone(FALSE
);
2195 constr
->top
.SetDone(FALSE
);
2196 constr
->right
.SetDone(FALSE
);
2197 constr
->bottom
.SetDone(FALSE
);
2198 constr
->width
.SetDone(FALSE
);
2199 constr
->height
.SetDone(FALSE
);
2200 constr
->centreX
.SetDone(FALSE
);
2201 constr
->centreY
.SetDone(FALSE
);
2203 wxNode
*node
= GetChildren()->First();
2206 wxWindow
*win
= (wxWindow
*)node
->Data();
2207 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2208 win
->ResetConstraints();
2209 node
= node
->Next();
2213 // Need to distinguish between setting the 'fake' size for
2214 // windows and sizers, and setting the real values.
2215 void wxWindow::SetConstraintSizes(const bool recurse
)
2217 wxLayoutConstraints
*constr
= GetConstraints();
2218 if (constr
&& constr
->left
.GetDone() && constr
->right
.GetDone() &&
2219 constr
->width
.GetDone() && constr
->height
.GetDone())
2221 int x
= constr
->left
.GetValue();
2222 int y
= constr
->top
.GetValue();
2223 int w
= constr
->width
.GetValue();
2224 int h
= constr
->height
.GetValue();
2226 // If we don't want to resize this window, just move it...
2227 if ((constr
->width
.GetRelationship() != wxAsIs
) ||
2228 (constr
->height
.GetRelationship() != wxAsIs
))
2230 // Calls Layout() recursively. AAAGH. How can we stop that.
2231 // Simply take Layout() out of non-top level OnSizes.
2232 SizerSetSize(x
, y
, w
, h
);
2241 char *windowClass
= this->GetClassInfo()->GetClassName();
2244 if (GetName() == "")
2245 winName
= "unnamed";
2247 winName
= GetName();
2248 wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass
, (const char *)winName
);
2249 if (!constr
->left
.GetDone())
2250 wxDebugMsg(" unsatisfied 'left' constraint.\n");
2251 if (!constr
->right
.GetDone())
2252 wxDebugMsg(" unsatisfied 'right' constraint.\n");
2253 if (!constr
->width
.GetDone())
2254 wxDebugMsg(" unsatisfied 'width' constraint.\n");
2255 if (!constr
->height
.GetDone())
2256 wxDebugMsg(" unsatisfied 'height' constraint.\n");
2257 wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
2262 wxNode
*node
= GetChildren()->First();
2265 wxWindow
*win
= (wxWindow
*)node
->Data();
2266 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) && !win
->IsKindOf(CLASSINFO(wxDialog
)))
2267 win
->SetConstraintSizes();
2268 node
= node
->Next();
2273 // This assumes that all sizers are 'on' the same
2274 // window, i.e. the parent of this window.
2275 void wxWindow::TransformSizerToActual(int *x
, int *y
) const
2277 if (!m_sizerParent
|| m_sizerParent
->IsKindOf(CLASSINFO(wxDialog
)) ||
2278 m_sizerParent
->IsKindOf(CLASSINFO(wxFrame
)) )
2282 m_sizerParent
->GetPosition(&xp
, &yp
);
2283 m_sizerParent
->TransformSizerToActual(&xp
, &yp
);
2288 void wxWindow::SizerSetSize(const int x
, const int y
, const int w
, const int h
)
2292 TransformSizerToActual(&xx
, &yy
);
2293 SetSize(xx
, yy
, w
, h
);
2296 void wxWindow::SizerMove(const int x
, const int y
)
2300 TransformSizerToActual(&xx
, &yy
);
2304 // Only set the size/position of the constraint (if any)
2305 void wxWindow::SetSizeConstraint(const int x
, const int y
, const int w
, const int h
)
2307 wxLayoutConstraints
*constr
= GetConstraints();
2312 constr
->left
.SetValue(x
);
2313 constr
->left
.SetDone(TRUE
);
2317 constr
->top
.SetValue(y
);
2318 constr
->top
.SetDone(TRUE
);
2322 constr
->width
.SetValue(w
);
2323 constr
->width
.SetDone(TRUE
);
2327 constr
->height
.SetValue(h
);
2328 constr
->height
.SetDone(TRUE
);
2333 void wxWindow::MoveConstraint(const int x
, const int y
)
2335 wxLayoutConstraints
*constr
= GetConstraints();
2340 constr
->left
.SetValue(x
);
2341 constr
->left
.SetDone(TRUE
);
2345 constr
->top
.SetValue(y
);
2346 constr
->top
.SetDone(TRUE
);
2351 void wxWindow::GetSizeConstraint(int *w
, int *h
) const
2353 wxLayoutConstraints
*constr
= GetConstraints();
2356 *w
= constr
->width
.GetValue();
2357 *h
= constr
->height
.GetValue();
2363 void wxWindow::GetClientSizeConstraint(int *w
, int *h
) const
2365 wxLayoutConstraints
*constr
= GetConstraints();
2368 *w
= constr
->width
.GetValue();
2369 *h
= constr
->height
.GetValue();
2372 GetClientSize(w
, h
);
2375 void wxWindow::GetPositionConstraint(int *x
, int *y
) const
2377 wxLayoutConstraints
*constr
= GetConstraints();
2380 *x
= constr
->left
.GetValue();
2381 *y
= constr
->top
.GetValue();