]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/listbox.h
a994417d49b4ced71c1947458fbc2cfc90f07489
[wxWidgets.git] / include / wx / msw / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "listbox.h"
17 #endif
18
19 #if wxUSE_LISTBOX
20
21 // ----------------------------------------------------------------------------
22 // simple types
23 // ----------------------------------------------------------------------------
24
25 #if wxUSE_OWNER_DRAWN
26 class WXDLLEXPORT wxOwnerDrawn;
27
28 // define the array of list box items
29 #include "wx/dynarray.h"
30
31 WX_DEFINE_EXPORTED_ARRAY_NO_PTR(wxOwnerDrawn *, wxListBoxItemsArray);
32 #endif // wxUSE_OWNER_DRAWN
33
34 // forward decl for GetSelections()
35 class wxArrayInt;
36
37 // ----------------------------------------------------------------------------
38 // List box control
39 // ----------------------------------------------------------------------------
40
41 class WXDLLEXPORT wxListBox : public wxListBoxBase
42 {
43 public:
44 // ctors and such
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,
52 const wxString& name = wxListBoxNameStr)
53 {
54 Create(parent, id, pos, size, n, choices, style, validator, name);
55 }
56
57 bool Create(wxWindow *parent, wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 int n = 0, const wxString choices[] = NULL,
61 long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxListBoxNameStr);
64
65 virtual ~wxListBox();
66
67 // implement base class pure virtuals
68 virtual void Clear();
69 virtual void Delete(int n);
70
71 virtual int GetCount() const;
72 virtual wxString GetString(int n) const;
73 virtual void SetString(int n, const wxString& s);
74 virtual int FindString(const wxString& s) const;
75
76 virtual bool IsSelected(int n) const;
77 virtual void SetSelection(int n, bool select = TRUE);
78 // rtti needs a function with just one signature
79 void SetSelectionLine(int n) { SetSelection( n ) ; }
80 virtual int GetSelection() const;
81 virtual int GetSelections(wxArrayInt& aSelections) const;
82
83 virtual int DoAppend(const wxString& item);
84 virtual void DoInsertItems(const wxArrayString& items, int pos);
85 virtual void DoSetItems(const wxArrayString& items, void **clientData);
86
87 virtual void DoSetFirstItem(int n);
88
89 virtual void DoSetItemClientData(int n, void* clientData);
90 virtual void* DoGetItemClientData(int n) const;
91 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
92 virtual wxClientData* DoGetItemClientObject(int n) const;
93
94 // wxCheckListBox support
95 #if wxUSE_OWNER_DRAWN
96 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
97 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
98
99 // plug-in for derived classes
100 virtual wxOwnerDrawn *CreateLboxItem(size_t n);
101
102 // allows to get the item and use SetXXX functions to set it's appearance
103 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
104
105 // get the index of the given item
106 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
107 #endif // wxUSE_OWNER_DRAWN
108
109 // Windows-specific code to set the horizontal extent of the listbox, if
110 // necessary. If s is non-NULL, it's used to calculate the horizontal
111 // extent. Otherwise, all strings are used.
112 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
113
114 // Windows callbacks
115 bool MSWCommand(WXUINT param, WXWORD id);
116
117 virtual void SetupColours();
118
119 protected:
120 // free memory (common part of Clear() and dtor)
121 void Free();
122
123 int m_noItems;
124 int m_selected;
125
126 virtual wxSize DoGetBestSize() const;
127
128 #if wxUSE_OWNER_DRAWN
129 // control items
130 wxListBoxItemsArray m_aItems;
131 #endif
132
133 private:
134 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox)
135 };
136
137 #endif // wxUSE_LISTBOX
138
139 #endif
140 // _WX_LISTBOX_H_