1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/listbox.cpp
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin (owner drawn stuff)
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
21 #include "wx/listbox.h"
24 #include "wx/dynarray.h"
25 #include "wx/settings.h"
31 #include "wx/window.h"
34 #include "wx/msw/private.h"
39 #include "wx/ownerdrw.h"
42 #if wxUSE_EXTENDED_RTTI
43 WX_DEFINE_FLAGS( wxListBoxStyle
)
45 wxBEGIN_FLAGS( wxListBoxStyle
)
46 // new style border flags, we put them first to
47 // use them for streaming out
48 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
49 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
50 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
51 wxFLAGS_MEMBER(wxBORDER_RAISED
)
52 wxFLAGS_MEMBER(wxBORDER_STATIC
)
53 wxFLAGS_MEMBER(wxBORDER_NONE
)
55 // old style border flags
56 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
57 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
58 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
59 wxFLAGS_MEMBER(wxRAISED_BORDER
)
60 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
61 wxFLAGS_MEMBER(wxBORDER
)
63 // standard window styles
64 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
65 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
66 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
67 wxFLAGS_MEMBER(wxWANTS_CHARS
)
68 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
69 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
70 wxFLAGS_MEMBER(wxVSCROLL
)
71 wxFLAGS_MEMBER(wxHSCROLL
)
73 wxFLAGS_MEMBER(wxLB_SINGLE
)
74 wxFLAGS_MEMBER(wxLB_MULTIPLE
)
75 wxFLAGS_MEMBER(wxLB_EXTENDED
)
76 wxFLAGS_MEMBER(wxLB_HSCROLL
)
77 wxFLAGS_MEMBER(wxLB_ALWAYS_SB
)
78 wxFLAGS_MEMBER(wxLB_NEEDED_SB
)
79 wxFLAGS_MEMBER(wxLB_SORT
)
81 wxEND_FLAGS( wxListBoxStyle
)
83 IMPLEMENT_DYNAMIC_CLASS_XTI(wxListBox
, wxControl
,"wx/listbox.h")
85 wxBEGIN_PROPERTIES_TABLE(wxListBox
)
86 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_LISTBOX_SELECTED
, wxCommandEvent
)
87 wxEVENT_PROPERTY( DoubleClick
, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, wxCommandEvent
)
89 wxPROPERTY( Font
, wxFont
, SetFont
, GetFont
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
90 wxPROPERTY_COLLECTION( Choices
, wxArrayString
, wxString
, AppendString
, GetStrings
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
91 wxPROPERTY( Selection
,int, SetSelection
, GetSelection
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
92 wxPROPERTY_FLAGS( WindowStyle
, wxListBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
93 wxEND_PROPERTIES_TABLE()
95 wxBEGIN_HANDLERS_TABLE(wxListBox
)
96 wxEND_HANDLERS_TABLE()
98 wxCONSTRUCTOR_4( wxListBox
, wxWindow
* , Parent
, wxWindowID
, Id
, wxPoint
, Position
, wxSize
, Size
)
100 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
110 // ============================================================================
111 // list box item declaration and implementation
112 // ============================================================================
114 #if wxUSE_OWNER_DRAWN
116 class wxListBoxItem
: public wxOwnerDrawn
119 wxListBoxItem(const wxString
& str
= wxEmptyString
);
122 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, false)
124 // no bitmaps/checkmarks
128 wxOwnerDrawn
*wxListBox::CreateLboxItem(size_t WXUNUSED(n
))
130 return new wxListBoxItem();
133 #endif //USE_OWNER_DRAWN
135 // ============================================================================
136 // list box control implementation
137 // ============================================================================
139 // ----------------------------------------------------------------------------
141 // ----------------------------------------------------------------------------
144 wxListBox::wxListBox()
150 bool wxListBox::Create(wxWindow
*parent
,
154 int n
, const wxString choices
[],
156 const wxValidator
& validator
,
157 const wxString
& name
)
162 // initialize base class fields
163 if ( !CreateControl(parent
, id
, pos
, size
, style
, validator
, name
) )
166 // create the native control
167 if ( !MSWCreateControl(_T("LISTBOX"), wxEmptyString
, pos
, size
) )
169 // control creation failed
173 // initialize the contents
174 for ( int i
= 0; i
< n
; i
++ )
179 // now we can compute our best size correctly, so do it if necessary
180 SetInitialSize(size
);
185 bool wxListBox::Create(wxWindow
*parent
,
189 const wxArrayString
& choices
,
191 const wxValidator
& validator
,
192 const wxString
& name
)
194 wxCArrayString
chs(choices
);
195 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
196 style
, validator
, name
);
199 wxListBox::~wxListBox()
204 WXDWORD
wxListBox::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
206 WXDWORD msStyle
= wxControl::MSWGetStyle(style
, exstyle
);
208 // always show the vertical scrollbar if necessary -- otherwise it is
209 // impossible to use the control with the mouse
210 msStyle
|= WS_VSCROLL
;
212 // we always want to get the notifications
213 msStyle
|= LBS_NOTIFY
;
215 // without this style, you get unexpected heights, so e.g. constraint
216 // layout doesn't work properly
217 msStyle
|= LBS_NOINTEGRALHEIGHT
;
219 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
220 _T("only one of listbox selection modes can be specified") );
222 if ( style
& wxLB_MULTIPLE
)
223 msStyle
|= LBS_MULTIPLESEL
;
224 else if ( style
& wxLB_EXTENDED
)
225 msStyle
|= LBS_EXTENDEDSEL
;
227 if ( m_windowStyle
& wxLB_ALWAYS_SB
)
228 msStyle
|= LBS_DISABLENOSCROLL
;
229 if ( m_windowStyle
& wxLB_HSCROLL
)
230 msStyle
|= WS_HSCROLL
;
231 if ( m_windowStyle
& wxLB_SORT
)
234 #if wxUSE_OWNER_DRAWN && !defined(__WXWINCE__)
235 if ( m_windowStyle
& wxLB_OWNERDRAW
)
237 // we don't support LBS_OWNERDRAWVARIABLE yet and we also always put
238 // the strings in the listbox for simplicity even though we could have
239 // avoided it in this case
240 msStyle
|= LBS_OWNERDRAWFIXED
| LBS_HASSTRINGS
;
242 #endif // wxUSE_OWNER_DRAWN
247 // ----------------------------------------------------------------------------
248 // implementation of wxListBoxBase methods
249 // ----------------------------------------------------------------------------
251 void wxListBox::DoSetFirstItem(int N
)
253 wxCHECK_RET( IsValid(N
),
254 wxT("invalid index in wxListBox::SetFirstItem") );
256 SendMessage(GetHwnd(), LB_SETTOPINDEX
, (WPARAM
)N
, (LPARAM
)0);
259 void wxListBox::Delete(unsigned int n
)
261 wxCHECK_RET( IsValid(n
),
262 wxT("invalid index in wxListBox::Delete") );
264 // for owner drawn objects, the data is used for storing wxOwnerDrawn
265 // pointers and we shouldn't touch it
266 #if !wxUSE_OWNER_DRAWN
267 if ( !(m_windowStyle
& wxLB_OWNERDRAW
) )
268 #endif // !wxUSE_OWNER_DRAWN
269 if ( HasClientObjectData() )
271 delete GetClientObject(n
);
274 SendMessage(GetHwnd(), LB_DELETESTRING
, n
, 0);
277 SetHorizontalExtent(wxEmptyString
);
280 int wxListBox::DoAppend(const wxString
& item
)
282 int index
= ListBox_AddString(GetHwnd(), item
);
285 #if wxUSE_OWNER_DRAWN
286 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
287 wxOwnerDrawn
*pNewItem
= CreateLboxItem(index
); // dummy argument
288 pNewItem
->SetName(item
);
289 m_aItems
.Insert(pNewItem
, index
);
290 ListBox_SetItemData(GetHwnd(), index
, pNewItem
);
291 pNewItem
->SetFont(GetFont());
293 #endif // wxUSE_OWNER_DRAWN
295 SetHorizontalExtent(item
);
300 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
302 // avoid flicker - but don't need to do this for a hidden listbox
303 bool hideAndShow
= IsShown();
306 ShowWindow(GetHwnd(), SW_HIDE
);
309 ListBox_ResetContent(GetHwnd());
311 m_noItems
= choices
.GetCount();
313 for (i
= 0; i
< m_noItems
; i
++)
315 ListBox_AddString(GetHwnd(), choices
[i
]);
318 SetClientData(i
, clientData
[i
]);
322 #if wxUSE_OWNER_DRAWN
323 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
324 // first delete old items
325 WX_CLEAR_ARRAY(m_aItems
);
327 // then create new ones
328 for ( unsigned int ui
= 0; ui
< m_noItems
; ui
++ ) {
329 wxOwnerDrawn
*pNewItem
= CreateLboxItem(ui
);
330 pNewItem
->SetName(choices
[ui
]);
331 m_aItems
.Add(pNewItem
);
332 ListBox_SetItemData(GetHwnd(), ui
, pNewItem
);
335 #endif // wxUSE_OWNER_DRAWN
337 SetHorizontalExtent();
341 // show the listbox back if we hid it
342 ShowWindow(GetHwnd(), SW_SHOW
);
346 int wxListBox::FindString(const wxString
& s
, bool bCase
) const
348 // back to base class search for not native search type
350 return wxItemContainerImmutable::FindString( s
, bCase
);
352 int pos
= ListBox_FindStringExact(GetHwnd(), -1, s
);
359 void wxListBox::Clear()
363 ListBox_ResetContent(GetHwnd());
366 SetHorizontalExtent();
369 void wxListBox::Free()
371 #if wxUSE_OWNER_DRAWN
372 if ( m_windowStyle
& wxLB_OWNERDRAW
)
374 WX_CLEAR_ARRAY(m_aItems
);
377 #endif // wxUSE_OWNER_DRAWN
378 if ( HasClientObjectData() )
380 for ( unsigned int n
= 0; n
< m_noItems
; n
++ )
382 delete GetClientObject(n
);
387 void wxListBox::DoSetSelection(int N
, bool select
)
389 wxCHECK_RET( N
== wxNOT_FOUND
|| IsValid(N
),
390 wxT("invalid index in wxListBox::SetSelection") );
392 if ( HasMultipleSelection() )
394 SendMessage(GetHwnd(), LB_SETSEL
, select
, N
);
398 SendMessage(GetHwnd(), LB_SETCURSEL
, select
? N
: -1, 0);
402 bool wxListBox::IsSelected(int N
) const
404 wxCHECK_MSG( IsValid(N
), false,
405 wxT("invalid index in wxListBox::Selected") );
407 return SendMessage(GetHwnd(), LB_GETSEL
, N
, 0) == 0 ? false : true;
410 wxClientData
* wxListBox::DoGetItemClientObject(unsigned int n
) const
412 return (wxClientData
*)DoGetItemClientData(n
);
415 void *wxListBox::DoGetItemClientData(unsigned int n
) const
417 wxCHECK_MSG( IsValid(n
), NULL
,
418 wxT("invalid index in wxListBox::GetClientData") );
420 return (void *)SendMessage(GetHwnd(), LB_GETITEMDATA
, n
, 0);
423 void wxListBox::DoSetItemClientObject(unsigned int n
, wxClientData
* clientData
)
425 DoSetItemClientData(n
, clientData
);
428 void wxListBox::DoSetItemClientData(unsigned int n
, void *clientData
)
430 wxCHECK_RET( IsValid(n
),
431 wxT("invalid index in wxListBox::SetClientData") );
433 #if wxUSE_OWNER_DRAWN
434 if ( m_windowStyle
& wxLB_OWNERDRAW
)
436 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
437 // in OnMeasure/OnDraw.
438 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
440 #endif // wxUSE_OWNER_DRAWN
442 if ( ListBox_SetItemData(GetHwnd(), n
, clientData
) == LB_ERR
)
443 wxLogDebug(wxT("LB_SETITEMDATA failed"));
446 // Return number of selections and an array of selected integers
447 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
451 if ( HasMultipleSelection() )
453 int countSel
= ListBox_GetSelCount(GetHwnd());
454 if ( countSel
== LB_ERR
)
456 wxLogDebug(_T("ListBox_GetSelCount failed"));
458 else if ( countSel
!= 0 )
460 int *selections
= new int[countSel
];
462 if ( ListBox_GetSelItems(GetHwnd(),
463 countSel
, selections
) == LB_ERR
)
465 wxLogDebug(wxT("ListBox_GetSelItems failed"));
470 aSelections
.Alloc(countSel
);
471 for ( int n
= 0; n
< countSel
; n
++ )
472 aSelections
.Add(selections
[n
]);
475 delete [] selections
;
480 else // single-selection listbox
482 if (ListBox_GetCurSel(GetHwnd()) > -1)
483 aSelections
.Add(ListBox_GetCurSel(GetHwnd()));
485 return aSelections
.Count();
489 // Get single selection, for single choice list items
490 int wxListBox::GetSelection() const
492 wxCHECK_MSG( !HasMultipleSelection(),
494 wxT("GetSelection() can't be used with multiple-selection listboxes, use GetSelections() instead.") );
496 return ListBox_GetCurSel(GetHwnd());
499 // Find string for position
500 wxString
wxListBox::GetString(unsigned int n
) const
502 wxCHECK_MSG( IsValid(n
), wxEmptyString
,
503 wxT("invalid index in wxListBox::GetString") );
505 int len
= ListBox_GetTextLen(GetHwnd(), n
);
507 // +1 for terminating NUL
509 ListBox_GetText(GetHwnd(), n
, (wxChar
*)wxStringBuffer(result
, len
+ 1));
515 wxListBox::DoInsertItems(const wxArrayString
& items
, unsigned int pos
)
517 wxCHECK_RET( IsValidInsert(pos
),
518 wxT("invalid index in wxListBox::InsertItems") );
520 unsigned int nItems
= items
.GetCount();
521 for ( unsigned int i
= 0; i
< nItems
; i
++ )
523 int idx
= ListBox_InsertString(GetHwnd(), i
+ pos
, items
[i
]);
525 #if wxUSE_OWNER_DRAWN
526 if ( m_windowStyle
& wxLB_OWNERDRAW
)
528 wxOwnerDrawn
*pNewItem
= CreateLboxItem(idx
);
529 pNewItem
->SetName(items
[i
]);
530 pNewItem
->SetFont(GetFont());
531 m_aItems
.Insert(pNewItem
, idx
);
533 ListBox_SetItemData(GetHwnd(), idx
, pNewItem
);
537 #endif // wxUSE_OWNER_DRAWN
542 SetHorizontalExtent();
545 int wxListBox::DoListHitTest(const wxPoint
& point
) const
547 LRESULT lRes
= ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT
,
548 0L, MAKELONG(point
.x
, point
.y
));
550 // non zero high-order word means that this item is outside of the client
551 // area, IOW the point is outside of the listbox
552 return HIWORD(lRes
) ? wxNOT_FOUND
: lRes
;
555 void wxListBox::SetString(unsigned int n
, const wxString
& s
)
557 wxCHECK_RET( IsValid(n
),
558 wxT("invalid index in wxListBox::SetString") );
560 // remember the state of the item
561 bool wasSelected
= IsSelected(n
);
563 void *oldData
= NULL
;
564 wxClientData
*oldObjData
= NULL
;
565 if ( m_clientDataItemsType
== wxClientData_Void
)
566 oldData
= GetClientData(n
);
567 else if ( m_clientDataItemsType
== wxClientData_Object
)
568 oldObjData
= GetClientObject(n
);
570 // delete and recreate it
571 SendMessage(GetHwnd(), LB_DELETESTRING
, n
, 0);
574 if ( n
== (m_noItems
- 1) )
577 ListBox_InsertString(GetHwnd(), newN
, s
);
579 // restore the client data
581 SetClientData(n
, oldData
);
582 else if ( oldObjData
)
583 SetClientObject(n
, oldObjData
);
585 #if wxUSE_OWNER_DRAWN
586 if ( m_windowStyle
& wxLB_OWNERDRAW
)
588 // update item's text
589 m_aItems
[n
]->SetName(s
);
591 // reassign the item's data
592 ListBox_SetItemData(GetHwnd(), n
, m_aItems
[n
]);
594 #endif //USE_OWNER_DRAWN
596 // we may have lost the selection
600 SetHorizontalExtent();
603 unsigned int wxListBox::GetCount() const
608 // ----------------------------------------------------------------------------
609 // size-related stuff
610 // ----------------------------------------------------------------------------
612 void wxListBox::SetHorizontalExtent(const wxString
& s
)
614 // in any case, our best size could have changed
615 InvalidateBestSize();
617 // the rest is only necessary if we want a horizontal scrollbar
618 if ( !HasFlag(wxHSCROLL
) )
622 WindowHDC
dc(GetHwnd());
623 SelectInHDC
selFont(dc
, GetHfontOf(GetFont()));
625 TEXTMETRIC lpTextMetric
;
626 ::GetTextMetrics(dc
, &lpTextMetric
);
628 int largestExtent
= 0;
633 // set extent to the max length of all strings
634 for ( unsigned int i
= 0; i
< m_noItems
; i
++ )
636 const wxString str
= GetString(i
);
637 ::GetTextExtentPoint32(dc
, str
.c_str(), str
.length(), &extentXY
);
639 int extentX
= (int)(extentXY
.cx
+ lpTextMetric
.tmAveCharWidth
);
640 if ( extentX
> largestExtent
)
641 largestExtent
= extentX
;
644 else // just increase the extent to the length of this string
646 int existingExtent
= (int)SendMessage(GetHwnd(),
647 LB_GETHORIZONTALEXTENT
, 0, 0L);
649 ::GetTextExtentPoint32(dc
, s
.c_str(), s
.length(), &extentXY
);
651 int extentX
= (int)(extentXY
.cx
+ lpTextMetric
.tmAveCharWidth
);
652 if ( extentX
> existingExtent
)
653 largestExtent
= extentX
;
657 SendMessage(GetHwnd(), LB_SETHORIZONTALEXTENT
, LOWORD(largestExtent
), 0L);
658 //else: it shouldn't change
661 wxSize
wxListBox::DoGetBestSize() const
663 // find the widest string
666 for (unsigned int i
= 0; i
< m_noItems
; i
++)
668 wxString
str(GetString(i
));
669 GetTextExtent(str
, &wLine
, NULL
);
670 if ( wLine
> wListbox
)
674 // give it some reasonable default value if there are no strings in the
679 // the listbox should be slightly larger than the widest string
681 wxGetCharSize(GetHWND(), &cx
, &cy
, GetFont());
685 // Add room for the scrollbar
686 wListbox
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
688 // don't make the listbox too tall (limit height to 10 items) but don't
689 // make it too small neither
690 int hListbox
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy
)*
691 wxMin(wxMax(m_noItems
, 3), 10);
693 wxSize
best(wListbox
, hListbox
);
698 // ----------------------------------------------------------------------------
700 // ----------------------------------------------------------------------------
702 bool wxListBox::MSWCommand(WXUINT param
, WXWORD
WXUNUSED(id
))
705 if ( param
== LBN_SELCHANGE
)
707 evtType
= wxEVT_COMMAND_LISTBOX_SELECTED
;
709 else if ( param
== LBN_DBLCLK
)
711 evtType
= wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
;
715 // some event we're not interested in
719 wxCommandEvent
event(evtType
, m_windowId
);
720 event
.SetEventObject( this );
722 // retrieve the affected item
723 int n
= SendMessage(GetHwnd(), LB_GETCARETINDEX
, 0, 0);
726 if ( HasClientObjectData() )
727 event
.SetClientObject( GetClientObject(n
) );
728 else if ( HasClientUntypedData() )
729 event
.SetClientData( GetClientData(n
) );
731 event
.SetString(GetString(n
));
732 event
.SetExtraLong( HasMultipleSelection() ? IsSelected(n
) : true );
737 return GetEventHandler()->ProcessEvent(event
);
740 // ----------------------------------------------------------------------------
741 // wxCheckListBox support
742 // ----------------------------------------------------------------------------
744 #if wxUSE_OWNER_DRAWN
749 // space beneath/above each row in pixels
750 // "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
751 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
753 // the height is the same for all items
754 // TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes
756 // NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
757 // message is not yet sent when we get here!
758 bool wxListBox::MSWOnMeasure(WXMEASUREITEMSTRUCT
*item
)
760 // only owner-drawn control should receive this message
761 wxCHECK( ((m_windowStyle
& wxLB_OWNERDRAW
) == wxLB_OWNERDRAW
), false );
763 MEASUREITEMSTRUCT
*pStruct
= (MEASUREITEMSTRUCT
*)item
;
766 HDC hdc
= GetDC(NULL
);
768 HDC hdc
= CreateIC(wxT("DISPLAY"), NULL
, NULL
, 0);
772 wxDCTemp
dc((WXHDC
)hdc
);
773 dc
.SetFont(GetFont());
775 pStruct
->itemHeight
= dc
.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE
;
776 pStruct
->itemWidth
= dc
.GetCharWidth();
780 ReleaseDC(NULL
, hdc
);
788 // forward the message to the appropriate item
789 bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT
*item
)
791 // only owner-drawn control should receive this message
792 wxCHECK( ((m_windowStyle
& wxLB_OWNERDRAW
) == wxLB_OWNERDRAW
), false );
794 DRAWITEMSTRUCT
*pStruct
= (DRAWITEMSTRUCT
*)item
;
795 UINT itemID
= pStruct
->itemID
;
797 // the item may be -1 for an empty listbox
798 if ( itemID
== (UINT
)-1 )
801 long data
= ListBox_GetItemData(GetHwnd(), pStruct
->itemID
);
803 wxCHECK( data
&& (data
!= LB_ERR
), false );
805 wxListBoxItem
*pItem
= (wxListBoxItem
*)data
;
807 wxDCTemp
dc((WXHDC
)pStruct
->hDC
);
808 wxPoint
pt1(pStruct
->rcItem
.left
, pStruct
->rcItem
.top
);
809 wxPoint
pt2(pStruct
->rcItem
.right
, pStruct
->rcItem
.bottom
);
810 wxRect
rect(pt1
, pt2
);
812 return pItem
->OnDrawItem(dc
, rect
,
813 (wxOwnerDrawn::wxODAction
)pStruct
->itemAction
,
814 (wxOwnerDrawn::wxODStatus
)pStruct
->itemState
);
817 #endif // wxUSE_OWNER_DRAWN
819 #endif // wxUSE_LISTBOX