-
- m_sizeSet = TRUE;
-
- wxSizeEvent event( wxSize(m_width,m_height), GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
-
- m_resizing = FALSE;
-}
-
-void wxWindow::SetSize( int width, int height )
-{
- SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
-}
-
-void wxWindow::Move( int x, int y )
-{
- SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
-}
-
-void wxWindow::GetSize( int *width, int *height ) const
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (width) (*width) = m_width;
- if (height) (*height) = m_height;
-}
-
-void wxWindow::SetClientSize( int width, int height )
-{
- wxASSERT_MSG( (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
-{
- wxASSERT_MSG( (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
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (x) (*x) = m_x;
- if (y) (*y) = m_y;
-}
-
-void wxWindow::ClientToScreen( int *x, int *y )
-{
- wxASSERT_MSG( (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 )
-{
- wxASSERT_MSG( (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 )
-{
- wxASSERT_MSG( (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()
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- int maxX = 0;
- int maxY = 0;
- wxNode *node = m_childrenFirst();
- 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 + 5, maxY + 10);
-}
-
-void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- m_minWidth = minW;
- m_minHeight = minH;
- m_maxWidth = maxW;
- m_maxHeight = maxH;
-}
-
-void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
-{
-// if (GetAutoLayout()) Layout();
-}
-
-bool wxWindow::Show( bool show )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (show)
- gtk_widget_show( m_widget );
- else
- gtk_widget_hide( m_widget );
- m_isShown = show;
- return TRUE;
-}
-
-void wxWindow::Enable( bool enable )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- m_isEnabled = enable;
- gtk_widget_set_sensitive( m_widget, enable );
- if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
-}
-
-int wxWindow::GetCharHeight() const
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (!m_font.Ok())
- {
- wxFAIL_MSG( "invalid font" );
- return -1;
- }
-
- GdkFont *font = m_font.GetInternalFont( 1.0 );
- return font->ascent + font->descent;
-}
-
-int wxWindow::GetCharWidth() const
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (!m_font.Ok())
- {
- wxFAIL_MSG( "invalid font" );
- return -1;
- }
-
- GdkFont *font = m_font.GetInternalFont( 1.0 );
- return gdk_string_width( font, "H" );
-}
-
-void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- wxFont fontToUse = m_font;
- if (theFont) fontToUse = *theFont;
-
- if (!fontToUse.Ok())
- {
- wxFAIL_MSG( "invalid font" );
- return;
- }
- wxASSERT_MSG( (m_font.Ok()), "invalid font" );
-
- GdkFont *font = fontToUse.GetInternalFont( 1.0 );
- if (x) (*x) = gdk_string_width( font, string );
- if (y) (*y) = font->ascent + font->descent;
- if (descent) (*descent) = font->descent;
- if (externalLeading) (*externalLeading) = 0; // ??
-}
-
-void wxWindow::MakeModal( bool modal )
-{
- return;
- // Disable all other windows
- if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
- {
- wxNode *node = wxTopLevelWindows.First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (win != this)
- win->Enable(!modal);
-
- node = node->Next();
- }
- }
-}
-
-void wxWindow::SetFocus()
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- GtkWidget *connect_widget = GetConnectWidget();
- if (connect_widget)
- {
- if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) )
- {
- gtk_widget_grab_focus (connect_widget);
- }
- }
-}
-
-bool wxWindow::OnClose()
-{
- return TRUE;
-}
-
-void wxWindow::AddChild( wxWindow *child )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxASSERT_MSG( (child != NULL), "invalid child" );
-
- m_children.Append( child );
-}
-
-wxList& wxWindow::GetChildren() const
-{
- return m_children;
-}
-
-wxWindow *wxWindow::ReParent( wxWindow *newParent )
-{
- wxWindow *oldParent = GetParent();
-
- if (oldParent) oldParent->RemoveChild( this );
-
- gtk_widget_unparent( m_widget );
-
- if (newParent)
- {
- newParent->AddChild( this );
- (newParent->m_insertCallback)( newParent, this );
- }
-
- return oldParent;
-}
-
-void wxWindow::RemoveChild( wxWindow *child )
-{
- m_children.DeleteObject( child );
- child->m_parent = (wxWindow *) NULL;
-}
-
-void wxWindow::SetReturnCode( int retCode )
-{
- m_retCode = retCode;
-}
-
-int wxWindow::GetReturnCode()
-{
- return m_retCode;
-}
-
-void wxWindow::Raise()
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (m_widget) gdk_window_raise( m_widget->window );
-}
-
-void wxWindow::Lower()
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (m_widget) gdk_window_lower( m_widget->window );
-}
-
-wxEvtHandler *wxWindow::GetEventHandler()
-{
- return m_eventHandler;
-}
-
-void wxWindow::SetEventHandler( wxEvtHandler *handler )
-{
- m_eventHandler = handler;
-}
-
-void wxWindow::PushEventHandler(wxEvtHandler *handler)
-{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
-}
-
-wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
-{
- if (GetEventHandler())
- {
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *) NULL);
- SetEventHandler(handlerB);
- if (deleteHandler)
- {
- delete handlerA;
- return (wxEvtHandler*) NULL;
- }
- else
- return handlerA;
- }
- else
- return (wxEvtHandler *) NULL;
-}
-
-wxValidator *wxWindow::GetValidator()
-{
- return m_windowValidator;
-}
-
-void wxWindow::SetValidator( const wxValidator& validator )
-{
- if (m_windowValidator) delete m_windowValidator;
- m_windowValidator = validator.Clone();
- if (m_windowValidator) m_windowValidator->SetWindow(this);
-}
-
-void wxWindow::SetClientObject( wxClientData *data )
-{
- if (m_clientObject) delete m_clientObject;
- m_clientObject = data;
-}
-
-wxClientData *wxWindow::GetClientObject()
-{
- return m_clientObject;
-}
-
-void wxWindow::SetClientData( void *data )
-{
- m_clientData = data;
-}
-
-void *wxWindow::GetClientData()
-{
- return m_clientData;
-}
-
-bool wxWindow::IsBeingDeleted()
-{
- return FALSE;
-}
-
-void wxWindow::SetId( wxWindowID id )
-{
- m_windowId = id;
-}
-
-wxWindowID wxWindow::GetId()
-{
- return m_windowId;
-}
-
-void wxWindow::SetCursor( const wxCursor &cursor )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (m_cursor == NULL)
- {
- wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
- m_cursor = new wxCursor( wxCURSOR_ARROW );
- }
-
- if (cursor.Ok())
- {
- if (*((wxCursor*)&cursor) == m_cursor) return;
- *m_cursor = cursor;
- }
- else
- {
- *m_cursor = *wxSTANDARD_CURSOR;
- }
-
- if ((m_widget) && (m_widget->window))
- gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
-
- if ((m_wxwindow) && (m_wxwindow->window))
- gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
-}
-
-void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
-{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-
- if (eraseBackground && m_wxwindow && m_wxwindow->window)
- {
- if (rect)
- gdk_window_clear_area( m_wxwindow->window,
- rect->x,
- rect->y,
- rect->width,
- rect->height );
- else
- Clear();
- }
- if (!rect)
- {
- if (m_wxwindow)
- {
- int w = 0;
- int h = 0;
- GetClientSize( &w, &h );
-
- GdkRectangle gdk_rect;
- gdk_rect.x = 0;
- gdk_rect.y = 0;
- gdk_rect.width = w;
- gdk_rect.height = h;
- gtk_widget_draw( m_wxwindow, &gdk_rect );
- }
- }
- else
- {
- GdkRectangle gdk_rect;
- gdk_rect.x = rect->x;
- gdk_rect.y = rect->y;
- gdk_rect.width = rect->width;
- gdk_rect.height = rect->height;
-
- if (m_wxwindow)
- gtk_widget_draw( m_wxwindow, &gdk_rect );
- else
- gtk_widget_draw( m_widget, &gdk_rect );
- }
-}
-
-wxRegion wxWindow::GetUpdateRegion() const
-{
- return m_updateRegion;
-}
-
-bool wxWindow::IsExposed( int x, int y) const
-{
- return (m_updateRegion.Contains( x, y ) != wxOutRegion );
-}