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
|
|
|
|
@wxheader{listbox.h}
|
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-03-08 08:52:38 -05:00
|
|
|
A listbox callback gets an event wxEVT_COMMAND_LISTBOX_SELECTED for single
|
|
|
|
clicks, and
|
2008-03-27 12:17:42 -04:00
|
|
|
wxEVT_COMMAND_LISTBOX_DOUBLECLICKED for double clicks.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
|
|
|
@style{wxLB_SINGLE}:
|
|
|
|
Single-selection list.
|
|
|
|
@style{wxLB_MULTIPLE}:
|
|
|
|
Multiple-selection list: the user can toggle multiple items on and
|
|
|
|
off.
|
|
|
|
@style{wxLB_EXTENDED}:
|
|
|
|
Extended-selection list: the user can select multiple items using
|
|
|
|
the SHIFT key and the mouse or special key combinations.
|
|
|
|
@style{wxLB_HSCROLL}:
|
|
|
|
Create horizontal scrollbar if contents are too wide (Windows only).
|
|
|
|
@style{wxLB_ALWAYS_SB}:
|
|
|
|
Always show a vertical scrollbar.
|
|
|
|
@style{wxLB_NEEDED_SB}:
|
|
|
|
Only create a vertical scrollbar if needed.
|
|
|
|
@style{wxLB_SORT}:
|
|
|
|
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-03-09 08:33:59 -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-03-09 08:33:59 -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}
|
|
|
|
@appearance{listbox.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxChoice, wxComboBox, wxListCtrl, wxCommandEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxListBox : public wxControlWithItems
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructor, creating and showing a list box.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Window identifier. The value wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Window position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Window size. If wxDefaultSize is specified then the window is
|
|
|
|
sized
|
|
|
|
appropriately.
|
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 choices
|
2008-03-09 08:33:59 -04:00
|
|
|
An array 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 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create(), wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxListBox();
|
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");
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
~wxListBox();
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
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-03-08 08:52:38 -05:00
|
|
|
@returns 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-03-09 12:24:26 -04:00
|
|
|
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-03-10 11:24:38 -04:00
|
|
|
@wxsince{2.7.0}. It is currently implemented
|
2008-03-08 08:52:38 -05:00
|
|
|
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-03-08 08:52:38 -05:00
|
|
|
@returns Item located at point, or wxNOT_FOUND if unimplemented or the
|
2008-03-09 08:33:59 -04:00
|
|
|
item does not exist.
|
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-03-09 08:33:59 -04:00
|
|
|
Position before which to insert the items: for example, if pos is 0 the
|
|
|
|
items
|
|
|
|
will be inserted in the beginning of the listbox
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void InsertItems(int nItems, const wxString items,
|
|
|
|
unsigned int pos);
|
2008-03-08 09:43:31 -05:00
|
|
|
void InsertItems(const wxArrayString& nItems,
|
|
|
|
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-03-08 08:52:38 -05:00
|
|
|
@returns @true if the given item is selected, @false otherwise.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
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-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks You may free the array from the calling program after this
|
2008-03-09 08:33:59 -04:00
|
|
|
function has been called.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void Set(int n, const wxString* choices, void clientData = NULL);
|
2008-03-08 09:43:31 -05:00
|
|
|
void Set(const wxArrayString& choices,
|
2008-03-09 08:33:59 -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-03-09 08:33:59 -04:00
|
|
|
The zero-based item index.
|
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
|
|
|
*/
|
|
|
|
void SetFirstItem(int n);
|
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
|
|
|
|