From 8dbe6ec69df69900217be7946b9bd597d813710d Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 27 Dec 2018 09:04:37 +0100 Subject: [PATCH] Add to propgrid sample an option to change virtual width of the grid --- samples/propgrid/propgrid.cpp | 23 +++++++++++++++++++++++ samples/propgrid/propgrid.h | 1 + 2 files changed, 24 insertions(+) diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index 49ff46bbb0..134c43cd88 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -422,6 +422,7 @@ enum ID_SETPROPERTYVALUE, ID_TESTREPLACE, ID_SETCOLUMNS, + ID_SETVIRTWIDTH, ID_TESTXRC, ID_ENABLECOMMONVALUES, ID_SELECTSTYLE, @@ -522,6 +523,7 @@ wxBEGIN_EVENT_TABLE(FormMain, wxFrame) EVT_MENU( ID_CATCOLOURS, FormMain::OnCatColours ) EVT_MENU( ID_SETCOLUMNS, FormMain::OnSetColumns ) + EVT_MENU( ID_SETVIRTWIDTH, FormMain::OnSetVirtualWidth ) EVT_MENU( ID_TESTXRC, FormMain::OnTestXRC ) EVT_MENU( ID_ENABLECOMMONVALUES, FormMain::OnEnableCommonValues ) EVT_MENU( ID_SELECTSTYLE, FormMain::OnSelectStyle ) @@ -2120,6 +2122,7 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size menuTry->AppendCheckItem(ID_BOOL_CHECKBOX, "Render Boolean values as checkboxes", "Renders Boolean values as checkboxes"); menuTry->Append(ID_SETCOLUMNS, "Set Number of Columns" ); + menuTry->Append(ID_SETVIRTWIDTH, "Set Virtual Width"); menuTry->AppendSeparator(); menuTry->Append(ID_TESTXRC, "Display XRC sample" ); @@ -2943,6 +2946,26 @@ void FormMain::OnSetColumns( wxCommandEvent& WXUNUSED(event) ) // ----------------------------------------------------------------------- +void FormMain::OnSetVirtualWidth(wxCommandEvent& WXUNUSED(evt)) +{ + long oldWidth = m_pPropGridManager->GetState()->GetVirtualWidth(); + long newWidth = oldWidth; + { + wxNumberEntryDialog dlg(this, "Enter virtual width (-1-2000).", "Width:", + "Change Virtual Width", oldWidth, -1, 2000); + if ( dlg.ShowModal() == wxID_OK ) + { + newWidth = dlg.GetValue(); + } + } + if ( newWidth != oldWidth ) + { + m_pPropGridManager->GetGrid()->SetVirtualWidth((int)newWidth); + } +} + +// ----------------------------------------------------------------------- + void FormMain::OnSetPropertyValue( wxCommandEvent& WXUNUSED(event) ) { wxPropertyGrid* pg = m_pPropGridManager->GetGrid(); diff --git a/samples/propgrid/propgrid.h b/samples/propgrid/propgrid.h index 8ed65a21aa..7827ed3395 100644 --- a/samples/propgrid/propgrid.h +++ b/samples/propgrid/propgrid.h @@ -198,6 +198,7 @@ public: void OnCatColoursUpdateUI( wxUpdateUIEvent& event ); void OnCatColours( wxCommandEvent& event ); void OnSetColumns( wxCommandEvent& event ); + void OnSetVirtualWidth(wxCommandEvent& evt); void OnMisc( wxCommandEvent& event ); void OnPopulateClick( wxCommandEvent& event ); void OnSetSpinCtrlEditorClick( wxCommandEvent& event );