]> git.saurik.com Git - wxWidgets.git/blob - src/os2/listbox.cpp
applied patch to build wxMSW with CW7 (patch 550445)
[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 #include "wx/scrolwin.h"
26 #endif
27
28 #define INCL_M
29 #include <os2.h>
30
31 #include "wx/dynarray.h"
32 #include "wx/log.h"
33
34 #if wxUSE_LISTBOX
35
36 #if wxUSE_OWNER_DRAWN
37 #include "wx/ownerdrw.h"
38 #endif
39
40 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
41
42 // ============================================================================
43 // list box item declaration and implementation
44 // ============================================================================
45
46 #if wxUSE_OWNER_DRAWN
47
48 class wxListBoxItem : public wxOwnerDrawn
49 {
50 public:
51 wxListBoxItem(const wxString& rsStr = "");
52 };
53
54 wxListBoxItem::wxListBoxItem(
55 const wxString& rsStr
56 )
57 : wxOwnerDrawn( rsStr
58 ,FALSE
59 )
60 {
61 //
62 // No bitmaps/checkmarks
63 //
64 SetMarginWidth(0);
65 } // end of wxListBoxItem::wxListBoxItem
66
67 wxOwnerDrawn* wxListBox::CreateItem(
68 size_t n
69 )
70 {
71 return new wxListBoxItem();
72 } // end of wxListBox::CreateItem
73
74 #endif //USE_OWNER_DRAWN
75
76 // ============================================================================
77 // list box control implementation
78 // ============================================================================
79
80 // Listbox item
81 wxListBox::wxListBox()
82 {
83 m_nNumItems = 0;
84 m_nSelected = 0;
85 } // end of wxListBox::wxListBox
86
87 bool wxListBox::Create(
88 wxWindow* pParent
89 , wxWindowID vId
90 , const wxPoint& rPos
91 , const wxSize& rSize
92 , int n
93 , const wxString asChoices[]
94 , long lStyle
95 #if wxUSE_VALIDATORS
96 , const wxValidator& rValidator
97 #endif
98 , const wxString& rsName
99 )
100 {
101 m_nNumItems = 0;
102 m_hWnd = 0;
103 m_nSelected = 0;
104
105 SetName(rsName);
106 #if wxUSE_VALIDATORS
107 SetValidator(rValidator);
108 #endif
109
110 if (pParent)
111 pParent->AddChild(this);
112
113 wxSystemSettings vSettings;
114
115 SetBackgroundColour(vSettings.GetSystemColour(wxSYS_COLOUR_WINDOW));
116 SetForegroundColour(pParent->GetForegroundColour());
117
118 m_windowId = (vId == -1) ? (int)NewControlId() : vId;
119
120 int nX = rPos.x;
121 int nY = rPos.y;
122 int nWidth = rSize.x;
123 int nHeight = rSize.y;
124
125 m_windowStyle = lStyle;
126
127 lStyle = WS_VISIBLE;
128
129 if (m_windowStyle & wxCLIP_SIBLINGS )
130 lStyle |= WS_CLIPSIBLINGS;
131 if (m_windowStyle & wxLB_MULTIPLE)
132 lStyle |= LS_MULTIPLESEL;
133 else if (m_windowStyle & wxLB_EXTENDED)
134 lStyle |= LS_EXTENDEDSEL;
135 if (m_windowStyle & wxLB_HSCROLL)
136 lStyle |= LS_HORZSCROLL;
137 if (m_windowStyle & wxLB_OWNERDRAW)
138 lStyle |= LS_OWNERDRAW;
139
140 //
141 // Without this style, you get unexpected heights, so e.g. constraint layout
142 // doesn't work properly
143 //
144 lStyle |= LS_NOADJUSTPOS;
145
146 m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent) // Parent
147 ,WC_LISTBOX // Default Listbox class
148 ,"LISTBOX" // Control's name
149 ,lStyle // Initial Style
150 ,0, 0, 0, 0 // Position and size
151 ,GetWinHwnd(pParent) // Owner
152 ,HWND_TOP // Z-Order
153 ,(HMENU)m_windowId // Id
154 ,NULL // Control Data
155 ,NULL // Presentation Parameters
156 );
157 if (m_hWnd == 0)
158 {
159 return FALSE;
160 }
161
162 //
163 // Subclass again for purposes of dialog editing mode
164 //
165 SubclassWin(m_hWnd);
166
167 LONG lUi;
168
169 for (lUi = 0; lUi < (LONG)n; lUi++)
170 {
171 Append(asChoices[lUi]);
172 }
173 wxFont* pTextFont = new wxFont( 10
174 ,wxMODERN
175 ,wxNORMAL
176 ,wxNORMAL
177 );
178 SetFont(*pTextFont);
179
180 //
181 // Set standard wxWindows colors for Listbox items and highlighting
182 //
183 wxColour vColour;
184
185 vColour.Set(wxString("WHITE"));
186
187 LONG lColor = (LONG)vColour.GetPixel();
188
189 ::WinSetPresParam( m_hWnd
190 ,PP_HILITEFOREGROUNDCOLOR
191 ,sizeof(LONG)
192 ,(PVOID)&lColor
193 );
194 vColour.Set(wxString("NAVY"));
195 lColor = (LONG)vColour.GetPixel();
196 ::WinSetPresParam( m_hWnd
197 ,PP_HILITEBACKGROUNDCOLOR
198 ,sizeof(LONG)
199 ,(PVOID)&lColor
200 );
201
202 SetSize( nX
203 ,nY
204 ,nWidth
205 ,nHeight
206 );
207 delete pTextFont;
208 return TRUE;
209 } // end of wxListBox::Create
210
211 wxListBox::~wxListBox()
212 {
213 #if wxUSE_OWNER_DRAWN
214 size_t lUiCount = m_aItems.Count();
215
216 while (lUiCount-- != 0)
217 {
218 delete m_aItems[lUiCount];
219 }
220 #endif // wxUSE_OWNER_DRAWN
221 } // end of wxListBox::~wxListBox
222
223 void wxListBox::SetupColours()
224 {
225 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
226 SetForegroundColour(GetParent()->GetForegroundColour());
227 } // end of wxListBox::SetupColours
228
229 // ----------------------------------------------------------------------------
230 // implementation of wxListBoxBase methods
231 // ----------------------------------------------------------------------------
232
233 void wxListBox::DoSetFirstItem(
234 int N
235 )
236 {
237 wxCHECK_RET( N >= 0 && N < m_nNumItems,
238 wxT("invalid index in wxListBox::SetFirstItem") );
239
240 ::WinSendMsg(GetHwnd(), LM_SETTOPINDEX, MPFROMLONG(N), (MPARAM)0);
241 } // end of wxListBox::DoSetFirstItem
242
243 void wxListBox::Delete(
244 int N
245 )
246 {
247 wxCHECK_RET( N >= 0 && N < m_nNumItems,
248 wxT("invalid index in wxListBox::Delete") );
249
250 #if wxUSE_OWNER_DRAWN
251 delete m_aItems[N];
252 m_aItems.RemoveAt(N);
253 #else // !wxUSE_OWNER_DRAWN
254 if (HasClientObjectData())
255 {
256 delete GetClientObject(N);
257 }
258 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
259
260 ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)N, (MPARAM)0);
261 m_nNumItems--;
262 } // end of wxListBox::DoSetFirstItem
263
264 int wxListBox::DoAppend(
265 const wxString& rsItem
266 )
267 {
268 int nIndex = 0;
269 SHORT nIndexType = 0;
270
271 if (m_windowStyle & wxLB_SORT)
272 nIndexType = LIT_SORTASCENDING;
273 else
274 nIndexType = LIT_END;
275 nIndex = (int)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)rsItem.c_str());
276 m_nNumItems++;
277
278 #if wxUSE_OWNER_DRAWN
279 if (m_windowStyle & wxLB_OWNERDRAW)
280 {
281 wxOwnerDrawn* pNewItem = CreateItem(nIndex); // dummy argument
282
283 pNewItem->SetName(rsItem);
284 m_aItems.Insert(pNewItem, nIndex);
285 ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem));
286 pNewItem->SetFont(GetFont());
287 }
288 #endif
289 return nIndex;
290 } // end of wxListBox::DoAppend
291
292 void wxListBox::DoSetItems(
293 const wxArrayString& raChoices
294 , void** ppClientData
295 )
296 {
297 BOOL bHideAndShow = IsShown();
298 int nCount = 0;
299 int i;
300 SHORT nIndexType = 0;
301
302 if (bHideAndShow)
303 {
304 ::WinShowWindow(GetHwnd(), FALSE);
305 }
306 ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
307 m_nNumItems = raChoices.GetCount();
308 for (i = 0; i < m_nNumItems; i++)
309 {
310
311 if (m_windowStyle & wxLB_SORT)
312 nIndexType = LIT_SORTASCENDING;
313 else
314 nIndexType = LIT_END;
315 ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)raChoices[i].c_str());
316
317 if (ppClientData)
318 {
319 #if wxUSE_OWNER_DRAWN
320 wxASSERT_MSG(ppClientData[i] == NULL,
321 wxT("Can't use client data with owner-drawn listboxes"));
322 #else // !wxUSE_OWNER_DRAWN
323 ::WinSendMsg(WinUtil_GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(lCount), MPFROMP(ppClientData[i]));
324 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
325 }
326 }
327
328 #if wxUSE_OWNER_DRAWN
329 if ( m_windowStyle & wxLB_OWNERDRAW )
330 {
331 //
332 // First delete old items
333 //
334 WX_CLEAR_ARRAY(m_aItems);
335
336 //
337 // Then create new ones
338 //
339 for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
340 {
341 wxOwnerDrawn* pNewItem = CreateItem(ui);
342
343 pNewItem->SetName(raChoices[ui]);
344 m_aItems.Add(pNewItem);
345 ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(ui), MPFROMP(pNewItem));
346 }
347 }
348 #endif // wxUSE_OWNER_DRAWN
349 ::WinShowWindow(GetHwnd(), TRUE);
350 } // end of wxListBox::DoSetItems
351
352 int wxListBox::FindString(
353 const wxString& rsString
354 ) const
355 {
356 int nPos;
357 LONG lTextLength;
358 PSZ zStr;
359
360
361 for (nPos = 0; nPos < m_nNumItems; nPos++)
362 {
363 lTextLength = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)nPos, (MPARAM)0));
364 zStr = new char[lTextLength + 1];
365 ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT(nPos, (SHORT)lTextLength), (MPARAM)zStr);
366 if (rsString == (char*)zStr)
367 {
368 delete [] zStr;
369 break;
370 }
371 delete [] zStr;
372 }
373 return nPos;
374 } // end of wxListBox::FindString
375
376 void wxListBox::Clear()
377 {
378 #if wxUSE_OWNER_DRAWN
379 size_t lUiCount = m_aItems.Count();
380
381 while (lUiCount-- != 0)
382 {
383 delete m_aItems[lUiCount];
384 }
385
386 m_aItems.Clear();
387 #else // !wxUSE_OWNER_DRAWN
388 if (HasClientObjectData())
389 {
390 for (size_t n = 0; n < (size_t)m_lNumItems; n++)
391 {
392 delete GetClientObject(n);
393 }
394 }
395 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
396 ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
397
398 m_nNumItems = 0;
399 } // end of wxListBox::Clear
400
401 void wxListBox::SetSelection(
402 int N
403 , bool bSelect
404 )
405 {
406 wxCHECK_RET( N >= 0 && N < m_nNumItems,
407 wxT("invalid index in wxListBox::SetSelection") );
408 ::WinSendMsg( GetHwnd()
409 ,LM_SELECTITEM
410 ,MPFROMLONG(N)
411 ,(MPARAM)bSelect
412 );
413 } // end of wxListBox::SetSelection
414
415 bool wxListBox::IsSelected(
416 int N
417 ) const
418 {
419 wxCHECK_MSG( N >= 0 && N < m_nNumItems, FALSE,
420 wxT("invalid index in wxListBox::Selected") );
421
422 LONG lItem;
423
424 lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)N, (MPARAM)0));
425 return (lItem != LIT_NONE);
426 } // end of wxListBox::IsSelected
427
428 wxClientData* wxListBox::DoGetItemClientObject(
429 int n
430 ) const
431 {
432 return (wxClientData *)DoGetItemClientData(n);
433 }
434
435 void* wxListBox::DoGetItemClientData(
436 int n
437 ) const
438 {
439 wxCHECK_MSG( n >= 0 && n < m_nNumItems, NULL,
440 wxT("invalid index in wxListBox::GetClientData") );
441
442 return((void *)::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, MPFROMLONG(n), (MPARAM)0));
443 } // end of wxListBox::DoGetItemClientData
444
445 void wxListBox::DoSetItemClientObject(
446 int n
447 , wxClientData* pClientData
448 )
449 {
450 DoSetItemClientData( n
451 ,pClientData
452 );
453 } // end of wxListBox::DoSetItemClientObject
454
455 void wxListBox::DoSetItemClientData(
456 int n
457 , void* pClientData
458 )
459 {
460 wxCHECK_RET( n >= 0 && n < m_nNumItems,
461 wxT("invalid index in wxListBox::SetClientData") );
462
463 #if wxUSE_OWNER_DRAWN
464 if ( m_windowStyle & wxLB_OWNERDRAW )
465 {
466 //
467 // Client data must be pointer to wxOwnerDrawn, otherwise we would crash
468 // in OnMeasure/OnDraw.
469 //
470 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
471 }
472 #endif // wxUSE_OWNER_DRAWN
473
474 ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(n), MPFROMP(pClientData));
475 } // end of wxListBox::DoSetItemClientData
476
477 bool wxListBox::HasMultipleSelection() const
478 {
479 return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
480 } // end of wxListBox::HasMultipleSelection
481
482 int wxListBox::GetSelections(
483 wxArrayInt& raSelections
484 ) const
485 {
486 int nCount = 0;
487 LONG lItem;
488
489
490 raSelections.Empty();
491 if (HasMultipleSelection())
492 {
493 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
494 ,LM_QUERYSELECTION
495 ,(MPARAM)LIT_FIRST
496 ,(MPARAM)0
497 )
498 );
499 if (lItem != LIT_NONE)
500 {
501 nCount++;
502 while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
503 ,LM_QUERYSELECTION
504 ,(MPARAM)lItem
505 ,(MPARAM)0
506 )
507 )) != LIT_NONE)
508 {
509 nCount++;
510 }
511 raSelections.Alloc(nCount);
512 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
513 ,LM_QUERYSELECTION
514 ,(MPARAM)LIT_FIRST
515 ,(MPARAM)0
516 )
517 );
518
519 raSelections.Add((int)lItem);
520 while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
521 ,LM_QUERYSELECTION
522 ,(MPARAM)lItem
523 ,(MPARAM)0
524 )
525 )) != LIT_NONE)
526 {
527 raSelections.Add((int)lItem);
528 }
529 return nCount;
530 }
531 return 0;
532 }
533 else // single-selection listbox
534 {
535 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
536 ,LM_QUERYSELECTION
537 ,(MPARAM)LIT_FIRST
538 ,(MPARAM)0
539 )
540 );
541 raSelections.Add((int)lItem);
542 return 1;
543 }
544 return 0;
545 } // end of wxListBox::GetSelections
546
547 int wxListBox::GetSelection() const
548 {
549 wxCHECK_MSG( !HasMultipleSelection(),
550 -1,
551 wxT("GetSelection() can't be used with multiple-selection "
552 "listboxes, use GetSelections() instead.") );
553
554 return(LONGFROMMR(::WinSendMsg( GetHwnd()
555 ,LM_QUERYSELECTION
556 ,(MPARAM)LIT_FIRST
557 ,(MPARAM)0
558 )
559 ));
560 } // end of wxListBox::GetSelection
561
562 wxString wxListBox::GetString(
563 int N
564 ) const
565 {
566 LONG lLen = 0;
567 char* zBuf;
568 wxString sResult;
569
570 wxCHECK_MSG( N >= 0 && N < m_nNumItems, "",
571 wxT("invalid index in wxListBox::GetClientData") );
572
573 lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
574 zBuf = new char[lLen + 1];
575 ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf);
576 zBuf[lLen] = '\0';
577 sResult = zBuf;
578 delete [] zBuf;
579 return sResult;
580 } // end of wxListBox::GetString
581
582 void wxListBox::DoInsertItems(
583 const wxArrayString& asItems
584 , int nPos
585 )
586 {
587 wxCHECK_RET( nPos >= 0 && nPos <= m_nNumItems,
588 wxT("invalid index in wxListBox::InsertItems") );
589
590 int nItems = asItems.GetCount();
591
592 for (int i = 0; i < nItems; i++)
593 {
594 int nIndex = (int)::WinSendMsg( GetHwnd()
595 ,LM_INSERTITEM
596 ,MPFROMLONG((LONG)(i + nPos))
597 ,(MPARAM)asItems[i].c_str()
598 );
599
600 wxOwnerDrawn* pNewItem = CreateItem(nIndex);
601
602 pNewItem->SetName(asItems[i]);
603 pNewItem->SetFont(GetFont());
604 m_aItems.Insert(pNewItem, nIndex);
605 ::WinSendMsg( GetHwnd()
606 ,LM_SETITEMHANDLE
607 ,(MPARAM)((SHORT)nIndex)
608 ,MPFROMP(pNewItem)
609 );
610 m_nNumItems += nItems;
611 }
612 } // end of wxListBox::DoInsertItems
613
614 void wxListBox::SetString(
615 int N
616 , const wxString& rsString
617 )
618 {
619 wxCHECK_RET( N >= 0 && N < m_nNumItems,
620 wxT("invalid index in wxListBox::SetString") );
621
622 //
623 // Remember the state of the item
624 //
625 bool bWasSelected = IsSelected(N);
626 void* pOldData = NULL;
627 wxClientData* pOldObjData = NULL;
628
629 if (m_clientDataItemsType == wxClientData_Void)
630 pOldData = GetClientData(N);
631 else if (m_clientDataItemsType == wxClientData_Object)
632 pOldObjData = GetClientObject(N);
633
634 //
635 // Delete and recreate it
636 //
637 ::WinSendMsg( GetHwnd()
638 ,LM_DELETEITEM
639 ,(MPARAM)N
640 ,(MPARAM)0
641 );
642
643 int nNewN = N;
644
645 if (N == m_nNumItems - 1)
646 nNewN = -1;
647
648 ::WinSendMsg( GetHwnd()
649 ,LM_INSERTITEM
650 ,(MPARAM)nNewN
651 ,(MPARAM)rsString.c_str()
652 );
653
654 //
655 // Restore the client data
656 //
657 if (pOldData)
658 SetClientData( N
659 ,pOldData
660 );
661 else if (pOldObjData)
662 SetClientObject( N
663 ,pOldObjData
664 );
665
666 //
667 // We may have lost the selection
668 //
669 if (bWasSelected)
670 Select(N);
671
672 #if wxUSE_OWNER_DRAWN
673 if (m_windowStyle & wxLB_OWNERDRAW)
674 //
675 // Update item's text
676 //
677 m_aItems[N]->SetName(rsString);
678 #endif //USE_OWNER_DRAWN
679 } // end of wxListBox::SetString
680
681 int wxListBox::GetCount() const
682 {
683 return m_nNumItems;
684 }
685
686 // ----------------------------------------------------------------------------
687 // helpers
688 // ----------------------------------------------------------------------------
689
690 wxSize wxListBox::DoGetBestSize() const
691 {
692 //
693 // Find the widest string
694 //
695 int nLine;
696 int nListbox = 0;
697 int nCx;
698 int nCy;
699
700 for (int i = 0; i < m_nNumItems; i++)
701 {
702 wxString vStr(GetString(i));
703
704 GetTextExtent( vStr
705 ,&nLine
706 ,NULL
707 );
708 if (nLine > nListbox)
709 nListbox = nLine;
710 }
711
712 //
713 // Give it some reasonable default value if there are no strings in the
714 // list.
715 //
716 if (nListbox == 0)
717 nListbox = 100;
718
719 //
720 // The listbox should be slightly larger than the widest string
721 //
722 wxGetCharSize( GetHWND()
723 ,&nCx
724 ,&nCy
725 ,(wxFont*)&GetFont()
726 );
727 nListbox += 3 * nCx;
728
729 int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
730
731 return wxSize( nListbox
732 ,hListbox
733 );
734 } // end of wxListBox::DoGetBestSize
735
736 // ----------------------------------------------------------------------------
737 // callbacks
738 // ----------------------------------------------------------------------------
739
740 bool wxListBox::OS2Command(
741 WXUINT uParam
742 , WXWORD WXUNUSED(wId))
743 {
744 wxEventType eEvtType;
745
746 if (uParam == LN_SELECT)
747 {
748 eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED;
749 }
750 if (uParam == LN_ENTER)
751 {
752 eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
753 }
754 else
755 {
756 //
757 // Some event we're not interested in
758 //
759 return FALSE;
760 }
761 wxCommandEvent vEvent( eEvtType
762 ,m_windowId
763 );
764
765 vEvent.SetEventObject(this);
766
767 wxArrayInt aSelections;
768 int n;
769 int nCount = GetSelections(aSelections);
770
771 if (nCount > 0)
772 {
773 n = aSelections[0];
774 if (HasClientObjectData())
775 vEvent.SetClientObject(GetClientObject(n));
776 else if ( HasClientUntypedData() )
777 vEvent.SetClientData(GetClientData(n));
778 vEvent.SetString(GetString(n));
779 }
780 else
781 {
782 n = -1;
783 }
784 vEvent.m_commandInt = n;
785 return GetEventHandler()->ProcessEvent(vEvent);
786 } // end of wxListBox::OS2Command
787
788 // ----------------------------------------------------------------------------
789 // wxCheckListBox support
790 // ----------------------------------------------------------------------------
791
792 #if wxUSE_OWNER_DRAWN
793
794 //
795 // Drawing
796 // -------
797 //
798 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
799
800 bool wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT *item)
801 {
802 //
803 // TODO: Get to this eventually
804 //
805 return TRUE;
806 }
807
808 bool wxListBox::OS2OnDraw(WXDRAWITEMSTRUCT *item)
809 {
810 //
811 // TODO: Get to this eventually
812 //
813 return FALSE;
814 }
815 #endif // ndef for wxUSE_OWNER_DRAWN
816
817 #endif // ndef for wxUSE_LISTBOX
818