| Version: 3.2.2

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
wxPGChoices Class Reference
Class List by Category » wxPropertyGrid

`#include <wx/propgrid/property.h>`

## Detailed Description

Helper class for managing choices of wxPropertyGrid properties.

Each entry can have label, value, bitmap, text colour, and background colour.

wxPGChoices uses reference counting, similar to other wxWidgets classes. This means that assignment operator and copy constructor only copy the reference and not the actual data. Use Copy() member function to create a real copy.

Remarks
  If you do not specify value for entry, index is used.

##

Library: wxPropertyGrid
Category: wxPropertyGrid

## Public Types

typedef long | ValArrItem

## Public Member Functions

| wxPGChoices ()
| Default constructor. More...
| wxPGChoices (const wxPGChoices &a)
| Copy constructor, uses reference counting. More...
| wxPGChoices (size_t count, const wxString *labels, const long *values=NULL)
| Constructor. More...
| wxPGChoices (const wxChar **labels, const long *values=NULL)
| Constructor overload taking wxChar strings. More...
| wxPGChoices (const wxArrayString &labels, const wxArrayInt &values=wxArrayInt())
| Constructor. More...
| wxPGChoices (wxPGChoicesData *data)
| Simple interface constructor. More...
| ~wxPGChoices ()
| Destructor. More...
void | Add (size_t count, const wxString *labels, const long *values=NULL)
| Adds to current. More...
void | Add (const wxChar **labels, const long *values=NULL)
| Adds to current. More...
void | Add (const wxArrayString &arr, const wxArrayInt &arrint)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
wxPGChoiceEntry & | Add (const wxString &label, int value=wxPG_INVALID_VALUE)
| Adds a single choice item. More...
wxPGChoiceEntry & | Add (const wxString &label, const wxBitmap &bitmap, int value=wxPG_INVALID_VALUE)
| Adds a single item, with bitmap. More...
wxPGChoiceEntry & | Add (const wxPGChoiceEntry &entry)
| Adds a single item with full entry information. More...
wxPGChoiceEntry & | AddAsSorted (const wxString &label, int value=wxPG_INVALID_VALUE)
| Adds a single item, sorted. More...
void | Assign (const wxPGChoices &a)
| Assigns choices data, using reference counting. More...
void | AssignData (wxPGChoicesData *data)
| Assigns data from another set of choices. More...
void | Clear ()
| Deletes all items. More...
wxPGChoices | Copy () const
| Returns a real copy of the choices. More...
void | EnsureData ()
wxPGChoicesId | GetId () const
| Gets an unsigned number identifying this list. More...
const wxString & | GetLabel (unsigned int ind) const
| Returns label of item. More...
unsigned int | GetCount () const
| Returns number of items. More...
int | GetValue (unsigned int ind) const
| Returns value of item. More...
wxArrayInt | GetValuesForStrings (const wxArrayString &strings) const
| Returns array of values matching the given strings. More...
wxArrayInt | GetIndicesForStrings (const wxArrayString &strings, wxArrayString *unmatched=NULL) const
| Returns array of indices matching given strings. More...
int | Index (const wxString &label) const
| Returns index of item with given label. More...
int | Index (int val) const
| Returns index of item with given value. More...
wxPGChoiceEntry & | Insert (const wxString &label, int index, int value=wxPG_INVALID_VALUE)
| Inserts a single item. More...
wxPGChoiceEntry & | Insert (const wxPGChoiceEntry &entry, int index)
| Inserts a single item with full entry information. More...
bool | IsOk () const
| Returns false if this is a constant empty set of choices, which should not be modified. More...
const wxPGChoiceEntry & | Item (unsigned int i) const
| Returns item at given index. More...
wxPGChoiceEntry & | Item (unsigned int i)
| Returns item at given index. More...
void | RemoveAt (size_t nIndex, size_t count=1)
| Removes count items starting at position nIndex. More...
void | Set (size_t count, const wxString *labels, const long *values=NULL)
| Sets contents from lists of strings and values. More...
void | Set (const wxChar **labels, const long *values=NULL)
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
void | Set (const wxArrayString &labels, const wxArrayInt &values=wxArrayInt())
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
void | AllocExclusive ()
| Creates exclusive copy of current choices. More...
wxPGChoicesData * | GetData ()
| Returns data, increases refcount. More...
wxPGChoicesData * | GetDataPtr () const
| Returns plain data ptr - no refcounting stuff is done. More...
wxPGChoicesData * | ExtractData ()
| Changes ownership of data to you. More...
wxArrayString | GetLabels () const
| Returns array of choice labels. More...
void | operator= (const wxPGChoices &a)
wxPGChoiceEntry & | operator[] (unsigned int i)
const wxPGChoiceEntry & | operator[] (unsigned int i) const

## Protected Member Functions

void | Init ()
void | Free ()

## Protected Attributes

wxPGChoicesData * | m_data

## Member Typedef Documentation

## ◆ ValArrItem

typedef long wxPGChoices::ValArrItem

## Constructor & Destructor Documentation

## ◆ wxPGChoices() [1/6]

wxPGChoices::wxPGChoices | ( |  | ) |

Default constructor.

## ◆ wxPGChoices() [2/6]

wxPGChoices::wxPGChoices | ( | const wxPGChoices & | a | ) |

Copy constructor, uses reference counting.

To create a real copy, use Copy() member function instead.

## ◆ wxPGChoices() [3/6]

wxPGChoices::wxPGChoices | ( | size_t | count,
|  | const wxString * | labels,
|  | const long * | values = `NULL`
| ) |  |

Constructor.

Parameters

  count | Number of the strings in labels array.
  labels | Labels for choices.
  values | Values for choices. If NULL, indexes are used. Otherwise must have at least count elements.

Since
  3.1.2

## ◆ wxPGChoices() [4/6]

wxPGChoices::wxPGChoices | ( | const wxChar ** | 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.

Parameters

  labels | Labels for choices, NULL-terminated.
  values | Values for choices. If NULL, indexes are used. Otherwise must have at least the same size as labels.

## ◆ wxPGChoices() [5/6]

wxPGChoices::wxPGChoices | ( | const wxArrayString & | labels,
|  | const wxArrayInt & | values = `wxArrayInt()`
| ) |  |

Constructor.

Parameters

  labels | Labels for choices.
  values | Values for choices. If empty, indexes are used. Otherwise must have at least the same size as labels.

## ◆ wxPGChoices() [6/6]

wxPGChoices::wxPGChoices | ( | wxPGChoicesData * | data | ) |

Simple interface constructor.

## ◆ ~wxPGChoices()

wxPGChoices::~wxPGChoices | ( |  | ) |

Destructor.

## Member Function Documentation

## ◆ Add() [1/6]

void wxPGChoices::Add | ( | const wxArrayString & | arr,
|  | const wxArrayInt & | arrint
| ) |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## ◆ Add() [2/6]

void wxPGChoices::Add | ( | const wxChar ** | 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.

Parameters

  labels | Labels for added choices, NULL-terminated.
  values | Values for added choices. If empty, relevant entry indexes are used. Otherwise must have at least the same size as labels.

## ◆ Add() [3/6]

wxPGChoiceEntry& wxPGChoices::Add | ( | const wxPGChoiceEntry & | entry | ) |

Adds a single item with full entry information.

## ◆ Add() [4/6]

wxPGChoiceEntry& wxPGChoices::Add | ( | const wxString & | label,
|  | const wxBitmap & | bitmap,
|  | int | value = `wxPG_INVALID_VALUE`
| ) |  |

Adds a single item, with bitmap.

## ◆ Add() [5/6]

wxPGChoiceEntry& wxPGChoices::Add | ( | const wxString & | label,
|  | int | value = `wxPG_INVALID_VALUE`
| ) |  |

Adds a single choice item.

Parameters

  label | Label for added choice.
  value | Value for added choice. If unspecified, index is used.

## ◆ Add() [6/6]

void wxPGChoices::Add | ( | size_t | count,
|  | const wxString * | labels,
|  | const long * | values = `NULL`
| ) |  |

Adds to current.

If did not have own copies, creates them now. If was empty, identical to set except that creates copies.

Parameters

  count | Number of the strings in labels array.
  labels | Labels for choices.
  values | Values for choices. If NULL, indexes are used. Otherwise must have at least count elements.

Since
  3.1.2

## ◆ AddAsSorted()

wxPGChoiceEntry& wxPGChoices::AddAsSorted | ( | const wxString & | label,
|  | int | value = `wxPG_INVALID_VALUE`
| ) |  |

Adds a single item, sorted.

## ◆ AllocExclusive()

void wxPGChoices::AllocExclusive | ( |  | ) |

Creates exclusive copy of current choices.

## ◆ Assign()

void wxPGChoices::Assign | ( | const wxPGChoices & | a | ) |

Assigns choices data, using reference counting.

To create a real copy, use Copy() member function instead.

## ◆ AssignData()

void wxPGChoices::AssignData | ( | wxPGChoicesData * | data | ) |

Assigns data from another set of choices.

## ◆ Clear()

void wxPGChoices::Clear | ( |  | ) |

Deletes all items.

## ◆ Copy()

wxPGChoices wxPGChoices::Copy | ( |  | ) | const

Returns a real copy of the choices.

## ◆ EnsureData()

void wxPGChoices::EnsureData | ( |  | ) |

## ◆ ExtractData()

wxPGChoicesData* wxPGChoices::ExtractData | ( |  | ) |

Changes ownership of data to you.

## ◆ Free()

void wxPGChoices::Free | ( |  | ) |

protected

## ◆ GetCount()

unsigned int wxPGChoices::GetCount | ( |  | ) | const

Returns number of items.

## ◆ GetData()

wxPGChoicesData* wxPGChoices::GetData | ( |  | ) |

Returns data, increases refcount.

## ◆ GetDataPtr()

wxPGChoicesData* wxPGChoices::GetDataPtr | ( |  | ) | const

Returns plain data ptr - no refcounting stuff is done.

## ◆ GetId()

wxPGChoicesId wxPGChoices::GetId | ( |  | ) | const

Gets an unsigned number identifying this list.

## ◆ GetIndicesForStrings()

wxArrayInt wxPGChoices::GetIndicesForStrings | ( | const wxArrayString & | strings,
|  | wxArrayString * | unmatched = `NULL`
| ) |  | const

Returns array of indices matching given strings.

Unmatching strings are added to 'unmatched', if not NULL.

## ◆ GetLabel()

const wxString& wxPGChoices::GetLabel | ( | unsigned int | ind | ) | const

Returns label of item.

## ◆ GetLabels()

wxArrayString wxPGChoices::GetLabels | ( |  | ) | const

Returns array of choice labels.

## ◆ GetValue()

int wxPGChoices::GetValue | ( | unsigned int | ind | ) | const

Returns value of item.

## ◆ GetValuesForStrings()

wxArrayInt wxPGChoices::GetValuesForStrings | ( | const wxArrayString & | strings | ) | const

Returns array of values matching the given strings.

Unmatching strings result in wxPG_INVALID_VALUE entry in array.

## ◆ Index() [1/2]

int wxPGChoices::Index | ( | const wxString & | label | ) | const

Returns index of item with given label.

## ◆ Index() [2/2]

int wxPGChoices::Index | ( | int | val | ) | const

Returns index of item with given value.

## ◆ Init()

void wxPGChoices::Init | ( |  | ) |

protected

## ◆ Insert() [1/2]

wxPGChoiceEntry& wxPGChoices::Insert | ( | const wxPGChoiceEntry & | entry,
|  | int | index
| ) |  |

Inserts a single item with full entry information.

## ◆ Insert() [2/2]

wxPGChoiceEntry& wxPGChoices::Insert | ( | const wxString & | label,
|  | int | index,
|  | int | value = `wxPG_INVALID_VALUE`
| ) |  |

Inserts a single item.

## ◆ IsOk()

bool wxPGChoices::IsOk | ( |  | ) | const

Returns false if this is a constant empty set of choices, which should not be modified.

## ◆ Item() [1/2]

wxPGChoiceEntry& wxPGChoices::Item | ( | unsigned int | i | ) |

Returns item at given index.

## ◆ Item() [2/2]

const wxPGChoiceEntry& wxPGChoices::Item | ( | unsigned int | i | ) | const

Returns item at given index.

## ◆ operator=()

void wxPGChoices::operator= | ( | const wxPGChoices & | a | ) |

## ◆ operator[]() [1/2]

wxPGChoiceEntry& wxPGChoices::operator[] | ( | unsigned int | i | ) |

## ◆ operator[]() [2/2]

const wxPGChoiceEntry& wxPGChoices::operator[] | ( | unsigned int | i | ) | const

## ◆ RemoveAt()

void wxPGChoices::RemoveAt | ( | size_t | nIndex,
|  | size_t | count = `1`
| ) |  |

Removes count items starting at position nIndex.

## ◆ Set() [1/3]

void wxPGChoices::Set | ( | const wxArrayString & | labels,
|  | const wxArrayInt & | values = `wxArrayInt()`
| ) |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## ◆ Set() [2/3]

void wxPGChoices::Set | ( | const wxChar ** | labels,
|  | const long * | values = `NULL`
| ) |  |

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

## ◆ Set() [3/3]

void wxPGChoices::Set | ( | size_t | count,
|  | const wxString * | labels,
|  | const long * | values = `NULL`
| ) |  |

Sets contents from lists of strings and values.

This is similar to calling Clear() and the corresponding overload of Add().

## Member Data Documentation

## ◆ m_data

wxPGChoicesData* wxPGChoices::m_data

protected