]>
Commit | Line | Data |
---|---|---|
2bda0e17 | 1 | ///////////////////////////////////////////////////////////////////////////// |
2ee3ee1b | 2 | // Name: wx/msw/listbox.h |
2bda0e17 KB |
3 | // Purpose: wxListBox class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc | 8 | // Copyright: (c) Julian Smart |
8ee9d618 | 9 | // Licence: wxWindows licence |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_LISTBOX_H_ |
13 | #define _WX_LISTBOX_H_ | |
2bda0e17 | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8ee9d618 | 16 | #pragma interface "listbox.h" |
2bda0e17 KB |
17 | #endif |
18 | ||
1e6feb95 VZ |
19 | #if wxUSE_LISTBOX |
20 | ||
2ee3ee1b VZ |
21 | // ---------------------------------------------------------------------------- |
22 | // simple types | |
23 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 24 | |
47d67540 | 25 | #if wxUSE_OWNER_DRAWN |
2bda0e17 KB |
26 | class WXDLLEXPORT wxOwnerDrawn; |
27 | ||
28 | // define the array of list box items | |
ace954f1 | 29 | #include "wx/dynarray.h" |
184b5d99 | 30 | |
d5d29b8a | 31 | WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn *, wxListBoxItemsArray); |
2ee3ee1b | 32 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 33 | |
7f17c6db VZ |
34 | // forward decl for GetSelections() |
35 | class wxArrayInt; | |
36 | ||
2ee3ee1b VZ |
37 | // ---------------------------------------------------------------------------- |
38 | // List box control | |
39 | // ---------------------------------------------------------------------------- | |
2bda0e17 | 40 | |
2ee3ee1b | 41 | class WXDLLEXPORT wxListBox : public wxListBoxBase |
2bda0e17 | 42 | { |
bfc6fde4 | 43 | public: |
2ee3ee1b | 44 | // ctors and such |
bfc6fde4 VZ |
45 | wxListBox(); |
46 | wxListBox(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, | |
1169a919 | 52 | const wxString& name = wxListBoxNameStr); |
bfc6fde4 VZ |
53 | |
54 | bool Create(wxWindow *parent, wxWindowID id, | |
2ee3ee1b VZ |
55 | const wxPoint& pos = wxDefaultPosition, |
56 | const wxSize& size = wxDefaultSize, | |
57 | int n = 0, const wxString choices[] = NULL, | |
58 | long style = 0, | |
59 | const wxValidator& validator = wxDefaultValidator, | |
60 | const wxString& name = wxListBoxNameStr); | |
bfc6fde4 | 61 | |
2ee3ee1b | 62 | virtual ~wxListBox(); |
bfc6fde4 | 63 | |
2ee3ee1b VZ |
64 | // implement base class pure virtuals |
65 | virtual void Clear(); | |
66 | virtual void Delete(int n); | |
67 | ||
68 | virtual int GetCount() const; | |
69 | virtual wxString GetString(int n) const; | |
70 | virtual void SetString(int n, const wxString& s); | |
71 | virtual int FindString(const wxString& s) const; | |
72 | ||
73 | virtual bool IsSelected(int n) const; | |
74 | virtual void SetSelection(int n, bool select = TRUE); | |
75 | virtual int GetSelection() const; | |
76 | virtual int GetSelections(wxArrayInt& aSelections) const; | |
77 | ||
78 | virtual int DoAppend(const wxString& item); | |
79 | virtual void DoInsertItems(const wxArrayString& items, int pos); | |
80 | virtual void DoSetItems(const wxArrayString& items, void **clientData); | |
2bda0e17 | 81 | |
2ee3ee1b VZ |
82 | virtual void DoSetFirstItem(int n); |
83 | ||
6c8a980f VZ |
84 | virtual void DoSetItemClientData(int n, void* clientData); |
85 | virtual void* DoGetItemClientData(int n) const; | |
86 | virtual void DoSetItemClientObject(int n, wxClientData* clientData); | |
87 | virtual wxClientData* DoGetItemClientObject(int n) const; | |
2ee3ee1b VZ |
88 | |
89 | // wxCheckListBox support | |
47d67540 | 90 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
91 | bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); |
92 | bool MSWOnDraw(WXDRAWITEMSTRUCT *item); | |
2bda0e17 | 93 | |
bfc6fde4 | 94 | // plug-in for derived classes |
2b5f62a0 | 95 | virtual wxOwnerDrawn *CreateLboxItem(size_t n); |
2bda0e17 | 96 | |
bfc6fde4 VZ |
97 | // allows to get the item and use SetXXX functions to set it's appearance |
98 | wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; } | |
dd3c394a VZ |
99 | |
100 | // get the index of the given item | |
101 | int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); } | |
bfc6fde4 | 102 | #endif // wxUSE_OWNER_DRAWN |
2bda0e17 | 103 | |
2ee3ee1b VZ |
104 | // Windows-specific code to set the horizontal extent of the listbox, if |
105 | // necessary. If s is non-NULL, it's used to calculate the horizontal | |
106 | // extent. Otherwise, all strings are used. | |
bfc6fde4 | 107 | virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); |
2bda0e17 | 108 | |
2ee3ee1b | 109 | // Windows callbacks |
2ee3ee1b | 110 | bool MSWCommand(WXUINT param, WXWORD id); |
2bda0e17 | 111 | |
bfc6fde4 | 112 | virtual void SetupColours(); |
2bda0e17 | 113 | |
bfc6fde4 | 114 | protected: |
8ee9d618 VZ |
115 | // free memory (common part of Clear() and dtor) |
116 | void Free(); | |
117 | ||
bfc6fde4 VZ |
118 | int m_noItems; |
119 | int m_selected; | |
2bda0e17 | 120 | |
f68586e5 | 121 | virtual wxSize DoGetBestSize() const; |
b908d224 | 122 | |
47d67540 | 123 | #if wxUSE_OWNER_DRAWN |
bfc6fde4 VZ |
124 | // control items |
125 | wxListBoxItemsArray m_aItems; | |
2bda0e17 | 126 | #endif |
2ee3ee1b VZ |
127 | |
128 | private: | |
fc7a2a60 | 129 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox) |
2bda0e17 KB |
130 | }; |
131 | ||
1e6feb95 VZ |
132 | #endif // wxUSE_LISTBOX |
133 | ||
2bda0e17 | 134 | #endif |
bbcdf8bc | 135 | // _WX_LISTBOX_H_ |