wxRearrangeDialog Class Reference
[Common Dialogs]

#include <wx/rearrangectrl.h>


Detailed Description

A dialog allowing the user to rearrange the specified items.

This dialog can be used to allow the user to modify the order of the items and to enable or disable them individually. For example:

        wxArrayString items;
        items.push_back("meat");
        items.push_back("fish");
        items.push_back("fruits");
        items.push_back("beer");
        wxArrayInt order;
        order.push_back(3);
        order.push_back(0);
        order.push_back(1);
        order.push_back(2);

        wxRearrangeDialog dlg(NULL,
                              "You can also uncheck the items you don't like "
                              "at all.",
                              "Sort the items in order of preference",
                              order, items);
        if ( dlg.ShowModal() == wxID_OK ) {
            order = dlg.GetOrder();
            for ( size_t n = 0; n < order.size(); n++ ) {
                if ( order[n] >= 0 ) {
                    wxLogMessage("Your most preferred item is \"%s\"",
                                 items[order[n]]);
                    break;
                }
            }
        }

Library:  wxCore
Category:  Common Dialogs

Public Member Functions

 wxRearrangeDialog ()
 Default constructor.
 wxRearrangeDialog (wxWindow *parent, const wxString &message, const wxString &title, const wxArrayInt &order, const wxArrayString &items, const wxPoint &pos=wxDefaultPosition, const wxString &name=wxRearrangeDialogNameStr)
 Constructor creating the dialog.
bool Create (wxWindow *parent, const wxString &message, const wxString &title, const wxArrayInt &order, const wxArrayString &items, const wxPoint &pos=wxDefaultPosition, const wxString &name=wxRearrangeDialogNameStr)
 Effectively creates the dialog for an object created using the default constructor.
void AddExtraControls (wxWindow *win)
 Customize the dialog by adding extra controls to it.
wxRearrangeListGetList () const
 Return the list control used by the dialog.
wxArrayInt GetOrder () const
 Return the array describing the order of items after it was modified by the user.

List of all members.


Constructor & Destructor Documentation

wxRearrangeDialog::wxRearrangeDialog (  ) 

Default constructor.

Create() must be called later to effectively create the control.

wxRearrangeDialog::wxRearrangeDialog ( wxWindow parent,
const wxString message,
const wxString title,
const wxArrayInt order,
const wxArrayString items,
const wxPoint pos = wxDefaultPosition,
const wxString name = wxRearrangeDialogNameStr 
)

Constructor creating the dialog.

Please see Create() for the parameters description.


Member Function Documentation

void wxRearrangeDialog::AddExtraControls ( wxWindow win  ) 

Customize the dialog by adding extra controls to it.

This function adds the given win to the dialog, putting it just below the part occupied by wxRearrangeCtrl. It must be called after creating the dialog and you will typically need to process the events generated by the extra controls for them to do something useful.

For example:

            class MyRearrangeDialog : public wxRearrangeDialog
            {
            public:
                MyRearrangeDialog(wxWindow *parent, ...)
                    : wxRearrangeDialog(parent, ...)
                {
                    wxPanel *panel = new wxPanel(this);
                    wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
                    sizer->Add(new wxStaticText(panel, wxID_ANY,
                                                "Column width in pixels:"));
                    sizer->Add(new wxTextCtrl(panel, wxID_ANY, ""));
                    panel->SetSizer(sizer);
                    AddExtraControls(panel);
                }

                ... code to update the text control with the currently selected
                    item width and to react to its changes omitted ...
            };

See also the complete example of a custom rearrange dialog in the dialogs sample.

Parameters:
win The window containing the extra controls. It must have this dialog as its parent.
bool wxRearrangeDialog::Create ( wxWindow parent,
const wxString message,
const wxString title,
const wxArrayInt order,
const wxArrayString items,
const wxPoint pos = wxDefaultPosition,
const wxString name = wxRearrangeDialogNameStr 
)

Effectively creates the dialog for an object created using the default constructor.

Parameters:
parent The dialog parent, possibly NULL.
message The message shown inside the dialog itself, above the items list.
title The title of the dialog.
order The initial order of the items in the convention used by wxRearrangeList.
items The items to show in the dialog.
pos Optional dialog position.
name Optional dialog name.
Returns:
true if the dialog was successfully created or false if creation failed.
wxRearrangeList* wxRearrangeDialog::GetList (  )  const

Return the list control used by the dialog.

See also:
wxRearrangeCtrl::GetList()
wxArrayInt wxRearrangeDialog::GetOrder (  )  const

Return the array describing the order of items after it was modified by the user.

Please notice that the array will contain negative items if any items were unchecked. See wxRearrangeList for more information about the convention used for this array.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



wxWidgets logo

[ top ]