Merge branch 'pgchoices-wxstring'
Make it more convenient to use wxPGChoices with wxString arrays.
This commit is contained in:
@@ -719,12 +719,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Constructor.
|
// Constructor.
|
||||||
// labels - Labels for choices.
|
// 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.
|
// values - Values for choices. If NULL, indexes are used.
|
||||||
wxPGChoices( const wxChar* const* labels, const long* values = NULL )
|
wxPGChoices( const wxChar* const* labels, const long* values = NULL )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
Set(labels,values);
|
Add(labels,values);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructor.
|
// Constructor.
|
||||||
@@ -734,7 +745,7 @@ public:
|
|||||||
const wxArrayInt& values = wxArrayInt() )
|
const wxArrayInt& values = wxArrayInt() )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
Set(labels,values);
|
Add(labels,values);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple interface constructor.
|
// Simple interface constructor.
|
||||||
@@ -754,7 +765,10 @@ public:
|
|||||||
// Adds to current.
|
// Adds to current.
|
||||||
// If did not have own copies, creates them now. If was empty, identical
|
// If did not have own copies, creates them now. If was empty, identical
|
||||||
// to set except that creates copies.
|
// to set except that creates copies.
|
||||||
// labels - Labels for added choices.
|
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.
|
// values - Values for added choices. If empty, relevant entry indexes are used.
|
||||||
void Add( const wxChar* const* labels, const ValArrItem* values = NULL );
|
void Add( const wxChar* const* labels, const ValArrItem* values = NULL );
|
||||||
|
|
||||||
@@ -879,6 +893,12 @@ public:
|
|||||||
// Sets contents from lists of strings and values.
|
// Sets contents from lists of strings and values.
|
||||||
// Does not create copies for itself.
|
// Does not create copies for itself.
|
||||||
// TODO: Deprecate.
|
// 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 )
|
void Set( const wxChar* const* labels, const long* values = NULL )
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
|
@@ -2487,11 +2487,30 @@ public:
|
|||||||
/**
|
/**
|
||||||
Constructor.
|
Constructor.
|
||||||
|
|
||||||
|
@param count
|
||||||
|
Number of the strings in @a labels array.
|
||||||
@param labels
|
@param labels
|
||||||
Labels for choices.
|
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.
|
||||||
|
|
||||||
@param values
|
@param values
|
||||||
Values for choices. If @NULL, indexes are used.
|
Values for choices. If @NULL, indexes are used. Otherwise must have
|
||||||
|
at least the same size as @a labels.
|
||||||
*/
|
*/
|
||||||
wxPGChoices( const wxChar** labels, const long* values = NULL );
|
wxPGChoices( const wxChar** labels, const long* values = NULL );
|
||||||
|
|
||||||
@@ -2502,7 +2521,8 @@ public:
|
|||||||
Labels for choices.
|
Labels for choices.
|
||||||
|
|
||||||
@param values
|
@param values
|
||||||
Values for choices. If empty, indexes are used.
|
Values for choices. If empty, indexes are used. Otherwise must have
|
||||||
|
at least the same size as @a labels.
|
||||||
*/
|
*/
|
||||||
wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
|
wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
|
||||||
|
|
||||||
@@ -2520,16 +2540,35 @@ public:
|
|||||||
Adds to current. If did not have own copies, creates them now. If was empty,
|
Adds to current. If did not have own copies, creates them now. If was empty,
|
||||||
identical to set except that creates copies.
|
identical to set except that creates copies.
|
||||||
|
|
||||||
|
@param count
|
||||||
|
Number of the strings in @a labels array.
|
||||||
@param labels
|
@param labels
|
||||||
Labels for added choices.
|
Labels for choices.
|
||||||
|
|
||||||
@param values
|
@param values
|
||||||
Values for added choices. If empty, relevant entry indexes are used.
|
Values for choices. If @NULL, indexes are used. Otherwise must have
|
||||||
|
at least @a count elements.
|
||||||
|
|
||||||
|
@since 3.1.2
|
||||||
*/
|
*/
|
||||||
void Add( const wxChar** labels, const ValArrItem* values = NULL );
|
void Add(size_t count, const wxString* labels, const long* values = NULL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds to current. Version that works with wxArrayString and wxArrayInt.
|
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.
|
||||||
|
|
||||||
|
@param values
|
||||||
|
Values for added choices. If empty, relevant entry indexes are
|
||||||
|
used. Otherwise must have at least the same size as @a labels.
|
||||||
|
*/
|
||||||
|
void Add( const wxChar** labels, const long* values = NULL );
|
||||||
|
|
||||||
|
/**
|
||||||
|
@overload
|
||||||
*/
|
*/
|
||||||
void Add( const wxArrayString& arr, const wxArrayInt& arrint );
|
void Add( const wxArrayString& arr, const wxArrayInt& arrint );
|
||||||
|
|
||||||
@@ -2659,11 +2698,18 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Sets contents from lists of strings and values.
|
Sets contents from lists of strings and values.
|
||||||
|
|
||||||
|
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 );
|
void Set( const wxChar** labels, const long* values = NULL );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets contents from lists of strings and values.
|
@overload
|
||||||
*/
|
*/
|
||||||
void Set( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
|
void Set( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() );
|
||||||
|
|
||||||
|
@@ -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 )
|
void wxPGChoices::Add( const wxChar* const* labels, const ValArrItem* values )
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
Reference in New Issue
Block a user