Allow testing hiding the widget in the widgets sample.

This provides a convenient way for testing that it actually works, which is
currently not quite the case for wxSlider under OS X, see #2388.
This commit is contained in:
Vadim Zeitlin
2015-07-04 00:21:47 +02:00
parent e70d597c2e
commit 086d4230cd
2 changed files with 16 additions and 0 deletions

View File

@@ -78,6 +78,7 @@ enum
Widgets_SetPageBg, Widgets_SetPageBg,
Widgets_SetFont, Widgets_SetFont,
Widgets_Enable, Widgets_Enable,
Widgets_Show,
Widgets_BorderNone, Widgets_BorderNone,
Widgets_BorderStatic, Widgets_BorderStatic,
@@ -172,6 +173,7 @@ protected:
void OnSetPageBg(wxCommandEvent& event); void OnSetPageBg(wxCommandEvent& event);
void OnSetFont(wxCommandEvent& event); void OnSetFont(wxCommandEvent& event);
void OnEnable(wxCommandEvent& event); void OnEnable(wxCommandEvent& event);
void OnShow(wxCommandEvent &event);
void OnSetBorder(wxCommandEvent& event); void OnSetBorder(wxCommandEvent& event);
void OnSetVariant(wxCommandEvent& event); void OnSetVariant(wxCommandEvent& event);
@@ -297,6 +299,7 @@ wxBEGIN_EVENT_TABLE(WidgetsFrame, wxFrame)
EVT_MENU(Widgets_SetPageBg, WidgetsFrame::OnSetPageBg) EVT_MENU(Widgets_SetPageBg, WidgetsFrame::OnSetPageBg)
EVT_MENU(Widgets_SetFont, WidgetsFrame::OnSetFont) EVT_MENU(Widgets_SetFont, WidgetsFrame::OnSetFont)
EVT_MENU(Widgets_Enable, WidgetsFrame::OnEnable) EVT_MENU(Widgets_Enable, WidgetsFrame::OnEnable)
EVT_MENU(Widgets_Show, WidgetsFrame::OnShow)
EVT_MENU_RANGE(Widgets_BorderNone, Widgets_BorderDefault, EVT_MENU_RANGE(Widgets_BorderNone, Widgets_BorderDefault,
WidgetsFrame::OnSetBorder) WidgetsFrame::OnSetBorder)
@@ -396,6 +399,7 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
menuWidget->Append(Widgets_SetPageBg, wxT("Set &page background...\tShift-Ctrl-B")); menuWidget->Append(Widgets_SetPageBg, wxT("Set &page background...\tShift-Ctrl-B"));
menuWidget->Append(Widgets_SetFont, wxT("Set f&ont...\tCtrl-O")); menuWidget->Append(Widgets_SetFont, wxT("Set f&ont...\tCtrl-O"));
menuWidget->AppendCheckItem(Widgets_Enable, wxT("&Enable/disable\tCtrl-E")); menuWidget->AppendCheckItem(Widgets_Enable, wxT("&Enable/disable\tCtrl-E"));
menuWidget->AppendCheckItem(Widgets_Show, wxT("Show/Hide"));
wxMenu *menuBorders = new wxMenu; wxMenu *menuBorders = new wxMenu;
menuBorders->AppendRadioItem(Widgets_BorderDefault, wxT("De&fault\tCtrl-Shift-9")); menuBorders->AppendRadioItem(Widgets_BorderDefault, wxT("De&fault\tCtrl-Shift-9"));
@@ -447,6 +451,8 @@ WidgetsFrame::WidgetsFrame(const wxString& title)
SetMenuBar(mbar); SetMenuBar(mbar);
mbar->Check(Widgets_Enable, true); mbar->Check(Widgets_Enable, true);
mbar->Check(Widgets_Show, true);
mbar->Check(Widgets_VariantNormal, true); mbar->Check(Widgets_VariantNormal, true);
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
@@ -880,6 +886,13 @@ void WidgetsFrame::OnEnable(wxCommandEvent& event)
CurrentPage()->SetUpWidget(); CurrentPage()->SetUpWidget();
} }
void WidgetsFrame::OnShow(wxCommandEvent &event)
{
WidgetsPage::GetAttrs().m_show = event.IsChecked();
CurrentPage()->SetUpWidget();
}
void WidgetsFrame::OnSetBorder(wxCommandEvent& event) void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
{ {
int border; int border;
@@ -1276,6 +1289,7 @@ void WidgetsPage::SetUpWidget()
(*it)->SetLayoutDirection(GetAttrs().m_dir); (*it)->SetLayoutDirection(GetAttrs().m_dir);
(*it)->Enable(GetAttrs().m_enabled); (*it)->Enable(GetAttrs().m_enabled);
(*it)->Show(GetAttrs().m_show);
if ( GetAttrs().m_cursor.IsOk() ) if ( GetAttrs().m_cursor.IsOk() )
{ {

View File

@@ -98,6 +98,7 @@ struct WidgetAttributes
m_tooltip = "This is a tooltip"; m_tooltip = "This is a tooltip";
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
m_enabled = true; m_enabled = true;
m_show = true;
m_dir = wxLayout_LeftToRight; m_dir = wxLayout_LeftToRight;
m_variant = wxWINDOW_VARIANT_NORMAL; m_variant = wxWINDOW_VARIANT_NORMAL;
m_cursor = *wxSTANDARD_CURSOR; m_cursor = *wxSTANDARD_CURSOR;
@@ -114,6 +115,7 @@ struct WidgetAttributes
wxColour m_colBg; wxColour m_colBg;
wxColour m_colPageBg; wxColour m_colPageBg;
bool m_enabled; bool m_enabled;
bool m_show;
wxLayoutDirection m_dir; wxLayoutDirection m_dir;
wxWindowVariant m_variant; wxWindowVariant m_variant;
wxCursor m_cursor; wxCursor m_cursor;