1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/listbox.h
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
18 #include "wx/dynarray.h"
19 #include "wx/arrstr.h"
21 // forward decl for GetSelections()
24 // forward decl for GetPeer()
25 class wxMacListControl
;
29 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 class WXDLLEXPORT wxListBox
: public wxListBoxBase
40 wxListBox(wxWindow
*parent
, wxWindowID id
,
41 const wxPoint
& pos
= wxDefaultPosition
,
42 const wxSize
& size
= wxDefaultSize
,
43 int n
= 0, const wxString choices
[] = NULL
,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxListBoxNameStr
)
48 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
50 wxListBox(wxWindow
*parent
, wxWindowID id
,
53 const wxArrayString
& choices
,
55 const wxValidator
& validator
= wxDefaultValidator
,
56 const wxString
& name
= wxListBoxNameStr
)
58 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
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
,
66 const wxValidator
& validator
= wxDefaultValidator
,
67 const wxString
& name
= wxListBoxNameStr
);
68 bool Create(wxWindow
*parent
, wxWindowID id
,
71 const wxArrayString
& choices
,
73 const wxValidator
& validator
= wxDefaultValidator
,
74 const wxString
& name
= wxListBoxNameStr
);
77 virtual void Refresh(bool eraseBack
= true, const wxRect
*rect
= NULL
);
79 // implement base class pure virtuals
81 virtual void Delete(unsigned int n
);
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;
88 virtual bool IsSelected(int n
) const;
89 virtual int GetSelection() const;
90 virtual int GetSelections(wxArrayInt
& aSelections
) const;
92 // wxCheckListBox support
93 static wxVisualAttributes
94 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
96 wxArrayString m_stringArray
;
97 wxListDataArray m_dataArray
;
99 wxMacListControl
* GetPeer() const { return (wxMacListControl
*) m_peer
; }
102 // internal storage for line n has changed, issue a redraw
103 void MacUpdateLine( int n
) ;
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;
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
) ;
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
) ;
130 // free memory (common part of Clear() and dtor)
131 // prevent collision with some BSD definitions of macro Free()
134 unsigned int m_noItems
;
136 bool m_suppressSelection
;
138 virtual wxSize
DoGetBestSize() const;
140 // common creation for all databrowser list implementations
141 wxMacListControl
* CreateMacListControl(const wxPoint
& pos
, const wxSize
& size
, long style
) ;
144 DECLARE_DYNAMIC_CLASS(wxListBox
)
145 DECLARE_EVENT_TABLE()
148 #endif // _WX_LISTBOX_H_