#include </home/zeitlin/src/wx/github/interface/wx/rearrangectrl.h>
A listbox-like control allowing the user to rearrange the items and to enable or disable them.
This class allows to change the order of the items shown in it as well as to check or uncheck them individually. The data structure used to allow this is the order array which contains the items indices indexed by their position with an added twist that the unchecked items are represented by the bitwise complement of the corresponding index (for any architecture using two's complement for negative numbers representation (i.e. just about any at all) this means that a checked item N is represented by -N-1 in unchecked state). In practice this means that you must apply the C bitwise complement operator when constructing the order array, e.g.
wxArrayInt order; order.push_back(0); // checked item #0 order.push_back(~1); // unchecked item #1
So, for example, the array order [1 -3 0] used in conjunction with the items array ["first", "second", "third"] means that the items order is "second", "third", "first" and the "third" item is unchecked while the other two are checked.
This convention is used both for the order argument of the control ctor or Create() and for the array returned from GetCurrentOrder().
Usually this control will be used together with other controls allowing to move the items around in it interactively. The simplest possible solution is to use wxRearrangeCtrl which combines it with two standard buttons to move the current item up or down.
Public Member Functions | |
wxRearrangeList () | |
Default constructor. | |
wxRearrangeList (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayInt &order, const wxArrayString &items, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRearrangeListNameStr) | |
Constructor really creating the control. | |
bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayInt &order, const wxArrayString &items, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRearrangeListNameStr) |
Effectively creates the window for an object created using the default constructor. | |
const wxArrayInt & | GetCurrentOrder () const |
Return the current order of the items. | |
bool | CanMoveCurrentUp () const |
Return true if the currently selected item can be moved up. | |
bool | CanMoveCurrentDown () const |
Return true if the currently selected item can be moved down. | |
bool | MoveCurrentUp () |
Move the currently selected item one position above. | |
bool | MoveCurrentDown () |
Move the currently selected item one position below. |
wxRearrangeList::wxRearrangeList | ( | ) |
Default constructor.
Create() must be called later to effectively create the control.
wxRearrangeList::wxRearrangeList | ( | wxWindow * | parent, |
wxWindowID | id, | ||
const wxPoint & | pos, | ||
const wxSize & | size, | ||
const wxArrayInt & | order, | ||
const wxArrayString & | items, | ||
long | style = 0 , |
||
const wxValidator & | validator = wxDefaultValidator , |
||
const wxString & | name = wxRearrangeListNameStr |
||
) |
Constructor really creating the control.
Please see Create() for the parameters description.
bool wxRearrangeList::CanMoveCurrentDown | ( | ) | const |
Return true if the currently selected item can be moved down.
bool wxRearrangeList::CanMoveCurrentUp | ( | ) | const |
Return true if the currently selected item can be moved up.
This function is useful for EVT_UPDATE_UI handler for the standard "Up" button often used together with this control and wxRearrangeCtrl uses it in this way.
bool wxRearrangeList::Create | ( | wxWindow * | parent, |
wxWindowID | id, | ||
const wxPoint & | pos, | ||
const wxSize & | size, | ||
const wxArrayInt & | order, | ||
const wxArrayString & | items, | ||
long | style = 0 , |
||
const wxValidator & | validator = wxDefaultValidator , |
||
const wxString & | name = wxRearrangeListNameStr |
||
) |
Effectively creates the window for an object created using the default constructor.
This function is very similar to wxCheckListBox::Create() except that it has an additional parameter specifying the initial order of the items. Please see the class documentation for the explanation of the conventions used by the order argument.
parent | The parent window, must be non-NULL. |
id | The window identifier. |
pos | The initial window position. |
size | The initial window size. |
order | Array specifying the initial order of the items in items array. |
items | The items to display in the list. |
style | The control style, there are no special styles for this class but the base class styles can be used here. |
validator | Optional window validator. |
name | Optional window name. |
const wxArrayInt& wxRearrangeList::GetCurrentOrder | ( | ) | const |
Return the current order of the items.
The order may be different from the one passed to the constructor if MoveCurrentUp() or MoveCurrentDown() were called.
bool wxRearrangeList::MoveCurrentDown | ( | ) |
Move the currently selected item one position below.
bool wxRearrangeList::MoveCurrentUp | ( | ) |
Move the currently selected item one position above.
This method is useful to implement the standard "Up" button behaviour and wxRearrangeCtrl uses it for this.