X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/98c0463399a5787ea9bf8644e2c4cacf2c98e214..059d234d4176165d975048eaa5436ef40af7d037:/src/propgrid/props.cpp diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index 1b61ba15df..77ecc238ee 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -134,7 +134,7 @@ bool wxStringProperty::DoSetAttribute( const wxString& name, wxVariant& value ) if ( name == wxPG_STRING_PASSWORD ) { m_flags &= ~(wxPG_PROP_PASSWORD); - if ( wxPGVariantToInt(value) ) m_flags |= wxPG_PROP_PASSWORD; + if ( value.GetLong() ) m_flags |= wxPG_PROP_PASSWORD; RecreateEditor(); return false; } @@ -169,11 +169,10 @@ wxString wxIntProperty::ValueToString( wxVariant& value, { return wxString::Format(wxS("%li"),value.GetLong()); } - else if ( value.GetType() == wxLongLong_VariantType ) + else if ( value.GetType() == wxPG_VARIANT_TYPE_LONGLONG ) { - wxLongLong ll; - ll << value; - return ll.ToString(); + wxLongLong ll = value.GetLongLong(); + return ll.ToString(); } return wxEmptyString; @@ -200,7 +199,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int int firstNonZeroPos = 0; - for ( ; i != iMax; i++ ) + for ( ; i != iMax; ++i ) { wxChar c = *i; if ( c != wxS('0') && c != wxS(' ') ) @@ -221,10 +220,9 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int { bool doChangeValue = isPrevLong; - if ( !isPrevLong && variantType == wxLongLong_VariantType ) + if ( !isPrevLong && variantType == wxPG_VARIANT_TYPE_LONGLONG ) { - wxLongLong oldValue; - oldValue << variant; + wxLongLong oldValue = variant.GetLongLong(); if ( oldValue.GetValue() != value64 ) doChangeValue = true; } @@ -232,7 +230,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int if ( doChangeValue ) { wxLongLong ll(value64); - variant << ll; + variant = ll; return true; } } @@ -274,14 +272,14 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va variant = property->GetAttribute(wxPGGlobalVars->m_strMin); if ( !variant.IsNull() ) { - wxPGVariantToLongLong(variant, &min); + min = variant.GetLongLong().GetValue(); minOk = true; } variant = property->GetAttribute(wxPGGlobalVars->m_strMax); if ( !variant.IsNull() ) { - wxPGVariantToLongLong(variant, &max); + max = variant.GetLongLong().GetValue(); maxOk = true; } @@ -319,12 +317,12 @@ bool wxIntProperty::DoValidation( const wxPGProperty* property, wxLongLong_t& va return true; } -bool wxIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const +bool wxIntProperty::ValidateValue( wxVariant& value, + wxPGValidationInfo& validationInfo ) const { - wxLongLong_t ll; - if ( wxPGVariantToLongLong(value, &ll) ) - return DoValidation(this, ll, &validationInfo, wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE); - return true; + wxLongLong_t ll = value.GetLongLong().GetValue(); + return DoValidation(this, ll, &validationInfo, + wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE); } wxValidator* wxIntProperty::GetClassValidator() @@ -406,11 +404,11 @@ wxString wxUIntProperty::ValueToString( wxVariant& value, if ( value.GetType() == wxPG_VARIANT_TYPE_LONG ) { - return wxString::Format(gs_uintTemplates32[index], (unsigned long)value.GetLong()); + return wxString::Format(gs_uintTemplates32[index], + (unsigned long)value.GetLong()); } - wxULongLong ull; - ull << value; + wxULongLong ull = value.GetULongLong(); return wxString::Format(gs_uintTemplates64[index], ull.GetValue()); } @@ -439,18 +437,16 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in { bool doChangeValue = isPrevLong; - if ( !isPrevLong && variantType == wxULongLong_VariantType ) + if ( !isPrevLong && variantType == wxPG_VARIANT_TYPE_ULONGLONG ) { - wxULongLong oldValue; - oldValue << variant; + wxULongLong oldValue = variant.GetULongLong(); if ( oldValue.GetValue() != value64 ) doChangeValue = true; } if ( doChangeValue ) { - wxULongLong ull(value64); - variant << ull; + variant = wxULongLong(value64); return true; } } @@ -478,49 +474,40 @@ bool wxUIntProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(ar return false; } -#ifdef ULLONG_MAX - #define wxUINT64_MAX ULLONG_MAX - #define wxUINT64_MIN wxULL(0) -#else - #define wxUINT64_MAX wxULL(0xFFFFFFFFFFFFFFFF) - #define wxUINT64_MIN wxULL(0) -#endif - bool wxUIntProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const { // Check for min/max - wxULongLong_t ll; - if ( wxPGVariantToULongLong(value, &ll) ) - { - wxULongLong_t min = wxUINT64_MIN; - wxULongLong_t max = wxUINT64_MAX; - wxVariant variant; + wxULongLong_t ll = value.GetULongLong().GetValue(); + + wxULongLong_t min = 0; + wxULongLong_t max = wxUINT64_MAX; + wxVariant variant; - variant = GetAttribute(wxPGGlobalVars->m_strMin); - if ( !variant.IsNull() ) + variant = GetAttribute(wxPGGlobalVars->m_strMin); + if ( !variant.IsNull() ) + { + min = variant.GetULongLong().GetValue(); + if ( ll < min ) { - wxPGVariantToULongLong(variant, &min); - if ( ll < min ) - { - validationInfo.SetFailureMessage( - wxString::Format(_("Value must be %llu or higher"),min) - ); - return false; - } + validationInfo.SetFailureMessage( + wxString::Format(_("Value must be %llu or higher"),min) + ); + return false; } - variant = GetAttribute(wxPGGlobalVars->m_strMax); - if ( !variant.IsNull() ) + } + variant = GetAttribute(wxPGGlobalVars->m_strMax); + if ( !variant.IsNull() ) + { + max = variant.GetULongLong().GetValue(); + if ( ll > max ) { - wxPGVariantToULongLong(variant, &max); - if ( ll > max ) - { - validationInfo.SetFailureMessage( - wxString::Format(_("Value must be %llu or less"),max) - ); - return false; - } + validationInfo.SetFailureMessage( + wxString::Format(_("Value must be %llu or less"),max) + ); + return false; } } + return true; } @@ -606,7 +593,7 @@ void wxPropertyGrid::DoubleToString(wxString& target, wxString::const_iterator i = target.end() - 1; size_t new_len = target.length() - 1; - for ( ; i != target.begin(); i-- ) + for ( ; i != target.begin(); --i ) { if ( *i != wxS('0') ) break; @@ -632,7 +619,7 @@ wxString wxFloatProperty::ValueToString( wxVariant& value, value, m_precision, !(argFlags & wxPG_FULL_VALUE), - (wxString*) NULL); + NULL); } return text; } @@ -663,7 +650,10 @@ bool wxFloatProperty::StringToValue( wxVariant& variant, const wxString& text, i return false; } -bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, wxPGValidationInfo* pValidationInfo, int mode ) +bool wxFloatProperty::DoValidation( const wxPGProperty* property, + double& value, + wxPGValidationInfo* pValidationInfo, + int mode ) { // Check for min/max double min = (double)wxINT64_MIN; @@ -675,14 +665,14 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, variant = property->GetAttribute(wxPGGlobalVars->m_strMin); if ( !variant.IsNull() ) { - wxPGVariantToDouble(variant, &min); + min = variant.GetDouble(); minOk = true; } variant = property->GetAttribute(wxPGGlobalVars->m_strMax); if ( !variant.IsNull() ) { - wxPGVariantToDouble(variant, &max); + max = variant.GetDouble(); maxOk = true; } @@ -704,7 +694,7 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, if ( maxOk ) { - wxPGVariantToDouble(variant, &max); + max = variant.GetDouble(); if ( value > max ) { if ( mode == wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE ) @@ -721,12 +711,13 @@ bool wxFloatProperty::DoValidation( const wxPGProperty* property, double& value, return true; } -bool wxFloatProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const +bool +wxFloatProperty::ValidateValue( wxVariant& value, + wxPGValidationInfo& validationInfo ) const { - double fpv; - if ( wxPGVariantToDouble(value, &fpv) ) - return DoValidation(this, fpv, &validationInfo, wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE); - return true; + double fpv = value.GetDouble(); + return DoValidation(this, fpv, &validationInfo, + wxPG_PROPERTY_VALIDATION_ERROR_MESSAGE); } bool wxFloatProperty::DoSetAttribute( const wxString& name, wxVariant& value ) @@ -857,8 +848,7 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value ) #if wxPG_INCLUDE_CHECKBOX if ( name == wxPG_BOOL_USE_CHECKBOX ) { - int ival = wxPGVariantToInt(value); - if ( ival ) + if ( value.GetLong() ) m_flags |= wxPG_PROP_USE_CHECKBOX; else m_flags &= ~(wxPG_PROP_USE_CHECKBOX); @@ -867,8 +857,7 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value ) #endif if ( name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING ) { - int ival = wxPGVariantToInt(value); - if ( ival ) + if ( value.GetLong() ) m_flags |= wxPG_PROP_USE_DCC; else m_flags &= ~(wxPG_PROP_USE_DCC); @@ -878,35 +867,108 @@ bool wxBoolProperty::DoSetAttribute( const wxString& name, wxVariant& value ) } // ----------------------------------------------------------------------- -// wxBaseEnumProperty +// wxEnumProperty // ----------------------------------------------------------------------- -int wxBaseEnumProperty::ms_nextIndex = -2; +IMPLEMENT_DYNAMIC_CLASS(wxEnumProperty, wxPGProperty) + +WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxEnumProperty,long,Choice) + +wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, const wxChar** labels, + const long* values, int value ) : wxPGProperty(label,name) +{ + SetIndex(0); + + if ( labels ) + { + m_choices.Add(labels,values); + + if ( GetItemCount() ) + SetValue( (long)value ); + } +} + +wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, const wxChar** labels, + const long* values, wxPGChoices* choicesCache, int value ) + : wxPGProperty(label,name) +{ + SetIndex(0); + + wxASSERT( choicesCache ); + + if ( choicesCache->IsOk() ) + { + m_choices.Assign( *choicesCache ); + m_value = wxPGVariant_Zero; + } + else if ( labels ) + { + m_choices.Add(labels,values); + + if ( GetItemCount() ) + SetValue( (long)value ); + } +} -wxBaseEnumProperty::wxBaseEnumProperty( const wxString& label, const wxString& name ) +wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, + const wxArrayString& labels, const wxArrayInt& values, int value ) : wxPGProperty(label,name) { - m_value = wxPGVariant_Zero; + SetIndex(0); + + if ( &labels && labels.size() ) + { + m_choices.Set(labels, values); + + if ( GetItemCount() ) + SetValue( (long)value ); + } } -/** If has values array, then returns number at index with value - - otherwise just returns the value. -*/ -int wxBaseEnumProperty::GetIndexForValue( int value ) const +wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, + wxPGChoices& choices, int value ) + : wxPGProperty(label,name) { + m_choices.Assign( choices ); + + if ( GetItemCount() ) + SetValue( (long)value ); +} + +int wxEnumProperty::GetIndexForValue( int value ) const +{ + if ( !m_choices.IsOk() ) + return -1; + + int intVal = m_choices.Index(value); + if ( intVal >= 0 ) + return intVal; + return value; } -void wxBaseEnumProperty::OnSetValue() +wxEnumProperty::~wxEnumProperty () +{ +} + +int wxEnumProperty::ms_nextIndex = -2; + +void wxEnumProperty::OnSetValue() { wxString variantType = m_value.GetType(); if ( variantType == wxPG_VARIANT_TYPE_LONG ) + { ValueFromInt_( m_value, m_value.GetLong(), wxPG_FULL_VALUE ); + } else if ( variantType == wxPG_VARIANT_TYPE_STRING ) + { ValueFromString_( m_value, m_value.GetString(), 0 ); + } else - wxASSERT( false ); + { + wxFAIL; + } if ( ms_nextIndex != -2 ) { @@ -915,7 +977,7 @@ void wxBaseEnumProperty::OnSetValue() } } -bool wxBaseEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WXUNUSED(validationInfo) ) const +bool wxEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WXUNUSED(validationInfo) ) const { // Make sure string value is in the list, // unless property has string as preferred value type @@ -927,7 +989,7 @@ bool wxBaseEnumProperty::ValidateValue( wxVariant& value, wxPGValidationInfo& WX return true; } -wxString wxBaseEnumProperty::ValueToString( wxVariant& value, +wxString wxEnumProperty::ValueToString( wxVariant& value, int WXUNUSED(argFlags) ) const { if ( value.GetType() == wxPG_VARIANT_TYPE_STRING ) @@ -940,36 +1002,30 @@ wxString wxBaseEnumProperty::ValueToString( wxVariant& value, return m_choices.GetLabel(index); } -bool wxBaseEnumProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const +bool wxEnumProperty::StringToValue( wxVariant& variant, const wxString& text, int argFlags ) const { return ValueFromString_( variant, text, argFlags ); } -bool wxBaseEnumProperty::IntToValue( wxVariant& variant, int intVal, int argFlags ) const +bool wxEnumProperty::IntToValue( wxVariant& variant, int intVal, int argFlags ) const { return ValueFromInt_( variant, intVal, argFlags ); } -bool wxBaseEnumProperty::ValueFromString_( wxVariant& value, const wxString& text, int argFlags ) const +bool wxEnumProperty::ValueFromString_( wxVariant& value, const wxString& text, int argFlags ) const { - size_t i = 0; - const wxString* entryLabel; - int entryValue; int useIndex = -1; long useValue = 0; - entryLabel = GetEntry(i, &entryValue); - while ( entryLabel ) + for ( unsigned int i=0; iIsOk() ) - { - m_choices.Assign( *choicesCache ); - m_value = wxPGVariant_Zero; - } - else if ( labels ) - { - m_choices.Add(labels,values); - - if ( GetItemCount() ) - SetValue( (long)value ); - } -} - -wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, - const wxArrayString& labels, const wxArrayInt& values, int value ) : wxBaseEnumProperty(label,name) -{ - SetIndex(0); - - if ( &labels && labels.size() ) - { - m_choices.Set(labels, values); - - if ( GetItemCount() ) - SetValue( (long)value ); - } + // Revert index + ResetNextIndex(); } -wxEnumProperty::wxEnumProperty( const wxString& label, const wxString& name, - wxPGChoices& choices, int value ) - : wxBaseEnumProperty(label,name) +void wxEnumProperty::SetIndex( int index ) { - m_choices.Assign( choices ); - - if ( GetItemCount() ) - SetValue( (long)value ); + ms_nextIndex = -2; + m_index = index; } -int wxEnumProperty::GetIndexForValue( int value ) const +int wxEnumProperty::GetIndex() const { - if ( !m_choices.IsOk() ) + if ( m_value.IsNull() ) return -1; - int intVal = m_choices.Index(value); - if ( intVal >= 0 ) - return intVal; - - return value; -} - -wxEnumProperty::~wxEnumProperty () -{ -} - -const wxString* wxEnumProperty::GetEntry( size_t index, int* pvalue ) const -{ - if ( m_choices.IsOk() && index < m_choices.GetCount() ) - { - int value = m_choices.GetValue(index); - - if ( pvalue ) - *pvalue = value; + if ( ms_nextIndex != -2 ) + return ms_nextIndex; - return &m_choices.GetLabel(index); - } - return (const wxString*) NULL; + return m_index; } // ----------------------------------------------------------------------- @@ -1213,8 +1182,6 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxFlagsProperty,long,TextCtrl) void wxFlagsProperty::Init() { - SetParentalType(wxPG_PROP_AGGREGATE); - long value = m_value; // @@ -1252,6 +1219,12 @@ void wxFlagsProperty::Init() m_children.clear(); + // Relay wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING + // to child bool property controls. + long attrUseCheckBox = GetAttributeAsLong(wxPG_BOOL_USE_CHECKBOX, 0); + long attrUseDCC = GetAttributeAsLong(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING, + 0); + if ( m_choices.IsOk() ) { const wxPGChoices& choices = m_choices; @@ -1274,7 +1247,13 @@ void wxFlagsProperty::Init() { boolProp = new wxBoolProperty( label, label, child_val ); } - AddChild(boolProp); + if ( attrUseCheckBox ) + boolProp->SetAttribute(wxPG_BOOL_USE_CHECKBOX, + true); + if ( attrUseDCC ) + boolProp->SetAttribute(wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING, + true); + AddPrivateChild(boolProp); } m_oldChoicesData = m_choices.GetDataPtr(); @@ -1289,7 +1268,7 @@ void wxFlagsProperty::Init() wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, const wxChar** labels, const long* values, long value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( labels ) { @@ -1309,7 +1288,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, const wxArrayString& labels, const wxArrayInt& values, int value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( &labels && labels.size() ) { @@ -1329,7 +1308,7 @@ wxFlagsProperty::wxFlagsProperty( const wxString& label, const wxString& name, wxPGChoices& choices, long value ) : wxPGProperty(label,name) { - m_oldChoicesData = (wxPGChoicesData*) NULL; + m_oldChoicesData = NULL; if ( choices.IsOk() ) { @@ -1511,15 +1490,34 @@ void wxFlagsProperty::RefreshChildren() m_oldValue = flags; } -void wxFlagsProperty::ChildChanged( wxVariant& thisValue, int childIndex, wxVariant& childValue ) const +wxVariant wxFlagsProperty::ChildChanged( wxVariant& thisValue, + int childIndex, + wxVariant& childValue ) const { long oldValue = thisValue.GetLong(); long val = childValue.GetLong(); unsigned long vi = m_choices.GetValue(childIndex); + if ( val ) - thisValue = (long)(oldValue | vi); - else - thisValue = (long)(oldValue & ~(vi)); + return (long) (oldValue | vi); + + return (long) (oldValue & ~(vi)); +} + +bool wxFlagsProperty::DoSetAttribute( const wxString& name, wxVariant& value ) +{ + if ( name == wxPG_BOOL_USE_CHECKBOX || + name == wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING ) + { + for ( size_t i=0; iSetAttribute(name, value); + } + // Must return false so that the attribute is stored in + // flag property's actual property storage + return false; + } + return false; } // ----------------------------------------------------------------------- @@ -1804,7 +1802,7 @@ bool wxFileProperty::DoSetAttribute( const wxString& name, wxVariant& value ) // stored in m_attributes. if ( name == wxPG_FILE_SHOW_FULL_PATH ) { - if ( wxPGVariantToInt(value) ) + if ( value.GetLong() ) m_flags |= wxPG_PROP_SHOW_FULL_FILENAME; else m_flags &= ~(wxPG_PROP_SHOW_FULL_FILENAME); @@ -1949,14 +1947,14 @@ bool wxLongStringProperty::DisplayEditorDialog( wxPGProperty* prop, wxPropertyGr rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing ); topsizer->Add( rowsizer, 1, wxEXPAND, 0 ); - rowsizer = new wxBoxSizer( wxHORIZONTAL ); - const int but_sz_flags = - wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT; - rowsizer->Add( new wxButton(dlg,wxID_OK,_("Ok")), - 0, but_sz_flags, spacing ); - rowsizer->Add( new wxButton(dlg,wxID_CANCEL,_("Cancel")), - 0, but_sz_flags, spacing ); - topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 ); + + wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); + buttonSizer->AddButton(new wxButton(dlg, wxID_OK)); + buttonSizer->AddButton(new wxButton(dlg, wxID_CANCEL)); + buttonSizer->Realize(); + topsizer->Add( buttonSizer, 0, + wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxRIGHT, + spacing ); dlg->SetSizer( topsizer ); topsizer->SetSizeHints( dlg ); @@ -2091,6 +2089,7 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, // On wxMAC the dialog shows incorrectly if style is not exactly wxCAPTION // FIXME: This should be only a temporary fix. #ifdef __WXMAC__ + wxUnusedVar(style); int useStyle = wxCAPTION; #else int useStyle = style; @@ -2110,9 +2109,6 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, m_curFocus = 1; - const int but_sz_flags = - wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL; //wxBOTTOM|wxLEFT|wxRIGHT; - wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL ); // Message @@ -2124,12 +2120,14 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL ); m_edValue = new wxTextCtrl(this,21,wxEmptyString, wxDefaultPosition,wxDefaultSize,wxTE_PROCESS_ENTER); +#if wxUSE_VALIDATORS wxValidator* validator = GetTextCtrlValidator(); if ( validator ) { m_edValue->SetValidator( *validator ); delete validator; } +#endif rowsizer->Add( m_edValue, 1, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing ); @@ -2154,7 +2152,7 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, // Manipulator buttons wxBoxSizer* colsizer = new wxBoxSizer( wxVERTICAL ); - m_butCustom = (wxButton*) NULL; + m_butCustom = NULL; if ( m_custBtText ) { m_butCustom = new wxButton(this,28,::wxGetTranslation(m_custBtText)); @@ -2182,17 +2180,14 @@ bool wxArrayEditorDialog::Create( wxWindow *parent, topsizer->Add( new wxStaticLine(this,-1), 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, spacing ); - // buttons - rowsizer = new wxBoxSizer( wxHORIZONTAL ); - /* - const int but_sz_flags = - wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT; - */ - rowsizer->Add( new wxButton(this,wxID_OK,_("Ok")), - 0, but_sz_flags, spacing ); - rowsizer->Add( new wxButton(this,wxID_CANCEL,_("Cancel")), - 0, but_sz_flags, spacing ); - topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 ); + // Standard dialog buttons + wxStdDialogButtonSizer* buttonSizer = new wxStdDialogButtonSizer(); + buttonSizer->AddButton(new wxButton(this, wxID_OK)); + buttonSizer->AddButton(new wxButton(this, wxID_CANCEL)); + buttonSizer->Realize(); + topsizer->Add( buttonSizer, 0, + wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL, + spacing ); m_edValue->SetFocus(); @@ -2364,7 +2359,7 @@ wxPGArrayStringEditorDialog::wxPGArrayStringEditorDialog() void wxPGArrayStringEditorDialog::Init() { - m_pCallingClass = (wxArrayStringProperty*) NULL; + m_pCallingClass = NULL; } void wxPGArrayStringEditorDialog::OnCustomEditClick(wxCommandEvent& ) @@ -2436,16 +2431,13 @@ void wxPropertyGrid::ArrayStringToString( wxString& dst, const wxArrayString& sr unsigned int i; unsigned int itemCount = src.size(); - wxChar preas[2]; + wxChar preas[2] = { 0, 0 }; dst.Empty(); - if ( !preDelim ) - preas[0] = 0; - else if ( (flags & 1) ) + if ( flags & 1 ) { preas[0] = preDelim; - preas[1] = 0; pdr = wxS("\\"); pdr += preDelim; }