1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_LISTBOX_H_
14 #define _WX_LISTBOX_H_
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
19 #include "wx/dynarray.h"
20 #include "wx/arrstr.h"
23 class WXDLLEXPORT wxOwnerDrawn
;
25 // define the array of list box items
26 #include "wx/dynarray.h"
28 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
29 #endif // wxUSE_OWNER_DRAWN
31 // forward decl for GetSelections()
36 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class WXDLLEXPORT wxListBox
: public wxListBoxBase
47 wxListBox(wxWindow
*parent
, wxWindowID id
,
48 const wxPoint
& pos
= wxDefaultPosition
,
49 const wxSize
& size
= wxDefaultSize
,
50 int n
= 0, const wxString choices
[] = NULL
,
52 const wxValidator
& validator
= wxDefaultValidator
,
53 const wxString
& name
= wxListBoxNameStr
)
55 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
57 wxListBox(wxWindow
*parent
, wxWindowID id
,
60 const wxArrayString
& choices
,
62 const wxValidator
& validator
= wxDefaultValidator
,
63 const wxString
& name
= wxListBoxNameStr
)
65 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
68 bool Create(wxWindow
*parent
, wxWindowID id
,
69 const wxPoint
& pos
= wxDefaultPosition
,
70 const wxSize
& size
= wxDefaultSize
,
71 int n
= 0, const wxString choices
[] = NULL
,
73 const wxValidator
& validator
= wxDefaultValidator
,
74 const wxString
& name
= wxListBoxNameStr
);
75 bool Create(wxWindow
*parent
, wxWindowID id
,
78 const wxArrayString
& choices
,
80 const wxValidator
& validator
= wxDefaultValidator
,
81 const wxString
& name
= wxListBoxNameStr
);
84 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
86 // implement base class pure virtuals
88 virtual void Delete(int n
);
90 virtual int GetCount() const;
91 virtual wxString
GetString(int n
) const;
92 virtual void SetString(int n
, const wxString
& s
);
93 virtual int FindString(const wxString
& s
) const;
95 virtual bool IsSelected(int n
) const;
96 virtual void DoSetSelection(int n
, bool select
);
97 virtual int GetSelection() const;
98 virtual int GetSelections(wxArrayInt
& aSelections
) const;
100 virtual int DoAppend(const wxString
& item
);
101 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
102 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
104 virtual void DoSetFirstItem(int n
);
106 virtual void DoSetItemClientData(int n
, void* clientData
);
107 virtual void* DoGetItemClientData(int n
) const;
108 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
109 virtual wxClientData
* DoGetItemClientObject(int n
) const;
110 virtual void DoSetSize(int x
, int y
,int width
, int height
,int sizeFlags
= wxSIZE_AUTO
) ;
112 // wxCheckListBox support
113 #if wxUSE_OWNER_DRAWN
114 // plug-in for derived classes
115 virtual wxOwnerDrawn
*CreateItem(size_t n
);
117 // allows to get the item and use SetXXX functions to set it's appearance
118 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
120 // get the index of the given item
121 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
122 #endif // wxUSE_OWNER_DRAWN
126 virtual void SetupColours();
127 virtual void MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool mouseStillDown
) ;
128 virtual bool MacCanFocus() const { return true ; }
129 void OnChar(wxKeyEvent
& event
);
132 wxArrayString m_stringArray
;
133 wxListDataArray m_dataArray
;
134 wxArrayInt m_selectionPreImage
;
135 void MacSetRedraw( bool doDraw
) ;
138 void MacDelete( int n
) ;
139 void MacInsert( int n
, const wxString
& item
) ;
140 void MacAppend( const wxString
& item
) ;
141 void MacSet( int n
, const wxString
& item
) ;
143 void MacSetSelection( int n
, bool select
) ;
144 int MacGetSelection() const ;
145 int MacGetSelections(wxArrayInt
& aSelections
) const ;
146 bool MacIsSelected( int n
) const ;
147 void MacScrollTo( int n
) ;
148 void OnSize( wxSizeEvent
&size
) ;
150 void MacDoDoubleClick() ;
152 // do we have multiple selections?
153 bool HasMultipleSelection() const;
155 // free memory (common part of Clear() and dtor)
156 // prevent collision with some BSD definitions of macro Free()
164 virtual wxSize
DoGetBestSize() const;
166 #if wxUSE_OWNER_DRAWN
168 wxListBoxItemsArray m_aItems
;
172 DECLARE_DYNAMIC_CLASS(wxListBox
)
173 DECLARE_EVENT_TABLE()