From: Jaakko Salli Date: Wed, 4 Mar 2009 19:53:34 +0000 (+0000) Subject: By default, always refresh editor and redraw properties when property value is changed X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e777bd14b3b3ce4a601fcc0df63d64e3dc75ae8e By default, always refresh editor and redraw properties when property value is changed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 15e520ee61..4f3a1b32bb 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -1897,12 +1897,15 @@ public: SetValueInEvent() instead. @param pList - Pointer to list variant that contains child values. Used to indicate - which children should be marked as modified. + Pointer to list variant that contains child values. Used to + indicate which children should be marked as modified. + @param flags - Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR). + Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR, which is + enabled by default). */ - void SetValue( wxVariant value, wxVariant* pList = NULL, int flags = 0 ); + void SetValue( wxVariant value, wxVariant* pList = NULL, + int flags = wxPG_SETVAL_REFRESH_EDITOR ); /** Set wxBitmap in front of the value. This bitmap may be ignored by custom cell renderers. diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index a43fdd5648..9b0c23b211 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1358,6 +1358,21 @@ public: virtual void SetWindowStyleFlag( long style ); + void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ); + + void DrawItem( wxPGProperty* p ) + { + DrawItems(p,p); + } + + virtual void DrawItemAndChildren( wxPGProperty* p ); + + /** + Draws item, children, and consequtive parents as long as category is + not met. + */ + void DrawItemAndValueRelated( wxPGProperty* p ); + protected: /** @@ -1760,21 +1775,6 @@ protected: void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy, const wxRect* clip_rect = (const wxRect*) NULL ); - void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 ); - - void DrawItem( wxPGProperty* p ) - { - DrawItems(p,p); - } - - virtual void DrawItemAndChildren( wxPGProperty* p ); - - /** - Draws item, children, and consequtive parents as long as category is - not met. - */ - void DrawItemAndValueRelated( wxPGProperty* p ); - // Translate wxKeyEvent to wxPG_ACTION_XXX int KeyEventToActions(wxKeyEvent &event, int* pSecond) const; diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 75efba3ce6..d8197e0abd 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -1371,10 +1371,11 @@ public: Pointer to list variant that contains child values. Used to indicate which children should be marked as modified. Usually you just use @NULL. @param flags - Use wxPG_SETVAL_REFRESH_EDITOR to update editor control, if it - was selected. + wxPG_SETVAL_REFRESH_EDITOR is set by default, to refresh editor + and redraw properties. */ - void SetValue( wxVariant value, wxVariant* pList = NULL, int flags = 0 ); + void SetValue( wxVariant value, wxVariant* pList = NULL, + int flags = wxPG_SETVAL_REFRESH_EDITOR ); /** Set wxBitmap in front of the value. This bitmap may be ignored diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index bfb0e446e9..a3b35d4f27 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -1327,7 +1327,12 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags ) // We need to check for these, otherwise GetGrid() may fail. if ( flags & wxPG_SETVAL_REFRESH_EDITOR ) + { RefreshEditor(); + wxPropertyGrid* pg = GetGridIfDisplayed(); + if ( pg ) + pg->DrawItemAndValueRelated(this); + } } @@ -1977,6 +1982,8 @@ bool wxPGProperty::IsVisible() const wxPropertyGrid* wxPGProperty::GetGridIfDisplayed() const { wxPropertyGridPageState* state = GetParentState(); + if ( !state ) + return NULL; wxPropertyGrid* propGrid = state->GetGrid(); if ( state == propGrid->GetState() ) return propGrid; diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index 8f0bab8b5a..ac348f9f1f 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -543,13 +543,7 @@ void wxPropertyGridInterface::SetPropVal( wxPGPropArg id, wxVariant& value ) wxPG_PROP_ARG_CALL_PROLOG() if ( p ) - { p->SetValue(value); - wxPropertyGrid* propGrid = p->GetGridIfDisplayed(); - if ( propGrid ) - propGrid->DrawItemAndValueRelated( p ); - - } } // ----------------------------------------------------------------------- @@ -558,12 +552,8 @@ void wxPropertyGridInterface::SetPropertyValueString( wxPGPropArg id, const wxSt { wxPG_PROP_ARG_CALL_PROLOG() - if ( m_pState->DoSetPropertyValueString(p,value) ) - { - wxPropertyGrid* propGrid = p->GetGridIfDisplayed(); - if ( propGrid ) - propGrid->DrawItemAndValueRelated( p ); - } + if ( p ) + m_pState->DoSetPropertyValueString(p, value); } // -----------------------------------------------------------------------