]> git.saurik.com Git - wxWidgets.git/commitdiff
Added 'bool editable' argument to wxPropertyGrid::MakeColumnEditable()
authorJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 1 Sep 2009 13:54:41 +0000 (13:54 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Tue, 1 Sep 2009 13:54:41 +0000 (13:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61802 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
interface/wx/propgrid/propgrid.h
samples/propgrid/tests.cpp
src/propgrid/propgrid.cpp

index a46583491e75c66e43bca0b2b3cff1da88cee8f0..40350413b3b5ee68b43ea2cb2ee2d65ab1beb8a6 100644 (file)
@@ -1029,13 +1029,10 @@ public:
     /**
         Makes given column editable by user.
 
-        @see BeginLabelEdit(), EndLabelEdit()
+        @param editable
+            Using @false here will disable column from being editable.
     */
-    void MakeColumnEditable( unsigned int column )
-    {
-        wxASSERT( column != 1 );
-        m_pState->m_editableColumns.push_back(column);
-    }
+    void MakeColumnEditable( unsigned int column, bool editable = true );
 
     /**
         Creates label editor wxTextCtrl for given column, for property
index 622be65cf46e89d6fd8136892a3465ea5cf91c0d..c65a6d86be9be87779e0b9883eadec738402aeaf 100644 (file)
@@ -751,9 +751,12 @@ public:
     /**
         Makes given column editable by user.
 
+        @param editable
+            Using @false here will disable column from being editable.
+
         @see BeginLabelEdit(), EndLabelEdit()
     */
-    void MakeColumnEditable( unsigned int column );
+    void MakeColumnEditable( unsigned int column, bool editable = true );
 
     /**
         It is recommended that you call this function any time your code causes
index 28d553b068f1aaf9b848957c9b62bc9d937b8d46..8efbe0f39247f85109507b8cb3f829d471dd5901 100644 (file)
@@ -775,6 +775,29 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
         RT_ASSERT( !pg->IsPropertySelected(prop3) )
     }
 
+    {
+        //
+        // Test label editing
+        RT_START_TEST(LABEL_EDITING)
+
+        wxPropertyGrid* pg = pgman->GetGrid();
+
+        // Just mostly test that these won't crash
+        pg->MakeColumnEditable(0, true);
+        pg->MakeColumnEditable(2, true);
+        pg->MakeColumnEditable(0, false);
+        pg->MakeColumnEditable(2, false);
+        pg->SelectProperty(wxT("Height"));
+        pg->BeginLabelEdit(0);
+        pg->BeginLabelEdit(0);
+        pg->EndLabelEdit(0);
+        pg->EndLabelEdit(0);
+
+        // Recreate grid
+        CreateGrid( -1, -1 );
+        pgman = m_pPropGridManager;
+    }
+
     {
         RT_START_TEST(Attributes)
 
index 6f8ad9737990eab98764c8fc8d906d838c2e3973..e520c268a2b1e6f458a78a522a1d8e67efc2d10d 100644 (file)
@@ -925,6 +925,29 @@ void wxPropertyGrid::DoSetSelection( const wxArrayPGProperty& newSelection,
 
 // -----------------------------------------------------------------------
 
+void wxPropertyGrid::MakeColumnEditable( unsigned int column,
+                                         bool editable )
+{
+    wxASSERT( column != 1 );
+
+    wxArrayInt& cols = m_pState->m_editableColumns;
+
+    if ( editable )
+    {
+        cols.push_back(column);
+    }
+    else
+    {
+        for ( int i = cols.size() - 1; i > 0; i-- )
+        {
+            if ( cols[i] == (int)column )
+                cols.erase( cols.begin() + i );
+        }
+    }
+}
+
+// -----------------------------------------------------------------------
+
 void wxPropertyGrid::DoBeginLabelEdit( unsigned int colIndex,
                                        int selFlags )
 {