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