]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/listbox.h
cleanup - reformatting
[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 // forward decl for GetPeer()
25 class wxMacListControl ;
26
27 // List box item
28
29 WX_DEFINE_ARRAY( char * , wxListDataArray ) ;
30
31 // ----------------------------------------------------------------------------
32 // List box control
33 // ----------------------------------------------------------------------------
34
35 class WXDLLEXPORT wxListBox : public wxListBoxBase
36 {
37 public:
38 // ctors and such
39 wxListBox();
40 wxListBox(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 int n = 0, const wxString choices[] = NULL,
44 long style = 0,
45 const wxValidator& validator = wxDefaultValidator,
46 const wxString& name = wxListBoxNameStr)
47 {
48 Create(parent, id, pos, size, n, choices, style, validator, name);
49 }
50 wxListBox(wxWindow *parent, wxWindowID id,
51 const wxPoint& pos,
52 const wxSize& size,
53 const wxArrayString& choices,
54 long style = 0,
55 const wxValidator& validator = wxDefaultValidator,
56 const wxString& name = wxListBoxNameStr)
57 {
58 Create(parent, id, pos, size, choices, style, validator, name);
59 }
60
61 bool Create(wxWindow *parent, wxWindowID id,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 int n = 0, const wxString choices[] = NULL,
65 long style = 0,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString& name = wxListBoxNameStr);
68 bool Create(wxWindow *parent, wxWindowID id,
69 const wxPoint& pos,
70 const wxSize& size,
71 const wxArrayString& choices,
72 long style = 0,
73 const wxValidator& validator = wxDefaultValidator,
74 const wxString& name = wxListBoxNameStr);
75
76 virtual ~wxListBox();
77 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
78
79 // implement base class pure virtuals
80 virtual void Clear();
81 virtual void Delete(unsigned int n);
82
83 virtual unsigned int GetCount() const;
84 virtual wxString GetString(unsigned int n) const;
85 virtual void SetString(unsigned int n, const wxString& s);
86 virtual int FindString(const wxString& s, bool bCase = false) const;
87
88 virtual bool IsSelected(int n) const;
89 virtual int GetSelection() const;
90 virtual int GetSelections(wxArrayInt& aSelections) const;
91
92 // wxCheckListBox support
93 static wxVisualAttributes
94 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
95
96 wxArrayString m_stringArray ;
97 wxListDataArray m_dataArray ;
98
99 wxMacListControl* GetPeer() const { return (wxMacListControl*) m_peer ; }
100
101 protected:
102 // internal storage for line n has changed, issue a redraw
103 void MacUpdateLine( int n ) ;
104
105 virtual void DoSetSelection(int n, bool select);
106 virtual int DoAppend(const wxString& item);
107 virtual void DoInsertItems(const wxArrayString& items, unsigned int pos);
108 virtual void DoSetItems(const wxArrayString& items, void **clientData);
109 virtual void DoSetFirstItem(int n);
110 virtual void DoSetItemClientData(unsigned int n, void* clientData);
111 virtual void* DoGetItemClientData(unsigned int n) const;
112 virtual void DoSetItemClientObject(unsigned int n, wxClientData* clientData);
113 virtual wxClientData* DoGetItemClientObject(unsigned int n) const;
114 virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
115 virtual int DoListHitTest(const wxPoint& point) const;
116
117 void MacDelete( int n ) ;
118 void MacInsert( int n , const wxString& item) ;
119 void MacAppend( const wxString& item) ;
120 void MacSet( int n , const wxString& item ) ;
121 void MacClear() ;
122 void MacDeselectAll() ;
123 void MacSetSelection( int n , bool select ) ;
124 int MacGetSelection() const ;
125 int MacGetSelections(wxArrayInt& aSelections) const ;
126 bool MacIsSelected( int n ) const ;
127 void MacScrollTo( int n ) ;
128 bool MacSuppressSelection( bool suppress ) ;
129
130 // free memory (common part of Clear() and dtor)
131 // prevent collision with some BSD definitions of macro Free()
132 void FreeData();
133
134 unsigned int m_noItems;
135 int m_selected;
136 bool m_suppressSelection ;
137
138 virtual wxSize DoGetBestSize() const;
139
140 // common creation for all databrowser list implementations
141 wxMacListControl* CreateMacListControl(const wxPoint& pos, const wxSize& size, long style) ;
142
143 private:
144 DECLARE_DYNAMIC_CLASS(wxListBox)
145 DECLARE_EVENT_TABLE()
146 };
147
148 #endif // _WX_LISTBOX_H_