1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/listbox.h
3 // Purpose: wxListBox class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
22 class WXDLLIMPEXP_FWD_CORE wxOwnerDrawn
;
24 // define the array of list box items
25 #include "wx/dynarray.h"
27 WX_DEFINE_EXPORTED_ARRAY_PTR(wxOwnerDrawn
*, wxListBoxItemsArray
);
28 #endif // wxUSE_OWNER_DRAWN
30 // forward decl for GetSelections()
31 class WXDLLIMPEXP_FWD_BASE wxArrayInt
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 class WXDLLIMPEXP_CORE wxListBox
: public wxListBoxBase
42 wxListBox(wxWindow
*parent
, wxWindowID id
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
45 int n
= 0, const wxString choices
[] = NULL
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxListBoxNameStr
)
50 Create(parent
, id
, pos
, size
, n
, choices
, style
, validator
, name
);
52 wxListBox(wxWindow
*parent
, wxWindowID id
,
55 const wxArrayString
& choices
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxListBoxNameStr
)
60 Create(parent
, id
, pos
, size
, choices
, style
, validator
, name
);
63 bool Create(wxWindow
*parent
, wxWindowID id
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
,
66 int n
= 0, const wxString choices
[] = NULL
,
68 const wxValidator
& validator
= wxDefaultValidator
,
69 const wxString
& name
= wxListBoxNameStr
);
70 bool Create(wxWindow
*parent
, wxWindowID id
,
73 const wxArrayString
& choices
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxListBoxNameStr
);
80 virtual unsigned int GetCount() const;
81 virtual wxString
GetString(unsigned int n
) const;
82 virtual void SetString(unsigned int n
, const wxString
& s
);
83 virtual int FindString(const wxString
& s
, bool bCase
= false) const;
85 virtual bool IsSelected(int n
) const;
86 virtual int GetSelection() const;
87 virtual int GetSelections(wxArrayInt
& aSelections
) const;
89 // wxCheckListBox support
91 bool MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
);
92 bool MSWOnDraw(WXDRAWITEMSTRUCT
*item
);
94 // plug-in for derived classes
95 virtual wxOwnerDrawn
*CreateLboxItem(size_t n
);
97 // allows to get the item and use SetXXX functions to set it's appearance
98 wxOwnerDrawn
*GetItem(size_t n
) const { return m_aItems
[n
]; }
100 // get the index of the given item
101 int GetItemIndex(wxOwnerDrawn
*item
) const { return m_aItems
.Index(item
); }
102 #endif // wxUSE_OWNER_DRAWN
104 // Windows-specific code to update the horizontal extent of the listbox, if
105 // necessary. If s is non-empty, the horizontal extent is increased to the
106 // length of this string if it's currently too short, otherwise the maximum
107 // extent of all strings is used. In any case calls InvalidateBestSize()
108 virtual void SetHorizontalExtent(const wxString
& s
= wxEmptyString
);
111 bool MSWCommand(WXUINT param
, WXWORD id
);
112 WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
114 // under XP when using "transition effect for menus and tooltips" if we
115 // return true for WM_PRINTCLIENT here then it causes noticable slowdown
116 virtual bool MSWShouldPropagatePrintChild()
121 virtual wxVisualAttributes
GetDefaultAttributes() const
123 return GetClassDefaultAttributes(GetWindowVariant());
126 static wxVisualAttributes
127 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
)
129 return GetCompositeControlsDefaultAttributes(variant
);
132 // returns true if the platform should explicitly apply a theme border
133 virtual bool CanApplyThemeBorder() const { return false; }
136 virtual wxSize
DoGetBestClientSize() const;
138 virtual void DoClear();
139 virtual void DoDeleteOneItem(unsigned int n
);
141 virtual void DoSetSelection(int n
, bool select
);
143 virtual int DoInsertItems(const wxArrayStringsAdapter
& items
,
145 void **clientData
, wxClientDataType type
);
147 virtual void DoSetFirstItem(int n
);
148 virtual void DoSetItemClientData(unsigned int n
, void* clientData
);
149 virtual void* DoGetItemClientData(unsigned int n
) const;
150 virtual int DoListHitTest(const wxPoint
& point
) const;
152 bool m_updateHorizontalExtent
;
153 virtual void OnInternalIdle();
155 // free memory (common part of Clear() and dtor)
158 unsigned int m_noItems
;
160 #if wxUSE_OWNER_DRAWN
162 wxListBoxItemsArray m_aItems
;
166 DECLARE_DYNAMIC_CLASS_NO_COPY(wxListBox
)
169 #endif // wxUSE_LISTBOX