From 628051704648f309df50fff9b3d485780e7ad022 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sat, 4 Oct 2008 10:59:06 +0000 Subject: [PATCH] Added Description Box Height to saveable/restoreable editable state git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/manager.h | 4 ++++ include/wx/propgrid/propgridiface.h | 27 ++++++++++++++++++++++++++- interface/wx/propgrid/propgridiface.h | 18 +++++++++++++----- src/propgrid/manager.cpp | 23 +++++++++++++++++++++++ src/propgrid/propgridiface.cpp | 20 ++++++++++++++++++++ 5 files changed, 86 insertions(+), 6 deletions(-) diff --git a/include/wx/propgrid/manager.h b/include/wx/propgrid/manager.h index 242ff70cdb..9db8d251cd 100644 --- a/include/wx/propgrid/manager.h +++ b/include/wx/propgrid/manager.h @@ -725,6 +725,10 @@ protected: void SetDescribedProperty( wxPGProperty* p ); + // Reimplement these to handle "descboxheight" state item + virtual bool SetEditableStateItem( const wxString& name, wxVariant value ); + virtual wxVariant GetEditableStateItem( const wxString& name ) const; + virtual bool ProcessEvent( wxEvent& event ); private: diff --git a/include/wx/propgrid/propgridiface.h b/include/wx/propgrid/propgridiface.h index 5960f7bc02..02114aeec6 100644 --- a/include/wx/propgrid/propgridiface.h +++ b/include/wx/propgrid/propgridiface.h @@ -794,6 +794,9 @@ public: PageState = 0x08, /** Include splitter position. Stored for each page. */ SplitterPosState = 0x10, + /** Include description box size. + Only applies to wxPropertyGridManager. */ + DescBoxState = 0x20, /** Include all supported user editable state information. @@ -802,7 +805,8 @@ public: ExpandedState | ScrollPosState | PageState | - SplitterPosState + SplitterPosState | + DescBoxState }; /** @@ -1435,6 +1439,27 @@ public: protected: + /** + In derived class, implement to set editable state component with + given name to given value. + */ + virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) + { + wxUnusedVar(name); + wxUnusedVar(value); + return false; + } + + /** + In derived class, implement to return editable state component with + given name. + */ + virtual wxVariant GetEditableStateItem( const wxString& name ) const + { + wxUnusedVar(name); + return wxNullVariant; + } + // Returns page state data for given (sub) page (-1 means current page). virtual wxPropertyGridPageState* GetPageState( int pageIndex ) const { diff --git a/interface/wx/propgrid/propgridiface.h b/interface/wx/propgrid/propgridiface.h index b0291e0433..2781d5410d 100644 --- a/interface/wx/propgrid/propgridiface.h +++ b/interface/wx/propgrid/propgridiface.h @@ -520,11 +520,19 @@ public: PageState = 0x08, /** Include splitter position. Stored for each page. */ SplitterPosState = 0x10, - - /** Include all supported user editable state information. This is - usually the default value. */ - AllStates = SelectionState | ExpandedState | ScrollPosState | - PageState | SplitterPosState + /** Include description box size. + Only applies to wxPropertyGridManager. */ + DescBoxState = 0x20, + + /** + Include all supported user editable state information. + This is usually the default value. */ + AllStates = SelectionState | + ExpandedState | + ScrollPosState | + PageState | + SplitterPosState | + DescBoxState }; /** diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index a99a07de43..16c4f459d7 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -1396,6 +1396,29 @@ void wxPropertyGridManager::OnToolbarClick( wxCommandEvent &event ) // ----------------------------------------------------------------------- +bool wxPropertyGridManager::SetEditableStateItem( const wxString& name, wxVariant value ) +{ + if ( name == wxS("descboxheight") ) + { + SetDescBoxHeight(value.GetLong(), true); + return true; + } + return false; +} + +// ----------------------------------------------------------------------- + +wxVariant wxPropertyGridManager::GetEditableStateItem( const wxString& name ) const +{ + if ( name == wxS("descboxheight") ) + { + return (long) GetDescBoxHeight(); + } + return wxNullVariant; +} + +// ----------------------------------------------------------------------- + void wxPropertyGridManager::SetDescription( const wxString& label, const wxString& content ) { if ( m_pTxtHelpCaption ) diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index c5cfb5af44..603a9164f1 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -1012,6 +1012,11 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const else result += wxS("0;"); } + if ( includedStates & DescBoxState ) + { + wxVariant v = GetEditableStateItem(wxS("descboxheight")); + result += wxString::Format(wxS("descboxheight=%i;"), (int)v.GetLong()); + } result.RemoveLast(); // Remove last semicolon result += wxS("|"); } @@ -1149,6 +1154,21 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res } } } + else if ( key == wxS("descboxheight") ) + { + if ( restoreStates & DescBoxState ) + { + long descBoxHeight; + if ( values.size() == 1 && values[0].ToLong(&descBoxHeight) ) + { + SetEditableStateItem(wxS("descboxheight"), descBoxHeight); + } + else + { + res = false; + } + } + } else { res = false; -- 2.45.2