X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/18ac7bef9e6dc557a513caacd734bd4abaaf1a44..8ca1a013e4e699724040ff1f514dab3b4a11d3c9:/src/gtk/window.cpp?ds=sidebyside diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index d953a3e68b..ccb4500d43 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -424,6 +424,8 @@ void wxgtk_window_size_request_callback(GtkWidget *widget, } } +#if wxUSE_COMBOBOX + extern "C" { static void wxgtk_combo_size_request_callback(GtkWidget *widget, @@ -459,6 +461,8 @@ void wxgtk_combo_size_request_callback(GtkWidget *widget, } } +#endif // wxUSE_COMBOBOX + //----------------------------------------------------------------------------- // "expose_event" of m_wxwindow //----------------------------------------------------------------------------- @@ -1240,15 +1244,6 @@ template void InitMouseEvent(wxWindowGTK *win, 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); - if (event.GetEventType() == wxEVT_MOUSEWHEEL) - { - event.m_linesPerAction = 3; - event.m_wheelDelta = 120; - if (((GdkEventButton*)gdk_event)->button == 4) - event.m_wheelRotation = 120; - else if (((GdkEventButton*)gdk_event)->button == 5) - event.m_wheelRotation = -120; - } wxPoint pt = win->GetClientAreaOrigin(); event.m_x = (wxCoord)gdk_event->x - pt.x; @@ -1443,7 +1438,7 @@ gtk_window_button_press_callback( GtkWidget *widget, g_lastButtonNumber = gdk_event->button; - if (win->m_wxwindow && (g_focusWindow != win) && win->CanAcceptFocus()) + if (win->m_wxwindow && (g_focusWindow != win) && win->IsFocusable()) { gtk_widget_grab_focus( win->m_wxwindow ); } @@ -1545,13 +1540,6 @@ gtk_window_button_press_callback( GtkWidget *widget, ; } } - else if (gdk_event->button == 4 || gdk_event->button == 5) - { - if (gdk_event->type == GDK_BUTTON_PRESS ) - { - event_type = wxEVT_MOUSEWHEEL; - } - } if ( event_type == wxEVT_NULL ) { @@ -1586,7 +1574,7 @@ gtk_window_button_press_callback( GtkWidget *widget, return TRUE; if ((event_type == wxEVT_LEFT_DOWN) && !win->IsOfStandardClass() && - (g_focusWindow != win) && win->CanAcceptFocus()) + (g_focusWindow != win) && win->IsFocusable()) { gtk_widget_grab_focus( win->m_wxwindow ); } @@ -1742,7 +1730,7 @@ gtk_window_motion_notify_callback( GtkWidget *widget, } //----------------------------------------------------------------------------- -// "scroll_event", (mouse wheel event) +// "scroll_event" (mouse wheel event) //----------------------------------------------------------------------------- static gboolean @@ -2020,9 +2008,7 @@ gtk_scrollbar_value_changed(GtkRange* range, wxWindow* win) wxScrollWinEvent event(eventType, win->GetScrollPos(orient), orient); event.SetEventObject(win); - win->m_blockValueChanged[dir] = true; win->GTKProcessEvent(event); - win->m_blockValueChanged[dir] = false; } } @@ -2264,7 +2250,6 @@ void wxWindowGTK::Init() { m_scrollBar[dir] = NULL; m_scrollPos[dir] = 0; - m_blockValueChanged[dir] = false; } m_oldClientWidth = @@ -2400,7 +2385,7 @@ bool wxWindowGTK::Create( wxWindow *parent, g_signal_handler_block(m_scrollBar[dir], handler_id); // these handlers get notified when scrollbar slider moves - g_signal_connect(m_scrollBar[dir], "value_changed", + g_signal_connect_after(m_scrollBar[dir], "value_changed", G_CALLBACK(gtk_scrollbar_value_changed), this); } @@ -2562,6 +2547,7 @@ void wxWindowGTK::PostCreation() G_CALLBACK (gtk_window_size_callback), this); } +#if wxUSE_COMBOBOX if (GTK_IS_COMBO(m_widget)) { GtkCombo *gcombo = GTK_COMBO(m_widget); @@ -2569,17 +2555,18 @@ void wxWindowGTK::PostCreation() g_signal_connect (gcombo->entry, "size_request", G_CALLBACK (wxgtk_combo_size_request_callback), this); - } + } else +#endif // wxUSE_COMBOBOX #ifdef GTK_IS_FILE_CHOOSER_BUTTON - else if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget)) + if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget)) { // If we connect to the "size_request" signal of a GtkFileChooserButton // then that control won't be sized properly when placed inside sizers // (this can be tested removing this elseif and running XRC or WIDGETS samples) // FIXME: what should be done here ? - } + } else #endif - else if ( !IsTopLevel() ) // top level windows use their own callback + if ( !IsTopLevel() ) // top level windows use their own callback { // This is needed if we want to add our windows into native // GTK controls, such as the toolbar. With this callback, the @@ -3198,11 +3185,13 @@ void wxWindowGTK::SetFocus() { if (GTK_IS_CONTAINER(m_widget)) { +#if wxUSE_RADIOBTN if (IsKindOf(CLASSINFO(wxRadioButton))) { gtk_widget_grab_focus (m_widget); return; } +#endif // wxUSE_RADIOBTN gtk_widget_child_focus( m_widget, GTK_DIR_TAB_FORWARD ); } @@ -3399,7 +3388,7 @@ bool wxWindowGTK::DoNavigateIn(int flags) } else // navigate inside the container { - wxWindow *parent = wxGetTopLevelParent(this); + wxWindow *parent = wxGetTopLevelParent((wxWindow *)this); wxCHECK_MSG( parent, false, _T("every window must have a TLW parent") ); GtkDirectionType dir; @@ -3962,11 +3951,16 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) if (style == wxBG_STYLE_CUSTOM) { - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) + GdkWindow *window; + if ( m_wxwindow ) + { window = GTK_PIZZA(m_wxwindow)->bin_window; + } else - window = GetConnectWidget()->window; + { + GtkWidget * const w = GetConnectWidget(); + window = w ? w->window : NULL; + } if (window) { @@ -3979,9 +3973,11 @@ bool wxWindowGTK::SetBackgroundStyle(wxBackgroundStyle style) #endif m_needsStyleChange = false; } - else + else // window not realized yet + { // Do in OnIdle, because the window is not yet available m_needsStyleChange = true; + } // Don't apply widget style, or we get a grey background } @@ -4126,9 +4122,8 @@ void wxWindowGTK::SetScrollbar(int orient, int range, bool WXUNUSED(update)) { - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") ); + GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)]; + wxCHECK_RET( sb, _T("this window is not scrollable") ); if (range > 0) { @@ -4145,7 +4140,7 @@ void wxWindowGTK::SetScrollbar(int orient, pos = range - thumbVisible; if (pos < 0) pos = 0; - GtkAdjustment* adj = m_scrollBar[ScrollDirFromOrient(orient)]->adjustment; + GtkAdjustment * const adj = sb->adjustment; adj->step_increment = 1; adj->page_increment = adj->page_size = thumbVisible; @@ -4156,16 +4151,15 @@ void wxWindowGTK::SetScrollbar(int orient, void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) { - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - wxCHECK_RET( m_wxwindow != m_widget, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") ); + const int dir = ScrollDirFromOrient(orient); + GtkRange * const sb = m_scrollBar[dir]; + wxCHECK_RET( sb, _T("this window is not scrollable") ); // This check is more than an optimization. Without it, the slider // will not move smoothly while tracking when using wxScrollHelper. if (GetScrollPos(orient) != pos) { - const int dir = ScrollDirFromOrient(orient); - GtkAdjustment* adj = m_scrollBar[dir]->adjustment; + GtkAdjustment* adj = sb->adjustment; const int max = int(adj->upper - adj->page_size); if (pos > max) pos = max; @@ -4173,39 +4167,38 @@ void wxWindowGTK::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) pos = 0; m_scrollPos[dir] = adj->value = pos; - // If a "value_changed" signal emission is not already in progress - if (!m_blockValueChanged[dir]) - { - gtk_adjustment_value_changed(adj); - } + g_signal_handlers_block_by_func(m_scrollBar[dir], + (gpointer)gtk_scrollbar_value_changed, this); + + gtk_adjustment_value_changed(adj); + + g_signal_handlers_unblock_by_func(m_scrollBar[dir], + (gpointer)gtk_scrollbar_value_changed, this); } } int wxWindowGTK::GetScrollThumb(int orient) const { - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") ); + GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)]; + wxCHECK_MSG( sb, 0, _T("this window is not scrollable") ); - return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->page_size); + return int(sb->adjustment->page_size); } int wxWindowGTK::GetScrollPos( int orient ) const { - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") ); + GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)]; + wxCHECK_MSG( sb, 0, _T("this window is not scrollable") ); - return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->value + 0.5); + return int(sb->adjustment->value + 0.5); } int wxWindowGTK::GetScrollRange( int orient ) const { - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - wxCHECK_MSG( m_wxwindow != m_widget, 0, wxT("no scrolling for this wxWindow, use wxHSCROLL or wxVSCROLL") ); + GtkRange * const sb = m_scrollBar[ScrollDirFromOrient(orient)]; + wxCHECK_MSG( sb, 0, _T("this window is not scrollable") ); - return int(m_scrollBar[ScrollDirFromOrient(orient)]->adjustment->upper); + return int(sb->adjustment->upper); } // Determine if increment is the same as +/-x, allowing for some small @@ -4270,7 +4263,7 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) // No scrolling requested. if ((dx == 0) && (dy == 0)) return; - + m_clipPaintRegion = true; if (GetLayoutDirection() == wxLayout_RightToLeft)