X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f4bc1aa27cb33f679d7e9c1518a7855bbc1fa471..bd412bc6b6b4d824e83a8eff5c694d5692b46f45:/src/propgrid/props.cpp diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index b161d8c10d..2d2890df73 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -4,7 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: 2005-05-14 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) Jaakko Salli // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// @@ -46,18 +46,15 @@ #include "wx/sizer.h" #include "wx/textdlg.h" #include "wx/filedlg.h" - #include "wx/statusbr.h" #include "wx/intl.h" #endif -#include +#include "wx/filename.h" -#include +#include "wx/propgrid/propgrid.h" #define wxPG_CUSTOM_IMAGE_WIDTH 20 // for wxColourProperty etc. -#include - // ----------------------------------------------------------------------- // wxStringProperty @@ -115,7 +112,7 @@ bool wxStringProperty::StringToValue( wxVariant& variant, const wxString& text, if ( GetChildCount() && HasFlag(wxPG_PROP_COMPOSED_VALUE) ) return wxPGProperty::StringToValue(variant, text, argFlags); - if ( m_value.GetString() != text ) + if ( variant != text ) { variant = text; return true; @@ -233,7 +230,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int if ( useText.ToLong( &value32, 0 ) ) { - if ( !isPrevLong || m_value.GetLong() != value32 ) + if ( !isPrevLong || variant != value32 ) { variant = value32; return true; @@ -248,7 +245,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int bool wxIntProperty::IntToValue( wxVariant& variant, int value, int WXUNUSED(argFlags) ) const { - if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant.GetLong() != value ) + if ( variant.GetType() != wxPG_VARIANT_TYPE_LONG || variant != (long)value ) { variant = (long)value; return true; @@ -284,7 +281,9 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va if ( value < min ) { if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE ) - pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min); + pValidationInfo->SetFailureMessage( + wxString::Format(_("Value must be %lld or higher"),min) + ); else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE ) value = min; else @@ -298,7 +297,9 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va if ( value > max ) { if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE ) - pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %lld or higher"),min); + pValidationInfo->SetFailureMessage( + wxString::Format(_("Value must be %lld or higher"),min) + ); else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE ) value = max; else @@ -446,7 +447,7 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in else { unsigned long value32 = wxLongLong(value64).GetLo(); - if ( !isPrevLong || m_value.GetLong() != (long)value32 ) + if ( !isPrevLong || m_value != (long)value32 ) { variant = (long)value32; return true; @@ -459,7 +460,7 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in bool wxUIntProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(argFlags) ) const { - if ( m_value != (long)number ) + if ( variant != (long)number ) { variant = (long)number; return true; @@ -491,7 +492,9 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida wxPGVariantToULongLong(variant, &min); if ( ll < min ) { - validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or higher"),min); + validationInfo.SetFailureMessage( + wxString::Format(_("Value must be %llu or higher"),min) + ); return false; } } @@ -501,7 +504,9 @@ bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& valida wxPGVariantToULongLong(variant, &max); if ( ll > max ) { - validationInfo.m_failureMessage = wxString::Format(_("Value must be %llu or less"),max); + validationInfo.SetFailureMessage( + wxString::Format(_("Value must be %llu or less"),max) + ); return false; } } @@ -635,7 +640,7 @@ bool wxFloatProperty::StringToValue( wxVariant& variant, const wxString& text, i bool res = text.ToDouble(&value); if ( res ) { - if ( m_value != value ) + if ( variant != value ) { variant = value; return true; @@ -675,7 +680,9 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, if ( value < min ) { if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE ) - pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or higher"),min); + pValidationInfo->SetFailureMessage( + wxString::Format(_("Value must be %f or higher"),min) + ); else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE ) value = min; else @@ -690,7 +697,9 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, if ( value > max ) { if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE ) - pValidationInfo->m_failureMessage = wxString::Format(_("Value must be %f or less"),max); + pValidationInfo->SetFailureMessage( + wxString::Format(_("Value must be %f or less"),max) + ); else if ( mode == wxPG_PROPERTY_VALIDATION_SATURATE ) value = max; else @@ -738,16 +747,18 @@ const wxPGEditor* wxBoolProperty::DoGetEditorClass() const // Select correct editor control. #if wxPG_INCLUDE_CHECKBOX if ( !(m_flags & wxPG_PROP_USE_CHECKBOX) ) - return wxPG_EDITOR(Choice); - return wxPG_EDITOR(CheckBox); + return wxPGEditor_Choice; + return wxPGEditor_CheckBox; #else - return wxPG_EDITOR(Choice); + return wxPGEditor_Choice; #endif } wxBoolProperty::wxBoolProperty( const wxString& label, const wxString& name, bool value ) : wxPGProperty(label,name) { + m_choices.Assign(wxPGGlobalVars->m_boolChoices); + SetValue(wxPGVariant_Bool(value)); m_flags |= wxPG_PROP_USE_DCC; @@ -795,23 +806,13 @@ wxString wxBoolProperty::GetValueAsString( int argFlags ) const return text; } -int wxBoolProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo ) -{ - if ( IsValueUnspecified() ) - return -1; - - if ( choiceinfo ) - choiceinfo->m_choices = &wxPGGlobalVars->m_boolChoices; - return m_value.GetBool()?1:0; -} - bool wxBoolProperty::StringToValue( wxVariant& variant, const wxString& text, int WXUNUSED(argFlags) ) const { - int value = 0; + bool boolValue = false; if ( text.CmpNoCase(wxPGGlobalVars->m_boolChoices[1].GetText()) == 0 || text.CmpNoCase(wxS("true")) == 0 || text.CmpNoCase(m_label) == 0 ) - value = 1; + boolValue = true; if ( text.length() == 0 ) { @@ -819,11 +820,9 @@ bool wxBoolProperty::StringToValue( wxVariant& variant, const wxString& text, in return true; } - bool oldValue = m_value.GetBool(); - - if ( (oldValue && !value) || (!oldValue && value) ) + if ( variant != boolValue ) { - variant = wxPGVariant_Bool(value); + variant = wxPGVariant_Bool(boolValue); return true; } return false; @@ -832,9 +831,8 @@ bool wxBoolProperty::StringToValue( wxVariant& variant, const wxString& text, in bool wxBoolProperty::IntToValue( wxVariant& variant, int value, int ) const { bool boolValue = value ? true : false; - bool oldValue = m_value.GetBool(); - if ( oldValue != boolValue ) + if ( variant != boolValue ) { variant = wxPGVariant_Bool(boolValue); return true; @@ -1161,17 +1159,6 @@ const wxString* wxEnumProperty::GetEntry( size_t index, int* pvalue ) const return (const wxString*) NULL; } -int wxEnumProperty::GetChoiceInfo( wxPGChoiceInfo* choiceinfo ) -{ - if ( choiceinfo ) - choiceinfo->m_choices = &m_choices; - - if ( !m_choices.IsOk() ) - return -1; - - return GetIndex(); -} - // ----------------------------------------------------------------------- // wxEditEnumProperty // ----------------------------------------------------------------------- @@ -1232,7 +1219,7 @@ void wxFlagsProperty::Init() // unsigned int i; - unsigned int prevChildCount = m_children.GetCount(); + unsigned int prevChildCount = m_children.size(); int oldSel = -1; if ( prevChildCount ) @@ -1248,7 +1235,7 @@ void wxFlagsProperty::Init() if ( selected ) { if ( selected->GetParent() == this ) - oldSel = selected->GetArrIndex(); + oldSel = selected->GetIndexInParent(); else if ( selected == this ) oldSel = -2; } @@ -1258,9 +1245,9 @@ void wxFlagsProperty::Init() // Delete old children for ( i=0; im_choices = &m_choices; - return -1; -} - // ----------------------------------------------------------------------- // wxDirProperty // ----------------------------------------------------------------------- -WX_PG_IMPLEMENT_DERIVED_PROPERTY_CLASS(wxDirProperty,wxLongStringProperty,const wxString&) +IMPLEMENT_DYNAMIC_CLASS(wxDirProperty, wxLongStringProperty) wxDirProperty::wxDirProperty( const wxString& name, const wxString& label, const wxString& value ) : wxLongStringProperty(name,label,value) { - m_flags |= wxPG_NO_ESCAPE; + m_flags |= wxPG_PROP_NO_ESCAPE; } + wxDirProperty::~wxDirProperty() { } wxValidator* wxDirProperty::DoGetValidator() const @@ -1576,6 +1557,7 @@ wxValidator* wxDirProperty::DoGetValidator() const bool wxDirProperty::OnButtonClick( wxPropertyGrid* propGrid, wxString& value ) { + // Update property value from editor, if necessary wxSize dlg_sz(300,400); wxDirDialog dlg( propGrid, @@ -1903,9 +1885,9 @@ bool wxLongStringProperty::OnEvent( wxPropertyGrid* propGrid, wxWindow* WXUNUSED if ( propGrid->IsMainButtonEvent(event) ) { // Update the value - PrepareValueForDialogEditing(propGrid); + wxVariant useValue = propGrid->GetUncommittedPropertyValue(); - wxString val1 = GetValueAsString(0); + wxString val1 = useValue.GetString(); wxString val_orig = val1; wxString value; @@ -1991,7 +1973,7 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr bool wxLongStringProperty::StringToValue( wxVariant& variant, const wxString& text, int ) const { - if ( m_value != text ) + if ( variant != text ) { variant = text; return true; @@ -2017,7 +1999,7 @@ END_EVENT_TABLE() IMPLEMENT_ABSTRACT_CLASS(wxArrayEditorDialog, wxDialog) -#include +#include "wx/statline.h" // ----------------------------------------------------------------------- @@ -2505,7 +2487,7 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, const wxChar* cbt ) { // Update the value - PrepareValueForDialogEditing(propGrid); + wxVariant useValue = propGrid->GetUncommittedPropertyValue(); if ( !propGrid->EditorValidate() ) return false; @@ -2522,7 +2504,7 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, if ( strEdDlg ) strEdDlg->SetCustomButton(cbt, this); - dlg->SetDialogValue( wxVariant(m_value) ); + dlg->SetDialogValue( useValue ); dlg->Create(propGrid, wxEmptyString, m_label); #if !wxPG_SMALL_SCREEN