]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: listbox.h | |
3 | // Purpose: wxListBox class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_LISTBOX_H_ |
13 | #define _WX_LISTBOX_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "listbox.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/control.h" | |
20 | ||
2bda0e17 KB |
21 | WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr; |
22 | ||
23 | #if USE_OWNER_DRAWN | |
24 | class WXDLLEXPORT wxOwnerDrawn; | |
25 | ||
26 | // define the array of list box items | |
27 | #include <wx/dynarray.h> | |
28 | WX_DEFINE_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray); | |
29 | #endif | |
30 | ||
7f17c6db VZ |
31 | // forward decl for GetSelections() |
32 | class wxArrayInt; | |
33 | ||
2bda0e17 KB |
34 | WXDLLEXPORT_DATA(extern const char*) wxEmptyString; |
35 | ||
36 | // List box item | |
37 | class WXDLLEXPORT wxListBox: public wxControl | |
38 | { | |
39 | DECLARE_DYNAMIC_CLASS(wxListBox) | |
40 | public: | |
41 | ||
42 | wxListBox(void); | |
debe6624 | 43 | inline wxListBox(wxWindow *parent, wxWindowID id, |
2bda0e17 KB |
44 | const wxPoint& pos = wxDefaultPosition, |
45 | const wxSize& size = wxDefaultSize, | |
debe6624 JS |
46 | int n = 0, const wxString choices[] = NULL, |
47 | long style = 0, | |
2bda0e17 KB |
48 | const wxValidator& validator = wxDefaultValidator, |
49 | const wxString& name = wxListBoxNameStr) | |
50 | { | |
51 | Create(parent, id, pos, size, n, choices, style, validator, name); | |
52 | } | |
53 | ||
debe6624 | 54 | bool Create(wxWindow *parent, wxWindowID id, |
2bda0e17 KB |
55 | const wxPoint& pos = wxDefaultPosition, |
56 | const wxSize& size = wxDefaultSize, | |
debe6624 JS |
57 | int n = 0, const wxString choices[] = NULL, |
58 | long style = 0, | |
2bda0e17 KB |
59 | const wxValidator& validator = wxDefaultValidator, |
60 | const wxString& name = wxListBoxNameStr); | |
61 | ||
62 | ~wxListBox(); | |
63 | ||
debe6624 | 64 | bool MSWCommand(WXUINT param, WXWORD id); |
2bda0e17 KB |
65 | |
66 | #if USE_OWNER_DRAWN | |
67 | bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); | |
68 | bool MSWOnDraw(WXDRAWITEMSTRUCT *item); | |
69 | ||
70 | // plug-in for derived classes | |
3cda6353 | 71 | virtual wxOwnerDrawn *CreateItem(size_t n); |
2bda0e17 KB |
72 | |
73 | // allows to get the item and use SetXXX functions to set it's appearance | |
3cda6353 | 74 | wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } |
2bda0e17 KB |
75 | #endif |
76 | ||
77 | virtual void Append(const wxString& item); | |
78 | virtual void Append(const wxString& item, char *clientData); | |
debe6624 | 79 | virtual void Set(int n, const wxString* choices, char **clientData = NULL); |
2bda0e17 KB |
80 | virtual int FindString(const wxString& s) const ; |
81 | virtual void Clear(void); | |
debe6624 | 82 | virtual void SetSelection(int n, bool select = TRUE); |
2bda0e17 | 83 | |
debe6624 | 84 | virtual void Deselect(int n); |
2bda0e17 KB |
85 | |
86 | // For single choice list item only | |
7f17c6db | 87 | virtual int GetSelection() const ; |
debe6624 JS |
88 | virtual void Delete(int n); |
89 | virtual char *GetClientData(int n) const ; | |
90 | virtual void SetClientData(int n, char *clientData); | |
91 | virtual void SetString(int n, const wxString& s); | |
2bda0e17 KB |
92 | |
93 | // For single or multiple choice list item | |
7f17c6db | 94 | virtual int GetSelections(wxArrayInt& aSelections) const; |
debe6624 JS |
95 | virtual bool Selected(int n) const ; |
96 | virtual wxString GetString(int n) const ; | |
97 | virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); | |
2bda0e17 KB |
98 | |
99 | // Set the specified item at the first visible item | |
100 | // or scroll to max range. | |
debe6624 | 101 | virtual void SetFirstItem(int n) ; |
2bda0e17 KB |
102 | virtual void SetFirstItem(const wxString& s) ; |
103 | ||
debe6624 | 104 | virtual void InsertItems(int nItems, const wxString items[], int pos); |
2bda0e17 KB |
105 | |
106 | virtual wxString GetStringSelection(void) const ; | |
debe6624 | 107 | virtual bool SetStringSelection(const wxString& s, bool flag = TRUE); |
2bda0e17 KB |
108 | virtual int Number(void) const ; |
109 | ||
110 | void Command(wxCommandEvent& event); | |
111 | ||
112 | // Windows-specific code to set the horizontal extent of | |
113 | // the listbox, if necessary. If s is non-NULL, it's | |
114 | // used to calculate the horizontal extent. | |
115 | // Otherwise, all strings are used. | |
116 | virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); | |
117 | ||
debe6624 | 118 | virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2bda0e17 KB |
119 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam); |
120 | ||
121 | virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); | |
122 | virtual void SetupColours(void); | |
123 | ||
124 | protected: | |
125 | int m_noItems; | |
126 | int m_selected; | |
2bda0e17 KB |
127 | |
128 | #if USE_OWNER_DRAWN | |
129 | // control items | |
130 | wxListBoxItemsArray m_aItems; | |
131 | #endif | |
132 | ||
133 | }; | |
134 | ||
135 | #endif | |
bbcdf8bc | 136 | // _WX_LISTBOX_H_ |