]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/listbox.h
Added knowledge of virtual size to wx(Scrolled)Windows, they can now
[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
1e6feb95
VZ
19#if wxUSE_LISTBOX
20
2ee3ee1b
VZ
21// ----------------------------------------------------------------------------
22// simple types
23// ----------------------------------------------------------------------------
2bda0e17 24
47d67540 25#if wxUSE_OWNER_DRAWN
2bda0e17
KB
26 class WXDLLEXPORT wxOwnerDrawn;
27
28 // define the array of list box items
29 #include <wx/dynarray.h>
184b5d99 30
a497618a 31 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn *, wxListBoxItemsArray);
2ee3ee1b 32#endif // wxUSE_OWNER_DRAWN
2bda0e17 33
7f17c6db
VZ
34// forward decl for GetSelections()
35class wxArrayInt;
36
2ee3ee1b
VZ
37// ----------------------------------------------------------------------------
38// List box control
39// ----------------------------------------------------------------------------
2bda0e17 40
2ee3ee1b 41class WXDLLEXPORT wxListBox : public wxListBoxBase
2bda0e17 42{
bfc6fde4 43public:
2ee3ee1b 44 // ctors and such
bfc6fde4
VZ
45 wxListBox();
46 wxListBox(wxWindow *parent, wxWindowID id,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 int n = 0, const wxString choices[] = NULL,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxListBoxNameStr)
53 {
54 Create(parent, id, pos, size, n, choices, style, validator, name);
55 }
56
57 bool Create(wxWindow *parent, wxWindowID id,
2ee3ee1b
VZ
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 int n = 0, const wxString choices[] = NULL,
61 long style = 0,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxListBoxNameStr);
bfc6fde4 64
2ee3ee1b 65 virtual ~wxListBox();
bfc6fde4 66
2ee3ee1b
VZ
67 // implement base class pure virtuals
68 virtual void Clear();
69 virtual void Delete(int n);
70
71 virtual int GetCount() const;
72 virtual wxString GetString(int n) const;
73 virtual void SetString(int n, const wxString& s);
74 virtual int FindString(const wxString& s) const;
75
76 virtual bool IsSelected(int n) const;
77 virtual void SetSelection(int n, bool select = TRUE);
78 virtual int GetSelection() const;
79 virtual int GetSelections(wxArrayInt& aSelections) const;
80
81 virtual int DoAppend(const wxString& item);
82 virtual void DoInsertItems(const wxArrayString& items, int pos);
83 virtual void DoSetItems(const wxArrayString& items, void **clientData);
2bda0e17 84
2ee3ee1b
VZ
85 virtual void DoSetFirstItem(int n);
86
6c8a980f
VZ
87 virtual void DoSetItemClientData(int n, void* clientData);
88 virtual void* DoGetItemClientData(int n) const;
89 virtual void DoSetItemClientObject(int n, wxClientData* clientData);
90 virtual wxClientData* DoGetItemClientObject(int n) const;
2ee3ee1b
VZ
91
92 // wxCheckListBox support
47d67540 93#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
94 bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
95 bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
2bda0e17 96
bfc6fde4
VZ
97 // plug-in for derived classes
98 virtual wxOwnerDrawn *CreateItem(size_t n);
2bda0e17 99
bfc6fde4
VZ
100 // allows to get the item and use SetXXX functions to set it's appearance
101 wxOwnerDrawn *GetItem(size_t n) const { return m_aItems[n]; }
dd3c394a
VZ
102
103 // get the index of the given item
104 int GetItemIndex(wxOwnerDrawn *item) const { return m_aItems.Index(item); }
bfc6fde4 105#endif // wxUSE_OWNER_DRAWN
2bda0e17 106
2ee3ee1b
VZ
107 // Windows-specific code to set the horizontal extent of the listbox, if
108 // necessary. If s is non-NULL, it's used to calculate the horizontal
109 // extent. Otherwise, all strings are used.
bfc6fde4 110 virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
2bda0e17 111
2ee3ee1b 112 // Windows callbacks
2ee3ee1b 113 bool MSWCommand(WXUINT param, WXWORD id);
2bda0e17 114
bfc6fde4 115 virtual void SetupColours();
2bda0e17 116
bfc6fde4 117protected:
8ee9d618
VZ
118 // free memory (common part of Clear() and dtor)
119 void Free();
120
bfc6fde4
VZ
121 int m_noItems;
122 int m_selected;
2bda0e17 123
f68586e5 124 virtual wxSize DoGetBestSize() const;
b908d224 125
47d67540 126#if wxUSE_OWNER_DRAWN
bfc6fde4
VZ
127 // control items
128 wxListBoxItemsArray m_aItems;
2bda0e17 129#endif
2ee3ee1b
VZ
130
131private:
132 DECLARE_DYNAMIC_CLASS(wxListBox)
2bda0e17
KB
133};
134
1e6feb95
VZ
135#endif // wxUSE_LISTBOX
136
2bda0e17 137#endif
bbcdf8bc 138 // _WX_LISTBOX_H_