]> git.saurik.com Git - wxWidgets.git/blob - src/os2/listbox.cpp
Fixed my utnpaste error (thanks to Marcin Wojdyr
[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 if (GetWindowStyleFlag() & wxLB_EXTENDED)
425 {
426 if (N == 0)
427 lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
428 else
429 lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)(N - 1), (MPARAM)0));
430 }
431 else
432 {
433 lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
434 }
435 return (lItem == (LONG)N && lItem != LIT_NONE);
436 } // end of wxListBox::IsSelected
437
438 wxClientData* wxListBox::DoGetItemClientObject(
439 int n
440 ) const
441 {
442 return (wxClientData *)DoGetItemClientData(n);
443 }
444
445 void* wxListBox::DoGetItemClientData(
446 int n
447 ) const
448 {
449 wxCHECK_MSG( n >= 0 && n < m_nNumItems, NULL,
450 wxT("invalid index in wxListBox::GetClientData") );
451
452 return((void *)::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, MPFROMLONG(n), (MPARAM)0));
453 } // end of wxListBox::DoGetItemClientData
454
455 void wxListBox::DoSetItemClientObject(
456 int n
457 , wxClientData* pClientData
458 )
459 {
460 DoSetItemClientData( n
461 ,pClientData
462 );
463 } // end of wxListBox::DoSetItemClientObject
464
465 void wxListBox::DoSetItemClientData(
466 int n
467 , void* pClientData
468 )
469 {
470 wxCHECK_RET( n >= 0 && n < m_nNumItems,
471 wxT("invalid index in wxListBox::SetClientData") );
472
473 #if wxUSE_OWNER_DRAWN
474 if ( m_windowStyle & wxLB_OWNERDRAW )
475 {
476 //
477 // Client data must be pointer to wxOwnerDrawn, otherwise we would crash
478 // in OnMeasure/OnDraw.
479 //
480 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
481 }
482 #endif // wxUSE_OWNER_DRAWN
483
484 ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(n), MPFROMP(pClientData));
485 } // end of wxListBox::DoSetItemClientData
486
487 bool wxListBox::HasMultipleSelection() const
488 {
489 return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
490 } // end of wxListBox::HasMultipleSelection
491
492 int wxListBox::GetSelections(
493 wxArrayInt& raSelections
494 ) const
495 {
496 int nCount = 0;
497 LONG lItem;
498
499
500 raSelections.Empty();
501 if (HasMultipleSelection())
502 {
503 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
504 ,LM_QUERYSELECTION
505 ,(MPARAM)LIT_FIRST
506 ,(MPARAM)0
507 )
508 );
509 if (lItem != LIT_NONE)
510 {
511 nCount++;
512 while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
513 ,LM_QUERYSELECTION
514 ,(MPARAM)lItem
515 ,(MPARAM)0
516 )
517 )) != LIT_NONE)
518 {
519 nCount++;
520 }
521 raSelections.Alloc(nCount);
522 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
523 ,LM_QUERYSELECTION
524 ,(MPARAM)LIT_FIRST
525 ,(MPARAM)0
526 )
527 );
528
529 raSelections.Add((int)lItem);
530 while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
531 ,LM_QUERYSELECTION
532 ,(MPARAM)lItem
533 ,(MPARAM)0
534 )
535 )) != LIT_NONE)
536 {
537 raSelections.Add((int)lItem);
538 }
539 return nCount;
540 }
541 return 0;
542 }
543 else // single-selection listbox
544 {
545 lItem = LONGFROMMR(::WinSendMsg( GetHwnd()
546 ,LM_QUERYSELECTION
547 ,(MPARAM)LIT_FIRST
548 ,(MPARAM)0
549 )
550 );
551 raSelections.Add((int)lItem);
552 return 1;
553 }
554 return 0;
555 } // end of wxListBox::GetSelections
556
557 int wxListBox::GetSelection() const
558 {
559 wxCHECK_MSG( !HasMultipleSelection(),
560 -1,
561 wxT("GetSelection() can't be used with multiple-selection "
562 "listboxes, use GetSelections() instead.") );
563
564 return(LONGFROMMR(::WinSendMsg( GetHwnd()
565 ,LM_QUERYSELECTION
566 ,(MPARAM)LIT_FIRST
567 ,(MPARAM)0
568 )
569 ));
570 } // end of wxListBox::GetSelection
571
572 wxString wxListBox::GetString(
573 int N
574 ) const
575 {
576 LONG lLen = 0;
577 char* zBuf;
578 wxString sResult;
579
580 wxCHECK_MSG( N >= 0 && N < m_nNumItems, "",
581 wxT("invalid index in wxListBox::GetClientData") );
582
583 lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
584 zBuf = new char[lLen + 1];
585 ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf);
586 zBuf[lLen] = '\0';
587 sResult = zBuf;
588 delete [] zBuf;
589 return sResult;
590 } // end of wxListBox::GetString
591
592 void wxListBox::DoInsertItems(
593 const wxArrayString& asItems
594 , int nPos
595 )
596 {
597 wxCHECK_RET( nPos >= 0 && nPos <= m_nNumItems,
598 wxT("invalid index in wxListBox::InsertItems") );
599
600 int nItems = asItems.GetCount();
601
602 for (int i = 0; i < nItems; i++)
603 {
604 int nIndex = (int)::WinSendMsg( GetHwnd()
605 ,LM_INSERTITEM
606 ,MPFROMLONG((LONG)(i + nPos))
607 ,(MPARAM)asItems[i].c_str()
608 );
609
610 wxOwnerDrawn* pNewItem = CreateItem(nIndex);
611
612 pNewItem->SetName(asItems[i]);
613 pNewItem->SetFont(GetFont());
614 m_aItems.Insert(pNewItem, nIndex);
615 ::WinSendMsg( GetHwnd()
616 ,LM_SETITEMHANDLE
617 ,(MPARAM)((SHORT)nIndex)
618 ,MPFROMP(pNewItem)
619 );
620 m_nNumItems += nItems;
621 }
622 } // end of wxListBox::DoInsertItems
623
624 void wxListBox::SetString(
625 int N
626 , const wxString& rsString
627 )
628 {
629 wxCHECK_RET( N >= 0 && N < m_nNumItems,
630 wxT("invalid index in wxListBox::SetString") );
631
632 //
633 // Remember the state of the item
634 //
635 bool bWasSelected = IsSelected(N);
636 void* pOldData = NULL;
637 wxClientData* pOldObjData = NULL;
638
639 if (m_clientDataItemsType == wxClientData_Void)
640 pOldData = GetClientData(N);
641 else if (m_clientDataItemsType == wxClientData_Object)
642 pOldObjData = GetClientObject(N);
643
644 //
645 // Delete and recreate it
646 //
647 ::WinSendMsg( GetHwnd()
648 ,LM_DELETEITEM
649 ,(MPARAM)N
650 ,(MPARAM)0
651 );
652
653 int nNewN = N;
654
655 if (N == m_nNumItems - 1)
656 nNewN = -1;
657
658 ::WinSendMsg( GetHwnd()
659 ,LM_INSERTITEM
660 ,(MPARAM)nNewN
661 ,(MPARAM)rsString.c_str()
662 );
663
664 //
665 // Restore the client data
666 //
667 if (pOldData)
668 SetClientData( N
669 ,pOldData
670 );
671 else if (pOldObjData)
672 SetClientObject( N
673 ,pOldObjData
674 );
675
676 //
677 // We may have lost the selection
678 //
679 if (bWasSelected)
680 Select(N);
681
682 #if wxUSE_OWNER_DRAWN
683 if (m_windowStyle & wxLB_OWNERDRAW)
684 //
685 // Update item's text
686 //
687 m_aItems[N]->SetName(rsString);
688 #endif //USE_OWNER_DRAWN
689 } // end of wxListBox::SetString
690
691 int wxListBox::GetCount() const
692 {
693 return m_nNumItems;
694 }
695
696 // ----------------------------------------------------------------------------
697 // helpers
698 // ----------------------------------------------------------------------------
699
700 wxSize wxListBox::DoGetBestSize() const
701 {
702 //
703 // Find the widest string
704 //
705 int nLine;
706 int nListbox = 0;
707 int nCx;
708 int nCy;
709
710 for (int i = 0; i < m_nNumItems; i++)
711 {
712 wxString vStr(GetString(i));
713
714 GetTextExtent( vStr
715 ,&nLine
716 ,NULL
717 );
718 if (nLine > nListbox)
719 nListbox = nLine;
720 }
721
722 //
723 // Give it some reasonable default value if there are no strings in the
724 // list.
725 //
726 if (nListbox == 0)
727 nListbox = 100;
728
729 //
730 // The listbox should be slightly larger than the widest string
731 //
732 wxGetCharSize( GetHWND()
733 ,&nCx
734 ,&nCy
735 ,(wxFont*)&GetFont()
736 );
737 nListbox += 3 * nCx;
738
739 int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
740
741 return wxSize( nListbox
742 ,hListbox
743 );
744 } // end of wxListBox::DoGetBestSize
745
746 // ----------------------------------------------------------------------------
747 // callbacks
748 // ----------------------------------------------------------------------------
749
750 bool wxListBox::OS2Command(
751 WXUINT uParam
752 , WXWORD WXUNUSED(wId))
753 {
754 wxEventType eEvtType;
755
756 if (uParam == LN_SELECT)
757 {
758 eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED;
759 }
760 if (uParam == LN_ENTER)
761 {
762 eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
763 }
764 else
765 {
766 //
767 // Some event we're not interested in
768 //
769 return FALSE;
770 }
771 wxCommandEvent vEvent( eEvtType
772 ,m_windowId
773 );
774
775 vEvent.SetEventObject(this);
776
777 wxArrayInt aSelections;
778 int n;
779 int nCount = GetSelections(aSelections);
780
781 if (nCount > 0)
782 {
783 n = aSelections[0];
784 if (HasClientObjectData())
785 vEvent.SetClientObject(GetClientObject(n));
786 else if ( HasClientUntypedData() )
787 vEvent.SetClientData(GetClientData(n));
788 vEvent.SetString(GetString(n));
789 }
790 else
791 {
792 n = -1;
793 }
794 vEvent.m_commandInt = n;
795 return GetEventHandler()->ProcessEvent(vEvent);
796 } // end of wxListBox::OS2Command
797
798 // ----------------------------------------------------------------------------
799 // wxCheckListBox support
800 // ----------------------------------------------------------------------------
801
802 #if wxUSE_OWNER_DRAWN
803
804 //
805 // Drawing
806 // -------
807 //
808 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
809
810 bool wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT *item)
811 {
812 //
813 // TODO: Get to this eventually
814 //
815 return TRUE;
816 }
817
818 bool wxListBox::OS2OnDraw(WXDRAWITEMSTRUCT *item)
819 {
820 //
821 // TODO: Get to this eventually
822 //
823 return FALSE;
824 }
825 #endif // ndef for wxUSE_OWNER_DRAWN
826
827 #endif // ndef for wxUSE_LISTBOX
828