+ 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()
+{
+ wxNode *node;
+ while ((node = m_children.First()) != (wxNode *)NULL)
+ {
+ wxWindow *child;
+ if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL)
+ {
+ delete child;
+ if (m_children.Member(child)) delete node;
+ }
+ }
+ return TRUE;
+}
+
+void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
+{
+ // are we to set fonts here ?
+}
+
+wxPoint wxWindow::GetClientAreaOrigin() const
+{
+ return wxPoint(0,0);
+}
+
+void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
+{
+ if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
+ {
+ wxPoint pt(GetParent()->GetClientAreaOrigin());
+ x += pt.x;
+ y += pt.y;
+ }
+}
+
+void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
+{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
+
+ if (m_resizing) return; /* I don't like recursions */
+ m_resizing = TRUE;
+
+ if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */
+ {
+ /* don't set the size for children of wxNotebook, just take the values. */
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
+ else
+ {
+ int old_width = m_width;
+ int old_height = m_height;
+
+ if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
+ {
+ if (x != -1) m_x = x;
+ if (y != -1) m_y = y;
+ if (width != -1) m_width = width;
+ if (height != -1) m_height = height;
+ }
+ else
+ {
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ {
+ if (width == -1) m_width = 80;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
+ {
+ if (height == -1) m_height = 26;
+ }
+
+ if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
+ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+
+ if (GTK_WIDGET_HAS_DEFAULT(m_widget))
+ {
+ /* the default button has a border around it */
+ int border = 5;
+
+ wxPoint pt( m_parent->GetClientAreaOrigin() );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x-border, m_y+pt.y-border );
+
+ gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+ }
+ else
+ {
+ wxPoint pt( m_parent->GetClientAreaOrigin() );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+
+ if ((old_width != m_width) || (old_height != m_height))
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
+ }
+
+ m_sizeSet = TRUE;
+
+ wxSizeEvent event( wxSize(m_width,m_height), GetId() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+
+ m_resizing = FALSE;
+}
+
+void wxWindow::OnInternalIdle()
+{
+ UpdateWindowUI();
+}
+
+void wxWindow::GetSize( int *width, int *height ) const
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ if (width) (*width) = m_width;
+ if (height) (*height) = m_height;
+}
+
+void wxWindow::DoSetClientSize( int width, int height )
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ if (!m_wxwindow)
+ {
+ SetSize( width, height );
+ }
+ else
+ {
+ int dw = 0;
+ int dh = 0;
+
+ if (!m_hasScrolling)
+ {
+ GtkStyleClass *window_class = m_wxwindow->style->klass;
+
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * window_class->xthickness;
+ dh += 2 * window_class->ythickness;
+ }
+ }
+ else
+ {
+ GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
+ GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
+ GtkWidget *viewport = scroll_window->viewport;
+#endif
+
+ GtkStyleClass *viewport_class = viewport->style->klass;
+
+ GtkWidget *hscrollbar = scroll_window->hscrollbar;
+ GtkWidget *vscrollbar = scroll_window->vscrollbar;
+
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * viewport_class->xthickness;
+ dh += 2 * viewport_class->ythickness;
+ }
+
+ if (scroll_window->vscrollbar_visible)
+ {
+ dw += vscrollbar->allocation.width;
+ dw += scroll_class->scrollbar_spacing;
+ }
+
+ if (scroll_window->hscrollbar_visible)
+ {
+ dh += hscrollbar->allocation.height;
+ dw += scroll_class->scrollbar_spacing;
+ }
+ }
+
+ SetSize( width+dw, height+dh );
+ }
+}
+
+void wxWindow::GetClientSize( int *width, int *height ) const
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ if (!m_wxwindow)
+ {
+ if (width) (*width) = m_width;
+ if (height) (*height) = m_height;
+ }
+ else
+ {
+ int dw = 0;
+ int dh = 0;
+
+ if (!m_hasScrolling)
+ {
+ GtkStyleClass *window_class = m_wxwindow->style->klass;
+
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * window_class->xthickness;
+ dh += 2 * window_class->ythickness;
+ }
+ }
+ else
+ {
+ GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
+ GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
+ GtkWidget *viewport = scroll_window->viewport;
+#endif
+
+ GtkStyleClass *viewport_class = viewport->style->klass;
+
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * viewport_class->xthickness;
+ dh += 2 * viewport_class->ythickness;
+ }
+
+ if (scroll_window->vscrollbar_visible)
+ {
+// dw += vscrollbar->allocation.width;
+ dw += 15; // range.slider_width = 11 + 2*2pts edge
+ dw += scroll_class->scrollbar_spacing;
+ }
+
+ if (scroll_window->hscrollbar_visible)
+ {
+// dh += hscrollbar->allocation.height;
+ dh += 15;
+ dh += scroll_class->scrollbar_spacing;
+ }
+ }
+
+ if (width) (*width) = m_width - dw;
+ if (height) (*height) = m_height - dh;
+ }
+}
+
+void wxWindow::GetPosition( int *x, int *y ) const
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ if (x) (*x) = m_x;
+ if (y) (*y) = m_y;
+}
+
+void wxWindow::ClientToScreen( int *x, int *y )
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ GdkWindow *source = (GdkWindow *) NULL;
+ if (m_wxwindow)
+ source = m_wxwindow->window;
+ else
+ source = m_widget->window;
+
+ int org_x = 0;
+ int org_y = 0;
+ gdk_window_get_origin( source, &org_x, &org_y );
+
+ if (!m_wxwindow)
+ {
+ if (GTK_WIDGET_NO_WINDOW (m_widget))
+ {
+ org_x += m_widget->allocation.x;
+ org_y += m_widget->allocation.y;
+ }
+ }
+
+ wxPoint pt(GetClientAreaOrigin());
+ org_x += pt.x;
+ org_y += pt.y;
+
+ if (x) *x += org_x;
+ if (y) *y += org_y;
+}
+
+void wxWindow::ScreenToClient( int *x, int *y )
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ GdkWindow *source = (GdkWindow *) NULL;
+ if (m_wxwindow)
+ source = m_wxwindow->window;
+ else
+ source = m_widget->window;
+
+ int org_x = 0;
+ int org_y = 0;
+ gdk_window_get_origin( source, &org_x, &org_y );
+
+ if (!m_wxwindow)
+ {
+ if (GTK_WIDGET_NO_WINDOW (m_widget))
+ {
+ org_x += m_widget->allocation.x;
+ org_y += m_widget->allocation.y;
+ }
+ }
+
+ wxPoint pt(GetClientAreaOrigin());
+ org_x -= pt.x;
+ org_y -= pt.y;
+
+ if (x) *x -= org_x;
+ if (y) *y -= org_y;
+}
+
+void wxWindow::Centre( int direction )
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ int x = m_x;
+ int y = m_y;
+
+ if (m_parent)
+ {
+ int p_w = 0;
+ int p_h = 0;
+ m_parent->GetSize( &p_w, &p_h );
+ if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
+ if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
+ }
+ else
+ {
+ if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
+ if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
+ }
+
+ Move( x, y );
+}
+
+void wxWindow::Fit()
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ int maxX = 0;
+ int maxY = 0;
+ wxNode *node = m_children.First();
+ while (node)
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ int wx, wy, ww, wh;
+ win->GetPosition(&wx, &wy);
+ win->GetSize(&ww, &wh);
+ if (wx + ww > maxX) maxX = wx + ww;
+ if (wy + wh > maxY) maxY = wy + wh;
+
+ node = node->Next();
+ }
+
+ SetClientSize(maxX + 7, maxY + 14);
+}
+
+void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
+{
+ wxCHECK_RET( (m_widget != NULL), "invalid window" );
+
+ m_minWidth = minW;
+ m_minHeight = minH;
+ m_maxWidth = maxW;
+ m_maxHeight = maxH;
+}