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