From f521bae6653b1c2f0e196fb5c5550c03206e59ce Mon Sep 17 00:00:00 2001
From: Jaakko Salli <jaakko.salli@dnainternet.net>
Date: Fri, 26 Dec 2008 18:46:08 +0000
Subject: [PATCH] Have wxPGTextCtrlEditor::UpdateControl() update wxTextCtrl
 font boldness based on property's modified-status

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/propgrid/property.h   |  4 ++--
 include/wx/propgrid/propgrid.h   |  5 +++++
 interface/wx/propgrid/propgrid.h |  5 +++++
 src/propgrid/editors.cpp         | 17 +++++++++++++++--
 src/propgrid/property.cpp        | 23 +++++++++--------------
 src/propgrid/propgrid.cpp        |  9 +++++++++
 src/propgrid/propgridiface.cpp   |  3 +++
 7 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h
index 38019dfe9b..28535bb644 100644
--- a/include/wx/propgrid/property.h
+++ b/include/wx/propgrid/property.h
@@ -1550,8 +1550,6 @@ public:
     */
     wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const );
 
-    void UpdateControl( wxWindow* primary );
-
     /**
         Returns wxPGCell of given column.
     */
@@ -2224,6 +2222,8 @@ protected:
     // moved to it.
     void SubPropsChanged( int oldSelInd = -1 );
 
+    void UpdateControl( wxWindow* editorWnd );
+
     int GetY2( int lh ) const;
 
     wxString                    m_label;
diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h
index 650bacbb41..4456641a4a 100644
--- a/include/wx/propgrid/propgrid.h
+++ b/include/wx/propgrid/propgrid.h
@@ -1179,6 +1179,11 @@ public:
         return m_wndEditor2;
     }
 
+    /**
+        Refreshes any active editor control.
+    */
+    void RefreshEditor();
+
     // Events from editor controls are forward to this function
     void HandleCustomEditorEvent( wxEvent &event );
 
diff --git a/interface/wx/propgrid/propgrid.h b/interface/wx/propgrid/propgrid.h
index 253c252f63..97ea3eb379 100644
--- a/interface/wx/propgrid/propgrid.h
+++ b/interface/wx/propgrid/propgrid.h
@@ -658,6 +658,11 @@ public:
     */
     bool IsFrozen() const;
 
+    /**
+        Refreshes any active editor control.
+    */
+    void RefreshEditor();
+
     /**
         Redraws given property.
     */
diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp
index d3a4418c6b..570ec33a80 100644
--- a/src/propgrid/editors.cpp
+++ b/src/propgrid/editors.cpp
@@ -283,9 +283,22 @@ void wxPGTextCtrlEditor::UpdateControl( wxPGProperty* property, wxWindow* ctrl )
     else
         s = property->GetDisplayedString();
 
-    tc->SetValue(s);    
-}
+    tc->SetValue(s);
+
+    // Update font boldness
+    wxPropertyGrid* pg = property->GetGrid();
+    if ( pg->HasFlag(wxPG_BOLD_MODIFIED) )
+    {
+        if ( property->HasFlag(wxPG_PROP_MODIFIED) )
+            tc->SetFont(pg->GetCaptionFont());
+        else
+            tc->SetFont(pg->GetFont());
 
+#if defined(__WXMSW__) && !defined(__WXWINCE__)
+        ::SendMessage(GetHwndOf(tc), EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0));
+#endif
+    }
+}
 
 // Provided so that, for example, ComboBox editor can use the same code
 // (multiple inheritance would get way too messy).
diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp
index addc80c0c2..1897d12761 100644
--- a/src/propgrid/property.cpp
+++ b/src/propgrid/property.cpp
@@ -639,10 +639,10 @@ int wxPGProperty::Index( const wxPGProperty* p ) const
     return wxNOT_FOUND;
 }
 
-void wxPGProperty::UpdateControl( wxWindow* primary )
+void wxPGProperty::UpdateControl( wxWindow* editorWnd )
 {
-    if ( primary )
-        GetEditorClass()->UpdateControl(this, primary);
+    if ( editorWnd )
+        GetEditorClass()->UpdateControl(this, editorWnd);
 }
 
 bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const
@@ -1336,18 +1336,13 @@ void wxPGProperty::SetFlagRecursively( FlagType flag, bool set )
 
 void wxPGProperty::RefreshEditor()
 {
-    if ( m_parent && GetParentState() )
-    {
-        wxPropertyGrid* pg = GetParentState()->GetGrid();
-        if ( pg->GetSelectedProperty() == this )
-        {
-            wxWindow* editor = pg->GetEditorControl();
-            if ( editor )
-                GetEditorClass()->UpdateControl( this, editor );
-        }
-    }
-}
+    if ( !m_parent )
+        return;
 
+    wxPropertyGrid* pg = GetGrid();
+    if ( pg && pg->GetSelectedProperty() == this )
+        UpdateControl(pg->GetEditorControl());
+}
 
 wxVariant wxPGProperty::GetDefaultValue() const
 {
diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp
index cbc0bd7ad6..a2ba810891 100644
--- a/src/propgrid/propgrid.cpp
+++ b/src/propgrid/propgrid.cpp
@@ -3636,6 +3636,15 @@ bool wxPropertyGrid::UnfocusEditor()
 
 // -----------------------------------------------------------------------
 
+void wxPropertyGrid::RefreshEditor()
+{
+    if ( !m_selected || !m_wndEditor || m_frozen )
+        return;
+    m_selected->UpdateControl(m_wndEditor);
+}
+
+// -----------------------------------------------------------------------
+
 // This method is not inline because it called dozens of times
 // (i.e. two-arg function calls create smaller code size).
 bool wxPropertyGrid::DoClearSelection()
diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp
index f762133260..603fc34ec0 100644
--- a/src/propgrid/propgridiface.cpp
+++ b/src/propgrid/propgridiface.cpp
@@ -523,6 +523,9 @@ void wxPropertyGridInterface::ClearModifiedStatus()
 
         pageIndex++;
     }
+
+    // Update active editor control, if any
+    GetPropertyGrid()->RefreshEditor();
 }
 
 // -----------------------------------------------------------------------
-- 
2.47.2