]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxPropertyGrid::GetUnspecifiedValueText(). Use it instead of assuming that...
authorJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 20 Dec 2009 12:48:41 +0000 (12:48 +0000)
committerJaakko Salli <jaakko.salli@dnainternet.net>
Sun, 20 Dec 2009 12:48:41 +0000 (12:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/propgrid/propgrid.h
interface/wx/propgrid/propgrid.h
src/propgrid/editors.cpp
src/propgrid/property.cpp
src/propgrid/propgrid.cpp

index db6c2bb94ddf3b0bee74685a543cbe5725c00034..494423697da92c4b64373a99488303b788a0506a 100644 (file)
@@ -1239,6 +1239,14 @@ public:
         return m_sortFunction;
     }
 
+    /**
+        Returns (visual) text representation of the unspecified
+        property value.
+
+        @param argFlags For internal use only.
+    */
+    wxString GetUnspecifiedValueText( int argFlags = 0 ) const;
+
     /** Set virtual width for this particular page. Width -1 indicates that the
         virtual width should be disabled. */
     void SetVirtualWidth( int width );
index a21f8cbcc003e14097f22f07328cf011fd292f24..c9bc3dfc0af7b060a59456c4ee1bfffdc157cee2 100644 (file)
@@ -740,6 +740,14 @@ public:
     */
     wxTextCtrl* GetEditorTextCtrl() const;
 
+    /**
+        Returns (visual) text representation of the unspecified
+        property value.
+
+        @param argFlags For internal use only.
+    */
+    wxString GetUnspecifiedValueText( int argFlags = 0 ) const;
+
     /**
         Returns current vertical spacing.
     */
index d20d1d6137b0df7f0c1e554e7926dbb0ef0920d2..fa487428a4116259e6a0423a968cf43d3a9ed927 100644 (file)
@@ -173,6 +173,9 @@ void wxPGEditor::DrawValue( wxDC& dc, const wxRect& rect, wxPGProperty* property
 {
     if ( !property->IsValueUnspecified() )
         dc.DrawText( text, rect.x+wxPG_XBEFORETEXT, rect.y );
+    else
+        dc.DrawText( property->GetGrid()->GetUnspecifiedValueText(),
+                     rect.x+wxPG_XBEFORETEXT, rect.y );
 }
 
 bool wxPGEditor::GetValueFromControl( wxVariant&, wxPGProperty*, wxWindow* ) const
@@ -232,9 +235,9 @@ wxPGWindowList wxPGTextCtrlEditor::CreateControls( wxPropertyGrid* propGrid,
          property->GetChildCount() )
         return NULL;
 
-    if ( !property->IsValueUnspecified() )
-        text = property->GetValueAsString(property->HasFlag(wxPG_PROP_READONLY) ?
-                                            0 : wxPG_EDITABLE_VALUE);
+    int argFlags = property->HasFlag(wxPG_PROP_READONLY) ? 
+        0 : wxPG_EDITABLE_VALUE;
+    text = property->GetValueAsString(argFlags);
 
     int flags = 0;
     if ( (property->GetFlags() & wxPG_PROP_PASSWORD) &&
@@ -371,7 +374,7 @@ void wxPGTextCtrlEditor::SetValueToUnspecified( wxPGProperty* property, wxWindow
     wxASSERT(pg);  // Really, property grid should exist if editor does
     if ( pg )
     {
-        wxString unspecValueText;
+        wxString unspecValueText = pg->GetUnspecifiedValueText();
         pg->SetupTextCtrlValue(unspecValueText);
         tc->SetValue(unspecValueText);
     }
@@ -987,6 +990,7 @@ bool wxPGChoiceEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property
                 if ( !cb->HasFlag(wxCB_READONLY) )
                 {
                     wxString unspecValueText;
+                    unspecValueText = propGrid->GetUnspecifiedValueText();
                     propGrid->SetupTextCtrlValue(unspecValueText);
                     cb->GetTextCtrl()->SetValue(unspecValueText);
                 }
@@ -1036,10 +1040,25 @@ void wxPGChoiceEditor::SetControlIntValue( wxPGProperty* WXUNUSED(property), wxW
 }
 
 
-void wxPGChoiceEditor::SetValueToUnspecified( wxPGProperty* WXUNUSED(property), wxWindow* ctrl ) const
+void wxPGChoiceEditor::SetValueToUnspecified( wxPGProperty* property,
+                                              wxWindow* ctrl ) const
 {
     wxOwnerDrawnComboBox* cb = (wxOwnerDrawnComboBox*)ctrl;
-    cb->SetSelection(-1);
+
+    if ( !cb->HasFlag(wxCB_READONLY) )
+    {
+        wxPropertyGrid* pg = property->GetGrid();
+        if ( pg )
+        {
+            wxString tcText = pg->GetUnspecifiedValueText();
+            pg->SetupTextCtrlValue(tcText);
+            cb->SetValue(tcText);
+        }
+    }
+    else
+    {
+        cb->SetSelection(-1);
+    }
 }
 
 
index e57a9406cef8e18f4ba9d418c12795f1fdc7d4f8..1e9f6100bd5995de7dcfafe2f02dd818ade96dc9 100644 (file)
@@ -928,8 +928,10 @@ wxString wxPGProperty::GetValueAsString( int argFlags ) const
     }
 #endif
 
+    wxPropertyGrid* pg = GetGrid();
+
     if ( IsValueUnspecified() )
-        return wxEmptyString;
+        return pg->GetUnspecifiedValueText(argFlags);
 
     if ( m_commonValue == -1 )
     {
@@ -939,7 +941,6 @@ wxString wxPGProperty::GetValueAsString( int argFlags ) const
 
     //
     // Return common value's string representation
-    wxPropertyGrid* pg = GetGrid();
     const wxPGCommonValue* cv = pg->GetCommonValue(m_commonValue);
 
     if ( argFlags & wxPG_FULL_VALUE )
index 96bd168463c362ae32327ee9ede3ffcb6948a02c..b35676b458218128aa6c5851c1af141ad51ab7f3 100644 (file)
@@ -3629,6 +3629,12 @@ void wxPropertyGrid::CustomSetCursor( int type, bool override )
     m_curcursor = type;
 }
 
+wxString
+wxPropertyGrid::GetUnspecifiedValueText( int WXUNUSED(argFlags) ) const
+{
+    return wxEmptyString;
+}
+
 // -----------------------------------------------------------------------
 // wxPropertyGrid property selection, editor creation
 // -----------------------------------------------------------------------