+void wxPGEditor::SetControlAppearance( wxPropertyGrid* pg,
+ wxPGProperty* property,
+ wxWindow* ctrl,
+ const wxPGCell& cell,
+ const wxPGCell& oCell,
+ bool unspecified ) const
+{
+ // Get old editor appearance
+ wxTextCtrl* tc = NULL;
+ wxComboCtrl* cb = NULL;
+ if ( wxDynamicCast(ctrl, wxTextCtrl) )
+ {
+ tc = (wxTextCtrl*) ctrl;
+ }
+ else
+ {
+ if ( wxDynamicCast(ctrl, wxComboCtrl) )
+ {
+ cb = (wxComboCtrl*) ctrl;
+ tc = cb->GetTextCtrl();
+ }
+ }
+
+ if ( tc || cb )
+ {
+ wxString tcText;
+ bool changeText = false;
+
+ if ( cell.HasText() && !pg->IsEditorFocused() )
+ {
+ tcText = cell.GetText();
+ changeText = true;
+ }
+ else if ( oCell.HasText() )
+ {
+ tcText = property->GetValueAsString(
+ property->HasFlag(wxPG_PROP_READONLY)?0:wxPG_EDITABLE_VALUE);
+ changeText = true;
+ }
+
+ if ( changeText )
+ {
+ // This prevents value from being modified
+ if ( tc )
+ {
+ pg->SetupTextCtrlValue(tcText);
+ tc->SetValue(tcText);
+ }
+ else
+ {
+ cb->SetText(tcText);
+ }
+ }
+ }
+
+ // Do not make the mistake of calling GetClassDefaultAttributes()
+ // here. It is static, while GetDefaultAttributes() is virtual
+ // and the correct one to use.
+ wxVisualAttributes vattrs = ctrl->GetDefaultAttributes();
+
+ // Foreground colour
+ const wxColour& fgCol = cell.GetFgCol();
+ if ( fgCol.IsOk() )
+ {
+ ctrl->SetForegroundColour(fgCol);
+ }
+ else if ( oCell.GetFgCol().IsOk() )
+ {
+ ctrl->SetForegroundColour(vattrs.colFg);
+ }
+
+ // Background colour
+ const wxColour& bgCol = cell.GetBgCol();
+ if ( bgCol.IsOk() )
+ {
+ ctrl->SetBackgroundColour(bgCol);
+ }
+ else if ( oCell.GetBgCol().IsOk() )
+ {
+ ctrl->SetBackgroundColour(vattrs.colBg);
+ }
+
+ // Font
+ const wxFont& font = cell.GetFont();
+ if ( font.IsOk() )
+ {
+ ctrl->SetFont(font);
+ }
+ else if ( oCell.GetFont().IsOk() )
+ {
+ ctrl->SetFont(vattrs.font);
+ }
+
+ // Also call the old SetValueToUnspecified()
+ if ( unspecified )
+ SetValueToUnspecified(property, ctrl);
+}
+
+void wxPGEditor::SetValueToUnspecified( wxPGProperty* WXUNUSED(property),
+ wxWindow* WXUNUSED(ctrl) ) const
+{
+}