Show
Ignore:
Timestamp:
10/08/08 11:15:10 (3 months ago)
Author:
JMS
Message:

Removed dysfunctional wxPGPropery::PrepareValueForDialogEditing(); Replaced its functionality with wxPropertyGrid::GetPendingEditedValue(); Added wxPropertyGrid::PerformValidation() flags so it can be called in generic context.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wxWidgets/trunk/src/propgrid/propgrid.cpp

    r56129 r56169  
    27322732// ----------------------------------------------------------------------- 
    27332733 
    2734 bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue ) 
     2734bool wxPropertyGrid::PerformValidation( wxPGProperty* p, wxVariant& pendingValue, 
     2735                                        int flags ) 
    27352736{ 
    27362737    // 
     
    28012802    wxVariant evtChangingValue = value; 
    28022803 
    2803     // FIXME: After proper ValueToString()s added, remove 
    2804     // this. It is just a temporary fix, as evt_changing 
    2805     // will simply not work for wxPG_PROP_COMPOSED_VALUE 
    2806     // (unless it is selected, and textctrl editor is open). 
    2807     if ( changedProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) ) 
    2808     { 
    2809         evtChangingProperty = baseChangedProperty; 
    2810         if ( evtChangingProperty != p ) 
    2811         { 
    2812             evtChangingProperty->AdaptListToValue( bcpPendingList, &evtChangingValue ); 
    2813         } 
    2814         else 
    2815         { 
    2816             evtChangingValue = pendingValue; 
    2817         } 
    2818     } 
    2819  
    2820     if ( evtChangingProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) ) 
    2821     { 
    2822         if ( changedProperty == m_selected ) 
    2823         { 
    2824             wxWindow* editor = GetEditorControl(); 
    2825             wxASSERT( editor->IsKindOf(CLASSINFO(wxTextCtrl)) ); 
    2826             evtChangingValue = wxStaticCast(editor, wxTextCtrl)->GetValue(); 
    2827         } 
    2828         else 
    2829         { 
    2830             wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value.")); 
     2804    if ( flags & SendEvtChanging ) 
     2805    { 
     2806        // FIXME: After proper ValueToString()s added, remove 
     2807        // this. It is just a temporary fix, as evt_changing 
     2808        // will simply not work for wxPG_PROP_COMPOSED_VALUE 
     2809        // (unless it is selected, and textctrl editor is open). 
     2810        if ( changedProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) ) 
     2811        { 
     2812            evtChangingProperty = baseChangedProperty; 
     2813            if ( evtChangingProperty != p ) 
     2814            { 
     2815                evtChangingProperty->AdaptListToValue( bcpPendingList, &evtChangingValue ); 
     2816            } 
     2817            else 
     2818            { 
     2819                evtChangingValue = pendingValue; 
     2820            } 
     2821        } 
     2822 
     2823        if ( evtChangingProperty->HasFlag(wxPG_PROP_COMPOSED_VALUE) ) 
     2824        { 
     2825            if ( changedProperty == m_selected ) 
     2826            { 
     2827                wxWindow* editor = GetEditorControl(); 
     2828                wxASSERT( editor->IsKindOf(CLASSINFO(wxTextCtrl)) ); 
     2829                evtChangingValue = wxStaticCast(editor, wxTextCtrl)->GetValue(); 
     2830            } 
     2831            else 
     2832            { 
     2833                wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value.")); 
     2834            } 
    28312835        } 
    28322836    } 
     
    28502854    } 
    28512855 
    2852     // SendEvent returns true if event was vetoed 
    2853     if ( SendEvent( wxEVT_PG_CHANGING, evtChangingProperty, &evtChangingValue, 0 ) ) 
    2854         return false; 
     2856    if ( flags & SendEvtChanging ) 
     2857    { 
     2858        // SendEvent returns true if event was vetoed 
     2859        if ( SendEvent( wxEVT_PG_CHANGING, evtChangingProperty, &evtChangingValue, 0 ) ) 
     2860            return false; 
     2861    } 
     2862 
     2863    if ( flags & IsStandaloneValidation ) 
     2864    { 
     2865        // If called in 'generic' context, we need to reset 
     2866        // m_chgInfo_changedProperty and write back translated value. 
     2867        m_chgInfo_changedProperty = NULL; 
     2868        pendingValue = value; 
     2869    } 
    28552870 
    28562871    return true; 
     
    30863101 
    30873102    return false; 
     3103} 
     3104 
     3105// ----------------------------------------------------------------------- 
     3106 
     3107wxVariant wxPropertyGrid::GetPendingEditedValue() 
     3108{ 
     3109    wxPGProperty* prop = GetSelectedProperty(); 
     3110 
     3111    if ( !prop ) 
     3112        return wxNullVariant; 
     3113 
     3114    wxTextCtrl* tc = GetEditorTextCtrl(); 
     3115    wxVariant value = prop->GetValue(); 
     3116 
     3117    if ( !tc || !IsEditorsValueModified() ) 
     3118        return value; 
     3119 
     3120    if ( !prop->StringToValue(value, tc->GetValue()) ) 
     3121        return value; 
     3122 
     3123    if ( !PerformValidation(prop, value, IsStandaloneValidation) ) 
     3124        return prop->GetValue(); 
     3125 
     3126    return value; 
    30883127} 
    30893128