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