X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e00b90802a3856692d41a84622dac20ff0c7496..c13d6ac1ea199d1e3908d40d129e2fd5a4d82df7:/src/propgrid/propgridiface.cpp diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index ea0b4ee072..5f66781a81 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -6,7 +6,7 @@ // Created: 2008-08-24 // RCS-ID: $Id$ // Copyright: (c) Jaakko Salli -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -73,10 +73,8 @@ wxPGProperty* wxPGPropArgCls::GetPtr( wxPropertyGridInterface* iface ) const return iface->GetPropertyByNameA(*m_ptr.stringName); else if ( m_flags & IsCharPtr ) return iface->GetPropertyByNameA(m_ptr.charName); -#if wxUSE_WCHAR_T else if ( m_flags & IsWCharPtr ) return iface->GetPropertyByNameA(m_ptr.wcharName); -#endif return NULL; } @@ -102,7 +100,7 @@ void wxPropertyGridInterface::RefreshGrid( wxPropertyGridPageState* state ) wxPGProperty* wxPropertyGridInterface::Append( wxPGProperty* property ) { wxPGProperty* retp = m_pState->DoAppend(property); - + wxPropertyGrid* grid = m_pState->GetGrid(); if ( grid ) grid->RefreshGrid(); @@ -147,10 +145,6 @@ void wxPropertyGridInterface::DeleteProperty( wxPGPropArg id ) wxPG_PROP_ARG_CALL_PROLOG() wxPropertyGridPageState* state = p->GetParentState(); - wxPropertyGrid* grid = state->GetGrid(); - - if ( grid->GetState() == state ) - grid->DoSelectProperty(NULL, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE); state->DoDelete( p, true ); @@ -167,20 +161,9 @@ wxPGProperty* wxPropertyGridInterface::RemoveProperty( wxPGPropArg id ) wxNullProperty); wxPropertyGridPageState* state = p->GetParentState(); - wxPropertyGrid* grid = state->GetGrid(); - - if ( grid->GetState() == state ) - { - grid->DoSelectProperty(NULL, - wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE); - } state->DoDelete( p, false ); - // Mark the property as 'unattached' - p->m_parentState = NULL; - p->m_parent = NULL; - RefreshGrid(state); return p; @@ -218,11 +201,29 @@ wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProp // wxPropertyGridInterface property operations // ----------------------------------------------------------------------- +wxPGProperty* wxPropertyGridInterface::GetSelection() const +{ + return m_pState->GetSelection(); +} + +// ----------------------------------------------------------------------- + bool wxPropertyGridInterface::ClearSelection( bool validation ) { - int flags = 0; + bool res = DoClearSelection(validation, wxPG_SEL_DONT_SEND_EVENT); + wxPropertyGrid* pg = GetPropertyGrid(); + if ( pg ) + pg->Refresh(); + return res; +} + +// ----------------------------------------------------------------------- + +bool wxPropertyGridInterface::DoClearSelection( bool validation, + int selFlags ) +{ if ( !validation ) - flags |= wxPG_SEL_NOVALIDATE; + selFlags |= wxPG_SEL_NOVALIDATE; wxPropertyGridPageState* state = m_pState; @@ -230,9 +231,9 @@ bool wxPropertyGridInterface::ClearSelection( bool validation ) { wxPropertyGrid* pg = state->GetGrid(); if ( pg->GetState() == state ) - return pg->DoSelectProperty(NULL, flags); + return pg->DoSelectProperty(NULL, selFlags); else - state->SetSelection(NULL); + state->DoSetSelection(NULL); } return true; @@ -263,7 +264,7 @@ bool wxPropertyGridInterface::EnableProperty( wxPGPropArg id, bool enable ) return false; // If active, Set active Editor. - if ( grid->GetState() == state && p == grid->GetSelection() ) + if ( grid && grid->GetState() == state && p == grid->GetSelection() ) grid->DoSelectProperty( p, wxPG_SEL_FORCE ); } else @@ -272,11 +273,11 @@ bool wxPropertyGridInterface::EnableProperty( wxPGPropArg id, bool enable ) return false; // If active, Disable as active Editor. - if ( grid->GetState() == state && p == grid->GetSelection() ) + if ( grid && grid->GetState() == state && p == grid->GetSelection() ) grid->DoSelectProperty( p, wxPG_SEL_FORCE ); } - state->DoEnableProperty(p, enable); + p->DoEnable(enable); RefreshProperty( p ); @@ -297,7 +298,7 @@ bool wxPropertyGridInterface::ExpandAll( bool doExpand ) if ( GetSelection() && GetSelection() != state->DoGetRoot() && !doExpand ) { - pg->ClearSelection(false); + pg->DoClearSelection(); } wxPGVIterator it; @@ -343,6 +344,7 @@ void wxPropertyGridInterface::ClearModifiedStatus() if ( !page ) break; page->DoGetRoot()->SetFlagRecursively(wxPG_PROP_MODIFIED, false); + page->m_anyModified = false; pageIndex++; } @@ -351,6 +353,17 @@ void wxPropertyGridInterface::ClearModifiedStatus() GetPropertyGrid()->RefreshEditor(); } +bool wxPropertyGridInterface::SetColumnProportion( unsigned int column, + int proportion ) +{ + wxCHECK(m_pState, false); + wxPropertyGrid* pg = m_pState->GetGrid(); + wxCHECK(pg, false); + wxCHECK(pg->HasFlag(wxPG_SPLITTER_AUTO_CENTER), false); + m_pState->DoSetColumnProportion(column, proportion); + return true; +} + // ----------------------------------------------------------------------- // wxPropertyGridInterface property value setting and getting // ----------------------------------------------------------------------- @@ -579,8 +592,6 @@ void wxPropertyGridInterface::Sort( int flags ) { wxPropertyGrid* pg = GetPropertyGrid(); - pg->ClearSelection(false); - unsigned int pageIndex = 0; for (;;) @@ -590,6 +601,10 @@ void wxPropertyGridInterface::Sort( int flags ) page->DoSort(flags); pageIndex++; } + + // Fix positions of any open editor controls + if ( pg ) + pg->CorrectEditorWidgetPosY(); } // ----------------------------------------------------------------------- @@ -645,22 +660,22 @@ bool wxPropertyGridInterface::SetPropertyMaxLength( wxPGPropArg id, int maxLen ) void wxPropertyGridInterface::SetPropertyBackgroundColour( wxPGPropArg id, const wxColour& colour, - bool recursively ) + int flags ) { wxPG_PROP_ARG_CALL_PROLOG() - p->SetBackgroundColour( colour, recursively ); - RefreshProperty( p ); + p->SetBackgroundColour(colour, flags); + RefreshProperty(p); } // ----------------------------------------------------------------------- void wxPropertyGridInterface::SetPropertyTextColour( wxPGPropArg id, const wxColour& colour, - bool recursively ) + int flags ) { wxPG_PROP_ARG_CALL_PROLOG() - p->SetTextColour( colour, recursively ); - RefreshProperty( p ); + p->SetTextColour(colour, flags); + RefreshProperty(p); } // ----------------------------------------------------------------------- @@ -684,7 +699,7 @@ void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id, wxPG_PROP_ARG_CALL_PROLOG() wxPGCell& cell = p->GetCell(column); - if ( text.length() && text != wxPG_LABEL ) + if ( !text.empty() && text != wxPG_LABEL ) cell.SetText(text); if ( bitmap.IsOk() ) cell.SetBitmap(bitmap); @@ -857,7 +872,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const if ( includedStates & ExpandedState ) { wxArrayPGProperty ptrs; - wxPropertyGridConstIterator it = + wxPropertyGridConstIterator it = wxPropertyGridConstIterator( pageState, wxPG_ITERATE_ALL_PARENTS_RECURSIVELY|wxPG_ITERATE_HIDDEN, wxNullProperty ); @@ -917,7 +932,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const } // Remove last '|' - if ( result.length() ) + if ( !result.empty() ) result.RemoveLast(); return result; @@ -961,7 +976,7 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res { if ( restoreStates & ExpandedState ) { - wxPropertyGridIterator it = + wxPropertyGridIterator it = wxPropertyGridIterator( pageState, wxPG_ITERATE_ALL, wxNullProperty ); @@ -1019,14 +1034,14 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res { if ( pageState->IsDisplayed() ) { - if ( values[0].length() ) + if ( !values[0].empty() ) newSelection = GetPropertyByName(value); pgSelectionSet = true; } else { - if ( values[0].length() ) - pageState->SetSelection(GetPropertyByName(value)); + if ( !values[0].empty() ) + pageState->DoSetSelection(GetPropertyByName(value)); else pageState->DoClearSelection(); } @@ -1091,9 +1106,9 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res if ( pgSelectionSet ) { if ( newSelection ) - pg->SelectProperty(newSelection); + pg->DoSelectProperty(newSelection); else - pg->ClearSelection(); + pg->DoClearSelection(); } if ( selectedPage != -1 )