]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/listbox.h
fixed compilation error
[wxWidgets.git] / include / wx / msw / listbox.h
CommitLineData
2bda0e17
KB
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$
bbcdf8bc
JS
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_LISTBOX_H_
13#define _WX_LISTBOX_H_
2bda0e17
KB
14
15#ifdef __GNUG__
16#pragma interface "listbox.h"
17#endif
18
19#include "wx/control.h"
20
20fd9757 21WXDLLEXPORT_DATA(extern const wxChar*) wxListBoxNameStr;
2bda0e17 22
47d67540 23#if wxUSE_OWNER_DRAWN
2bda0e17
KB
24 class WXDLLEXPORT wxOwnerDrawn;
25
26 // define the array of list box items
27 #include <wx/dynarray.h>
184b5d99 28
2bda0e17 29 WX_DEFINE_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
184b5d99 30
2bda0e17
KB
31#endif
32
7f17c6db
VZ
33// forward decl for GetSelections()
34class wxArrayInt;
35
39ca6d79 36WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
2bda0e17
KB
37
38// List box item
bfc6fde4 39class WXDLLEXPORT wxListBox : public wxControl
2bda0e17 40{
bfc6fde4
VZ
41 DECLARE_DYNAMIC_CLASS(wxListBox)
42
43public:
44 wxListBox();
45 wxListBox(wxWindow *parent, wxWindowID id,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 int n = 0, const wxString choices[] = NULL,
49 long style = 0,
50 const wxValidator& validator = wxDefaultValidator,
51 const wxString& name = wxListBoxNameStr)
52 {
53 Create(parent, id, pos, size, n, choices, style, validator, name);
54 }
55
56 bool Create(wxWindow *parent, wxWindowID id,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 int n = 0, const wxString choices[] = NULL,
60 long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxListBoxNameStr);
63
64 ~wxListBox();
65
66 bool MSWCommand(WXUINT param, WXWORD id);
2bda0e17 67
47d67540 68#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
69 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
70 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
2bda0e17 71
bfc6fde4
VZ
72 // plug-in for derived classes
73 virtual wxOwnerDrawn *CreateItem(size_t n);
2bda0e17 74
bfc6fde4
VZ
75 // allows to get the item and use SetXXX functions to set it's appearance
76 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
dd3c394a
VZ
77
78 // get the index of the given item
79 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
bfc6fde4 80#endif // wxUSE_OWNER_DRAWN
2bda0e17 81
bfc6fde4 82 virtual void Append(const wxString& item);
32c1cda2
OK
83 virtual void Append(const wxString& item, void *clientData);
84 virtual void Set(int n, const wxString* choices, void **clientData = NULL);
bfc6fde4
VZ
85 virtual int FindString(const wxString& s) const ;
86 virtual void Clear();
87 virtual void SetSelection(int n, bool select = TRUE);
2bda0e17 88
bfc6fde4 89 virtual void Deselect(int n);
2bda0e17 90
bfc6fde4
VZ
91 // For single choice list item only
92 virtual int GetSelection() const ;
93 virtual void Delete(int n);
32c1cda2
OK
94 virtual void *GetClientData(int n) const ;
95 virtual void SetClientData(int n, void *clientData);
bfc6fde4 96 virtual void SetString(int n, const wxString& s);
2bda0e17 97
bfc6fde4
VZ
98 // For single or multiple choice list item
99 virtual int GetSelections(wxArrayInt& aSelections) const;
100 virtual bool Selected(int n) const ;
101 virtual wxString GetString(int n) const ;
2bda0e17 102
bfc6fde4
VZ
103 // Set the specified item at the first visible item
104 // or scroll to max range.
105 virtual void SetFirstItem(int n) ;
106 virtual void SetFirstItem(const wxString& s) ;
2bda0e17 107
bfc6fde4 108 virtual void InsertItems(int nItems, const wxString items[], int pos);
2bda0e17 109
bfc6fde4
VZ
110 virtual wxString GetStringSelection() const ;
111 virtual bool SetStringSelection(const wxString& s, bool flag = TRUE);
112 virtual int Number() const ;
2bda0e17 113
bfc6fde4 114 void Command(wxCommandEvent& event);
2bda0e17 115
bfc6fde4
VZ
116 // Windows-specific code to set the horizontal extent of
117 // the listbox, if necessary. If s is non-NULL, it's
118 // used to calculate the horizontal extent.
119 // Otherwise, all strings are used.
120 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
2bda0e17 121
bfc6fde4
VZ
122 virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
123 WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
2bda0e17 124
bfc6fde4
VZ
125 virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
126 virtual void SetupColours();
2bda0e17 127
bfc6fde4
VZ
128protected:
129 int m_noItems;
130 int m_selected;
2bda0e17 131
b908d224
VZ
132 virtual wxSize DoGetBestSize();
133
47d67540 134#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
135 // control items
136 wxListBoxItemsArray m_aItems;
2bda0e17 137#endif
2bda0e17
KB
138};
139
140#endif
bbcdf8bc 141 // _WX_LISTBOX_H_