2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: listbox.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxListBox
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxListBox
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05: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 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
List box elements are numbered from zero. Their number may be limited
|
|
|
|
under some platforms.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-05-22 16:19:00 -04: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 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_SINGLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Single-selection list.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_MULTIPLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Multiple-selection list: the user can toggle multiple items on and
|
2008-06-23 18:49:21 -04:00
|
|
|
off. This is the same as wxLB_EXTENDED in wxGTK2 port.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_EXTENDED}
|
2008-06-23 18:49:21 -04: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 10:43:04 -04:00
|
|
|
@style{wxLB_HSCROLL}
|
2008-03-08 08:52:38 -05:00
|
|
|
Create horizontal scrollbar if contents are too wide (Windows only).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_ALWAYS_SB}
|
2008-03-08 08:52:38 -05:00
|
|
|
Always show a vertical scrollbar.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_NEEDED_SB}
|
2008-03-08 08:52:38 -05:00
|
|
|
Only create a vertical scrollbar if needed.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxLB_SORT}
|
2008-03-08 08:52:38 -05:00
|
|
|
The listbox contents are sorted in alphabetical order.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-28 12:19:12 -04:00
|
|
|
@beginEventTable{wxCommandEvent}
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_LISTBOX(id, func)}
|
2008-03-08 08:52:38 -05:00
|
|
|
Process a wxEVT_COMMAND_LISTBOX_SELECTED event, when an item on the
|
|
|
|
list is selected or the selection changes.
|
2008-04-06 10:43:04 -04:00
|
|
|
@event{EVT_LISTBOX_DCLICK(id, func)}
|
2008-03-27 12:17:42 -04:00
|
|
|
Process a wxEVT_COMMAND_LISTBOXDOUBLECLICKED event, when the
|
2008-03-08 08:52:38 -05:00
|
|
|
listbox is double-clicked.
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{ctrl}
|
2008-05-02 00:52:42 -04:00
|
|
|
<!-- @appearance{listbox.png} -->
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-01 10:22:54 -04:00
|
|
|
@see wxEditableListBox, wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxListBox : public wxControlWithItems
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-22 16:19:00 -04:00
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxListBox();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
Number of strings with which to initialise the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxListBox.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-05-22 16:19:00 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
wxListBox(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0,
|
2008-03-09 08:33:59 -04:00
|
|
|
const wxString choices[] = NULL,
|
2008-03-08 09:43:31 -05:00
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "listBox");
|
2008-05-22 16:19:00 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor
|
|
|
|
|
|
|
|
@param choices
|
|
|
|
An array of strings with which to initialise the control.
|
|
|
|
@param style
|
|
|
|
Window style. See wxListBox.
|
|
|
|
*/
|
|
|
|
|
2008-03-08 09:43:31 -05: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 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the list box.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxListBox();
|
2008-03-08 08:52:38 -05: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 08:33:59 -04:00
|
|
|
const wxString choices[] = NULL,
|
2008-03-08 08:52:38 -05:00
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = "listBox");
|
2008-03-08 09:43:31 -05: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 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deselects an item in the list box.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
The zero-based item to deselect.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05: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 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param selections
|
2008-03-09 08:33:59 -04:00
|
|
|
A reference to an wxArrayInt instance that is used to store the result of
|
|
|
|
the query.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The number of selections.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Use this with a multiple selection listbox.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxControlWithItems::GetSelection, wxControlWithItems::GetStringSelection,
|
|
|
|
wxControlWithItems::SetSelection
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetSelections(wxArrayInt& selections) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the item located at @e point, or @c wxNOT_FOUND if there
|
|
|
|
is no item located at @e point.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-21 06:34:23 -04:00
|
|
|
It is currently implemented for wxMSW, wxMac and wxGTK2 ports.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param point
|
2008-03-09 08:33:59 -04:00
|
|
|
Point of item (in client coordinates) to obtain
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return Item located at point, or wxNOT_FOUND if unimplemented or the
|
2008-03-09 08:33:59 -04:00
|
|
|
item does not exist.
|
2008-04-21 06:34:23 -04:00
|
|
|
|
|
|
|
@since 2.7.0
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int HitTest(const wxPoint point) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Insert the given number of strings before the specified position.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param nItems
|
2008-03-09 08:33:59 -04:00
|
|
|
Number of items in the array items
|
2008-03-08 09:43:31 -05:00
|
|
|
@param items
|
2008-03-09 08:33:59 -04:00
|
|
|
Labels of items to be inserted
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-05-22 16:19:00 -04: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 08:52:38 -05:00
|
|
|
*/
|
2008-05-22 16:19:00 -04:00
|
|
|
void InsertItems(int nItems, const wxString *items,
|
2008-03-08 08:52:38 -05:00
|
|
|
unsigned int pos);
|
2008-05-22 16:19:00 -04: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 09:43:31 -05:00
|
|
|
unsigned int pos);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Determines whether an item is selected.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
The zero-based item index.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the given item is selected, @false otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsSelected(int n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Clears the list box and adds the given strings to it.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-03-09 08:33:59 -04:00
|
|
|
The number of strings to set.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param choices
|
2008-03-09 08:33:59 -04:00
|
|
|
An array of strings to set.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param clientData
|
2008-03-09 08:33:59 -04:00
|
|
|
Options array of client data pointers
|
2008-05-22 16:19:00 -04:00
|
|
|
*/
|
|
|
|
void Set(int n, const wxString* choices, void **clientData = NULL);
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-22 16:19:00 -04: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 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
void Set(const wxArrayString& choices,
|
2008-05-22 16:19:00 -04:00
|
|
|
void **clientData = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the specified item to be the first visible item.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param n
|
2008-05-22 16:19:00 -04: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 09:43:31 -05:00
|
|
|
@param string
|
2008-03-09 08:33:59 -04:00
|
|
|
The string that should be visible.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
void SetFirstItem(const wxString& string);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|