]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/listbox.cpp
removed redundant code
[wxWidgets.git] / src / mac / carbon / listbox.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.cpp
3 // Purpose: wxListBox
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "listbox.h"
14 #endif
15
16 #include "wx/app.h"
17 #include "wx/listbox.h"
18 #include "wx/settings.h"
19 #include "wx/toplevel.h"
20 #include "wx/dynarray.h"
21 #include "wx/log.h"
22
23 #include "wx/utils.h"
24
25 #if !USE_SHARED_LIBRARY
26 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
27
28 BEGIN_EVENT_TABLE(wxListBox, wxControl)
29 EVT_SIZE( wxListBox::OnSize )
30 END_EVENT_TABLE()
31 #endif
32
33 #include "wx/mac/uma.h"
34
35
36 typedef struct {
37 unsigned short instruction;
38 void (*function)();
39 } ldefRec, *ldefPtr, **ldefHandle;
40
41 extern "C"
42 {
43 static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
44 Cell cell, short dataOffset, short dataLength,
45 ListHandle listHandle ) ;
46 }
47
48 static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect,
49 Cell cell, short dataOffset, short dataLength,
50 ListHandle listHandle )
51 {
52 FontInfo fontInfo;
53 GrafPtr savePort;
54 GrafPtr grafPtr;
55 RgnHandle savedClipRegion;
56 SInt32 savedPenMode;
57 wxListBox* list;
58 GetPort(&savePort);
59 SetPort((**listHandle).port);
60 grafPtr = (**listHandle).port ;
61 // typecast our refCon
62 list = (wxListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
63
64 // Calculate the cell rect.
65
66 switch( message ) {
67 case lInitMsg:
68 break;
69
70 case lCloseMsg:
71 break;
72
73 case lDrawMsg:
74 {
75 const wxString text = list->m_stringArray[cell.v] ;
76
77 // Save the current clip region, and set the clip region to the area we are about
78 // to draw.
79
80 savedClipRegion = NewRgn();
81 GetClip( savedClipRegion );
82
83 ClipRect( drawRect );
84 EraseRect( drawRect );
85
86 MoveTo(drawRect->left + 4 , drawRect->top + 10 );
87 ::TextFont( kFontIDMonaco ) ;
88 ::TextSize( 9 );
89 ::TextFace( 0 ) ;
90
91 DrawText(text, 0 , text.Length());
92 // If the cell is hilited, do the hilite now. Paint the cell contents with the
93 // appropriate QuickDraw transform mode.
94
95 if( isSelected ) {
96 savedPenMode = GetPortPenMode( grafPtr );
97 SetPortPenMode( grafPtr, hilitetransfermode );
98 PaintRect( drawRect );
99 SetPortPenMode( grafPtr, savedPenMode );
100 }
101
102 // Restore the saved clip region.
103
104 SetClip( savedClipRegion );
105 DisposeRgn( savedClipRegion );
106 }
107 break;
108 case lHiliteMsg:
109
110 // Hilite or unhilite the cell. Paint the cell contents with the
111 // appropriate QuickDraw transform mode.
112
113 GetPort( &grafPtr );
114 savedPenMode = GetPortPenMode( grafPtr );
115 SetPortPenMode( grafPtr, hilitetransfermode );
116 PaintRect( drawRect );
117 SetPortPenMode( grafPtr, savedPenMode );
118 break;
119 default :
120 break ;
121 }
122 SetPort(savePort);
123 }
124
125 extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
126 const short kwxMacListWithVerticalScrollbar = 128 ;
127
128 // ============================================================================
129 // list box control implementation
130 // ============================================================================
131
132 // Listbox item
133 wxListBox::wxListBox()
134 {
135 m_noItems = 0;
136 m_selected = 0;
137 m_macList = NULL ;
138 }
139
140 static ListDefUPP macListDefUPP = NULL ;
141
142 bool wxListBox::Create(wxWindow *parent, wxWindowID id,
143 const wxPoint& pos,
144 const wxSize& size,
145 int n, const wxString choices[],
146 long style,
147 const wxValidator& validator,
148 const wxString& name)
149 {
150 m_noItems = 0 ; // this will be increased by our append command
151 m_selected = 0;
152
153 Rect bounds ;
154 Str255 title ;
155
156 MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
157
158 ListDefSpec listDef;
159 listDef.defType = kListDefUserProcType;
160 if ( macListDefUPP == NULL )
161 {
162 macListDefUPP = NewListDefUPP( wxMacListDefinition );
163 }
164 listDef.u.userProc = macListDefUPP ;
165 #if TARGET_CARBON
166 Size asize;
167
168
169 CreateListBoxControl( parent->MacGetRootWindow(), &bounds, false, 0, 1, false, true,
170 14, 14, false, &listDef, &m_macControl );
171
172 GetControlData(m_macControl, kControlNoPart, kControlListBoxListHandleTag,
173 sizeof(ListHandle), (Ptr) &m_macList, &asize);
174
175 SetControlReference(m_macControl, (long) this);
176 SetControlVisibility(m_macControl, false, false);
177
178 #else
179 long result ;
180
181 m_macControl = ::NewControl( parent->MacGetRootWindow() , &bounds , title , false ,
182 kwxMacListWithVerticalScrollbar , 0 , 0,
183 kControlListBoxProc , (long) this ) ;
184 ::GetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
185 sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
186
187 HLock( (Handle) m_macList ) ;
188 ldefHandle ldef ;
189 ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ;
190 if ( (**m_macList).listDefProc != NULL )
191 {
192 (**ldef).instruction = 0x4EF9; /* JMP instruction */
193 (**ldef).function = (void(*)()) listDef.u.userProc;
194 (**m_macList).listDefProc = (Handle) ldef ;
195 }
196
197 Point pt = (**m_macList).cellSize ;
198 pt.v = 14 ;
199 LCellSize( pt , m_macList ) ;
200
201 LAddColumn( 1 , 0 , m_macList ) ;
202 #endif
203 OptionBits options = 0;
204 if ( style & wxLB_MULTIPLE )
205 {
206 options += lNoExtend ;
207 }
208 else if ( style & wxLB_EXTENDED )
209 {
210 options += lExtendDrag ;
211 }
212 else
213 {
214 options = lOnlyOne ;
215 }
216 SetListSelectionFlags(m_macList, options);
217
218 MacPostControlCreate() ;
219
220 for ( int i = 0 ; i < n ; i++ )
221 {
222 Append( choices[i] ) ;
223 }
224
225 LSetDrawingMode( true , m_macList ) ;
226
227 return TRUE;
228 }
229
230 wxListBox::~wxListBox()
231 {
232 Free() ;
233 if ( m_macList )
234 {
235 #if !TARGET_CARBON
236 DisposeHandle( (**m_macList).listDefProc ) ;
237 (**m_macList).listDefProc = NULL ;
238 #endif
239 m_macList = NULL ;
240 }
241 }
242
243 void wxListBox::Free()
244 {
245 #if wxUSE_OWNER_DRAWN
246 if ( m_windowStyle & wxLB_OWNERDRAW )
247 {
248 size_t uiCount = m_aItems.Count();
249 while ( uiCount-- != 0 ) {
250 delete m_aItems[uiCount];
251 }
252
253 m_aItems.Clear();
254 }
255 else
256 #endif // wxUSE_OWNER_DRAWN
257 if ( HasClientObjectData() )
258 {
259 for ( size_t n = 0; n < (size_t)m_noItems; n++ )
260 {
261 delete GetClientObject(n);
262 }
263 }
264 }
265
266 void wxListBox::DoSetSize(int x, int y,
267 int width, int height,
268 int sizeFlags )
269 {
270 wxControl::DoSetSize( x , y , width , height , sizeFlags ) ;
271 #if TARGET_CARBON
272 Rect bounds ;
273 GetControlBounds( m_macControl , &bounds ) ;
274 ControlRef control = GetListVerticalScrollBar( m_macList ) ;
275 if ( control )
276 {
277 Rect scrollbounds ;
278 GetControlBounds( control , &scrollbounds ) ;
279 if( scrollbounds.right != bounds.right + 1 )
280 {
281 UMAMoveControl( control , bounds.right - (scrollbounds.right - scrollbounds.left) + 1 ,
282 scrollbounds.top ) ;
283 }
284 }
285 #endif
286 }
287 void wxListBox::DoSetFirstItem(int N)
288 {
289 MacScrollTo( N ) ;
290 }
291
292 void wxListBox::Delete(int N)
293 {
294 wxCHECK_RET( N >= 0 && N < m_noItems,
295 wxT("invalid index in wxListBox::Delete") );
296
297 #if wxUSE_OWNER_DRAWN
298 delete m_aItems[N];
299 m_aItems.RemoveAt(N);
300 #else // !wxUSE_OWNER_DRAWN
301 if ( HasClientObjectData() )
302 {
303 delete GetClientObject(N);
304 }
305 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
306 m_stringArray.Remove( N ) ;
307 m_dataArray.RemoveAt( N ) ;
308 m_noItems --;
309
310 MacDelete( N ) ;
311 }
312
313 int wxListBox::DoAppend(const wxString& item)
314 {
315 int index = m_noItems ;
316 if( wxApp::s_macDefaultEncodingIsPC )
317 {
318 m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
319 m_dataArray.Add( NULL );
320 }
321 else {
322 m_stringArray.Add( item ) ;
323 m_dataArray.Add( NULL );
324 }
325 m_noItems ++;
326 DoSetItemClientData( index , NULL ) ;
327 MacAppend( item ) ;
328
329 return index ;
330 }
331
332 void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
333 {
334 MacSetRedraw( false ) ;
335 Clear() ;
336 int n = choices.GetCount();
337
338 for( int i = 0 ; i < n ; ++i )
339 {
340 if ( clientData )
341 {
342 #if wxUSE_OWNER_DRAWN
343 wxASSERT_MSG(clientData[i] == NULL,
344 wxT("Can't use client data with owner-drawn listboxes"));
345 #else // !wxUSE_OWNER_DRAWN
346 Append( choices[i] , clientData[i] ) ;
347 #endif
348 }
349 else
350 Append( choices[i] ) ;
351 }
352
353 #if wxUSE_OWNER_DRAWN
354 if ( m_windowStyle & wxLB_OWNERDRAW ) {
355 // first delete old items
356 size_t ui = m_aItems.Count();
357 while ( ui-- != 0 ) {
358 delete m_aItems[ui];
359 }
360 m_aItems.Empty();
361
362 // then create new ones
363 for ( ui = 0; ui < (size_t)m_noItems; ui++ ) {
364 wxOwnerDrawn *pNewItem = CreateItem(ui);
365 pNewItem->SetName(choices[ui]);
366 m_aItems.Add(pNewItem);
367 }
368 }
369 #endif // wxUSE_OWNER_DRAWN
370 MacSetRedraw( true ) ;
371 }
372
373 bool wxListBox::HasMultipleSelection() const
374 {
375 return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
376 }
377
378 int wxListBox::FindString(const wxString& st) const
379 {
380 wxString s ;
381 if( wxApp::s_macDefaultEncodingIsPC )
382 {
383 s = wxMacMakeMacStringFromPC( st ) ;
384 }
385 else
386 s = st ;
387
388 if ( s.Right(1) == "*" )
389 {
390 wxString search = s.Left( s.Length() - 1 ) ;
391 int len = search.Length() ;
392 Str255 s1 , s2 ;
393
394 #if TARGET_CARBON
395 c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
396 #else
397 strcpy( (char *) s2 , search.c_str() ) ;
398 c2pstr( (char *) s2 ) ;
399 #endif
400
401 for ( int i = 0 ; i < m_noItems ; ++ i )
402 {
403 #if TARGET_CARBON
404 c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
405 #else
406 strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
407 c2pstr( (char *) s1 ) ;
408 #endif
409 if ( EqualString( s1 , s2 , false , false ) )
410 return i ;
411 }
412 if ( s.Left(1) == "*" && s.Length() > 1 )
413 {
414 s.MakeLower() ;
415 for ( int i = 0 ; i < m_noItems ; ++i )
416 {
417 if ( GetString(i).Lower().Matches(s) )
418 return i ;
419 }
420 }
421
422 }
423 else
424 {
425 Str255 s1 , s2 ;
426
427 #if TARGET_CARBON
428 c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
429 #else
430 strcpy( (char *) s2 , s.c_str() ) ;
431 c2pstr( (char *) s2 ) ;
432 #endif
433
434 for ( int i = 0 ; i < m_noItems ; ++ i )
435 {
436 #if TARGET_CARBON
437 c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
438 #else
439 strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
440 c2pstr( (char *) s1 ) ;
441 #endif
442 if ( EqualString( s1 , s2 , false , false ) )
443 return i ;
444 }
445 }
446 return -1;
447 }
448
449 void wxListBox::Clear()
450 {
451 Free();
452 m_noItems = 0;
453 m_stringArray.Empty() ;
454 m_dataArray.Empty() ;
455 MacClear() ;
456 }
457
458 void wxListBox::SetSelection(int N, bool select)
459 {
460 wxCHECK_RET( N >= 0 && N < m_noItems,
461 "invalid index in wxListBox::SetSelection" );
462 MacSetSelection( N , select ) ;
463 GetSelections( m_selectionPreImage ) ;
464 }
465
466 bool wxListBox::IsSelected(int N) const
467 {
468 wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
469 "invalid index in wxListBox::Selected" );
470
471 return MacIsSelected( N ) ;
472 }
473
474 void *wxListBox::DoGetItemClientData(int N) const
475 {
476 wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
477 wxT("invalid index in wxListBox::GetClientData"));
478
479 return (void *)m_dataArray[N];
480 }
481
482 wxClientData *wxListBox::DoGetItemClientObject(int N) const
483 {
484 return (wxClientData *) DoGetItemClientData( N ) ;
485 }
486
487 void wxListBox::DoSetItemClientData(int N, void *Client_data)
488 {
489 wxCHECK_RET( N >= 0 && N < m_noItems,
490 "invalid index in wxListBox::SetClientData" );
491
492 #if wxUSE_OWNER_DRAWN
493 if ( m_windowStyle & wxLB_OWNERDRAW )
494 {
495 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
496 // in OnMeasure/OnDraw.
497 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
498 }
499 #endif // wxUSE_OWNER_DRAWN
500 wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
501
502 if ( m_dataArray.GetCount() > N )
503 {
504 m_dataArray[N] = (char*) Client_data ;
505 }
506 else
507 {
508 m_dataArray.Add( (char*) Client_data ) ;
509 }
510 }
511
512 void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
513 {
514 DoSetItemClientData(n, clientData);
515 }
516
517 // Return number of selections and an array of selected integers
518 int wxListBox::GetSelections(wxArrayInt& aSelections) const
519 {
520 return MacGetSelections( aSelections ) ;
521 }
522
523 // Get single selection, for single choice list items
524 int wxListBox::GetSelection() const
525 {
526 return MacGetSelection() ;
527 }
528
529 // Find string for position
530 wxString wxListBox::GetString(int N) const
531 {
532 if( wxApp::s_macDefaultEncodingIsPC )
533 {
534 return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
535 }
536 else
537 return m_stringArray[N] ;
538 }
539
540 void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
541 {
542 wxCHECK_RET( pos >= 0 && pos <= m_noItems,
543 wxT("invalid index in wxListBox::InsertItems") );
544
545 int nItems = items.GetCount();
546
547 for ( int i = 0 ; i < nItems ; i++ )
548 {
549 m_stringArray.Insert( items[i] , pos + i ) ;
550 m_dataArray.Insert( NULL , pos + i ) ;
551 MacInsert( pos + i , items[i] ) ;
552 }
553
554 m_noItems += nItems;
555 }
556
557 void wxListBox::SetString(int N, const wxString& s)
558 {
559 wxString str ;
560 if( wxApp::s_macDefaultEncodingIsPC )
561 {
562 str = wxMacMakeMacStringFromPC( s ) ;
563 }
564 else
565 str = s ;
566 m_stringArray[N] = str ;
567 MacSet( N , s ) ;
568 }
569
570 wxSize wxListBox::DoGetBestSize() const
571 {
572 return wxSize(100, 100);
573 }
574
575 int wxListBox::GetCount() const
576 {
577 return m_noItems;
578 }
579
580 void wxListBox::SetupColours()
581 {
582 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
583 SetForegroundColour(GetParent()->GetForegroundColour());
584 }
585
586 void wxListBox::Refresh(bool eraseBack, const wxRect *rect)
587 {
588 // Set up port
589 WindowRef rootwindow = MacGetRootWindow() ;
590 wxWindow* wxrootwindow = wxFindWinFromMacWindow( rootwindow ) ;
591 wxMacDrawingHelper focus( wxrootwindow );
592
593 UMADrawControl(m_macControl);
594 }
595
596 #if wxUSE_OWNER_DRAWN
597
598 class wxListBoxItem : public wxOwnerDrawn
599 {
600 public:
601 wxListBoxItem(const wxString& str = "");
602 };
603
604 wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
605 {
606 // no bitmaps/checkmarks
607 SetMarginWidth(0);
608 }
609
610 wxOwnerDrawn *wxListBox::CreateItem(size_t n)
611 {
612 return new wxListBoxItem();
613 }
614
615 #endif //USE_OWNER_DRAWN
616
617 // ============================================================================
618 // list box control implementation
619 // ============================================================================
620
621 void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
622 {
623 wxListBox* list;
624 // typecast our refCon
625 list = (wxListBox*)refCon;
626
627 MoveTo(cellRect->left + 4 , cellRect->top + 10 );
628 const wxString text = list->m_stringArray[lCell.v] ;
629 ::TextFont( kFontIDMonaco ) ;
630 ::TextSize( 9 );
631 ::TextFace( 0 ) ;
632 DrawText(text, 0 , text.Length());
633
634 }
635
636 void wxListBox::MacDelete( int N )
637 {
638 LDelRow( 1 , N , m_macList) ;
639 Refresh();
640 }
641
642 void wxListBox::MacInsert( int n , const char * text)
643 {
644 Cell cell = { 0 , 0 } ;
645 cell.v = n ;
646 LAddRow( 1 , cell.v , m_macList ) ;
647 // LSetCell(text, strlen(text), cell, m_macList);
648 Refresh();
649 }
650
651 void wxListBox::MacAppend( const char * text)
652 {
653 Cell cell = { 0 , 0 } ;
654 cell.v = (**m_macList).dataBounds.bottom ;
655 LAddRow( 1 , cell.v , m_macList ) ;
656 // LSetCell(text, strlen(text), cell, m_macList);
657 Refresh();
658 }
659
660 void wxListBox::MacClear()
661 {
662 LDelRow( (**m_macList).dataBounds.bottom , 0 , m_macList ) ;
663 Refresh();
664 }
665
666 void wxListBox::MacSetSelection( int n , bool select )
667 {
668 Cell cell = { 0 , 0 } ;
669 if ( ! (m_windowStyle & wxLB_MULTIPLE) )
670 {
671 if ( LGetSelect( true , &cell , m_macList ) )
672 {
673 LSetSelect( false , cell , m_macList ) ;
674 }
675 }
676
677 cell.v = n ;
678 LSetSelect( select , cell , m_macList ) ;
679 LAutoScroll( m_macList ) ;
680 Refresh();
681 }
682
683 bool wxListBox::MacIsSelected( int n ) const
684 {
685 Cell cell = { 0 , 0 } ;
686 cell.v = n ;
687 return LGetSelect( false , &cell , m_macList ) ;
688 }
689
690 void wxListBox::MacDestroy()
691 {
692 // DisposeExtLDEFInfo( m_macList ) ;
693 }
694
695 int wxListBox::MacGetSelection() const
696 {
697 Cell cell = { 0 , 0 } ;
698 if ( LGetSelect( true , &cell , m_macList ) )
699 return cell.v ;
700 else
701 return -1 ;
702 }
703
704 int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
705 {
706 int no_sel = 0 ;
707
708 aSelections.Empty();
709
710 Cell cell = { 0 , 0 } ;
711 cell.v = 0 ;
712
713 while ( LGetSelect( true , &cell , m_macList ) )
714 {
715 aSelections.Add( cell.v ) ;
716 no_sel++ ;
717 cell.v++ ;
718 }
719 return no_sel ;
720 }
721
722 void wxListBox::MacSet( int n , const char * text )
723 {
724 // our implementation does not store anything in the list
725 // so we just have to redraw
726 Cell cell = { 0 , 0 } ;
727 cell.v = n ;
728 // LSetCell(text, strlen(text), cell, m_macList);
729 Refresh();
730 }
731
732 void wxListBox::MacScrollTo( int n )
733 {
734 // TODO implement scrolling
735 }
736
737 void wxListBox::OnSize( const wxSizeEvent &event)
738 {
739 Point pt;
740
741 #if TARGET_CARBON
742 GetListCellSize(m_macList, &pt);
743 #else
744 pt = (**m_macList).cellSize ;
745 #endif
746 pt.h = m_width - 15 ;
747 LCellSize( pt , m_macList ) ;
748 }
749
750 void wxListBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
751 {
752 Boolean wasDoubleClick = false ;
753 long result ;
754
755 ::GetControlData( m_macControl , kControlNoPart , kControlListBoxDoubleClickTag , sizeof( wasDoubleClick ) , (char*) &wasDoubleClick , &result ) ;
756 if ( !wasDoubleClick )
757 {
758 MacDoClick() ;
759 }
760 else
761 {
762 MacDoDoubleClick() ;
763 }
764 }
765
766 void wxListBox::MacSetRedraw( bool doDraw )
767 {
768 LSetDrawingMode( doDraw , m_macList ) ;
769
770 }
771
772 void wxListBox::MacDoClick()
773 {
774 wxArrayInt aSelections;
775 int n, count = GetSelections(aSelections);
776
777 if ( count == m_selectionPreImage.GetCount() )
778 {
779 bool hasChanged = false ;
780 for ( int i = 0 ; i < count ; ++i )
781 {
782 if ( aSelections[i] != m_selectionPreImage[i] )
783 {
784 hasChanged = true ;
785 break ;
786 }
787 }
788 if ( !hasChanged )
789 {
790 return ;
791 }
792 }
793
794 m_selectionPreImage = aSelections;
795
796 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
797 event.SetEventObject( this );
798
799 if ( count > 0 )
800 {
801 n = aSelections[0];
802 if ( HasClientObjectData() )
803 event.SetClientObject( GetClientObject(n) );
804 else if ( HasClientUntypedData() )
805 event.SetClientData( GetClientData(n) );
806 event.SetString( GetString(n) );
807 }
808 else
809 {
810 n = -1;
811 }
812
813 event.m_commandInt = n;
814
815 GetEventHandler()->ProcessEvent(event);
816 }
817
818 void wxListBox::MacDoDoubleClick()
819 {
820 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
821 event.SetEventObject( this );
822 GetEventHandler()->ProcessEvent(event) ;
823 }