X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed673c6a48b3479beac60a93ff8f44611e44415f..e7494fa9961c39cd14069ef8b12f5c059c7d3b35:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 5ccb0ec542..5c6a1422e1 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -303,7 +303,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g } //----------------------------------------------------------------------------- -// "draw" of m_wxwindow +// "draw" of m_widget //----------------------------------------------------------------------------- static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win ) @@ -1711,6 +1711,12 @@ gtk_window_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child ) { + /* the window might have been scrolled already, do we + have to adapt the position */ + GtkMyFixed *myfixed = GTK_MYFIXED(parent->m_wxwindow); + child->m_x += myfixed->xoffset; + child->m_y += myfixed->yoffset; + gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow), GTK_WIDGET(child->m_widget), child->m_x, @@ -1760,6 +1766,8 @@ void wxWindow::Init() m_hasVMT = FALSE; m_needParent = TRUE; m_isBeingDeleted = FALSE; + + m_noExpose = FALSE; m_hasScrolling = FALSE; m_isScrolling = FALSE; @@ -1770,7 +1778,6 @@ void wxWindow::Init() m_oldVerticalPos = 0.0; m_resizing = FALSE; - m_scrollGC = (GdkGC*) NULL; m_widgetStyle = (GtkStyle*) NULL; m_insertCallback = (wxInsertChildFunction) NULL; @@ -1971,12 +1978,6 @@ wxWindow::~wxWindow() m_widgetStyle = (GtkStyle*) NULL; } - if (m_scrollGC) - { - gdk_gc_unref( m_scrollGC ); - m_scrollGC = (GdkGC*) NULL; - } - if (m_wxwindow) { gtk_widget_destroy( m_wxwindow ); @@ -2028,12 +2029,15 @@ void wxWindow::PostCreation() if (m_wxwindow) { - /* these get reported to wxWindows -> wxPaintEvent */ - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); + if (!m_noExpose) + { + /* these get reported to wxWindows -> wxPaintEvent */ + 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 ); + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", + GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); + } #if (GTK_MINOR_VERSION > 0) /* these are called when the "sunken" or "raised" borders are drawn */ @@ -2114,17 +2118,19 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) } else { + GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow); + if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) { - if (x != -1) m_x = x; - if (y != -1) m_y = y; + if (x != -1) m_x = x + myfixed->xoffset; + if (y != -1) m_y = y + myfixed->yoffset; if (width != -1) m_width = width; if (height != -1) m_height = height; } else { - m_x = x; - m_y = y; + m_x = x + myfixed->xoffset; + m_y = y + myfixed->yoffset; m_width = width; m_height = height; } @@ -2154,27 +2160,6 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) bottom_border = 5; } - /* this is the result of hours of debugging: the following code - means that if we have a m_wxwindow and we set the size of - m_widget, m_widget (which is a GtkScrolledWindow) does NOT - automatically propagate its size down to its m_wxwindow, - which is its client area. therefore, we have to tell the - client area directly that it has to resize itself. - this will lead to that m_widget (GtkScrolledWindow) will - calculate how much size it needs for scrollbars etc and - it will then call XXX_size_allocate of its child, which - is m_wxwindow. m_wxwindow in turn will do the same with its - children and so on. problems can arise if this happens - before all the children have been realized as some widgets - stupidy need to be realized during XXX_size_allocate (e.g. - GtkNotebook) and they will segv if called otherwise. this - emergency is tested in gtk_myfixed_size_allocate. Normally - this shouldn't be needed and only gtk_widget_queue_resize() - should be enough to provoke a resize at the next appropriate - moment, but this seems to fail, e.g. when a wxNotebook contains - a wxSplitterWindow: the splitter window's children won't - show up properly resized then. */ - gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, @@ -2203,7 +2188,7 @@ void wxWindow::OnInternalIdle() as setting the cursor in a parent window also effects the windows above so that checking for the current cursor is not possible. */ - + if (m_wxwindow) { GdkWindow *window = GTK_MYFIXED(m_wxwindow)->bin_window; @@ -2392,8 +2377,17 @@ void wxWindow::DoGetPosition( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - if (x) (*x) = m_x; - if (y) (*y) = m_y; + int dx = 0; + int dy = 0; + if (m_parent && m_parent->m_wxwindow) + { + GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow); + dx = myfixed->xoffset; + dy = myfixed->yoffset; + } + + if (x) (*x) = m_x - dx; + if (y) (*y) = m_y - dy; } void wxWindow::DoClientToScreen( int *x, int *y ) const @@ -2669,50 +2663,44 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect ) } } + /* there is no GTK equivalent of "draw only, don't clear" so we + invent our own in the GtkMyFixed widget */ + if (!rect) { if (m_wxwindow) { - /* call the callback directly for preventing GTK from - clearing the background */ - int w = 0; - int h = 0; - GetClientSize( &w, &h ); + GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow); + gboolean old_clear = myfixed->clear_on_draw; + gtk_my_fixed_set_clear( myfixed, FALSE ); + + gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL ); - GetUpdateRegion().Union( 0, 0, w, h ); - wxPaintEvent event( GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - GetUpdateRegion().Clear(); + gtk_my_fixed_set_clear( myfixed, old_clear ); } else - { gtk_widget_draw( m_widget, (GdkRectangle*) NULL ); - } } 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) { - /* call the callback directly for preventing GTK from - clearing the background */ - GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); - wxPaintEvent event( GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - GetUpdateRegion().Clear(); + GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow); + gboolean old_clear = myfixed->clear_on_draw; + gtk_my_fixed_set_clear( myfixed, FALSE ); + + gtk_widget_draw( m_wxwindow, &gdk_rect ); + + gtk_my_fixed_set_clear( myfixed, old_clear ); } else - { - GdkRectangle gdk_rect; - gdk_rect.x = rect->x; - gdk_rect.y = rect->y; - gdk_rect.width = rect->width; - gdk_rect.height = rect->height; - gtk_widget_draw( m_widget, &gdk_rect ); - } } }