]> git.saurik.com Git - wxWidgets.git/blob - src/os2/listbox.cpp
Quick VA fix
[wxWidgets.git] / src / os2 / listbox.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.cpp
3 // Purpose: wxListBox
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/window.h"
16 #include "wx/os2/private.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/listbox.h"
20 #include "wx/settings.h"
21 #include "wx/brush.h"
22 #include "wx/font.h"
23 #include "wx/dc.h"
24 #include "wx/utils.h"
25 #endif
26
27 #define INCL_M
28 #include <os2.h>
29
30 #include "wx/dynarray.h"
31 #include "wx/log.h"
32
33 #if wxUSE_OWNER_DRAWN
34 #include "wx/ownerdrw.h"
35 #endif
36
37 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
38
39 // ============================================================================
40 // list box item declaration and implementation
41 // ============================================================================
42
43 #if wxUSE_OWNER_DRAWN
44
45 class wxListBoxItem : public wxOwnerDrawn
46 {
47 public:
48 wxListBoxItem(const wxString& str = "");
49 };
50
51 wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
52 {
53 // no bitmaps/checkmarks
54 SetMarginWidth(0);
55 }
56
57 wxOwnerDrawn *wxListBox::CreateItem(size_t n)
58 {
59 return new wxListBoxItem();
60 }
61
62 #endif //USE_OWNER_DRAWN
63
64 // ============================================================================
65 // list box control implementation
66 // ============================================================================
67
68 // Listbox item
69 wxListBox::wxListBox()
70 {
71 m_noItems = 0;
72 m_selected = 0;
73 }
74
75 bool wxListBox::Create(wxWindow *parent,
76 wxWindowID id,
77 const wxPoint& pos,
78 const wxSize& size,
79 int n, const wxString choices[],
80 long style,
81 #if wxUSE_VALIDATORS
82 const wxValidator& validator,
83 #endif
84 const wxString& name)
85 {
86 m_noItems = 0;
87 m_hWnd = 0;
88 m_selected = 0;
89
90 SetName(name);
91 #if wxUSE_VALIDATORS
92 SetValidator(validator);
93 #endif
94
95 if (parent)
96 parent->AddChild(this);
97
98 wxSystemSettings settings;
99 SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
100 SetForegroundColour(parent->GetForegroundColour());
101
102 m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
103
104 int x = pos.x;
105 int y = pos.y;
106 int width = size.x;
107 int height = size.y;
108 m_windowStyle = style;
109
110 // TODO:
111 /*
112 DWORD wstyle = WS_VISIBLE | WS_VSCROLL | WS_TABSTOP |
113 LBS_NOTIFY | LBS_HASSTRINGS;
114 if (m_windowStyle & wxLB_MULTIPLE)
115 wstyle |= LBS_MULTIPLESEL;
116 else if (m_windowStyle & wxLB_EXTENDED)
117 wstyle |= LBS_EXTENDEDSEL;
118
119 if (m_windowStyle & wxLB_ALWAYS_SB)
120 wstyle |= LBS_DISABLENOSCROLL;
121 if (m_windowStyle & wxLB_HSCROLL)
122 wstyle |= WS_HSCROLL;
123 if (m_windowStyle & wxLB_SORT)
124 wstyle |= LBS_SORT;
125
126 #if wxUSE_OWNER_DRAWN
127 if ( m_windowStyle & wxLB_OWNERDRAW ) {
128 // we don't support LBS_OWNERDRAWVARIABLE yet
129 wstyle |= LBS_OWNERDRAWFIXED;
130 }
131 #endif
132
133 // Without this style, you get unexpected heights, so e.g. constraint layout
134 // doesn't work properly
135 wstyle |= LBS_NOINTEGRALHEIGHT;
136
137 bool want3D;
138 WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
139
140 // Even with extended styles, need to combine with WS_BORDER for them to
141 // look right.
142 if ( want3D || wxStyleHasBorder(m_windowStyle) )
143 {
144 wstyle |= WS_BORDER;
145 }
146
147 m_hWnd = (WXHWND)::CreateWindowEx(exStyle, wxT("LISTBOX"), NULL,
148 wstyle | WS_CHILD,
149 0, 0, 0, 0,
150 (HWND)parent->GetHWND(), (HMENU)m_windowId,
151 wxGetInstance(), NULL);
152
153 wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create listbox") );
154
155 // Subclass again to catch messages
156 SubclassWin(m_hWnd);
157
158 size_t ui;
159 for (ui = 0; ui < (size_t)n; ui++) {
160 Append(choices[ui]);
161 }
162
163 if ( (m_windowStyle & wxLB_MULTIPLE) == 0 )
164 SendMessage(GetHwnd(), LB_SETCURSEL, 0, 0);
165 */
166 SetFont(parent->GetFont());
167
168 SetSize(x, y, width, height);
169
170 Show(TRUE);
171
172 return TRUE;
173 }
174
175 wxListBox::~wxListBox()
176 {
177 #if wxUSE_OWNER_DRAWN
178 size_t uiCount = m_aItems.Count();
179 while ( uiCount-- != 0 ) {
180 delete m_aItems[uiCount];
181 }
182 #endif // wxUSE_OWNER_DRAWN
183 }
184
185 void wxListBox::SetupColours()
186 {
187 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
188 SetForegroundColour(GetParent()->GetForegroundColour());
189 }
190
191 // ----------------------------------------------------------------------------
192 // implementation of wxListBoxBase methods
193 // ----------------------------------------------------------------------------
194
195 void wxListBox::DoSetFirstItem(int N)
196 {
197 wxCHECK_RET( N >= 0 && N < m_noItems,
198 wxT("invalid index in wxListBox::SetFirstItem") );
199
200 // SendMessage(GetHwnd(), LB_SETTOPINDEX, (WPARAM)N, (LPARAM)0);
201 }
202
203 void wxListBox::Delete(int N)
204 {
205 wxCHECK_RET( N >= 0 && N < m_noItems,
206 wxT("invalid index in wxListBox::Delete") );
207
208 #if wxUSE_OWNER_DRAWN
209 delete m_aItems[N];
210 m_aItems.Remove(N);
211 #else // !wxUSE_OWNER_DRAWN
212 if ( HasClientObjectData() )
213 {
214 delete GetClientObject(N);
215 }
216 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
217
218 // SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
219 m_noItems--;
220
221 SetHorizontalExtent("");
222 }
223
224 int wxListBox::DoAppend(const wxString& item)
225 {
226 // TODO:
227 /*
228 int index = ListBox_AddString(GetHwnd(), item);
229 m_noItems++;
230
231 #if wxUSE_OWNER_DRAWN
232 if ( m_windowStyle & wxLB_OWNERDRAW ) {
233 wxOwnerDrawn *pNewItem = CreateItem(index); // dummy argument
234 pNewItem->SetName(item);
235 m_aItems.Add(pNewItem);
236 ListBox_SetItemData(GetHwnd(), index, pNewItem);
237 }
238 #endif
239
240 SetHorizontalExtent(item);
241
242 return index;
243 */
244 return 0;
245 }
246
247 void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
248 {
249 // TODO:
250 /*
251 ShowWindow(GetHwnd(), SW_HIDE);
252
253 ListBox_ResetContent(GetHwnd());
254
255 m_noItems = choices.GetCount();
256 int i;
257 for (i = 0; i < m_noItems; i++)
258 {
259 ListBox_AddString(GetHwnd(), choices[i]);
260 if ( clientData )
261 {
262 #if wxUSE_OWNER_DRAWN
263 wxASSERT_MSG(clientData[ui] == NULL,
264 wxT("Can't use client data with owner-drawn listboxes"));
265 #else // !wxUSE_OWNER_DRAWN
266 ListBox_SetItemData(GetHwnd(), i, clientData[i]);
267 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
268 }
269 }
270
271 #if wxUSE_OWNER_DRAWN
272 if ( m_windowStyle & wxLB_OWNERDRAW ) {
273 // first delete old items
274 size_t ui = m_aItems.Count();
275 while ( ui-- != 0 ) {
276 delete m_aItems[ui];
277 }
278 m_aItems.Empty();
279
280 // then create new ones
281 for ( ui = 0; ui < (size_t)m_noItems; ui++ ) {
282 wxOwnerDrawn *pNewItem = CreateItem(ui);
283 pNewItem->SetName(choices[ui]);
284 m_aItems.Add(pNewItem);
285 ListBox_SetItemData(GetHwnd(), ui, pNewItem);
286 }
287 }
288 #endif // wxUSE_OWNER_DRAWN
289
290 SetHorizontalExtent();
291
292 ShowWindow(GetHwnd(), SW_SHOW);
293 */
294 }
295
296 int wxListBox::FindString(const wxString& s) const
297 {
298 // TODO:
299 /*
300 int pos = ListBox_FindStringExact(GetHwnd(), (WPARAM)-1, s);
301 if (pos == LB_ERR)
302 return wxNOT_FOUND;
303 else
304 return pos;
305 */
306 return 0;
307 }
308
309 void wxListBox::Clear()
310 {
311 #if wxUSE_OWNER_DRAWN
312 size_t uiCount = m_aItems.Count();
313 while ( uiCount-- != 0 ) {
314 delete m_aItems[uiCount];
315 }
316
317 m_aItems.Clear();
318 #else // !wxUSE_OWNER_DRAWN
319 if ( HasClientObjectData() )
320 {
321 for ( size_t n = 0; n < (size_t)m_noItems; n++ )
322 {
323 delete GetClientObject(n);
324 }
325 }
326 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
327 // TODO:
328 /*
329
330 ListBox_ResetContent(GetHwnd());
331
332 m_noItems = 0;
333 SetHorizontalExtent();
334 */
335 }
336
337 void wxListBox::SetSelection(int N, bool select)
338 {
339 wxCHECK_RET( N >= 0 && N < m_noItems,
340 wxT("invalid index in wxListBox::SetSelection") );
341 // TODO:
342 /*
343
344 if ( HasMultipleSelection() )
345 {
346 SendMessage(GetHwnd(), LB_SETSEL, select, N);
347 }
348 else
349 {
350 SendMessage(GetHwnd(), LB_SETCURSEL, select ? N : -1, 0);
351 }
352 */
353 }
354
355 bool wxListBox::IsSelected(int N) const
356 {
357 wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
358 wxT("invalid index in wxListBox::Selected") );
359
360 // return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? FALSE : TRUE;
361 return FALSE;
362 }
363
364 wxClientData* wxListBox::DoGetItemClientObject(int n) const
365 {
366 return (wxClientData *)DoGetItemClientData(n);
367 }
368
369 void *wxListBox::DoGetItemClientData(int n) const
370 {
371 wxCHECK_MSG( n >= 0 && n < m_noItems, NULL,
372 wxT("invalid index in wxListBox::GetClientData") );
373
374 // return (void *)SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
375 return NULL;
376 }
377
378 void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
379 {
380 DoSetItemClientData(n, clientData);
381 }
382
383 void wxListBox::DoSetItemClientData(int n, void *clientData)
384 {
385 wxCHECK_RET( n >= 0 && n < m_noItems,
386 wxT("invalid index in wxListBox::SetClientData") );
387
388 #if wxUSE_OWNER_DRAWN
389 if ( m_windowStyle & wxLB_OWNERDRAW )
390 {
391 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
392 // in OnMeasure/OnDraw.
393 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
394 }
395 #endif // wxUSE_OWNER_DRAWN
396
397 // TODO:
398 /*
399 if ( ListBox_SetItemData(GetHwnd(), n, clientData) == LB_ERR )
400 wxLogDebug(wxT("LB_SETITEMDATA failed"));
401 */
402 }
403
404 bool wxListBox::HasMultipleSelection() const
405 {
406 return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
407 }
408
409 // Return number of selections and an array of selected integers
410 int wxListBox::GetSelections(wxArrayInt& aSelections) const
411 {
412 aSelections.Empty();
413
414 // TODO:
415 /*
416 if ( HasMultipleSelection() )
417 {
418 int no_sel = ListBox_GetSelCount(GetHwnd());
419 if (no_sel != 0) {
420 int *selections = new int[no_sel];
421 int rc = ListBox_GetSelItems(GetHwnd(), no_sel, selections);
422
423 wxCHECK_MSG(rc != LB_ERR, -1, wxT("ListBox_GetSelItems failed"));
424
425 aSelections.Alloc(no_sel);
426 for ( int n = 0; n < no_sel; n++ )
427 aSelections.Add(selections[n]);
428
429 delete [] selections;
430 }
431
432 return no_sel;
433 }
434 else // single-selection listbox
435 {
436 aSelections.Add(ListBox_GetCurSel(GetHwnd()));
437
438 return 1;
439 }
440 */
441 return 0;
442 }
443
444 // Get single selection, for single choice list items
445 int wxListBox::GetSelection() const
446 {
447 wxCHECK_MSG( !HasMultipleSelection(),
448 -1,
449 wxT("GetSelection() can't be used with multiple-selection "
450 "listboxes, use GetSelections() instead.") );
451
452 // return ListBox_GetCurSel(GetHwnd());
453 return 0;
454 }
455
456 // Find string for position
457 wxString wxListBox::GetString(int N) const
458 {
459 wxCHECK_MSG( N >= 0 && N < m_noItems, "",
460 wxT("invalid index in wxListBox::GetClientData") );
461
462 // TODO:
463 /*
464 int len = ListBox_GetTextLen(GetHwnd(), N);
465
466 // +1 for terminating NUL
467 wxString result;
468 ListBox_GetText(GetHwnd(), N, result.GetWriteBuf(len + 1));
469 result.UngetWriteBuf();
470
471 return result;
472 */
473 return((wxString)"");
474 }
475
476 void
477 wxListBox::DoInsertItems(const wxArrayString& items, int pos)
478 {
479 wxCHECK_RET( pos >= 0 && pos <= m_noItems,
480 wxT("invalid index in wxListBox::InsertItems") );
481
482 // TODO:
483 /*
484 int nItems = items.GetCount();
485 for ( int i = 0; i < nItems; i++ )
486 ListBox_InsertString(GetHwnd(), i + pos, items[i]);
487 m_noItems += nItems;
488
489 SetHorizontalExtent();
490 */
491 }
492
493 void wxListBox::SetString(int N, const wxString& s)
494 {
495 wxCHECK_RET( N >= 0 && N < m_noItems,
496 wxT("invalid index in wxListBox::SetString") );
497
498 // remember the state of the item
499 bool wasSelected = IsSelected(N);
500
501 void *oldData = NULL;
502 wxClientData *oldObjData = NULL;
503 if ( m_clientDataItemsType == ClientData_Void )
504 oldData = GetClientData(N);
505 else if ( m_clientDataItemsType == ClientData_Object )
506 oldObjData = GetClientObject(N);
507 // TODO:
508 /*
509
510 // delete and recreate it
511 SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
512
513 int newN = N;
514 if ( N == m_noItems - 1 )
515 newN = -1;
516
517 ListBox_InsertString(GetHwnd(), newN, s);
518
519 // restore the client data
520 if ( oldData )
521 SetClientData(N, oldData);
522 else if ( oldObjData )
523 SetClientObject(N, oldObjData);
524
525 // we may have lost the selection
526 if ( wasSelected )
527 Select(N);
528
529 #if wxUSE_OWNER_DRAWN
530 if ( m_windowStyle & wxLB_OWNERDRAW )
531 // update item's text
532 m_aItems[N]->SetName(s);
533 #endif //USE_OWNER_DRAWN
534 */
535 }
536
537 int wxListBox::GetCount() const
538 {
539 return m_noItems;
540 }
541
542 // ----------------------------------------------------------------------------
543 // helpers
544 // ----------------------------------------------------------------------------
545
546 // Windows-specific code to set the horizontal extent of the listbox, if
547 // necessary. If s is non-NULL, it's used to calculate the horizontal extent.
548 // Otherwise, all strings are used.
549 void wxListBox::SetHorizontalExtent(const wxString& s)
550 {
551 // TODO:
552 /*
553 // Only necessary if we want a horizontal scrollbar
554 if (!(m_windowStyle & wxHSCROLL))
555 return;
556 TEXTMETRIC lpTextMetric;
557
558 if ( !s.IsEmpty() )
559 {
560 int existingExtent = (int)SendMessage(GetHwnd(), LB_GETHORIZONTALEXTENT, 0, 0L);
561 HDC dc = GetWindowDC(GetHwnd());
562 HFONT oldFont = 0;
563 if (GetFont().Ok() && GetFont().GetResourceHandle())
564 oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
565
566 GetTextMetrics(dc, &lpTextMetric);
567 SIZE extentXY;
568 ::GetTextExtentPoint(dc, (LPTSTR) (const wxChar *)s, s.Length(), &extentXY);
569 int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
570
571 if (oldFont)
572 ::SelectObject(dc, oldFont);
573
574 ReleaseDC(GetHwnd(), dc);
575 if (extentX > existingExtent)
576 SendMessage(GetHwnd(), LB_SETHORIZONTALEXTENT, LOWORD(extentX), 0L);
577 }
578 else
579 {
580 int largestExtent = 0;
581 HDC dc = GetWindowDC(GetHwnd());
582 HFONT oldFont = 0;
583 if (GetFont().Ok() && GetFont().GetResourceHandle())
584 oldFont = (HFONT) ::SelectObject(dc, (HFONT) GetFont().GetResourceHandle());
585
586 GetTextMetrics(dc, &lpTextMetric);
587 int i;
588 for (i = 0; i < m_noItems; i++)
589 {
590 int len = (int)SendMessage(GetHwnd(), LB_GETTEXT, i, (LONG)wxBuffer);
591 wxBuffer[len] = 0;
592 SIZE extentXY;
593 ::GetTextExtentPoint(dc, (LPTSTR)wxBuffer, len, &extentXY);
594 int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
595 if (extentX > largestExtent)
596 largestExtent = extentX;
597 }
598 if (oldFont)
599 ::SelectObject(dc, oldFont);
600
601 ReleaseDC(GetHwnd(), dc);
602 SendMessage(GetHwnd(), LB_SETHORIZONTALEXTENT, LOWORD(largestExtent), 0L);
603 }
604 */
605 }
606
607 wxSize wxListBox::DoGetBestSize() const
608 {
609 // find the widest string
610 int wLine;
611 int wListbox = 0;
612 for ( int i = 0; i < m_noItems; i++ )
613 {
614 wxString str(GetString(i));
615 GetTextExtent(str, &wLine, NULL);
616 if ( wLine > wListbox )
617 wListbox = wLine;
618 }
619
620 // give it some reasonable default value if there are no strings in the
621 // list
622 if ( wListbox == 0 )
623 wListbox = 100;
624
625 // the listbox should be slightly larger than the widest string
626 int cx, cy;
627 wxGetCharSize(GetHWND(), &cx, &cy, (wxFont*)&GetFont());
628
629 wListbox += 3*cx;
630
631 int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMax(m_noItems, 7));
632
633 return wxSize(wListbox, hListbox);
634 }
635
636 // ----------------------------------------------------------------------------
637 // callbacks
638 // ----------------------------------------------------------------------------
639
640 bool wxListBox::OS2Command(WXUINT param, WXWORD WXUNUSED(id))
641 {
642 /*
643 if (param == LBN_SELCANCEL)
644 {
645 event.extraLong = FALSE;
646 }
647 */
648 // TODO:
649 /*
650 if (param == LBN_SELCHANGE)
651 {
652 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
653 wxArrayInt aSelections;
654 int count = GetSelections(aSelections);
655 if ( count > 0 )
656 {
657 event.m_commandInt = aSelections[0];
658 event.m_clientData = GetClientData(event.m_commandInt);
659 wxString str(GetString(event.m_commandInt));
660 if (str != wxT(""))
661 {
662 event.m_commandString = str;
663 }
664 }
665 else
666 {
667 event.m_commandInt = -1;
668 event.m_commandString.Empty();
669 }
670
671 event.SetEventObject( this );
672 ProcessCommand(event);
673 return TRUE;
674 }
675 else if (param == LBN_DBLCLK)
676 {
677 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
678 event.SetEventObject( this );
679 GetEventHandler()->ProcessEvent(event);
680 return TRUE;
681 }
682 */
683 return FALSE;
684 }
685
686 WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
687 WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
688 {
689 // TODO:
690 /*
691 if (GetParent()->GetTransparentBackground())
692 SetBkMode((HDC) pDC, TRANSPARENT);
693 else
694 SetBkMode((HDC) pDC, OPAQUE);
695
696 ::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
697 ::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
698
699 wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
700
701 // Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
702 // has a zero usage count.
703 backgroundBrush->RealizeResource();
704 return (WXHBRUSH) backgroundBrush->GetResourceHandle();
705 */
706 return (WXHBRUSH)0;
707 }
708
709 // ----------------------------------------------------------------------------
710 // wxCheckListBox support
711 // ----------------------------------------------------------------------------
712
713 #if wxUSE_OWNER_DRAWN
714
715 // drawing
716 // -------
717
718 // space beneath/above each row in pixels
719 // "standard" checklistbox use 1 here, some might prefer 2. 0 is ugly.
720 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
721
722 // the height is the same for all items
723 // TODO should be changed for LBS_OWNERDRAWVARIABLE style listboxes
724
725 // NB: can't forward this to wxListBoxItem because LB_SETITEMDATA
726 // message is not yet sent when we get here!
727 bool wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT *item)
728 {
729 // TODO:
730 /*
731 // only owner-drawn control should receive this message
732 wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
733
734 MEASUREITEMSTRUCT *pStruct = (MEASUREITEMSTRUCT *)item;
735
736 wxDC dc;
737 dc.SetHDC((WXHDC)CreateIC(wxT("DISPLAY"), NULL, NULL, 0));
738 dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_ANSI_VAR_FONT));
739
740 pStruct->itemHeight = dc.GetCharHeight() + 2*OWNER_DRAWN_LISTBOX_EXTRA_SPACE;
741 pStruct->itemWidth = dc.GetCharWidth();
742
743 return TRUE;
744 */
745 return TRUE;
746 }
747
748 // forward the message to the appropriate item
749 bool wxListBox::OS2OnDraw(WXDRAWITEMSTRUCT *item)
750 {
751 // TODO:
752 /*
753 // only owner-drawn control should receive this message
754 wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
755
756 DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
757
758 long data = ListBox_GetItemData(GetHwnd(), pStruct->itemID);
759
760 wxCHECK( data && (data != LB_ERR), FALSE );
761
762 wxListBoxItem *pItem = (wxListBoxItem *)data;
763
764 wxDC dc;
765 dc.SetHDC((WXHDC)pStruct->hDC, FALSE);
766 wxRect rect(wxPoint(pStruct->rcItem.left, pStruct->rcItem.top),
767 wxPoint(pStruct->rcItem.right, pStruct->rcItem.bottom));
768
769 return pItem->OnDrawItem(dc, rect,
770 (wxOwnerDrawn::wxODAction)pStruct->itemAction,
771 (wxOwnerDrawn::wxODStatus)pStruct->itemState);
772 */
773 return FALSE;
774 }
775 #endif
776 // wxUSE_OWNER_DRAWN