]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/listbox.h
New Unix configure system
[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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __LISTBOXH__
13 #define __LISTBOXH__
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 WXDLLEXPORT_DATA(extern const char*) wxListBoxNameStr;
23
24 #if USE_OWNER_DRAWN
25 class WXDLLEXPORT wxOwnerDrawn;
26
27 // define the array of list box items
28 #include <wx/dynarray.h>
29 WX_DEFINE_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
30 #endif
31
32 // forward decl for GetSelections()
33 class wxArrayInt;
34
35 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
36
37 // List box item
38 class WXDLLEXPORT wxListBox: public wxControl
39 {
40 DECLARE_DYNAMIC_CLASS(wxListBox)
41 public:
42
43 wxListBox(void);
44 inline 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 ~wxListBox();
64
65 bool MSWCommand(WXUINT param, WXWORD id);
66
67 #if USE_OWNER_DRAWN
68 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
69 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
70
71 // plug-in for derived classes
72 virtual wxOwnerDrawn *CreateItem(uint n);
73
74 // allows to get the item and use SetXXX functions to set it's appearance
75 wxOwnerDrawn *GetItem(uint n) const { return m_aItems[n]; }
76 #endif
77
78 virtual void Append(const wxString& item);
79 virtual void Append(const wxString& item, char *clientData);
80 virtual void Set(int n, const wxString* choices, char **clientData = NULL);
81 virtual int FindString(const wxString& s) const ;
82 virtual void Clear(void);
83 virtual void SetSelection(int n, bool select = TRUE);
84
85 virtual void Deselect(int n);
86
87 // For single choice list item only
88 virtual int GetSelection() const ;
89 virtual void Delete(int n);
90 virtual char *GetClientData(int n) const ;
91 virtual void SetClientData(int n, char *clientData);
92 virtual void SetString(int n, const wxString& s);
93
94 // For single or multiple choice list item
95 virtual int GetSelections(wxArrayInt& aSelections) const;
96 virtual bool Selected(int n) const ;
97 virtual wxString GetString(int n) const ;
98 virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
99
100 // Set the specified item at the first visible item
101 // or scroll to max range.
102 virtual void SetFirstItem(int n) ;
103 virtual void SetFirstItem(const wxString& s) ;
104
105 virtual void InsertItems(int nItems, const wxString items[], int pos);
106
107 virtual wxString GetStringSelection(void) const ;
108 virtual bool SetStringSelection(const wxString& s, bool flag = TRUE);
109 virtual int Number(void) const ;
110
111 void Command(wxCommandEvent& event);
112
113 // Windows-specific code to set the horizontal extent of
114 // the listbox, if necessary. If s is non-NULL, it's
115 // used to calculate the horizontal extent.
116 // Otherwise, all strings are used.
117 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
118
119 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
120 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
121
122 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
123 virtual void SetupColours(void);
124
125 protected:
126 int m_noItems;
127 int m_selected;
128
129 #if USE_OWNER_DRAWN
130 // control items
131 wxListBoxItemsArray m_aItems;
132 #endif
133
134 };
135
136 #endif
137 // __LISTBOXH__