X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3208e55e12f7f8509aedf7b85c2864adeb85ffc9..d10e22fe8ad283f37b1809349028ffc282e393ce:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 081370a010..11567f27fb 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -78,8 +78,6 @@ #undef HAVE_XIM #endif -extern GtkContainerClass *pizza_parent_class; - //----------------------------------------------------------------------------- // documentation on internals //----------------------------------------------------------------------------- @@ -340,14 +338,6 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) if (!win->m_hasVMT) return; - int dw = 0; - int dh = 0; - - if (win->m_hasScrolling) - { - GetScrollbarWidth(widget, dw, dh); - } - int dx = 0; int dy = 0; if (GTK_WIDGET_NO_WINDOW (widget)) @@ -356,6 +346,27 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) dy += widget->allocation.y; } + int x = dx; + int y = dy; + + int dw = 0; + int dh = 0; + if (win->m_hasScrolling) + { + GetScrollbarWidth(widget, dw, dh); + + if (win->GetLayoutDirection() == wxLayout_RightToLeft) + { + // This is actually wrong for old GTK+ version + // which do not display the scrollbar on the + // left side in RTL + x += dw; + } + } + + int w = widget->allocation.width-dw; + int h = widget->allocation.height-dh; + if (win->HasFlag(wxRAISED_BORDER)) { gtk_paint_shadow (widget->style, @@ -363,8 +374,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, NULL, NULL, // FIXME: No clipping? - dx, dy, - widget->allocation.width-dw, widget->allocation.height-dh ); + x, y, w, h ); return; } @@ -375,8 +385,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL, NULL, NULL, // FIXME: No clipping? - dx, dy, - widget->allocation.width-dw, widget->allocation.height-dh ); + x, y, w, h ); return; } @@ -385,9 +394,7 @@ static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) GdkGC *gc; gc = gdk_gc_new( widget->window ); gdk_gc_set_foreground( gc, &widget->style->black ); - gdk_draw_rectangle( widget->window, gc, FALSE, - dx, dy, - widget->allocation.width-dw-1, widget->allocation.height-dh-1 ); + gdk_draw_rectangle( widget->window, gc, FALSE, x, y, w-1, h-1 ); g_object_unref (gc); return; } @@ -513,8 +520,6 @@ gtk_window_expose_callback( GtkWidget *widget, win->GtkSendPaintEvents(); // Let parent window draw window-less widgets - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event); - return FALSE; } } @@ -2141,7 +2146,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), alloc->height ); #endif - GTK_PIZZA(win->m_wxwindow)->m_width = alloc->width; + GTK_PIZZA(win->m_wxwindow)->m_width = win->GetClientSize().x; win->m_oldClientWidth = client_width; win->m_oldClientHeight = client_height; @@ -2464,12 +2469,14 @@ bool wxWindowGTK::Create( wxWindow *parent, m_scrollBar[ScrollDir_Horz] = GTK_RANGE(scrolledWindow->hscrollbar); m_scrollBar[ScrollDir_Vert] = GTK_RANGE(scrolledWindow->vscrollbar); + if (GetLayoutDirection() == wxLayout_RightToLeft) + gtk_range_set_inverted( m_scrollBar[ScrollDir_Horz], TRUE ); m_wxwindow = gtk_pizza_new(); #ifndef __WXUNIVERSAL__ GtkPizza *pizza = GTK_PIZZA(m_wxwindow); - + if (HasFlag(wxRAISED_BORDER)) { gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT ); @@ -2604,8 +2611,6 @@ void wxWindowGTK::PostCreation() { // these get reported to wxWidgets -> wxPaintEvent - gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE ); - g_signal_connect (m_wxwindow, "expose_event", G_CALLBACK (gtk_window_expose_callback), this); @@ -2759,10 +2764,6 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") ); -/* - printf( "DoSetSize: name %s, x,y,w,h: %d,%d,%d,%d \n", GetName().c_str(), x,y,width,height ); -*/ - if (m_resizing) return; /* I don't like recursions */ m_resizing = true; @@ -3018,9 +3019,7 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const int dh = 0; if (m_hasScrolling) - { GetScrollbarWidth(m_widget, dw, dh); - } #ifndef __WXUNIVERSAL__ if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) @@ -3113,7 +3112,15 @@ void wxWindowGTK::DoClientToScreen( int *x, int *y ) const } } - if (x) *x += org_x; + + if (x) + { + if (GetLayoutDirection() == wxLayout_RightToLeft) + *x = (GetClientSize().x - *x) + org_x; + else + *x += org_x; + } + if (y) *y += org_y; } @@ -3142,7 +3149,13 @@ void wxWindowGTK::DoScreenToClient( int *x, int *y ) const } } - if (x) *x -= org_x; + if (x) + { + if (GetLayoutDirection() == wxLayout_RightToLeft) + *x = (GetClientSize().x - *x) - org_x; + else + *x -= org_x; + } if (y) *y -= org_y; } @@ -3758,6 +3771,9 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) gdk_rect.y = rect->y; gdk_rect.width = rect->width; gdk_rect.height = rect->height; + if (GetLayoutDirection() == wxLayout_RightToLeft) + gdk_rect.x = GetClientSize().x - gdk_rect.x - gdk_rect.width; + p = &gdk_rect; } else // invalidate everything @@ -3765,8 +3781,6 @@ void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) p = NULL; } - p = NULL; - gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, p, TRUE ); } } @@ -3825,18 +3839,18 @@ void wxWindowGTK::GtkSendPaintEvents() // Clip to paint region in wxClientDC m_clipPaintRegion = true; - wxRegion maybe_rtl_region = m_updateRegion; - -#if 0 + m_nativeUpdateRegion = m_updateRegion; + if (GetLayoutDirection() == wxLayout_RightToLeft) { - maybe_rtl_region.Clear(); + // Transform m_updateRegion under RTL + m_updateRegion.Clear(); gint width; gdk_window_get_geometry( GTK_PIZZA(m_wxwindow)->bin_window, NULL, NULL, &width, NULL, NULL ); - wxRegionIterator upd( m_updateRegion ); + wxRegionIterator upd( m_nativeUpdateRegion ); while (upd) { wxRect rect; @@ -3846,12 +3860,11 @@ void wxWindowGTK::GtkSendPaintEvents() rect.height = upd.GetHeight(); rect.x = width - rect.x - rect.width; - maybe_rtl_region.Union( rect ); + m_updateRegion.Union( rect ); ++upd; } } -#endif // widget to draw on GtkPizza *pizza = GTK_PIZZA (m_wxwindow); @@ -3865,7 +3878,7 @@ void wxWindowGTK::GtkSendPaintEvents() if (GTK_WIDGET_MAPPED(parent->m_widget)) { - wxRegionIterator upd( m_updateRegion ); + wxRegionIterator upd( m_nativeUpdateRegion ); while (upd) { GdkRectangle rect; @@ -3889,8 +3902,6 @@ void wxWindowGTK::GtkSendPaintEvents() } else { - m_updateRegion = maybe_rtl_region; - wxWindowDC dc( (wxWindow*)this ); dc.SetClippingRegion( m_updateRegion ); @@ -3900,8 +3911,6 @@ void wxWindowGTK::GtkSendPaintEvents() GetEventHandler()->ProcessEvent(erase_event); } - m_updateRegion = maybe_rtl_region; - wxNcPaintEvent nc_paint_event( GetId() ); nc_paint_event.SetEventObject( this ); GetEventHandler()->ProcessEvent( nc_paint_event ); @@ -3913,6 +3922,7 @@ void wxWindowGTK::GtkSendPaintEvents() m_clipPaintRegion = false; m_updateRegion.Clear(); + m_nativeUpdateRegion.Clear(); } void wxWindowGTK::SetDoubleBuffered( bool on ) @@ -3923,6 +3933,11 @@ void wxWindowGTK::SetDoubleBuffered( bool on ) gtk_widget_set_double_buffered( m_wxwindow, on ); } +bool wxWindowGTK::IsDoubleBuffered() const +{ + return GTK_WIDGET_DOUBLE_BUFFERED( m_wxwindow ); +} + void wxWindowGTK::ClearBackground() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); @@ -4286,8 +4301,8 @@ void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) pos = max; if (pos < 0) pos = 0; - m_scrollPos[dir] = - adj->value = pos; + m_scrollPos[dir] = adj->value = pos; + // If a "value_changed" signal emission is not already in progress if (!m_blockValueChanged[dir]) { @@ -4340,7 +4355,9 @@ wxEventType wxWindowGTK::GetScrollEventType(GtkRange* range) const int barIndex = range == m_scrollBar[1]; GtkAdjustment* adj = range->adjustment; + const int value = int(adj->value + 0.5); + // save previous position const double oldPos = m_scrollPos[barIndex]; // update current position @@ -4386,7 +4403,10 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) m_clipPaintRegion = true; - gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy ); + if (GetLayoutDirection() == wxLayout_RightToLeft) + gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), dx, -dy ); + else + gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy ); m_clipPaintRegion = false; }