From c02e5a31c5bd451fd3c82c7b6359a01c68352907 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 31 Jul 2003 13:59:28 +0000 Subject: [PATCH] Removed some warnings in widgets sample Reduced some flicker in wxNotebook when using XP controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22413 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/notebook.h | 2 ++ samples/notebook/notebook.cpp | 6 +++--- samples/notebook/notebook.h | 2 +- samples/widgets/button.cpp | 4 ++-- samples/widgets/combobox.cpp | 10 ++++----- samples/widgets/gauge.cpp | 2 +- samples/widgets/listbox.cpp | 8 +++---- samples/widgets/notebook.cpp | 4 ++-- samples/widgets/radiobox.cpp | 2 +- samples/widgets/slider.cpp | 2 +- samples/widgets/spinbtn.cpp | 2 +- samples/widgets/static.cpp | 10 ++++----- samples/widgets/textctrl.cpp | 4 ++-- samples/widgets/widgets.cpp | 12 +++++------ src/msw/notebook.cpp | 39 ++++++++++++++++++++++++++++++++++- 15 files changed, 74 insertions(+), 35 deletions(-) diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index a0782fb3cb..ca756a6477 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -148,6 +148,8 @@ protected: // set the size of the given page to fit in the notebook void AdjustPageSize(wxNotebookPage *page); + // override WndProc + virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); // the current selection (-1 if none) int m_nSelection; diff --git a/samples/notebook/notebook.cpp b/samples/notebook/notebook.cpp index e654d15bcf..cf7f04fcb3 100644 --- a/samples/notebook/notebook.cpp +++ b/samples/notebook/notebook.cpp @@ -229,7 +229,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, ); m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, - wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER); + wxTAB_TRAVERSAL | wxCLIP_CHILDREN | wxNO_BORDER | wxNO_FULL_REPAINT_ON_RESIZE); // Create remaining controls @@ -368,7 +368,7 @@ void MyFrame::ReInitNotebook() m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, - flags); + flags|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); if ( m_chkShowImages->IsChecked() ) { @@ -429,7 +429,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_IDLE(MyFrame::OnIdle) END_EVENT_TABLE() -void MyFrame::OnCheckOrRadioBox(wxCommandEvent& event) +void MyFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { ReInitNotebook(); } diff --git a/samples/notebook/notebook.h b/samples/notebook/notebook.h index 4bb0005270..f38fe3b512 100644 --- a/samples/notebook/notebook.h +++ b/samples/notebook/notebook.h @@ -48,7 +48,7 @@ class MyFrame : public wxFrame { public: MyFrame(const wxString& title, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE); + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE); virtual ~MyFrame(); diff --git a/samples/widgets/button.cpp b/samples/widgets/button.cpp index d14df3ae57..d4c000977d 100644 --- a/samples/widgets/button.cpp +++ b/samples/widgets/button.cpp @@ -355,7 +355,7 @@ void ButtonWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) CreateButton(); } -void ButtonWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void ButtonWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateButton(); } @@ -365,7 +365,7 @@ void ButtonWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event)) m_button->SetLabel(m_textLabel->GetValue()); } -void ButtonWidgetsPage::OnButton(wxCommandEvent& event) +void ButtonWidgetsPage::OnButton(wxCommandEvent& WXUNUSED(event)) { wxLogMessage(_T("Test button clicked.")); } diff --git a/samples/widgets/combobox.cpp b/samples/widgets/combobox.cpp index 0fb153f667..4fe53e9572 100644 --- a/samples/widgets/combobox.cpp +++ b/samples/widgets/combobox.cpp @@ -420,12 +420,12 @@ void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event)) } } -void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event)) { m_combobox->Clear(); } -void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event)) { static unsigned int s_item = 0; @@ -440,7 +440,7 @@ void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event) m_combobox->Insert(s, m_combobox->GetSelection()); } -void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event)) { static unsigned int s_item = 0; @@ -463,7 +463,7 @@ void ComboboxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event)) } } -void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& event) +void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(event)) { m_combobox->Append(_T("First")); m_combobox->Append(_T("another one")); @@ -545,7 +545,7 @@ void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event) wxLogMessage(_T("Combobox item %ld selected"), sel); } -void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateCombo(); } diff --git a/samples/widgets/gauge.cpp b/samples/widgets/gauge.cpp index e7d7eba313..477f8d429b 100644 --- a/samples/widgets/gauge.cpp +++ b/samples/widgets/gauge.cpp @@ -362,7 +362,7 @@ void GaugeWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) event.Enable( m_chkVert->GetValue() || m_chkSmooth->GetValue() ); } -void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateGauge(); } diff --git a/samples/widgets/listbox.cpp b/samples/widgets/listbox.cpp index 33d578c86c..dc87d04c5b 100644 --- a/samples/widgets/listbox.cpp +++ b/samples/widgets/listbox.cpp @@ -422,12 +422,12 @@ void ListboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event)) } } -void ListboxWidgetsPage::OnButtonClear(wxCommandEvent& event) +void ListboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event)) { m_lbox->Clear(); } -void ListboxWidgetsPage::OnButtonAdd(wxCommandEvent& event) +void ListboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event)) { static unsigned int s_item = 0; @@ -450,7 +450,7 @@ void ListboxWidgetsPage::OnButtonAddMany(wxCommandEvent& WXUNUSED(event)) } } -void ListboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& event) +void ListboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(event)) { wxArrayString items; items.Add(_T("First")); @@ -508,7 +508,7 @@ void ListboxWidgetsPage::OnCheckListbox(wxCommandEvent& event) wxLogMessage( _T("Listbox item %ld toggled"), event.GetInt() ); } -void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateLbox(); } diff --git a/samples/widgets/notebook.cpp b/samples/widgets/notebook.cpp index 8534da6d87..5c81ee9117 100644 --- a/samples/widgets/notebook.cpp +++ b/samples/widgets/notebook.cpp @@ -459,7 +459,7 @@ void NotebookWidgetsPage::OnButtonDeleteAll(wxCommandEvent& WXUNUSED(event)) m_notebook->DeleteAllPages(); } -void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& event) +void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& WXUNUSED(event)) { int pos = GetTextValue(m_textSelect); wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") ); @@ -521,7 +521,7 @@ void NotebookWidgetsPage::OnUpdateUICurSelectText(wxUpdateUIEvent& event) event.SetText( wxString::Format(_T("%d"), m_notebook->GetSelection()) ); } -void NotebookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void NotebookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateNotebook(); } diff --git a/samples/widgets/radiobox.cpp b/samples/widgets/radiobox.cpp index ef45264175..3a23989e52 100644 --- a/samples/widgets/radiobox.cpp +++ b/samples/widgets/radiobox.cpp @@ -377,7 +377,7 @@ void RadioWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) CreateRadio(); } -void RadioWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void RadioWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateRadio(); } diff --git a/samples/widgets/slider.cpp b/samples/widgets/slider.cpp index b0f1fa8d3e..45f1bed255 100644 --- a/samples/widgets/slider.cpp +++ b/samples/widgets/slider.cpp @@ -536,7 +536,7 @@ void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) m_chkBothSides->GetValue() ); } -void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateSlider(); } diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index 1d39412359..089bfb4fb2 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -384,7 +384,7 @@ void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) event.Enable( !m_chkVert->GetValue() || m_chkWrap->GetValue() ); } -void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateSpin(); } diff --git a/samples/widgets/static.cpp b/samples/widgets/static.cpp index 98b8d5803d..531041b2dc 100644 --- a/samples/widgets/static.cpp +++ b/samples/widgets/static.cpp @@ -94,7 +94,7 @@ public: } protected: - void OnMouseEvent(wxMouseEvent& event) + void OnMouseEvent(wxMouseEvent& WXUNUSED(event)) { wxLogMessage(wxT("Clicked on static text")); } @@ -116,7 +116,7 @@ public: } protected: - void OnMouseEvent(wxMouseEvent& event) + void OnMouseEvent(wxMouseEvent& WXUNUSED(event)) { wxLogMessage(wxT("Clicked on static box")); } @@ -413,17 +413,17 @@ void StaticWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) CreateStatic(); } -void StaticWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void StaticWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateStatic(); } -void StaticWidgetsPage::OnButtonBoxText(wxCommandEvent& event) +void StaticWidgetsPage::OnButtonBoxText(wxCommandEvent& WXUNUSED(event)) { m_sizerStatBox->GetStaticBox()->SetLabel(m_textBox->GetValue()); } -void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& event) +void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& WXUNUSED(event)) { m_statText->SetLabel(m_textLabel->GetValue()); } diff --git a/samples/widgets/textctrl.cpp b/samples/widgets/textctrl.cpp index 6c52e64825..bf45656175 100644 --- a/samples/widgets/textctrl.cpp +++ b/samples/widgets/textctrl.cpp @@ -735,7 +735,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event) (m_chkWrapLines->GetValue() != DEFAULTS.wraplines) ); } -void TextWidgetsPage::OnText(wxCommandEvent& event) +void TextWidgetsPage::OnText(wxCommandEvent& WXUNUSED(event)) { // small hack to suppress the very first message: by then the logging is // not yet redirected and so initial setting of the text value results in @@ -755,7 +755,7 @@ void TextWidgetsPage::OnTextEnter(wxCommandEvent& event) wxLogMessage(_T("Text entered: '%s'"), event.GetString().c_str()); } -void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) +void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event)) { CreateText(); } diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index b4d38ea141..494d77bd00 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -142,7 +142,7 @@ private: } } - virtual void DoLogString(const wxChar *szString, time_t t) + virtual void DoLogString(const wxChar *szString, time_t WXUNUSED(t)) { wxString msg; TimeStamp(&msg); @@ -228,7 +228,7 @@ bool WidgetsApp::OnInit() // ---------------------------------------------------------------------------- WidgetsFrame::WidgetsFrame(const wxString& title) - : wxFrame(NULL, -1, title, wxPoint(0, 50)) + : wxFrame(NULL, -1, title, wxPoint(0, 50), wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN) { // init everything m_lboxLog = (wxListBox *)NULL; @@ -237,14 +237,14 @@ WidgetsFrame::WidgetsFrame(const wxString& title) m_imaglist = (wxImageList *)NULL; // create controls - m_panel = new wxPanel(this, -1); + m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN); wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); // we have 2 panes: notebook which pages demonstrating the controls in the // upper one and the log window with some buttons in the lower - m_notebook = new wxNotebook(m_panel, -1); + m_notebook = new wxNotebook(m_panel, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN); InitNotebook(); wxSizer *sizerUp = new wxNotebookSizer(m_notebook); @@ -333,7 +333,7 @@ void WidgetsFrame::OnButtonQuit(wxCommandEvent& WXUNUSED(event)) Close(); } -void WidgetsFrame::OnButtonClearLog(wxCommandEvent& event) +void WidgetsFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event)) { m_lboxLog->Clear(); } @@ -358,7 +358,7 @@ WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label) // ---------------------------------------------------------------------------- WidgetsPage::WidgetsPage(wxNotebook *notebook) - : wxPanel(notebook, -1) + : wxPanel(notebook, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN) { } diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 2594af1c81..5a858d1a57 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -485,11 +485,21 @@ bool wxNotebook::InsertPage(int nPage, _T("notebook pages must have notebook as parent") ); #if wxUSE_UXTHEME && wxUSE_UXTHEME_AUTO + static bool g_TestedForTheme = FALSE; + static bool g_UseTheme = FALSE; + if (!g_TestedForTheme) + { + int commCtrlVersion = wxTheApp->GetComCtl32Version() ; + + g_UseTheme = (commCtrlVersion >= 600); + g_TestedForTheme = TRUE; + } + // Automatically apply the theme background, // changing the colour of the panel to match the // tab page colour. This won't work well with all // themes but it's a start. - if (wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel))) + if (g_UseTheme && wxUxThemeEngine::Get() && pPage->IsKindOf(CLASSINFO(wxPanel))) { ApplyThemeBackground(pPage, GetThemeBackgroundColour()); } @@ -848,4 +858,31 @@ void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour) #endif } +long wxNotebook::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +{ + static bool g_TestedForTheme = FALSE; + static bool g_UseTheme = FALSE; + switch ( nMsg ) + { + case WM_ERASEBKGND: + { + if (!g_TestedForTheme) + { + int commCtrlVersion = wxTheApp->GetComCtl32Version() ; + + g_UseTheme = (commCtrlVersion >= 600); + g_TestedForTheme = TRUE; + } + + // If using XP themes, it seems we can get away + // with not drawing a background, which reduces flicker. + if (g_UseTheme) + return TRUE; + } + } + + return wxControl::MSWWindowProc(nMsg, wParam, lParam); +} + + #endif // wxUSE_NOTEBOOK -- 2.45.2