| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: listbox.h |
| 3 | // Purpose: wxListBox class |
| 4 | // Author: AUTHOR |
| 5 | // Modified by: |
| 6 | // Created: ??/??/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) AUTHOR |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifndef _WX_LISTBOX_H_ |
| 13 | #define _WX_LISTBOX_H_ |
| 14 | |
| 15 | #ifdef __GNUG__ |
| 16 | #pragma interface "listbox.h" |
| 17 | #endif |
| 18 | |
| 19 | #include "wx/control.h" |
| 20 | |
| 21 | WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr; |
| 22 | |
| 23 | // forward decl for GetSelections() |
| 24 | class WXDLLEXPORT wxArrayInt; |
| 25 | |
| 26 | WXDLLEXPORT_DATA(extern const char*) wxEmptyString; |
| 27 | |
| 28 | // List box item |
| 29 | class WXDLLEXPORT wxListBox: public wxControl |
| 30 | { |
| 31 | DECLARE_DYNAMIC_CLASS(wxListBox) |
| 32 | public: |
| 33 | |
| 34 | wxListBox(); |
| 35 | inline wxListBox(wxWindow *parent, wxWindowID id, |
| 36 | const wxPoint& pos = wxDefaultPosition, |
| 37 | const wxSize& size = wxDefaultSize, |
| 38 | int n = 0, const wxString choices[] = NULL, |
| 39 | long style = 0, |
| 40 | const wxValidator& validator = wxDefaultValidator, |
| 41 | const wxString& name = wxListBoxNameStr) |
| 42 | { |
| 43 | Create(parent, id, pos, size, n, choices, style, validator, name); |
| 44 | } |
| 45 | |
| 46 | bool Create(wxWindow *parent, wxWindowID id, |
| 47 | const wxPoint& pos = wxDefaultPosition, |
| 48 | const wxSize& size = wxDefaultSize, |
| 49 | int n = 0, const wxString choices[] = NULL, |
| 50 | long style = 0, |
| 51 | const wxValidator& validator = wxDefaultValidator, |
| 52 | const wxString& name = wxListBoxNameStr); |
| 53 | |
| 54 | ~wxListBox(); |
| 55 | |
| 56 | virtual void Append(const wxString& item); |
| 57 | virtual void Append(const wxString& item, char *clientData); |
| 58 | virtual void Set(int n, const wxString* choices, char **clientData = NULL); |
| 59 | virtual int FindString(const wxString& s) const ; |
| 60 | virtual void Clear(); |
| 61 | virtual void SetSelection(int n, bool select = TRUE); |
| 62 | |
| 63 | virtual void Deselect(int n); |
| 64 | |
| 65 | // For single choice list item only |
| 66 | virtual int GetSelection() const ; |
| 67 | virtual void Delete(int n); |
| 68 | virtual char *GetClientData(int n) const ; |
| 69 | virtual void SetClientData(int n, char *clientData); |
| 70 | virtual void SetString(int n, const wxString& s); |
| 71 | |
| 72 | // For single or multiple choice list item |
| 73 | virtual int GetSelections(wxArrayInt& aSelections) const; |
| 74 | virtual bool Selected(int n) const ; |
| 75 | virtual wxString GetString(int n) const ; |
| 76 | virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); |
| 77 | |
| 78 | // Set the specified item at the first visible item |
| 79 | // or scroll to max range. |
| 80 | virtual void SetFirstItem(int n) ; |
| 81 | virtual void SetFirstItem(const wxString& s) ; |
| 82 | |
| 83 | virtual void InsertItems(int nItems, const wxString items[], int pos); |
| 84 | |
| 85 | virtual wxString GetStringSelection() const ; |
| 86 | virtual bool SetStringSelection(const wxString& s, bool flag = TRUE); |
| 87 | virtual int Number() const ; |
| 88 | |
| 89 | void Command(wxCommandEvent& event); |
| 90 | |
| 91 | protected: |
| 92 | int m_noItems; |
| 93 | int m_selected; |
| 94 | }; |
| 95 | |
| 96 | #endif |
| 97 | // _WX_LISTBOX_H_ |