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
This commit is contained in:
Julian Smart
2003-07-31 13:59:28 +00:00
parent 055f8a8b28
commit c02e5a31c5
15 changed files with 74 additions and 35 deletions

View File

@@ -148,6 +148,8 @@ protected:
// set the size of the given page to fit in the notebook // set the size of the given page to fit in the notebook
void AdjustPageSize(wxNotebookPage *page); void AdjustPageSize(wxNotebookPage *page);
// override WndProc
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// the current selection (-1 if none) // the current selection (-1 if none)
int m_nSelection; int m_nSelection;

View File

@@ -229,7 +229,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
); );
m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, 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 // Create remaining controls
@@ -368,7 +368,7 @@ void MyFrame::ReInitNotebook()
m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK, m_notebook = new MyNotebook(m_panel, ID_NOTEBOOK,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
flags); flags|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE);
if ( m_chkShowImages->IsChecked() ) if ( m_chkShowImages->IsChecked() )
{ {
@@ -429,7 +429,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_IDLE(MyFrame::OnIdle) EVT_IDLE(MyFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
void MyFrame::OnCheckOrRadioBox(wxCommandEvent& event) void MyFrame::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
ReInitNotebook(); ReInitNotebook();
} }

View File

@@ -48,7 +48,7 @@ class MyFrame : public wxFrame
{ {
public: public:
MyFrame(const wxString& title, const wxPoint& pos = wxDefaultPosition, 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(); virtual ~MyFrame();

View File

@@ -355,7 +355,7 @@ void ButtonWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
CreateButton(); CreateButton();
} }
void ButtonWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void ButtonWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateButton(); CreateButton();
} }
@@ -365,7 +365,7 @@ void ButtonWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event))
m_button->SetLabel(m_textLabel->GetValue()); m_button->SetLabel(m_textLabel->GetValue());
} }
void ButtonWidgetsPage::OnButton(wxCommandEvent& event) void ButtonWidgetsPage::OnButton(wxCommandEvent& WXUNUSED(event))
{ {
wxLogMessage(_T("Test button clicked.")); wxLogMessage(_T("Test button clicked."));
} }

View File

@@ -420,12 +420,12 @@ void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
} }
} }
void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& event) void ComboboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
{ {
m_combobox->Clear(); m_combobox->Clear();
} }
void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event) void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event))
{ {
static unsigned int s_item = 0; static unsigned int s_item = 0;
@@ -440,7 +440,7 @@ void ComboboxWidgetsPage::OnButtonInsert(wxCommandEvent& event)
m_combobox->Insert(s, m_combobox->GetSelection()); m_combobox->Insert(s, m_combobox->GetSelection());
} }
void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& event) void ComboboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
{ {
static unsigned int s_item = 0; 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("First"));
m_combobox->Append(_T("another one")); m_combobox->Append(_T("another one"));
@@ -545,7 +545,7 @@ void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
wxLogMessage(_T("Combobox item %ld selected"), sel); wxLogMessage(_T("Combobox item %ld selected"), sel);
} }
void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateCombo(); CreateCombo();
} }

View File

@@ -362,7 +362,7 @@ void GaugeWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
event.Enable( m_chkVert->GetValue() || m_chkSmooth->GetValue() ); event.Enable( m_chkVert->GetValue() || m_chkSmooth->GetValue() );
} }
void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateGauge(); CreateGauge();
} }

View File

@@ -422,12 +422,12 @@ void ListboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
} }
} }
void ListboxWidgetsPage::OnButtonClear(wxCommandEvent& event) void ListboxWidgetsPage::OnButtonClear(wxCommandEvent& WXUNUSED(event))
{ {
m_lbox->Clear(); m_lbox->Clear();
} }
void ListboxWidgetsPage::OnButtonAdd(wxCommandEvent& event) void ListboxWidgetsPage::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
{ {
static unsigned int s_item = 0; 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; wxArrayString items;
items.Add(_T("First")); items.Add(_T("First"));
@@ -508,7 +508,7 @@ void ListboxWidgetsPage::OnCheckListbox(wxCommandEvent& event)
wxLogMessage( _T("Listbox item %ld toggled"), event.GetInt() ); wxLogMessage( _T("Listbox item %ld toggled"), event.GetInt() );
} }
void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateLbox(); CreateLbox();
} }

View File

@@ -459,7 +459,7 @@ void NotebookWidgetsPage::OnButtonDeleteAll(wxCommandEvent& WXUNUSED(event))
m_notebook->DeleteAllPages(); m_notebook->DeleteAllPages();
} }
void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& event) void NotebookWidgetsPage::OnButtonSelectPage(wxCommandEvent& WXUNUSED(event))
{ {
int pos = GetTextValue(m_textSelect); int pos = GetTextValue(m_textSelect);
wxCHECK_RET( IsValidValue(pos), _T("button should be disabled") ); 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()) ); event.SetText( wxString::Format(_T("%d"), m_notebook->GetSelection()) );
} }
void NotebookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void NotebookWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateNotebook(); CreateNotebook();
} }

View File

@@ -377,7 +377,7 @@ void RadioWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
CreateRadio(); CreateRadio();
} }
void RadioWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void RadioWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateRadio(); CreateRadio();
} }

View File

@@ -536,7 +536,7 @@ void SliderWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
m_chkBothSides->GetValue() ); m_chkBothSides->GetValue() );
} }
void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void SliderWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateSlider(); CreateSlider();
} }

View File

@@ -384,7 +384,7 @@ void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
event.Enable( !m_chkVert->GetValue() || m_chkWrap->GetValue() ); event.Enable( !m_chkVert->GetValue() || m_chkWrap->GetValue() );
} }
void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void SpinBtnWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateSpin(); CreateSpin();
} }

View File

@@ -94,7 +94,7 @@ public:
} }
protected: protected:
void OnMouseEvent(wxMouseEvent& event) void OnMouseEvent(wxMouseEvent& WXUNUSED(event))
{ {
wxLogMessage(wxT("Clicked on static text")); wxLogMessage(wxT("Clicked on static text"));
} }
@@ -116,7 +116,7 @@ public:
} }
protected: protected:
void OnMouseEvent(wxMouseEvent& event) void OnMouseEvent(wxMouseEvent& WXUNUSED(event))
{ {
wxLogMessage(wxT("Clicked on static box")); wxLogMessage(wxT("Clicked on static box"));
} }
@@ -413,17 +413,17 @@ void StaticWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
CreateStatic(); CreateStatic();
} }
void StaticWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void StaticWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateStatic(); CreateStatic();
} }
void StaticWidgetsPage::OnButtonBoxText(wxCommandEvent& event) void StaticWidgetsPage::OnButtonBoxText(wxCommandEvent& WXUNUSED(event))
{ {
m_sizerStatBox->GetStaticBox()->SetLabel(m_textBox->GetValue()); m_sizerStatBox->GetStaticBox()->SetLabel(m_textBox->GetValue());
} }
void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& event) void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& WXUNUSED(event))
{ {
m_statText->SetLabel(m_textLabel->GetValue()); m_statText->SetLabel(m_textLabel->GetValue());
} }

View File

@@ -735,7 +735,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
(m_chkWrapLines->GetValue() != DEFAULTS.wraplines) ); (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 // 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 // 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()); wxLogMessage(_T("Text entered: '%s'"), event.GetString().c_str());
} }
void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& event) void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
{ {
CreateText(); CreateText();
} }

View File

@@ -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; wxString msg;
TimeStamp(&msg); TimeStamp(&msg);
@@ -228,7 +228,7 @@ bool WidgetsApp::OnInit()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
WidgetsFrame::WidgetsFrame(const wxString& title) 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 // init everything
m_lboxLog = (wxListBox *)NULL; m_lboxLog = (wxListBox *)NULL;
@@ -237,14 +237,14 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
m_imaglist = (wxImageList *)NULL; m_imaglist = (wxImageList *)NULL;
// create controls // create controls
m_panel = new wxPanel(this, -1); m_panel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxCLIP_CHILDREN);
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
// we have 2 panes: notebook which pages demonstrating the controls in the // we have 2 panes: notebook which pages demonstrating the controls in the
// upper one and the log window with some buttons in the lower // 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(); InitNotebook();
wxSizer *sizerUp = new wxNotebookSizer(m_notebook); wxSizer *sizerUp = new wxNotebookSizer(m_notebook);
@@ -333,7 +333,7 @@ void WidgetsFrame::OnButtonQuit(wxCommandEvent& WXUNUSED(event))
Close(); Close();
} }
void WidgetsFrame::OnButtonClearLog(wxCommandEvent& event) void WidgetsFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event))
{ {
m_lboxLog->Clear(); m_lboxLog->Clear();
} }
@@ -358,7 +358,7 @@ WidgetsPageInfo::WidgetsPageInfo(Constructor ctor, const wxChar *label)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
WidgetsPage::WidgetsPage(wxNotebook *notebook) WidgetsPage::WidgetsPage(wxNotebook *notebook)
: wxPanel(notebook, -1) : wxPanel(notebook, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE|wxCLIP_CHILDREN)
{ {
} }

View File

@@ -485,11 +485,21 @@ bool wxNotebook::InsertPage(int nPage,
_T("notebook pages must have notebook as parent") ); _T("notebook pages must have notebook as parent") );
#if wxUSE_UXTHEME && wxUSE_UXTHEME_AUTO #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, // Automatically apply the theme background,
// changing the colour of the panel to match the // changing the colour of the panel to match the
// tab page colour. This won't work well with all // tab page colour. This won't work well with all
// themes but it's a start. // 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()); ApplyThemeBackground(pPage, GetThemeBackgroundColour());
} }
@@ -848,4 +858,31 @@ void wxNotebook::ApplyThemeBackground(wxWindow* window, const wxColour& colour)
#endif #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 #endif // wxUSE_NOTEBOOK