2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: listbox.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxListBox
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxListBox
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
A listbox is used to select one or more of a list of strings.
|
|
|
|
|
|
|
|
The strings are displayed in a scrolling box, with the selected string(s)
|
|
|
|
marked in reverse video. A listbox can be single selection (if an item is
|
|
|
|
selected, the previous selection is removed) or multiple selection
|
2008-03-08 13:52:38 +00:00
|
|
|
(clicking an item toggles the item on or off independently of other
|
|
|
|
selections).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
List box elements are numbered from zero.
|
|
|
|
Their number may be limited under some platforms.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
A listbox callback gets an event @c wxEVT_COMMAND_LISTBOX_SELECTED for
|
|
|
|
single clicks, and @c wxEVT_COMMAND_LISTBOX_DOUBLECLICKED for double clicks.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@beginStyleTable
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_SINGLE}
|
2009-02-18 17:58:51 +00:00
|
|
|
Single-selection list.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_MULTIPLE}
|
2009-02-18 17:58:51 +00:00
|
|
|
Multiple-selection list: the user can toggle multiple items on and off.
|
|
|
|
This is the same as wxLB_EXTENDED in wxGTK2 port.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_EXTENDED}
|
2009-02-18 17:58:51 +00:00
|
|
|
Extended-selection list: the user can extend the selection by using
|
|
|
|
@c SHIFT or @c CTRL keys together with the cursor movement keys or
|
|
|
|
the mouse.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_HSCROLL}
|
2009-02-18 17:58:51 +00:00
|
|
|
Create horizontal scrollbar if contents are too wide (Windows only).
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_ALWAYS_SB}
|
2009-02-18 17:58:51 +00:00
|
|
|
Always show a vertical scrollbar.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_NEEDED_SB}
|
2009-02-18 17:58:51 +00:00
|
|
|
Only create a vertical scrollbar if needed.
|
2009-07-17 14:36:30 +00:00
|
|
|
@style{wxLB_NO_SB}
|
|
|
|
Don't create vertical scrollbar (wxMSW only).
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_SORT}
|
2009-02-18 17:58:51 +00:00
|
|
|
The listbox contents are sorted in alphabetical order.
|
2008-03-08 13:52:38 +00:00
|
|
|
@endStyleTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
Note that @c wxLB_SINGLE, @c wxLB_MULTIPLE and @c wxLB_EXTENDED styles are
|
|
|
|
mutually exclusive and you can specify at most one of them (single selection
|
|
|
|
is the default). See also @ref overview_windowstyles.
|
|
|
|
|
2009-02-18 17:58:51 +00:00
|
|
|
@beginEventEmissionTable{wxCommandEvent}
|
2008-04-06 14:43:04 +00:00
|
|
|
@event{EVT_LISTBOX(id, func)}
|
2011-01-06 19:52:14 +00:00
|
|
|
Process a @c wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the
|
2009-02-18 17:58:51 +00:00
|
|
|
list is selected or the selection changes.
|
2008-04-06 14:43:04 +00:00
|
|
|
@event{EVT_LISTBOX_DCLICK(id, func)}
|
2011-01-06 19:52:14 +00:00
|
|
|
Process a @c wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event, when the listbox
|
2009-02-18 17:58:51 +00:00
|
|
|
is double-clicked.
|
2008-03-08 13:52:38 +00:00
|
|
|
@endEventTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2008-10-13 08:05:18 +00:00
|
|
|
@appearance{listbox.png}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-09-01 14:22:54 +00:00
|
|
|
@see wxEditableListBox, wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxListBox : public wxControlWithItems
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-22 20:19:00 +00:00
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxListBox();
|
2008-10-19 12:49:07 +00:00
|
|
|
|
2008-05-22 20:19:00 +00:00
|
|
|
/**
|
2008-10-19 12:49:07 +00:00
|
|
|
Constructor, creating and showing a list box.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
@param parent
|
|
|
|
The parent window.
|
|
|
|
@param id
|
|
|
|
The ID of this control. A value of @c wxID_ANY indicates a default value.
|
|
|
|
@param pos
|
|
|
|
The initial position.
|
2009-04-21 11:21:36 +00:00
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-10-19 12:49:07 +00:00
|
|
|
@param size
|
|
|
|
The initial size.
|
2009-04-21 11:21:36 +00:00
|
|
|
If ::wxDefaultSize is specified then the window is sized appropriately.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
Number of strings with which to initialise the control.
|
2008-10-19 12:49:07 +00:00
|
|
|
@param choices
|
|
|
|
The strings to use to initialize the control.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param style
|
2008-03-09 12:33:59 +00:00
|
|
|
Window style. See wxListBox.
|
2008-10-19 12:49:07 +00:00
|
|
|
@param validator
|
|
|
|
The validator for this control.
|
|
|
|
@param name
|
|
|
|
The name of this class.
|
2009-10-18 17:47:01 +00:00
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
Not supported by wxPerl.
|
|
|
|
@endWxPerlOnly
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-19 12:49:07 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
wxListBox(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0,
|
2008-03-09 12:33:59 +00:00
|
|
|
const wxString choices[] = NULL,
|
2008-03-08 14:43:31 +00:00
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-10-19 12:49:07 +00:00
|
|
|
const wxString& name = wxListBoxNameStr);
|
|
|
|
|
2008-05-22 20:19:00 +00:00
|
|
|
/**
|
2008-10-19 12:49:07 +00:00
|
|
|
Constructor, creating and showing a list box.
|
2008-05-22 20:19:00 +00:00
|
|
|
|
2008-10-19 12:49:07 +00:00
|
|
|
See the other wxListBox() constructor; the only difference is that
|
|
|
|
this overload takes a wxArrayString instead of a pointer to an array
|
|
|
|
of wxString.
|
2009-10-18 17:47:01 +00:00
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
Use an array reference for the @a choices parameter.
|
|
|
|
@endWxPerlOnly
|
2008-05-22 20:19:00 +00:00
|
|
|
*/
|
2008-10-19 12:49:07 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
wxListBox(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-10-19 12:49:07 +00:00
|
|
|
const wxString& name = wxListBoxNameStr);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the list box.
|
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual ~wxListBox();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-10-19 12:49:07 +00:00
|
|
|
Creates the listbox for two-step construction.
|
|
|
|
See wxListBox() for further details.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2009-01-10 22:10:54 +00:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-01-10 22:10:54 +00:00
|
|
|
int n = 0, const wxString choices[] = NULL,
|
2008-03-08 13:52:38 +00:00
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2009-01-10 22:10:54 +00:00
|
|
|
const wxString& name = wxListBoxNameStr);
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
2008-03-08 14:43:31 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2009-01-10 22:10:54 +00:00
|
|
|
const wxString& name = wxListBoxNameStr);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deselects an item in the list box.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
The zero-based item to deselect.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@remarks This applies to multiple selection listboxes only.
|
|
|
|
*/
|
|
|
|
void Deselect(int n);
|
|
|
|
|
2011-09-16 17:03:01 +00:00
|
|
|
virtual void SetSelection(int n);
|
|
|
|
|
|
|
|
virtual int GetSelection() const;
|
|
|
|
|
|
|
|
virtual bool SetStringSelection(const wxString& s, bool select);
|
|
|
|
virtual bool SetStringSelection(const wxString& s);
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Fill an array of ints with the positions of the currently selected items.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param selections
|
2008-03-09 12:33:59 +00:00
|
|
|
A reference to an wxArrayInt instance that is used to store the result of
|
2008-10-19 12:49:07 +00:00
|
|
|
the query.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return The number of selections.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@remarks Use this with a multiple selection listbox.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2009-10-18 17:47:01 +00:00
|
|
|
@beginWxPerlOnly
|
|
|
|
In wxPerl this method takes no parameters and return the
|
|
|
|
selected items as a list.
|
|
|
|
@endWxPerlOnly
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection,
|
|
|
|
wxControlWithItems::SetSelection
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual int GetSelections(wxArrayInt& selections) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-10-19 12:49:07 +00:00
|
|
|
Returns the item located at @a point, or @c wxNOT_FOUND if there
|
|
|
|
is no item located at @a point.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-04-21 10:34:23 +00:00
|
|
|
It is currently implemented for wxMSW, wxMac and wxGTK2 ports.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param point
|
2008-03-09 12:33:59 +00:00
|
|
|
Point of item (in client coordinates) to obtain
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return Item located at point, or wxNOT_FOUND if unimplemented or the
|
2008-10-19 12:49:07 +00:00
|
|
|
item does not exist.
|
2008-04-21 10:34:23 +00:00
|
|
|
|
|
|
|
@since 2.7.0
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-10-19 12:49:07 +00:00
|
|
|
int HitTest(const wxPoint& point) const;
|
2009-01-28 00:51:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
@overload
|
|
|
|
*/
|
2009-01-25 18:10:24 +00:00
|
|
|
int HitTest(int x, int y) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Insert the given number of strings before the specified position.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param nItems
|
2008-03-09 12:33:59 +00:00
|
|
|
Number of items in the array items
|
2008-03-08 14:43:31 +00:00
|
|
|
@param items
|
2008-03-09 12:33:59 +00:00
|
|
|
Labels of items to be inserted
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pos
|
2008-05-22 20:19:00 +00:00
|
|
|
Position before which to insert the items: if pos is 0 the
|
|
|
|
items will be inserted in the beginning of the listbox
|
2009-10-18 17:47:01 +00:00
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
Not supported by wxPerl.
|
|
|
|
@endWxPerlOnly
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-11-10 21:33:25 +00:00
|
|
|
void InsertItems(unsigned int nItems, const wxString *items,
|
2008-03-08 13:52:38 +00:00
|
|
|
unsigned int pos);
|
2008-05-22 20:19:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Insert the given number of strings before the specified position.
|
|
|
|
|
|
|
|
@param items
|
|
|
|
Labels of items to be inserted
|
|
|
|
@param pos
|
2008-10-19 12:49:07 +00:00
|
|
|
Position before which to insert the items: if pos is @c 0 the
|
2008-05-22 20:19:00 +00:00
|
|
|
items will be inserted in the beginning of the listbox
|
2009-10-18 17:47:01 +00:00
|
|
|
|
|
|
|
@beginWxPerlOnly
|
|
|
|
Use an array reference for the @a items parameter.
|
|
|
|
@endWxPerlOnly
|
2008-05-22 20:19:00 +00:00
|
|
|
*/
|
|
|
|
void InsertItems(const wxArrayString& items,
|
2008-03-08 14:43:31 +00:00
|
|
|
unsigned int pos);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Determines whether an item is selected.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
The zero-based item index.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-11 01:38:53 +00:00
|
|
|
@return @true if the given item is selected, @false otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-09-27 11:21:10 +00:00
|
|
|
virtual bool IsSelected(int n) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Clears the list box and adds the given strings to it.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-03-09 12:33:59 +00:00
|
|
|
The number of strings to set.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param choices
|
2008-03-09 12:33:59 +00:00
|
|
|
An array of strings to set.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param clientData
|
2008-03-09 12:33:59 +00:00
|
|
|
Options array of client data pointers
|
2008-05-22 20:19:00 +00:00
|
|
|
*/
|
2008-11-10 21:33:25 +00:00
|
|
|
void Set(unsigned int n, const wxString* choices, void *clientData);
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-22 20:19:00 +00:00
|
|
|
/**
|
2008-10-19 12:49:07 +00:00
|
|
|
Clears the list box and adds the given strings to it.
|
|
|
|
You may free the array from the calling program after this method
|
2008-05-22 20:19:00 +00:00
|
|
|
has been called.
|
|
|
|
|
|
|
|
@param choices
|
|
|
|
An array of strings to set.
|
|
|
|
@param clientData
|
|
|
|
Options array of client data pointers
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-11-10 21:33:25 +00:00
|
|
|
void Set(const wxArrayString& choices, void *clientData);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the specified item to be the first visible item.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param n
|
2008-05-22 20:19:00 +00:00
|
|
|
The zero-based item index that should be visible.
|
|
|
|
*/
|
|
|
|
void SetFirstItem(int n);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the specified item to be the first visible item.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param string
|
2008-03-09 12:33:59 +00:00
|
|
|
The string that should be visible.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
void SetFirstItem(const wxString& string);
|
2011-09-16 17:03:01 +00:00
|
|
|
|
|
|
|
virtual void EnsureVisible(int n);
|
|
|
|
|
|
|
|
virtual bool IsSorted() const;
|
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
|
|
|
|
|
|
|
|
virtual unsigned int GetCount() const;
|
|
|
|
virtual wxString GetString(unsigned int n) const;
|
|
|
|
virtual void SetString(unsigned int n, const wxString& s);
|
|
|
|
virtual int FindString(const wxString& s, bool bCase = false) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|