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$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxListBox
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +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
|
|
|
|
(clicking an item toggles the item on or off independently of other
|
|
|
|
selections).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +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-05-22 20:19:00 +00:00
|
|
|
A listbox callback gets an event wxEVT_COMMAND_LISTBOX_SELECTED for
|
|
|
|
single clicks, and 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}
|
2008-03-08 13:52:38 +00:00
|
|
|
Single-selection list.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_MULTIPLE}
|
2008-03-08 13:52:38 +00:00
|
|
|
Multiple-selection list: the user can toggle multiple items on and
|
2008-06-23 22:49:21 +00:00
|
|
|
off. This is the same as wxLB_EXTENDED in wxGTK2 port.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_EXTENDED}
|
2008-06-23 22:49:21 +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}
|
2008-03-08 13:52:38 +00:00
|
|
|
Create horizontal scrollbar if contents are too wide (Windows only).
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_ALWAYS_SB}
|
2008-03-08 13:52:38 +00:00
|
|
|
Always show a vertical scrollbar.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_NEEDED_SB}
|
2008-03-08 13:52:38 +00:00
|
|
|
Only create a vertical scrollbar if needed.
|
2008-04-06 14:43:04 +00:00
|
|
|
@style{wxLB_SORT}
|
2008-03-08 13:52:38 +00:00
|
|
|
The listbox contents are sorted in alphabetical order.
|
|
|
|
@endStyleTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-28 16:19:12 +00:00
|
|
|
@beginEventTable{wxCommandEvent}
|
2008-04-06 14:43:04 +00:00
|
|
|
@event{EVT_LISTBOX(id, func)}
|
2008-03-08 13:52:38 +00:00
|
|
|
Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the
|
|
|
|
list is selected or the selection changes.
|
2008-04-06 14:43:04 +00:00
|
|
|
@event{EVT_LISTBOX_DCLICK(id, func)}
|
2008-03-27 16:17:42 +00:00
|
|
|
Process a wxEVT_COMMAND_LISTBOXDOUBLECLICKED event, when the
|
2008-03-08 13:52:38 +00:00
|
|
|
listbox is double-clicked.
|
|
|
|
@endEventTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2008-05-02 04:52:42 +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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor
|
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
|
|
|
Number of strings with which to initialise 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-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-05-22 20:19:00 +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,
|
|
|
|
const wxString& name = "listBox");
|
2008-05-22 20:19:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor
|
|
|
|
|
|
|
|
@param choices
|
|
|
|
An array of strings with which to initialise the control.
|
|
|
|
@param style
|
|
|
|
Window style. See wxListBox.
|
|
|
|
*/
|
|
|
|
|
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,
|
|
|
|
const wxString& name = "listBox");
|
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
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Creates the listbox for two-step construction. See wxListBox()
|
|
|
|
for further details.
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n,
|
2008-03-09 12:33:59 +00:00
|
|
|
const wxString choices[] = NULL,
|
2008-03-08 13:52:38 +00:00
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "listBox");
|
2008-03-08 14:43:31 +00:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "listBox");
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the item located at @e point, or @c wxNOT_FOUND if there
|
|
|
|
is no item located at @e 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-03-09 12:33:59 +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-03-09 16:24:26 +00:00
|
|
|
int HitTest(const wxPoint point) 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
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-05-22 20:19:00 +00:00
|
|
|
void InsertItems(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
|
|
|
|
Position before which to insert the items: if pos is 0 the
|
|
|
|
items will be inserted in the beginning of the listbox
|
|
|
|
*/
|
|
|
|
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
|
|
|
*/
|
|
|
|
void Set(int n, const wxString* choices, void **clientData = NULL);
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-22 20:19:00 +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
|
|
|
|
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-03-08 14:43:31 +00:00
|
|
|
void Set(const wxArrayString& choices,
|
2008-05-22 20:19:00 +00:00
|
|
|
void **clientData = NULL);
|
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);
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|