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