From 69005ef1458ee64b5e98388cfb58582814e5645c Mon Sep 17 00:00:00 2001 From: Roberto Perpuly Date: Sat, 4 Apr 2015 10:18:36 +0200 Subject: [PATCH] Add to propgrid sample the option to select the way Boolean values are rendered. This option is useful to demonstrate how to globally change the way Boolean values are rendered (either as check boxes or selection lists). See #16922. --- samples/propgrid/propgrid.cpp | 10 +++++++++- samples/propgrid/propgrid.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index d65acb8b4a..610fb0c143 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -384,6 +384,7 @@ enum ID_ENABLE, ID_SETREADONLY, ID_HIDE, + ID_BOOL_CHECKBOX, ID_DELETE, ID_DELETER, ID_DELETEALL, @@ -492,6 +493,7 @@ wxBEGIN_EVENT_TABLE(FormMain, wxFrame) EVT_MENU( ID_ENABLE, FormMain::OnEnableDisable ) EVT_MENU( ID_SETREADONLY, FormMain::OnSetReadOnly ) EVT_MENU( ID_HIDE, FormMain::OnHide ) + EVT_MENU( ID_BOOL_CHECKBOX, FormMain::OnBoolCheckbox ) EVT_MENU( ID_ITERATE1, FormMain::OnIterate1Click ) EVT_MENU( ID_ITERATE2, FormMain::OnIterate2Click ) @@ -1943,7 +1945,6 @@ void FormMain::CreateGrid( int style, int extraStyle ) // Change some attributes in all properties //pgman->SetPropertyAttributeAll(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING,true); - //pgman->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX,true); //m_pPropGridManager->SetSplitterLeft(true); //m_pPropGridManager->SetSplitterPosition(137); @@ -2106,6 +2107,8 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size menuTry->AppendSeparator(); menuTry->AppendCheckItem(ID_STATICLAYOUT, wxT("Static Layout"), wxT("Switches between user-modifiable and static layouts.") ); + menuTry->AppendCheckItem(ID_BOOL_CHECKBOX, wxT("Render Boolean values as checkboxes"), + wxT("Renders Boolean values as checkboxes")); menuTry->Append(ID_SETCOLUMNS, wxT("Set Number of Columns") ); menuTry->AppendSeparator(); menuTry->Append(ID_TESTXRC, wxT("Display XRC sample") ); @@ -2536,6 +2539,11 @@ void FormMain::OnHide( wxCommandEvent& WXUNUSED(event) ) m_pPropGridManager->HideProperty( id, true ); } +void FormMain::OnBoolCheckbox(wxCommandEvent& evt) +{ + m_pPropGridManager->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, evt.IsChecked()); +} + // ----------------------------------------------------------------------- #include "wx/colordlg.h" diff --git a/samples/propgrid/propgrid.h b/samples/propgrid/propgrid.h index b017e0e5c2..2501ce5f13 100644 --- a/samples/propgrid/propgrid.h +++ b/samples/propgrid/propgrid.h @@ -186,6 +186,7 @@ public: void OnEnableDisable( wxCommandEvent& event ); void OnSetReadOnly( wxCommandEvent& event ); void OnHide( wxCommandEvent& event ); + void OnBoolCheckbox( wxCommandEvent& evt ); void OnSetBackgroundColour( wxCommandEvent& event ); void OnClearModifyStatusClick( wxCommandEvent& event ); void OnFreezeClick( wxCommandEvent& event );