X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/433969811ec21a6036347f1be157e08f8f4720ec..12b5f4b4d2d8a07962da7ba3b78c8c1ec2634a67:/src/propgrid/propgrid.cpp?ds=sidebyside diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 4eaae9aedd..56738c1635 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -154,7 +154,7 @@ public: IMPLEMENT_DYNAMIC_CLASS(wxPGGlobalVarsClassManager, wxModule) -wxPGGlobalVarsClass* wxPGGlobalVars = (wxPGGlobalVarsClass*) NULL; +wxPGGlobalVarsClass* wxPGGlobalVars = NULL; wxPGGlobalVarsClass::wxPGGlobalVarsClass() @@ -164,7 +164,7 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass() m_boolChoices.Add(_("False")); m_boolChoices.Add(_("True")); - m_fontFamilyChoices = (wxPGChoices*) NULL; + m_fontFamilyChoices = NULL; m_defaultRenderer = new wxPGDefaultRenderer(); @@ -454,13 +454,13 @@ void wxPropertyGrid::Init1() wxPropertyGrid::RegisterDefaultEditors(); m_iFlags = 0; - m_pState = (wxPropertyGridPageState*) NULL; - m_wndEditor = m_wndEditor2 = (wxWindow*) NULL; - m_selected = (wxPGProperty*) NULL; + m_pState = NULL; + m_wndEditor = m_wndEditor2 = NULL; + m_selected = NULL; m_selColumn = -1; - m_propHover = (wxPGProperty*) NULL; + m_propHover = NULL; m_eventObject = this; - m_curFocused = (wxWindow*) NULL; + m_curFocused = NULL; m_tlwHandler = NULL; m_sortFunction = NULL; m_inDoPropertyChanged = 0; @@ -488,7 +488,7 @@ void wxPropertyGrid::Init1() m_canvas = NULL; #if wxPG_DOUBLE_BUFFER - m_doubleBuffer = (wxBitmap*) NULL; + m_doubleBuffer = NULL; #endif #ifndef wxPG_ICON_WIDTH @@ -643,7 +643,7 @@ wxPropertyGrid::~wxPropertyGrid() delete m_doubleBuffer; #endif - //m_selected = (wxPGProperty*) NULL; + //m_selected = NULL; if ( m_iFlags & wxPG_FL_CREATEDSTATE ) delete m_pState; @@ -728,7 +728,7 @@ void wxPropertyGrid::SetWindowStyleFlag( long style ) // // Tooltips disabled // - m_canvas->SetToolTip( (wxToolTip*) NULL ); + m_canvas->SetToolTip( NULL ); } #endif } @@ -1180,29 +1180,11 @@ void wxPropertyGrid::PrepareAfterItemsAdded() m_pState->m_itemsAdded = 0; if ( m_windowStyle & wxPG_AUTO_SORT ) - Sort(); + Sort(wxPG_SORT_TOP_LEVEL_ONLY); RecalculateVirtualSize(); } -// ----------------------------------------------------------------------- -// wxPropertyGrid property value setting and getting -// ----------------------------------------------------------------------- - -void wxPropertyGrid::DoSetPropertyValueUnspecified( wxPGProperty* p ) -{ - m_pState->DoSetPropertyValueUnspecified(p); - DrawItemAndChildren(p); - - wxPGProperty* parent = p->GetParent(); - while ( parent && - (parent->GetFlags() & wxPG_PROP_PARENTAL_FLAGS) == wxPG_PROP_MISC_PARENT ) - { - DrawItem(parent); - parent = parent->GetParent(); - } -} - // ----------------------------------------------------------------------- // wxPropertyGrid property operations // ----------------------------------------------------------------------- @@ -1422,7 +1404,7 @@ wxPGProperty* wxPropertyGrid::DoGetItemAtY( int y ) const { // Outside? if ( y < 0 ) - return (wxPGProperty*) NULL; + return NULL; unsigned int a = 0; return m_pState->m_properties->GetItemAtY(y, m_lineHeight, &a); @@ -1932,7 +1914,8 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, unsigned int ci; int cellX = x + 1; - int nextCellWidth = state->m_colWidths[0]; + int nextCellWidth = state->m_colWidths[0] - + (greyDepthX - m_marginWidth); wxRect cellRect(greyDepthX+1, y, 0, rowHeight-1); int textXAdd = textMarginHere - greyDepthX; @@ -2035,7 +2018,7 @@ wxRect wxPropertyGrid::GetPropertyRect( const wxPGProperty* p1, const wxPGProper if ( m_width < 10 || m_height < 10 || !m_pState->m_properties->GetChildCount() || - p1 == (wxPGProperty*) NULL ) + p1 == NULL ) return wxRect(0,0,0,0); int vy = 0; @@ -2266,7 +2249,7 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState ) pNewState->OnClientWidthChange( pgWidth, pgWidth - pNewState->m_width ); } - m_propHover = (wxPGProperty*) NULL; + m_propHover = NULL; // If necessary, convert state to correct mode. if ( orig_mode != new_state_mode ) @@ -2277,8 +2260,7 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState ) else if ( !m_frozen ) { // Refresh, if not frozen. - if ( m_pState->m_itemsAdded ) - PrepareAfterItemsAdded(); + m_pState->PrepareAfterItemsAdded(); // Reselect if ( m_pState->m_selected ) @@ -2621,6 +2603,29 @@ void wxPropertyGrid::DoShowPropertyError( wxPGProperty* WXUNUSED(property), cons // ----------------------------------------------------------------------- +bool wxPropertyGrid::OnValidationFailure( wxPGProperty* property, + wxVariant& invalidValue ) +{ + wxWindow* editor = GetEditorControl(); + + // First call property's handler + property->OnValidationFailure(invalidValue); + + bool res = DoOnValidationFailure(property, invalidValue); + + // + // For non-wxTextCtrl editors, we do need to revert the value + if ( !editor->IsKindOf(CLASSINFO(wxTextCtrl)) && + property == m_selected ) + { + property->GetEditorClass()->UpdateControl(property, editor); + } + + property->SetFlag(wxPG_PROP_INVALID_VALUE); + + return res; +} + bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty* property, wxVariant& WXUNUSED(invalidValue) ) { int vfb = m_validationInfo.m_failureBehavior; @@ -3214,18 +3219,20 @@ void wxPropertyGrid::FreeEditors() // Do not free editors immediately if processing events if ( m_wndEditor2 ) { - m_wndEditor2->PopEventHandler(true); + wxEvtHandler* handler = m_wndEditor2->PopEventHandler(false); m_wndEditor2->Hide(); + wxPendingDelete.Append( handler ); wxPendingDelete.Append( m_wndEditor2 ); - m_wndEditor2 = (wxWindow*) NULL; + m_wndEditor2 = NULL; } if ( m_wndEditor ) { - m_wndEditor->PopEventHandler(true); + wxEvtHandler* handler = m_wndEditor->PopEventHandler(false); m_wndEditor->Hide(); + wxPendingDelete.Append( handler ); wxPendingDelete.Append( m_wndEditor ); - m_wndEditor = (wxWindow*) NULL; + m_wndEditor = NULL; } } @@ -3279,7 +3286,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) FreeEditors(); // Prevent any further selection measures in this call - p = (wxPGProperty*) NULL; + p = NULL; } else { @@ -3330,8 +3337,8 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) FreeEditors(); m_selColumn = -1; - m_selected = (wxPGProperty*) NULL; - m_pState->m_selected = (wxPGProperty*) NULL; + m_selected = NULL; + m_pState->m_selected = NULL; // We need to always fully refresh the grid here Refresh(false); @@ -3356,7 +3363,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) if ( p != prev ) m_iFlags &= ~(wxPG_FL_VALIDATION_FAILED); - wxASSERT( m_wndEditor == (wxWindow*) NULL ); + wxASSERT( m_wndEditor == NULL ); // // Only create editor for non-disabled non-caption @@ -3555,7 +3562,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags ) if ( !(GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS) ) { - wxStatusBar* statusbar = (wxStatusBar*) NULL; + wxStatusBar* statusbar = NULL; if ( !(m_iFlags & wxPG_FL_NOSTATUSBARHELP) ) { wxFrame* frame = wxDynamicCast(::wxGetTopLevelParent(this),wxFrame); @@ -3636,7 +3643,12 @@ void wxPropertyGrid::RefreshEditor() wnd->SetFont(GetFont()); } - p->GetEditorClass()->UpdateControl(p, wnd); + const wxPGEditor* editorClass = p->GetEditorClass(); + + editorClass->UpdateControl(p, wnd); + + if ( p->IsValueUnspecified() ) + editorClass ->SetValueToUnspecified(p, wnd); } // ----------------------------------------------------------------------- @@ -3645,7 +3657,7 @@ void wxPropertyGrid::RefreshEditor() // (i.e. two-arg function calls create smaller code size). bool wxPropertyGrid::DoClearSelection() { - return DoSelectProperty((wxPGProperty*)NULL); + return DoSelectProperty(NULL); } // ----------------------------------------------------------------------- @@ -4451,7 +4463,7 @@ bool wxPropertyGrid::OnMouseCommon( wxMouseEvent& event, int* px, int* py ) wxRect r; if ( wnd ) r = wnd->GetRect(); - if ( wnd == (wxWindow*) NULL || m_dragStatus || + if ( wnd == NULL || m_dragStatus || ( ux <= (splitterX + wxPG_SPLITTERX_DETECTMARGIN2) || ux >= (r.x+r.width) || @@ -5098,7 +5110,7 @@ wxPGEditor* wxPropertyGrid::RegisterEditorClass( wxPGEditor* editorClass, // Use this in RegisterDefaultEditors. #define wxPGRegisterDefaultEditorClass(EDITOR) \ - if ( wxPGEditor_##EDITOR == (wxPGEditor*) NULL ) \ + if ( wxPGEditor_##EDITOR == NULL ) \ { \ wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \ new wxPG##EDITOR##Editor, true ); \ @@ -5499,15 +5511,15 @@ void wxPGChoices::Free() IMPLEMENT_DYNAMIC_CLASS(wxPropertyGridEvent, wxCommandEvent) -DEFINE_EVENT_TYPE( wxEVT_PG_SELECTED ) -DEFINE_EVENT_TYPE( wxEVT_PG_CHANGING ) -DEFINE_EVENT_TYPE( wxEVT_PG_CHANGED ) -DEFINE_EVENT_TYPE( wxEVT_PG_HIGHLIGHTED ) -DEFINE_EVENT_TYPE( wxEVT_PG_RIGHT_CLICK ) -DEFINE_EVENT_TYPE( wxEVT_PG_PAGE_CHANGED ) -DEFINE_EVENT_TYPE( wxEVT_PG_ITEM_EXPANDED ) -DEFINE_EVENT_TYPE( wxEVT_PG_ITEM_COLLAPSED ) -DEFINE_EVENT_TYPE( wxEVT_PG_DOUBLE_CLICK ) +wxDEFINE_EVENT( wxEVT_PG_SELECTED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_CHANGING, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_CHANGED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_HIGHLIGHTED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_RIGHT_CLICK, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_PAGE_CHANGED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEvent ) +wxDEFINE_EVENT( wxEVT_PG_DOUBLE_CLICK, wxPropertyGridEvent ) // -----------------------------------------------------------------------