]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/listbox.h
Compile fix
[wxWidgets.git] / include / wx / mac / carbon / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/listbox.h
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
14
15 // ----------------------------------------------------------------------------
16 // simple types
17 // ----------------------------------------------------------------------------
18 #include "wx/dynarray.h"
19 #include "wx/arrstr.h"
20
21 // forward decl for GetSelections()
22 class wxArrayInt;
23
24 // exposed for subclasses like wxCheckListBox
25
26 class wxMacListControl
27 {
28 public:
29 virtual void MacDelete( unsigned int n ) = 0;
30 virtual void MacInsert( unsigned int n, const wxString& item ) = 0;
31 virtual void MacInsert( unsigned int n, const wxArrayString& items ) = 0;
32 // returns index of newly created line
33 virtual int MacAppend( const wxString& item ) = 0;
34 virtual void MacSetString( unsigned int n, const wxString& item ) = 0;
35 virtual void MacClear() = 0;
36 virtual void MacDeselectAll() = 0;
37 virtual void MacSetSelection( unsigned int n, bool select ) = 0;
38 virtual int MacGetSelection() const = 0;
39 virtual int MacGetSelections( wxArrayInt& aSelections ) const = 0;
40 virtual bool MacIsSelected( unsigned int n ) const = 0;
41 virtual void MacScrollTo( unsigned int n ) = 0;
42 virtual wxString MacGetString( unsigned int n) const = 0;
43 virtual unsigned int MacGetCount() const = 0;
44
45 virtual void MacSetClientData( unsigned int n, void * data) = 0;
46 virtual void * MacGetClientData( unsigned int) const = 0;
47
48 virtual ~wxMacListControl() { }
49 };
50
51 // List box item
52
53 WX_DEFINE_ARRAY( char* , wxListDataArray );
54
55 // ----------------------------------------------------------------------------
56 // List box control
57 // ----------------------------------------------------------------------------
58
59 class WXDLLEXPORT wxListBox : public wxListBoxBase
60 {
61 public:
62 // ctors and such
63 wxListBox();
64
65 wxListBox(
66 wxWindow *parent,
67 wxWindowID winid,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 int n = 0, const wxString choices[] = NULL,
71 long style = 0,
72 const wxValidator& validator = wxDefaultValidator,
73 const wxString& name = wxListBoxNameStr)
74 {
75 Create(parent, winid, pos, size, n, choices, style, validator, name);
76 }
77
78 wxListBox(
79 wxWindow *parent,
80 wxWindowID winid,
81 const wxPoint& pos,
82 const wxSize& size,
83 const wxArrayString& choices,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxListBoxNameStr)
87 {
88 Create(parent, winid, pos, size, choices, style, validator, name);
89 }
90
91 bool Create(
92 wxWindow *parent,
93 wxWindowID winid,
94 const wxPoint& pos = wxDefaultPosition,
95 const wxSize& size = wxDefaultSize,
96 int n = 0,
97 const wxString choices[] = NULL,
98 long style = 0,
99 const wxValidator& validator = wxDefaultValidator,
100 const wxString& name = wxListBoxNameStr);
101
102 bool Create(
103 wxWindow *parent,
104 wxWindowID winid,
105 const wxPoint& pos,
106 const wxSize& size,
107 const wxArrayString& choices,
108 long style = 0,
109 const wxValidator& validator = wxDefaultValidator,
110 const wxString& name = wxListBoxNameStr);
111
112 virtual ~wxListBox();
113
114 // implement base class pure virtuals
115 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
116 virtual void Clear();
117 virtual void Delete(unsigned int n);
118
119 virtual unsigned int GetCount() const;
120 virtual wxString GetString(unsigned int n) const;
121 virtual void SetString(unsigned int n, const wxString& s);
122 virtual int FindString(const wxString& s, bool bCase = false) const;
123
124 virtual bool IsSelected(int n) const;
125 virtual int GetSelection() const;
126 virtual int GetSelections(wxArrayInt& aSelections) const;
127
128 virtual void EnsureVisible(int n);
129
130 // wxCheckListBox support
131 static wxVisualAttributes
132 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
133
134 wxMacListControl* GetPeer() const;
135
136 protected:
137 // from wxItemContainer
138 virtual int DoAppend(const wxString& item);
139 virtual void DoSetItemClientData(unsigned int n, void* clientData);
140 virtual void* DoGetItemClientData(unsigned int n) const;
141 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
142 virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
143
144 // from wxListBoxBase
145 virtual void DoSetSelection(int n, bool select);
146 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
147 virtual void DoSetItems(const wxArrayString& items, void **clientData);
148 virtual void DoSetFirstItem(int n);
149 virtual int DoListHitTest(const wxPoint& point) const;
150
151 // free memory (common part of Clear() and dtor)
152 // prevent collision with some BSD definitions of macro Free()
153 void FreeData();
154
155 virtual wxSize DoGetBestSize() const;
156
157 private:
158 DECLARE_DYNAMIC_CLASS(wxListBox)
159 DECLARE_EVENT_TABLE()
160 };
161
162 #endif // _WX_LISTBOX_H_