From a2d93e735a9f126b855a9353ca8ddeacaaf52817 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 15 Sep 2000 13:15:37 +0000 Subject: [PATCH] Added Set/GetThemeEnabled and used this for determining whether to paint a theme background. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8367 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/window.h | 4 ++++ src/common/wincmn.cpp | 3 +++ src/generic/statusbr.cpp | 1 + src/gtk/dialog.cpp | 1 + src/gtk/frame.cpp | 4 +++- src/gtk/notebook.cpp | 4 ++++ src/gtk/tbargtk.cpp | 3 +-- src/gtk/window.cpp | 15 ++++++++++++++- src/gtk1/dialog.cpp | 1 + src/gtk1/frame.cpp | 4 +++- src/gtk1/notebook.cpp | 4 ++++ src/gtk1/tbargtk.cpp | 3 +-- src/gtk1/window.cpp | 15 ++++++++++++++- 13 files changed, 54 insertions(+), 8 deletions(-) diff --git a/include/wx/window.h b/include/wx/window.h index 61e65b7a9f..2fc3e20a8a 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -333,6 +333,9 @@ public: // make the window modal (all other windows unresponsive) virtual void MakeModal(bool modal = TRUE); + virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; } + virtual bool GetThemeEnabled() const { return m_themeEnabled; } + // focus handling // -------------- @@ -773,6 +776,7 @@ protected: long m_windowStyle, m_exStyle; wxString m_windowName; + bool m_themeEnabled; protected: // common part of all ctors: it is not virtual because it is called from diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index c419076210..ef975509ea 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -162,6 +162,9 @@ void wxWindowBase::InitBase() #if wxUSE_CARET m_caret = (wxCaret *)NULL; #endif // wxUSE_CARET + + // Whether we're using the current theme for this window (wxGTK only for now) + m_themeEnabled = FALSE; } // common part of window creation process diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index 9121f45f62..a65e6c1e5c 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -80,6 +80,7 @@ bool wxStatusBarGeneric::Create(wxWindow *parent, m_nFields = 0; m_borderX = wxTHICK_LINE_BORDER; m_borderY = wxTHICK_LINE_BORDER; + m_themeEnabled = TRUE; bool success = wxWindow::Create(parent, id, wxDefaultPosition, wxDefaultSize, diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 25f2982814..b52338cef1 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -231,6 +231,7 @@ void wxDialog::Init() m_returnCode = 0; m_sizeSet = FALSE; m_modalShowing = FALSE; + m_themeEnabled = TRUE; } wxDialog::wxDialog( wxWindow *parent, diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index a0be42f520..bb7d68e74f 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -449,6 +449,7 @@ void wxFrame::Init() m_insertInClientArea = TRUE; m_isIconized = FALSE; m_fsIsShowing = FALSE; + m_themeEnabled = TRUE; } bool wxFrame::Create( wxWindow *parent, @@ -1177,8 +1178,9 @@ void wxFrame::Maximize(bool WXUNUSED(maximize)) bool wxFrame::IsMaximized() const { - wxFAIL_MSG( _T("not implemented") ); + // wxFAIL_MSG( _T("not implemented") ); + // This is an approximation return FALSE; } diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 3626e86c46..a05a2f1b00 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -216,6 +216,7 @@ void wxNotebook::Init() m_imageList = (wxImageList *) NULL; m_pages.DeleteContents( TRUE ); m_lastSelection = -1; + m_themeEnabled = TRUE; } wxNotebook::wxNotebook() @@ -561,6 +562,9 @@ bool wxNotebook::InsertPage( int position, wxNotebookPage* win, const wxString& gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); + if (m_themeEnabled) + win->SetThemeEnabled(TRUE); + GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); wxGtkNotebookPage *page = new wxGtkNotebookPage(); diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index bac1d93d79..06a06a0d5c 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -220,10 +220,9 @@ void wxToolBar::Init() { m_fg = m_bg = (GdkColor *)NULL; - m_toolbar = (GtkToolbar *)NULL; - m_blockNextEvent = FALSE; + m_themeEnabled = TRUE; } wxToolBar::~wxToolBar() diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 1bd4d35d83..cdbcf62cf0 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -680,7 +680,8 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev */ GtkPizza *pizza = GTK_PIZZA (widget); - + +/* if (win->IsTopLevel()) { gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, @@ -695,6 +696,18 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); } +*/ + if (win->GetThemeEnabled()) + { + wxWindow *parent = win->GetParent(); + while (parent && !parent->IsTopLevel()) + parent = parent->GetParent(); + if (!parent) + parent = win; + + gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); + } win->GetUpdateRegion().Union( gdk_event->area.x, gdk_event->area.y, diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 25f2982814..b52338cef1 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -231,6 +231,7 @@ void wxDialog::Init() m_returnCode = 0; m_sizeSet = FALSE; m_modalShowing = FALSE; + m_themeEnabled = TRUE; } wxDialog::wxDialog( wxWindow *parent, diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index a0be42f520..bb7d68e74f 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -449,6 +449,7 @@ void wxFrame::Init() m_insertInClientArea = TRUE; m_isIconized = FALSE; m_fsIsShowing = FALSE; + m_themeEnabled = TRUE; } bool wxFrame::Create( wxWindow *parent, @@ -1177,8 +1178,9 @@ void wxFrame::Maximize(bool WXUNUSED(maximize)) bool wxFrame::IsMaximized() const { - wxFAIL_MSG( _T("not implemented") ); + // wxFAIL_MSG( _T("not implemented") ); + // This is an approximation return FALSE; } diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 3626e86c46..a05a2f1b00 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -216,6 +216,7 @@ void wxNotebook::Init() m_imageList = (wxImageList *) NULL; m_pages.DeleteContents( TRUE ); m_lastSelection = -1; + m_themeEnabled = TRUE; } wxNotebook::wxNotebook() @@ -561,6 +562,9 @@ bool wxNotebook::InsertPage( int position, wxNotebookPage* win, const wxString& gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); + if (m_themeEnabled) + win->SetThemeEnabled(TRUE); + GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); wxGtkNotebookPage *page = new wxGtkNotebookPage(); diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index bac1d93d79..06a06a0d5c 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -220,10 +220,9 @@ void wxToolBar::Init() { m_fg = m_bg = (GdkColor *)NULL; - m_toolbar = (GtkToolbar *)NULL; - m_blockNextEvent = FALSE; + m_themeEnabled = TRUE; } wxToolBar::~wxToolBar() diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 1bd4d35d83..cdbcf62cf0 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -680,7 +680,8 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev */ GtkPizza *pizza = GTK_PIZZA (widget); - + +/* if (win->IsTopLevel()) { gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, @@ -695,6 +696,18 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); } +*/ + if (win->GetThemeEnabled()) + { + wxWindow *parent = win->GetParent(); + while (parent && !parent->IsTopLevel()) + parent = parent->GetParent(); + if (!parent) + parent = win; + + gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); + } win->GetUpdateRegion().Union( gdk_event->area.x, gdk_event->area.y, -- 2.45.2