]> git.saurik.com Git - wxWidgets.git/commitdiff
Added Description Box Height to saveable/restoreable editable state
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 4 Oct 2008 10:59:06 +0000 (10:59 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sat, 4 Oct 2008 10:59:06 +0000 (10:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/manager.h
include/wx/propgrid/propgridiface.h
interface/wx/propgrid/propgridiface.h
src/propgrid/manager.cpp
src/propgrid/propgridiface.cpp

index 242ff70cdb41af3f5e5fba4a78e75410c88ea73c..9db8d251cd77d554180d548fd45fac5b3ded7bf7 100644 (file)
@@ -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:
index 5960f7bc02ec676ec1a3d5a2efcb828a35cc7ffb..02114aeec652ec3fd943a1ecea191fc49354922c 100644 (file)
@@ -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
     {
index b0291e04337c884db29c85aa1cc5be5e6836f184..2781d5410dc19e12575478e80c802d1350654c25 100644 (file)
@@ -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
     };
 
     /**
index a99a07de43ad56a1eaf856ab063894b3d89bf930..16c4f459d7268b5770b6833c8812166584e69dff 100644 (file)
@@ -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 )
index c5cfb5af4409a16d9ea973f882dcfef03aa7ca3a..603a9164f1db917f32c33ca229053ce131ea2cc9 100644 (file)
@@ -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;