X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7f3f8f1e85e34898a30a8463ca73c86d6550548d..65702d2fe95b8ca16a9b74f53832780bf1c81970:/src/propgrid/propgridpagestate.cpp?ds=sidebyside diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index fa4d8cf261..b1dd806885 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -107,7 +107,8 @@ void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase& it ) void wxPropertyGridIteratorBase::Prev() { wxPGProperty* property = m_property; - wxASSERT( property ); + if ( !property ) + return; wxPGProperty* parent = property->GetParent(); wxASSERT( parent ); @@ -152,7 +153,8 @@ void wxPropertyGridIteratorBase::Prev() void wxPropertyGridIteratorBase::Next( bool iterateChildren ) { wxPGProperty* property = m_property; - wxASSERT( property ); + if ( !property ) + return; if ( property->GetChildCount() && wxPG_ITERATOR_PARENTEXMASK_TEST(property, m_parentExMask) && @@ -215,6 +217,9 @@ wxPropertyGridPageState::wxPropertyGridPageState() m_colWidths.push_back( wxPG_DEFAULT_SPLITTERX ); m_colWidths.push_back( wxPG_DEFAULT_SPLITTERX ); m_fSplitterX = wxPG_DEFAULT_SPLITTERX; + + // By default, we only have the 'value' column editable + m_editableColumns.push_back(1); } // ----------------------------------------------------------------------- @@ -730,11 +735,13 @@ wxPGProperty* wxPropertyGridPageState::DoGetItemAtY( int y ) const // ----------------------------------------------------------------------- -wxPropertyGridHitTestResult wxPropertyGridPageState::HitTest( const wxPoint&pt ) const +wxPropertyGridHitTestResult +wxPropertyGridPageState::HitTest( const wxPoint&pt ) const { wxPropertyGridHitTestResult result; - result.column = HitTestH( pt.x, &result.splitter, &result.splitterHitOffset ); - result.property = DoGetItemAtY( pt.y ); + result.m_column = HitTestH( pt.x, &result.m_splitter, + &result.m_splitterHitOffset ); + result.m_property = DoGetItemAtY( pt.y ); return result; } @@ -763,8 +770,10 @@ int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC& dc, if ( col == 0 ) w += ( ((int)p->m_depth-1) * pg->m_subgroup_extramargin ); - // - // TODO: Add bitmap support. + // account for the bitmap + if ( col == 1 ) + w += p->GetImageOffset(pg->GetImageRect(p, -1).GetWidth()); + w += (wxPG_XBEFORETEXT*2); @@ -1132,6 +1141,29 @@ int wxPropertyGridPageState::HitTestH( int x, int* pSplitterHit, int* pSplitterH return col; } +bool wxPropertyGridPageState::ArePropertiesAdjacent( wxPGProperty* prop1, + wxPGProperty* prop2, + int iterFlags ) const +{ + const wxPGProperty* ap1 = + wxPropertyGridConstIterator::OneStep(this, + iterFlags, + prop1, + 1); + if ( ap1 && ap1 == prop2 ) + return true; + + const wxPGProperty* ap2 = + wxPropertyGridConstIterator::OneStep(this, + iterFlags, + prop1, + -1); + if ( ap2 && ap2 == prop2 ) + return true; + + return false; +} + // ----------------------------------------------------------------------- // wxPropertyGridPageState property value setting and getting // ----------------------------------------------------------------------- @@ -1218,7 +1250,31 @@ void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty* prop ) { if ( m_selection[i] == prop ) { - m_selection.erase( m_selection.begin() + i ); + wxPropertyGrid* pg = m_pPropGrid; + if ( i == 0 && pg->GetState() == this ) + { + // If first item (ie. one with the active editor) was + // deselected, then we need to take some extra measures. + wxArrayPGProperty sel = m_selection; + sel.erase( sel.begin() + i ); + + wxPGProperty* newFirst; + if ( sel.size() ) + newFirst = sel[0]; + else + newFirst = NULL; + + pg->DoSelectProperty(newFirst, + wxPG_SEL_DONT_SEND_EVENT); + + m_selection = sel; + + pg->Refresh(); + } + else + { + m_selection.erase( m_selection.begin() + i ); + } return; } } @@ -1747,7 +1803,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete ) wxASSERT( item->GetParentState() == this ); - wxPropertyGrid* pg = GetGrid(); + wxPropertyGrid* pg = GetGrid(); if ( DoIsPropertySelected(item) ) { @@ -1829,13 +1885,13 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete ) } } - if ( item->GetBaseName().length() && + if ( item->GetBaseName().length() && (parent->IsCategory() || parent->IsRoot()) ) m_dictName.erase(item->GetBaseName()); - // We need to clear parent grid's m_propHover, if it matches item - if ( pg && pg->m_propHover == item ) - pg->m_propHover = NULL; + // We need to clear parent grid's m_propHover, if it matches item + if ( pg && pg->m_propHover == item ) + pg->m_propHover = NULL; // We can actually delete it now if ( doDelete )