From 6493aacaeb7b22b9fa35c559f7753e9fec0da71f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 16 Apr 2006 23:38:26 +0000 Subject: [PATCH] centralized the handling of border styles; added borders support for wxListBox and support of other kinds of borders (patch 1448088) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38771 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/gtk/window.h | 3 +++ src/gtk/dataview.cpp | 3 ++- src/gtk/listbox.cpp | 3 +++ src/gtk/textctrl.cpp | 3 +-- src/gtk/window.cpp | 23 +++++++++++++++++++++++ 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 21dfdb3b5a..01d4dbd982 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -203,6 +203,7 @@ wxGTK: - Fixed problems with CJK input method. - Implemented ScrollLines/Pages() for all windows (Paul Cornett). - Support underlined fonts in wxTextCtrl. +- Support all border styles; wxListBox honours the borders now wxMac: diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 44b7940a8e..689a81c255 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -277,6 +277,9 @@ protected: // ApplyWidgetStyle -- override this, not ApplyWidgetStyle virtual void DoApplyWidgetStyle(GtkRcStyle *style); + // sets the border of a given GtkScrolledWindow from a wx style + static void GtkScrolledWindowSetBorder(GtkWidget* w, int style); + protected: // GtkAdjustment to be used by Scroll{Lines,Pages} void SetVScrollAdjustment(GtkAdjustment* adj); diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index ddfe171080..55767284db 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1407,7 +1407,8 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id, } m_widget = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (m_widget), GTK_SHADOW_IN); + + GtkScrolledWindowSetBorder(m_widget, style); m_treeview = gtk_tree_view_new(); gtk_container_add (GTK_CONTAINER (m_widget), m_treeview); diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 02a7a5d88f..fbe7e88e41 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -467,6 +467,9 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); } + + GtkScrolledWindowSetBorder(m_widget, style); + m_treeview = GTK_TREE_VIEW( gtk_tree_view_new( ) ); //wxListBox doesn't have a header :) diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 5a550f140b..53c0f69396 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -600,8 +600,7 @@ bool wxTextCtrl::Create( wxWindow *parent, gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), wrap ); - if (!HasFlag(wxNO_BORDER)) - gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); + GtkScrolledWindowSetBorder(m_widget, style); gtk_widget_add_events( GTK_WIDGET(m_text), GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 70d044e9b8..b582d55476 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4334,6 +4334,29 @@ void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) m_clipPaintRegion = false; } +void wxWindowGTK::GtkScrolledWindowSetBorder(GtkWidget* w, int wxstyle) +{ + //RN: Note that static controls usually have no border on gtk, so maybe + //it makes sense to treat that as simply no border at the wx level + //as well... + if (!(wxstyle & wxNO_BORDER) && !(wxstyle & wxBORDER_STATIC)) + { + GtkShadowType gtkstyle; + + if(wxstyle & wxBORDER_RAISED) + gtkstyle = GTK_SHADOW_OUT; + else if (wxstyle & wxBORDER_SUNKEN) + gtkstyle = GTK_SHADOW_IN; + else if (wxstyle & wxBORDER_DOUBLE) + gtkstyle = GTK_SHADOW_ETCHED_IN; + else //default + gtkstyle = GTK_SHADOW_IN; + + gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(w), + gtkstyle ); + } +} + void wxWindowGTK::SetWindowStyleFlag( long style ) { // Updates the internal variable. NB: Now m_windowStyle bits carry the _new_ style values already -- 2.47.2