]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/listbox.h
Corrected typo.
[wxWidgets.git] / include / wx / msw / listbox.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
2ee3ee1b 2// Name: wx/msw/listbox.h
2bda0e17
KB
3// Purpose: wxListBox class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
8ee9d618 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__
8ee9d618 16 #pragma interface "listbox.h"
2bda0e17
KB
17#endif
18
2ee3ee1b
VZ
19// ----------------------------------------------------------------------------
20// simple types
21// ----------------------------------------------------------------------------
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
a497618a 29 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
2ee3ee1b 30#endif // wxUSE_OWNER_DRAWN
2bda0e17 31
7f17c6db
VZ
32// forward decl for GetSelections()
33class wxArrayInt;
34
2ee3ee1b
VZ
35// ----------------------------------------------------------------------------
36// List box control
37// ----------------------------------------------------------------------------
2bda0e17 38
2ee3ee1b 39class WXDLLEXPORT wxListBox : public wxListBoxBase
2bda0e17 40{
bfc6fde4 41public:
2ee3ee1b 42 // ctors and such
bfc6fde4
VZ
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,
2ee3ee1b
VZ
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);
bfc6fde4 62
2ee3ee1b 63 virtual ~wxListBox();
bfc6fde4 64
2ee3ee1b
VZ
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);
2bda0e17 82
2ee3ee1b
VZ
83 virtual void DoSetFirstItem(int n);
84
6c8a980f
VZ
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;
2ee3ee1b
VZ
89
90 // wxCheckListBox support
47d67540 91#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
92 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
93 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
2bda0e17 94
bfc6fde4
VZ
95 // plug-in for derived classes
96 virtual wxOwnerDrawn *CreateItem(size_t n);
2bda0e17 97
bfc6fde4
VZ
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]; }
dd3c394a
VZ
100
101 // get the index of the given item
102 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
bfc6fde4 103#endif // wxUSE_OWNER_DRAWN
2bda0e17 104
2ee3ee1b
VZ
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.
bfc6fde4 108 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
2bda0e17 109
2ee3ee1b 110 // Windows callbacks
2ee3ee1b 111 bool MSWCommand(WXUINT param, WXWORD id);
2bda0e17 112
bfc6fde4 113 virtual void SetupColours();
2bda0e17 114
bfc6fde4 115protected:
2ee3ee1b
VZ
116 // do we have multiple selections?
117 bool HasMultipleSelection() const;
118
8ee9d618
VZ
119 // free memory (common part of Clear() and dtor)
120 void Free();
121
bfc6fde4
VZ
122 int m_noItems;
123 int m_selected;
2bda0e17 124
f68586e5 125 virtual wxSize DoGetBestSize() const;
b908d224 126
47d67540 127#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
128 // control items
129 wxListBoxItemsArray m_aItems;
2bda0e17 130#endif
2ee3ee1b
VZ
131
132private:
133 DECLARE_DYNAMIC_CLASS(wxListBox)
2bda0e17
KB
134};
135
136#endif
bbcdf8bc 137 // _WX_LISTBOX_H_