1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_LISTBOX_H_
14 #define _WX_LISTBOX_H_
17 #pragma interface "listbox.h"
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxOwnerDrawn
;
27 // define the array of list box items
28 #include "wx/dynarray.h"
30 WX_DEFINE_EXPORTED_ARRAY(wxOwnerDrawn
*, wxListBoxItemsArray
);
31 #endif // wxUSE_OWNER_DRAWN
33 // forward decl for GetSelections()
38 WX_DEFINE_ARRAY( char * , wxListDataArray
) ;
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 class WXDLLEXPORT wxListBox
: public wxListBoxBase
49 wxListBox(wxWindow
*parent
, wxWindowID id
,
50 const wxPoint
& pos
= wxDefaultPosition
,
51 const wxSize
& size
= wxDefaultSize
,
52 int n
= 0, const wxString choices
[] = NULL
,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxListBoxNameStr
)
57 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
60 bool Create(wxWindow
*parent
, wxWindowID id
,
61 const wxPoint
& pos
= wxDefaultPosition
,
62 const wxSize
& size
= wxDefaultSize
,
63 int n
= 0, const wxString choices
[] = NULL
,
65 const wxValidator
& validator
= wxDefaultValidator
,
66 const wxString
& name
= wxListBoxNameStr
);
69 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
71 // implement base class pure virtuals
73 virtual void Delete(int n
);
75 virtual int GetCount() const;
76 virtual wxString
GetString(int n
) const;
77 virtual void SetString(int n
, const wxString
& s
);
78 virtual int FindString(const wxString
& s
) const;
80 virtual bool IsSelected(int n
) const;
81 virtual void SetSelection(int n
, bool select
= TRUE
);
82 virtual int GetSelection() const;
83 virtual int GetSelections(wxArrayInt
& aSelections
) const;
85 virtual int DoAppend(const wxString
& item
);
86 virtual void DoInsertItems(const wxArrayString
& items
, int pos
);
87 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
);
89 virtual void DoSetFirstItem(int n
);
91 virtual void DoSetItemClientData(int n
, void* clientData
);
92 virtual void* DoGetItemClientData(int n
) const;
93 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
);
94 virtual wxClientData
* DoGetItemClientObject(int n
) const;
95 virtual void DoSetSize(int x
, int y
,int width
, int height
,int sizeFlags
= wxSIZE_AUTO
) ;
97 // wxCheckListBox support
99 // plug-in for derived classes
100 virtual wxOwnerDrawn
*CreateItem(size_t n
);
102 // allows to get the item and use SetXXX functions to set it's appearance
103 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
105 // get the index of the given item
106 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
107 #endif // wxUSE_OWNER_DRAWN
111 virtual void SetupColours();
112 virtual void MacHandleControlClick( WXWidget control
, wxInt16 controlpart
) ;
115 wxArrayString m_stringArray
;
116 wxListDataArray m_dataArray
;
117 wxArrayInt m_selectionPreImage
;
118 void MacSetRedraw( bool doDraw
) ;
121 void MacDelete( int n
) ;
122 void MacInsert( int n
, const char * text
) ;
123 void MacAppend( const char * text
) ;
124 void MacSet( int n
, const char *text
) ;
126 void MacSetSelection( int n
, bool select
) ;
127 int MacGetSelection() const ;
128 int MacGetSelections(wxArrayInt
& aSelections
) const ;
129 bool MacIsSelected( int n
) const ;
130 void MacScrollTo( int n
) ;
131 void OnSize( const wxSizeEvent
&size
) ;
133 void MacDoDoubleClick() ;
135 // do we have multiple selections?
136 bool HasMultipleSelection() const;
138 // free memory (common part of Clear() and dtor)
144 virtual wxSize
DoGetBestSize() const;
146 #if wxUSE_OWNER_DRAWN
148 wxListBoxItemsArray m_aItems
;
152 DECLARE_DYNAMIC_CLASS(wxListBox
)
153 DECLARE_EVENT_TABLE()