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