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