+ }
+ else
+ {
+ if ((child->m_wxwindow == (GtkWidget*) NULL) &&
+ (child->m_x <= event.m_x) &&
+ (child->m_y <= event.m_y) &&
+ (child->m_x+child->m_width >= event.m_x) &&
+ (child->m_y+child->m_height >= event.m_y))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+ }
+ node = node->Next();
+ }
+ }
+
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
+ event.SetEventObject( win );
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "motion_notify_event"
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
+{
+ if (gdk_event->is_hint)
+ {
+ int x = 0;
+ int y = 0;
+ GdkModifierType state;
+ gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
+ gdk_event->x = x;
+ gdk_event->y = y;
+ gdk_event->state = state;
+ }
+
+ if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+
+ if (g_blockEventsOnDrag) return TRUE;
+ if (g_blockEventsOnScroll) return TRUE;
+
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnMotion from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ wxMouseEvent event( wxEVT_MOTION );
+ event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
+ event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
+ event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
+ event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
+ event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK);
+ event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK);
+ event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK);
+
+ event.m_x = (long)gdk_event->x;
+ event.m_y = (long)gdk_event->y;
+
+ // Some control don't have their own X window and thus cannot get
+ // any events.
+
+ if (!g_capturing)
+ {
+ wxNode *node = win->GetChildren().First();
+ while (node)
+ {
+ wxWindow *child = (wxWindow*)node->Data();
+
+ if (child->m_isStaticBox)
+ {
+ // wxStaticBox is transparent in the box itself
+ int x = event.m_x;
+ int y = event.m_y;
+ int xx1 = child->m_x;
+ int yy1 = child->m_y;
+ int xx2 = child->m_x + child->m_width;
+ int yy2 = child->m_x + child->m_height;
+
+ // left
+ if (((x >= xx1) && (x <= xx1+10) && (y >= yy1) && (y <= yy2)) ||
+ // right
+ ((x >= xx2-10) && (x <= xx2) && (y >= yy1) && (y <= yy2)) ||
+ // top
+ ((x >= xx1) && (x <= xx2) && (y >= yy1) && (y <= yy1+10)) ||
+ // bottom
+ ((x >= xx1) && (x <= xx2) && (y >= yy2-1) && (y <= yy2)))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+
+ }
+ else
+ {
+ if ((child->m_wxwindow == (GtkWidget*) NULL) &&
+ (child->m_x <= event.m_x) &&
+ (child->m_y <= event.m_y) &&
+ (child->m_x+child->m_width >= event.m_x) &&
+ (child->m_y+child->m_height >= event.m_y))
+ {
+ win = child;
+ event.m_x -= child->m_x;
+ event.m_y -= child->m_y;
+ break;
+ }
+ }
+ node = node->Next();
+ }
+ }
+
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
+ event.SetEventObject( win );
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "focus_in_event"
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return TRUE;
+
+ g_focusWindow = win;
+
+ if (win->m_wxwindow)
+ {
+ if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
+ {
+ GTK_WIDGET_SET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+/*
+ printf( "SetFocus flag from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+ }
+ }
+
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnSetFocus from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( " " );
+ printf( WXSTRINGCAST win->GetLabel() );
+ printf( ".\n" );
+*/
+
+ wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
+ event.SetEventObject( win );
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "focus_out_event"
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return TRUE;
+ if (win->m_wxwindow)
+ {
+ if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
+ GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
+ }
+
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnKillFocus from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
+ event.SetEventObject( win );
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "enter_notify_event"
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return TRUE;
+
+ if ((widget->window) && (win->m_cursor))
+ gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
+
+ if (widget->window != gdk_event->window) return TRUE;
+
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnEnter from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ wxMouseEvent event( wxEVT_ENTER_WINDOW );
+ event.SetEventObject( win );
+
+ int x = 0;
+ int y = 0;
+ GdkModifierType state = (GdkModifierType)0;
+
+ gdk_window_get_pointer( widget->window, &x, &y, &state );
+
+ event.m_shiftDown = (state & GDK_SHIFT_MASK);
+ event.m_controlDown = (state & GDK_CONTROL_MASK);
+ event.m_altDown = (state & GDK_MOD1_MASK);
+ event.m_metaDown = (state & GDK_MOD2_MASK);
+ event.m_leftDown = (state & GDK_BUTTON1_MASK);
+ event.m_middleDown = (state & GDK_BUTTON2_MASK);
+ event.m_rightDown = (state & GDK_BUTTON3_MASK);
+
+ event.m_x = (long)x;
+ event.m_y = (long)y;
+
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "leave_notify_event"
+//-----------------------------------------------------------------------------
+
+static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return TRUE;
+
+ if ((widget->window) && (win->m_cursor))
+ gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
+
+ if (widget->window != gdk_event->window) return TRUE;
+
+ if (!win->HasVMT()) return TRUE;
+
+/*
+ printf( "OnLeave from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ wxMouseEvent event( wxEVT_LEAVE_WINDOW );
+ event.SetEventObject( win );
+
+ int x = 0;
+ int y = 0;
+ GdkModifierType state = (GdkModifierType)0;
+
+ gdk_window_get_pointer( widget->window, &x, &y, &state );
+
+ event.m_shiftDown = (state & GDK_SHIFT_MASK);
+ event.m_controlDown = (state & GDK_CONTROL_MASK);
+ event.m_altDown = (state & GDK_MOD1_MASK);
+ event.m_metaDown = (state & GDK_MOD2_MASK);
+ event.m_leftDown = (state & GDK_BUTTON1_MASK);
+ event.m_middleDown = (state & GDK_BUTTON2_MASK);
+ event.m_rightDown = (state & GDK_BUTTON3_MASK);
+
+ event.m_x = (long)x;
+ event.m_y = (long)y;
+
+ wxPoint pt(win->GetClientAreaOrigin());
+ event.m_x -= pt.x;
+ event.m_y -= pt.y;
+
+ if (win->GetEventHandler()->ProcessEvent( event ))
+ gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
+
+ return TRUE;
+}
+
+//-----------------------------------------------------------------------------
+// "value_changed" from m_vAdjust
+//-----------------------------------------------------------------------------
+
+static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return;
+
+/*
+ printf( "OnVScroll from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if (!win->HasVMT()) return;
+
+ float diff = win->m_vAdjust->value - win->m_oldVerticalPos;
+ if (fabs(diff) < 0.2) return;
+ win->m_oldVerticalPos = win->m_vAdjust->value;
+
+ wxEventType command = wxEVT_NULL;
+
+ float line_step = win->m_vAdjust->step_increment;
+ float page_step = win->m_vAdjust->page_increment;
+
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
+
+ int value = (int)(win->m_vAdjust->value+0.5);
+
+ wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+}
+
+//-----------------------------------------------------------------------------
+// "value_changed" from m_hAdjust
+//-----------------------------------------------------------------------------
+
+static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return;
+
+/*
+ printf( "OnHScroll from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if (!win->HasVMT()) return;
+
+ float diff = win->m_hAdjust->value - win->m_oldHorizontalPos;
+ if (fabs(diff) < 0.2) return;
+ win->m_oldHorizontalPos = win->m_hAdjust->value;
+
+ wxEventType command = wxEVT_NULL;
+
+ float line_step = win->m_hAdjust->step_increment;
+ float page_step = win->m_hAdjust->page_increment;
+
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
+
+ int value = (int)(win->m_hAdjust->value+0.5);
+
+ wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+}
+
+//-----------------------------------------------------------------------------
+// "changed" from m_vAdjust
+//-----------------------------------------------------------------------------
+
+static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return;
+
+/*
+ printf( "OnVScroll change from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if (!win->HasVMT()) return;
+
+ wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+ int value = (int)(win->m_vAdjust->value+0.5);
+
+ wxScrollEvent event( command, win->GetId(), value, wxVERTICAL );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+}
+
+//-----------------------------------------------------------------------------
+// "changed" from m_hAdjust
+//-----------------------------------------------------------------------------
+
+static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
+{
+ if (g_blockEventsOnDrag) return;
+
+/*
+ printf( "OnHScroll change from " );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ printf( win->GetClassInfo()->GetClassName() );
+ printf( ".\n" );
+*/
+
+ if (!win->HasVMT()) return;
+
+ wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+ int value = (int)(win->m_hAdjust->value+0.5);
+
+ wxScrollEvent event( command, win->GetId(), value, wxHORIZONTAL );
+ event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( event );
+}
+
+//-----------------------------------------------------------------------------
+// "button_press_event" from scrollbar
+//-----------------------------------------------------------------------------
+
+static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
+{
+// don't test here as we can release the mouse while being over
+// a different window then the slider
+//
+// if (gdk_event->window != widget->slider) return FALSE;
+
+ win->m_isScrolling = TRUE;
+ g_blockEventsOnScroll = TRUE;
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// "button_release_event" from scrollbar
+//-----------------------------------------------------------------------------
+
+static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
+{
+
+// don't test here as we can release the mouse while being over
+// a different window then the slider
+//
+// if (gdk_event->window != widget->slider) return FALSE;
+
+ GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
+
+ if (widget == GTK_RANGE(s_window->vscrollbar))
+ gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
+ else
+ gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
+
+ win->m_isScrolling = FALSE;
+ g_blockEventsOnScroll = FALSE;
+
+ return FALSE;
+}
+
+//-----------------------------------------------------------------------------
+// InsertChild for wxWindow.
+//-----------------------------------------------------------------------------
+
+/* Callback for wxWindow. This very strange beast has to be used because
+ * C++ has no virtual methods in a constructor. We have to emulate a
+ * virtual function here as wxNotebook requires a different way to insert
+ * a child in it. I had opted for creating a wxNotebookPage window class
+ * which would have made this superfluous (such in the MDI window system),
+ * but no-one was listening to me... */
+
+static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
+{
+ gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+
+ gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
+ child->m_width,
+ child->m_height );
+
+ if (wxIS_KIND_OF(parent,wxFrame))
+ {
+ parent->m_sizeSet = FALSE;
+ }
+
+ if (parent->m_windowStyle & wxTAB_TRAVERSAL)
+ {
+ /* we now allow a window to get the focus as long as it
+ doesn't have any children. */
+ GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// global functions
+//-----------------------------------------------------------------------------
+
+wxWindow* wxGetActiveWindow()
+{
+ return g_focusWindow;
+}
+
+//-----------------------------------------------------------------------------
+// wxWindow
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxWindow,wxEvtHandler)
+
+BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
+ EVT_SIZE(wxWindow::OnSize)
+ EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
+ EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+ EVT_KEY_DOWN(wxWindow::OnKeyDown)
+END_EVENT_TABLE()
+
+void wxWindow::Init()
+{
+ m_isWindow = TRUE;
+
+ m_widget = (GtkWidget *) NULL;
+ m_wxwindow = (GtkWidget *) NULL;
+ m_parent = (wxWindow *) NULL;
+ m_children.DeleteContents( FALSE );
+
+ m_x = 0;
+ m_y = 0;
+ m_width = 0;
+ m_height = 0;
+ m_minWidth = -1;
+ m_minHeight = -1;
+ m_maxWidth = -1;
+ m_maxHeight = -1;
+
+ m_retCode = 0;
+
+ m_eventHandler = this;
+ m_windowValidator = (wxValidator *) NULL;
+
+ m_windowId = -1;
+
+ m_cursor = (wxCursor *) NULL;
+ m_font = *wxSWISS_FONT;
+ m_windowStyle = 0;
+ m_windowName = "noname";
+
+ m_constraints = (wxLayoutConstraints *) NULL;
+ m_constraintsInvolvedIn = (wxList *) NULL;
+ m_windowSizer = (wxSizer *) NULL;
+ m_sizerParent = (wxWindow *) NULL;
+ m_autoLayout = FALSE;
+
+ m_sizeSet = FALSE;
+ m_hasVMT = FALSE;
+ m_needParent = TRUE;
+
+ m_hasScrolling = FALSE;
+ m_isScrolling = FALSE;
+ m_hAdjust = (GtkAdjustment*) NULL;
+ m_vAdjust = (GtkAdjustment*) NULL;
+ m_oldHorizontalPos = 0.0;
+ m_oldVerticalPos = 0.0;
+
+ m_isShown = FALSE;
+ m_isEnabled = TRUE;
+
+#if wxUSE_DRAG_AND_DROP
+ m_dropTarget = (wxDropTarget*) NULL;
+#endif
+ m_resizing = FALSE;
+ m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
+
+ m_insertCallback = wxInsertChildInWindow;
+
+ m_clientObject = (wxClientData*) NULL;
+ m_clientData = NULL;
+
+ m_isStaticBox = FALSE;
+ m_acceptsFocus = FALSE;
+
+#if wxUSE_TOOLTIPS
+ m_toolTip = (wxToolTip*) NULL;
+#endif // wxUSE_TOOLTIPS
+}
+
+wxWindow::wxWindow()
+{
+ Init();
+}
+
+wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size,
+ long style, const wxString &name )
+{
+ Init();
+
+ Create( parent, id, pos, size, style, name );
+}
+
+bool wxWindow::Create( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size,
+ long style, const wxString &name )
+{
+ wxASSERT_MSG( m_isWindow, "Init() must have been called before!" );
+
+ PreCreation( parent, id, pos, size, style, name );
+
+ m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+
+#ifdef __WXDEBUG__
+ debug_focus_in( m_widget, "wxWindow::m_widget", name );
+#endif
+
+ GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
+
+#ifdef __WXDEBUG__
+ debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
+ debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
+#endif
+
+ GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+ scroll_class->scrollbar_spacing = 0;
+
+ gtk_scrolled_window_set_policy( s_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+
+ m_oldHorizontalPos = 0.0;
+ m_oldVerticalPos = 0.0;
+
+ m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
+ m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
+
+ m_wxwindow = gtk_myfixed_new();
+
+#ifdef __WXDEBUG__
+ debug_focus_in( m_wxwindow, "wxWindow::m_wxwindow", name );
+#endif
+
+#ifdef NEW_GTK_SCROLL_CODE
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
+ GtkViewport *viewport = GTK_VIEWPORT( GTK_BIN(s_window)->child );
+#else
+ gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#endif
+
+#ifdef __WXDEBUG__
+ debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
+#endif
+
+ if (m_windowStyle & wxRAISED_BORDER)
+ {
+ gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT );
+ }
+ else if (m_windowStyle & wxSUNKEN_BORDER)
+ {
+ gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_IN );
+ }
+ else
+ {
+ gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
+ }
+
+ if (m_windowStyle & wxTAB_TRAVERSAL)
+ {
+ /* we now allow a window to get the focus as long as it
+ doesn't have any children. */
+ GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+ m_acceptsFocus = FALSE;
+ }
+ else
+ {
+ GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+ m_acceptsFocus = TRUE;
+ }
+
+ // shut the viewport up
+ gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
+ gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
+
+ // I _really_ don't want scrollbars in the beginning
+ m_vAdjust->lower = 0.0;
+ m_vAdjust->upper = 1.0;
+ m_vAdjust->value = 0.0;
+ m_vAdjust->step_increment = 1.0;
+ m_vAdjust->page_increment = 1.0;
+ m_vAdjust->page_size = 5.0;
+ gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
+ m_hAdjust->lower = 0.0;
+ m_hAdjust->upper = 1.0;
+ m_hAdjust->value = 0.0;
+ m_hAdjust->step_increment = 1.0;
+ m_hAdjust->page_increment = 1.0;
+ m_hAdjust->page_size = 5.0;
+ gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
+
+ // these handlers block mouse events to any window during scrolling
+ // such as motion events and prevent GTK and wxWindows from fighting
+ // over where the slider should be
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ // these handers het notified when screen updates are required either when
+ // scrolling or when the window size (and therefore scrollbar configuration)
+ // has changed
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
+ gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
+ (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
+ gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
+ (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
+
+ gtk_widget_show( m_wxwindow );
+
+ if (m_parent) m_parent->AddChild( this );
+
+ (m_parent->m_insertCallback)( m_parent, this );
+
+ PostCreation();
+
+ Show( TRUE );
+
+ return TRUE;
+}
+
+wxWindow::~wxWindow()
+{
+ m_hasVMT = FALSE;
+
+#if wxUSE_DRAG_AND_DROP
+ if (m_dropTarget)
+ {
+ delete m_dropTarget;
+ m_dropTarget = (wxDropTarget*) NULL;
+ }
+#endif
+
+#if wxUSE_TOOLTIPS
+ if (m_toolTip)
+ {
+ delete m_toolTip;
+ m_toolTip = (wxToolTip*) NULL;
+ }
+#endif // wxUSE_TOOLTIPS
+
+ if (m_widget) Show( FALSE );
+
+ DestroyChildren();
+
+ if (m_parent) m_parent->RemoveChild( this );
+
+ if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
+
+ if (m_scrollGC) gdk_gc_unref( m_scrollGC );
+
+ if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
+
+ if (m_widget) gtk_widget_destroy( m_widget );
+
+ if (m_cursor) delete m_cursor;
+
+ DeleteRelatedConstraints();
+ if (m_constraints)
+ {
+ /* This removes any dangling pointers to this window
+ * in other windows' constraintsInvolvedIn lists. */
+ UnsetConstraints(m_constraints);
+ delete m_constraints;
+ m_constraints = (wxLayoutConstraints *) NULL;
+ }
+
+ if (m_windowSizer)
+ {
+ delete m_windowSizer;
+ m_windowSizer = (wxSizer *) NULL;
+ }
+ /* If this is a child of a sizer, remove self from parent */
+ if (m_sizerParent) m_sizerParent->RemoveChild((wxWindow *)this);
+
+ /* Just in case the window has been Closed, but
+ * we're then deleting immediately: don't leave
+ * dangling pointers. */
+ wxPendingDelete.DeleteObject(this);
+
+ /* Just in case we've loaded a top-level window via
+ * wxWindow::LoadNativeDialog but we weren't a dialog
+ * class */
+ wxTopLevelWindows.DeleteObject(this);
+
+ if (m_windowValidator) delete m_windowValidator;
+
+ if (m_clientObject) delete m_clientObject;
+}
+
+void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size,
+ long style, const wxString &name )
+{
+ wxASSERT_MSG( (!m_needParent) || (parent), "Need complete parent." );
+
+ m_widget = (GtkWidget*) NULL;
+ m_wxwindow = (GtkWidget*) NULL;
+ m_hasVMT = FALSE;
+ m_parent = parent;
+ m_children.DeleteContents( FALSE );
+
+ m_width = size.x;
+ if (m_width == -1) m_width = 20;
+ m_height = size.y;
+ if (m_height == -1) m_height = 20;
+
+ m_x = (int)pos.x;
+ m_y = (int)pos.y;
+
+ if (!m_needParent) /* some reasonable defaults */
+ {
+ if (m_x == -1)
+ {
+ m_x = (gdk_screen_width () - m_width) / 2;
+ if (m_x < 10) m_x = 10;
+ }
+ if (m_y == -1)
+ {
+ m_y = (gdk_screen_height () - m_height) / 2;
+ if (m_y < 10) m_y = 10;
+ }
+ }
+
+ m_minWidth = -1;
+ m_minHeight = -1;
+ m_maxWidth = -1;
+ m_maxHeight = -1;
+
+ m_retCode = 0;
+
+ m_eventHandler = this;
+
+ m_windowId = id == -1 ? wxNewId() : id;
+
+ m_sizeSet = FALSE;
+
+ m_cursor = new wxCursor( wxCURSOR_ARROW );
+ m_font = *wxSWISS_FONT;
+ m_backgroundColour = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
+ m_foregroundColour = *wxBLACK;
+ m_windowStyle = style;
+ m_windowName = name;
+
+ m_constraints = (wxLayoutConstraints *) NULL;
+ m_constraintsInvolvedIn = (wxList *) NULL;
+ m_windowSizer = (wxSizer *) NULL;
+ m_sizerParent = (wxWindow *) NULL;
+ m_autoLayout = FALSE;
+
+ m_hasScrolling = FALSE;
+ m_isScrolling = FALSE;
+ m_hAdjust = (GtkAdjustment *) NULL;
+ m_vAdjust = (GtkAdjustment *) NULL;
+ m_oldHorizontalPos = 0.0;
+ m_oldVerticalPos = 0.0;
+
+ m_isShown = FALSE;
+ m_isEnabled = TRUE;
+
+#if wxUSE_DRAG_AND_DROP
+ m_dropTarget = (wxDropTarget *) NULL;
+#endif
+ m_resizing = FALSE;
+ m_windowValidator = (wxValidator *) NULL;
+ m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
+
+ m_clientObject = (wxClientData*)NULL;
+ m_clientData = NULL;
+
+ m_isStaticBox = FALSE;
+
+#if wxUSE_TOOLTIPS
+ m_toolTip = (wxToolTip*) NULL;
+#endif // wxUSE_TOOLTIPS
+}
+
+void wxWindow::PostCreation()
+{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ if (m_wxwindow)
+ {
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
+ GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
+ }
+
+ ConnectWidget( GetConnectWidget() );
+
+ /* we force the creation of wxFrame and wxDialog in the respective code */
+ if (m_parent) gtk_widget_realize( m_widget );
+
+ if (m_wxwindow) gtk_widget_realize( m_wxwindow );
+
+ SetCursor( *wxSTANDARD_CURSOR );
+
+ m_hasVMT = TRUE;
+}
+
+void wxWindow::ConnectWidget( GtkWidget *widget )
+{
+ gtk_signal_connect( GTK_OBJECT(widget), "key_press_event",
+ GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "key_release_event",
+ GTK_SIGNAL_FUNC(gtk_window_key_release_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "button_press_event",
+ GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "button_release_event",
+ GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event",
+ GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
+ GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "focus_out_event",
+ GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event",
+ GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
+ GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
+}
+
+bool wxWindow::HasVMT()
+{
+ return m_hasVMT;
+}
+
+bool wxWindow::Close( bool force )
+{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
+ event.SetEventObject(this);
+ event.SetCanVeto(!force);
+
+ /* return FALSE if window wasn't closed because the application vetoed the
+ * close event */
+ return GetEventHandler()->ProcessEvent(event) && !event.GetVeto();
+}
+
+bool wxWindow::Destroy()
+{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
+ m_hasVMT = FALSE;
+ delete this;
+ return TRUE;
+}
+
+bool wxWindow::DestroyChildren()