X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3c7789014106c9269b0f4ecc1a3071b14f351d3f..12b5f4b4d2d8a07962da7ba3b78c8c1ec2634a67:/src/propgrid/propgrid.cpp?ds=inline diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index bf16d22fdf..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 } @@ -1404,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); @@ -1914,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; @@ -2017,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; @@ -2248,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 ) @@ -2602,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; @@ -3195,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; } } @@ -3260,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 { @@ -3311,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); @@ -3337,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 @@ -3536,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); @@ -3631,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); } // ----------------------------------------------------------------------- @@ -4437,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) || @@ -5084,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 ); \