# wxRearrangeList Class Reference
[Controls]

`#include <wx/rearrangectrl.h>`

Inheritance diagram for wxRearrangeList:
[legend]

## Detailed Description

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.

Since:
  2.9.0

##

Library: wxCore

Category: Controls

## 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.

List of all members.

## Constructor & Destructor Documentation

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.

## Member Function Documentation

bool wxRearrangeList::CanMoveCurrentDown | ( |  | ) | const

Return true if the currently selected item can be moved down.

See also:
  CanMoveCurrentUp()

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.

Returns:
  true if the currently selected item can be moved up in the listbox, false if there is no selection or the current item is the first one.

See also:
  CanMoveCurrentDown()

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.

Parameters:

  | 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.

See also:
  MoveCurrentUp()

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.

Returns:
  true if the item was moved or false if this couldn't be done.

See also:
  MoveCurrentDown()

|  | [ top ]