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