1. wxDropTarget::OnData() returns wxDragResult now, not bool
[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 #ifdef __GNUG__
16 #pragma interface "listbox.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // simple types
21 // ----------------------------------------------------------------------------
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_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
30 #endif // wxUSE_OWNER_DRAWN
31
32 // forward decl for GetSelections()
33 class wxArrayInt;
34
35 // ----------------------------------------------------------------------------
36 // List box control
37 // ----------------------------------------------------------------------------
38
39 class WXDLLEXPORT wxListBox : public wxListBoxBase
40 {
41 public:
42 // ctors and such
43 wxListBox();
44 wxListBox(wxWindow *parent, wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 int n = 0, const wxString choices[] = NULL,
48 long style = 0,
49 const wxValidator& validator = wxDefaultValidator,
50 const wxString& name = wxListBoxNameStr)
51 {
52 Create(parent, id, pos, size, n, choices, style, validator, name);
53 }
54
55 bool Create(wxWindow *parent, wxWindowID id,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 int n = 0, const wxString choices[] = NULL,
59 long style = 0,
60 const wxValidator& validator = wxDefaultValidator,
61 const wxString& name = wxListBoxNameStr);
62
63 virtual ~wxListBox();
64
65 // implement base class pure virtuals
66 virtual void Clear();
67 virtual void Delete(int n);
68
69 virtual int GetCount() const;
70 virtual wxString GetString(int n) const;
71 virtual void SetString(int n, const wxString& s);
72 virtual int FindString(const wxString& s) const;
73
74 virtual bool IsSelected(int n) const;
75 virtual void SetSelection(int n, bool select = TRUE);
76 virtual int GetSelection() const;
77 virtual int GetSelections(wxArrayInt& aSelections) const;
78
79 virtual int DoAppend(const wxString& item);
80 virtual void DoInsertItems(const wxArrayString& items, int pos);
81 virtual void DoSetItems(const wxArrayString& items, void **clientData);
82
83 virtual void DoSetFirstItem(int n);
84
85 virtual void DoSetItemClientData(int n, void* clientData);
86 virtual void* DoGetItemClientData(int n) const;
87 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
88 virtual wxClientData* DoGetItemClientObject(int n) const;
89
90 // wxCheckListBox support
91 #if wxUSE_OWNER_DRAWN
92 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
93 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
94
95 // plug-in for derived classes
96 virtual wxOwnerDrawn *CreateItem(size_t n);
97
98 // allows to get the item and use SetXXX functions to set it's appearance
99 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
100
101 // get the index of the given item
102 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
103 #endif // wxUSE_OWNER_DRAWN
104
105 // Windows-specific code to set the horizontal extent of the listbox, if
106 // necessary. If s is non-NULL, it's used to calculate the horizontal
107 // extent. Otherwise, all strings are used.
108 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
109
110 // Windows callbacks
111 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
112 WXUINT message,
113 WXWPARAM wParam, WXLPARAM lParam);
114
115 bool MSWCommand(WXUINT param, WXWORD id);
116
117 virtual void SetupColours();
118
119 protected:
120 // do we have multiple selections?
121 bool HasMultipleSelection() const;
122
123 // free memory (common part of Clear() and dtor)
124 void Free();
125
126 int m_noItems;
127 int m_selected;
128
129 virtual wxSize DoGetBestSize();
130
131 #if wxUSE_OWNER_DRAWN
132 // control items
133 wxListBoxItemsArray m_aItems;
134 #endif
135
136 private:
137 DECLARE_DYNAMIC_CLASS(wxListBox)
138 };
139
140 #endif
141 // _WX_LISTBOX_H_