diff --git a/include/wx/propgrid/property.h b/include/wx/propgrid/property.h index 937fabcd06..82b5c3bb83 100644 --- a/include/wx/propgrid/property.h +++ b/include/wx/propgrid/property.h @@ -719,6 +719,17 @@ public: } // Constructor. + // count - Number of labels. + // labels - Labels themselves. + // values - Values for choices. If NULL, indexes are used. + wxPGChoices(size_t count, const wxString* labels, const long* values = NULL) + { + Init(); + Add(count, labels, values); + } + + // Constructor overload taking wxChar strings, provided mostly for + // compatibility. // labels - Labels for choices, NULL-terminated. // values - Values for choices. If NULL, indexes are used. wxPGChoices( const wxChar* const* labels, const long* values = NULL ) @@ -754,6 +765,9 @@ public: // Adds to current. // If did not have own copies, creates them now. If was empty, identical // to set except that creates copies. + void Add(size_t count, const wxString* labels, const long* values = NULL); + + // Overload taking wxChar strings, provided mostly for compatibility. // labels - Labels for added choices, NULL-terminated. // values - Values for added choices. If empty, relevant entry indexes are used. void Add( const wxChar* const* labels, const ValArrItem* values = NULL ); @@ -879,6 +893,12 @@ public: // Sets contents from lists of strings and values. // Does not create copies for itself. // TODO: Deprecate. + void Set(size_t count, const wxString* labels, const long* values = NULL) + { + Free(); + Add(count, labels, values); + } + void Set( const wxChar* const* labels, const long* values = NULL ) { Free(); diff --git a/interface/wx/propgrid/property.h b/interface/wx/propgrid/property.h index 758f9b810a..e60002a638 100644 --- a/interface/wx/propgrid/property.h +++ b/interface/wx/propgrid/property.h @@ -2487,6 +2487,24 @@ public: /** Constructor. + @param count + Number of the strings in @a labels array. + @param labels + Labels for choices. + @param values + Values for choices. If @NULL, indexes are used. Otherwise must have + at least @a count elements. + + @since 3.1.2 + */ + wxPGChoices(size_t count, const wxString* labels, const long* values = NULL); + + /** + Constructor overload taking wxChar strings. + + This constructor is provided mostly for compatibility, prefer to use + one of the other constructor overloads in the new code. + @param labels Labels for choices, @NULL-terminated. @@ -2522,6 +2540,24 @@ public: Adds to current. If did not have own copies, creates them now. If was empty, identical to set except that creates copies. + @param count + Number of the strings in @a labels array. + @param labels + Labels for choices. + @param values + Values for choices. If @NULL, indexes are used. Otherwise must have + at least @a count elements. + + @since 3.1.2 + */ + void Add(size_t count, const wxString* labels, const long* values = NULL); + + /** + Adds to current. + + This overload is provided mostly for compatibility, prefer to use one + of the other ones in the new code. + @param labels Labels for added choices, @NULL-terminated. @@ -2532,7 +2568,7 @@ public: void Add( const wxChar** labels, const long* values = NULL ); /** - Adds to current. Version that works with wxArrayString and wxArrayInt. + @overload */ void Add( const wxArrayString& arr, const wxArrayInt& arrint ); @@ -2665,6 +2701,11 @@ public: This is similar to calling Clear() and the corresponding overload of Add(). */ + void Set(size_t count, const wxString* labels, const long* values = NULL); + + /** + @overload + */ void Set( const wxChar** labels, const long* values = NULL ); /** diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 281ed15d23..5cfa571546 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -3013,6 +3013,20 @@ wxPGChoiceEntry& wxPGChoices::AddAsSorted( const wxString& label, int value ) // ----------------------------------------------------------------------- +void wxPGChoices::Add(size_t count, const wxString* labels, const long* values) +{ + AllocExclusive(); + + for ( size_t i = 0; i < count; ++i ) + { + const int value = values ? values[i] : i; + wxPGChoiceEntry entry(labels[i], value); + m_data->Insert( i, entry ); + } +} + +// ----------------------------------------------------------------------- + void wxPGChoices::Add( const wxChar* const* labels, const ValArrItem* values ) { AllocExclusive();