X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d91eb06e9c6626c246e4b18587165bcda5126644..1abfa172c547a37751e598084fb8d541071471a3:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 086f2f13ee..8f71b6e2ec 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -326,61 +326,18 @@ void wxgtk_window_size_request_callback(GtkWidget * WXUNUSED(widget), } } -#if wxUSE_COMBOBOX - -extern "C" { -static -void wxgtk_combo_size_request_callback(GtkWidget * WXUNUSED(widget), - GtkRequisition *requisition, - wxWindow* win) -{ - // This callback is actually hooked into the text entry - // of the combo box, not the GtkHBox. - - int w, h; - win->GetSize( &w, &h ); - if (w < 2) - w = 2; - if (h < 2) - h = 2; - - GtkCombo *gcombo = GTK_COMBO(win->m_widget); - - GtkRequisition entry_req; - entry_req.width = 2; - entry_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(gcombo->entry) )->size_request ) - (gcombo->entry, &entry_req ); - - GtkRequisition button_req; - button_req.width = 2; - button_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(gcombo->button) )->size_request ) - (gcombo->button, &button_req ); - - requisition->width = w - button_req.width; - requisition->height = entry_req.height; -} -} - -#endif // wxUSE_COMBOBOX - //----------------------------------------------------------------------------- // "expose_event" of m_wxwindow //----------------------------------------------------------------------------- extern "C" { static gboolean -gtk_window_expose_callback( GtkWidget *widget, +gtk_window_expose_callback( GtkWidget*, GdkEventExpose *gdk_event, wxWindow *win ) { DEBUG_MAIN_THREAD - // if this event is for the border-only GdkWindow - if (gdk_event->window != widget->window) - return false; - #if 0 if (win->GetName()) { @@ -420,12 +377,15 @@ gtk_window_expose_callback( GtkWidget *widget, //----------------------------------------------------------------------------- #ifndef __WXUNIVERSAL__ + +GtkWidget* GetEntryWidget(); + extern "C" { static gboolean -expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win) +expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) { // if this event is not for the GdkWindow the border is drawn on - if (win->m_wxwindow == win->m_widget && event->window == widget->window) + if (win->m_wxwindow == win->m_widget && gdk_event->window == widget->window) return false; int x = 0; @@ -440,10 +400,9 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win) int h = win->m_wxwindow->allocation.height; if (win->HasFlag(wxBORDER_SIMPLE)) { - GdkGC* gc; - gc = gdk_gc_new(event->window); + GdkGC* gc = gdk_gc_new(gdk_event->window); gdk_gc_set_foreground(gc, &widget->style->black); - gdk_draw_rectangle(event->window, gc, false, x, y, w - 1, h - 1); + gdk_draw_rectangle(gdk_event->window, gc, false, x, y, w - 1, h - 1); g_object_unref(gc); } else @@ -451,9 +410,20 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* event, wxWindow* win) GtkShadowType shadow = GTK_SHADOW_IN; if (win->HasFlag(wxBORDER_RAISED)) shadow = GTK_SHADOW_OUT; + + // Style detail to use + const char* detail; + if (widget == win->m_wxwindow) + // for non-scrollable wxWindows + detail = "entry"; + else + // for scrollable ones + detail = "viewport"; + + GtkWidget* styleWidget = GetEntryWidget(); gtk_paint_shadow( - widget->style, event->window, GTK_STATE_NORMAL, - shadow, &event->area, widget, NULL, x, y, w, h); + styleWidget->style, gdk_event->window, GTK_STATE_NORMAL, + shadow, NULL, styleWidget, detail, x, y, w, h); } // no further painting is needed for border-only GdkWindow @@ -2064,11 +2034,8 @@ void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget), GtkStyle *previous_style, wxWindow* win ) { - //wxLogDebug(wxT("gtk_window_style_set_callback")); if (win && previous_style) { - wxString name(win->GetName()); - //wxLogDebug(wxT("gtk_window_style_set_callback %s"), name.c_str()); wxSysColourChangedEvent event; event.SetEventObject(win); @@ -2078,40 +2045,28 @@ void gtk_window_style_set_callback( GtkWidget *WXUNUSED(widget), } // extern "C" -// Connect/disconnect style-set - -void wxConnectStyleSet(wxWindow* win) -{ - if (win->m_wxwindow) - g_signal_connect (win->m_wxwindow, "style_set", - G_CALLBACK (gtk_window_style_set_callback), win); -} - -void wxDisconnectStyleSet(wxWindow* win) -{ - if (win->m_wxwindow) - g_signal_handlers_disconnect_by_func (win->m_wxwindow, - (gpointer) gtk_window_style_set_callback, - win); -} - // Helper to suspend colour change event event processing while we change a widget's style class wxSuspendStyleEvents { public: - wxSuspendStyleEvents(wxWindow* win) - { - m_win = win; - if (win->IsTopLevel()) - wxDisconnectStyleSet(win); - } - ~wxSuspendStyleEvents() - { - if (m_win->IsTopLevel()) - wxConnectStyleSet(m_win); - } + wxSuspendStyleEvents(wxWindow* win) + { + m_win = NULL; + if (win->m_wxwindow && win->IsTopLevel()) + { + m_win = win; + g_signal_handlers_block_by_func( + m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win); + } + } + ~wxSuspendStyleEvents() + { + if (m_win) + g_signal_handlers_unblock_by_func( + m_win->m_wxwindow, (void*)gtk_window_style_set_callback, m_win); + } - wxWindow* m_win; + wxWindow* m_win; }; // ---------------------------------------------------------------------------- @@ -2271,6 +2226,11 @@ bool wxWindowGTK::Create( wxWindow *parent, long style, const wxString &name ) { + // Get default border + wxBorder border = GetBorder(style); + style &= ~wxBORDER_MASK; + style |= border; + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { @@ -2278,6 +2238,7 @@ bool wxWindowGTK::Create( wxWindow *parent, return false; } + m_wxwindow = wxPizza::New(m_windowStyle); if (!HasFlag(wxHSCROLL) && !HasFlag(wxVSCROLL)) m_widget = m_wxwindow; @@ -2453,7 +2414,7 @@ void wxWindowGTK::PostCreation() // border drawing #ifndef __WXUNIVERSAL__ - if (HasFlag(wxBORDER_SIMPLE | wxBORDER_RAISED | wxBORDER_SUNKEN)) + if (HasFlag(wxPizza::BORDER_STYLES)) { g_signal_connect(m_widget, "expose_event", G_CALLBACK(expose_event_border), this); @@ -2533,16 +2494,6 @@ void wxWindowGTK::PostCreation() #endif } -#if wxUSE_COMBOBOX - if (GTK_IS_COMBO(m_widget)) - { - GtkCombo *gcombo = GTK_COMBO(m_widget); - - 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 if (!gtk_check_version(2,6,0) && GTK_IS_FILE_CHOOSER_BUTTON(m_widget)) { @@ -3327,7 +3278,7 @@ wxWindowGTK::AdjustForLayoutDirection(wxCoord x, return x; } -void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, MoveKind move) +void wxWindowGTK::DoMoveInTabOrder(wxWindow *win, WindowOrder move) { wxWindowBase::DoMoveInTabOrder(win, move); m_dirtyTabOrder = true;