1 ///////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "listbox.h"
17 #include "wx/listbox.h"
18 #include "wx/button.h"
19 #include "wx/settings.h"
20 #include "wx/toplevel.h"
21 #include "wx/dynarray.h"
26 #if !USE_SHARED_LIBRARY
27 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
29 BEGIN_EVENT_TABLE(wxListBox
, wxControl
)
30 #if !TARGET_API_MAC_OSX
31 EVT_SIZE( wxListBox::OnSize
)
32 EVT_CHAR( wxListBox::OnChar
)
37 #include "wx/mac/uma.h"
39 #if TARGET_API_MAC_OSX
41 // new databrowserbased version
44 wxListBox::wxListBox()
51 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
54 const wxArrayString
& choices
,
56 const wxValidator
& validator
,
59 wxCArrayString
chs(choices
);
61 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
62 style
, validator
, name
);
65 static pascal OSStatus
ListBoxGetSetItemData(ControlRef browser
,
66 DataBrowserItemID itemID
, DataBrowserPropertyID property
,
67 DataBrowserItemDataRef itemData
, Boolean changeValue
)
69 OSStatus err
= errDataBrowserPropertyNotSupported
;
78 long ref
= GetControlReference( browser
) ;
81 wxListBox
* list
= wxDynamicCast( ref
, wxListBox
) ;
82 for ( size_t i
= 0 ; i
< list
->m_idArray
.GetCount() ; ++i
)
83 if ( list
->m_idArray
[i
] == (long) itemID
)
85 wxMacCFStringHolder
cf( list
->GetString(i
) , list
->GetFont().GetEncoding() ) ;
86 verify_noerr( ::SetDataBrowserItemDataText( itemData
, cf
) ) ;
102 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
105 int n
, const wxString choices
[],
107 const wxValidator
& validator
,
108 const wxString
& name
)
110 m_macIsUserPane
= FALSE
;
112 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
115 m_noItems
= 0 ; // this will be increased by our append command
120 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
123 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, (ControlRef
*)&m_macControl
) );
124 browser
= (ControlRef
) m_macControl
;
126 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
127 if ( style
& wxLB_MULTIPLE
)
129 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
131 else if ( style
& wxLB_EXTENDED
)
137 options
+= kDataBrowserSelectOnlyOne
;
139 verify_noerr(SetDataBrowserSelectionFlags (browser
, options
) );
141 DataBrowserListViewColumnDesc columnDesc
;
142 columnDesc
.headerBtnDesc
.titleOffset
= 0;
143 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
145 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
146 kControlUseFontMask
| kControlUseJustMask
;
148 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
149 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
150 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
151 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
152 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
154 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
155 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
156 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
158 columnDesc
.propertyDesc
.propertyID
= 1024;
159 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
160 columnDesc
.propertyDesc
.propertyFlags
=
161 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
162 kDataBrowserListViewTypeSelectColumn
|
164 kDataBrowserTableViewSelectionColumn
;
167 verify_noerr(::AddDataBrowserListViewColumn(browser
, &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
168 verify_noerr(::AutoSizeDataBrowserListViewColumns( browser
) ) ;
169 verify_noerr(::SetDataBrowserHasScrollBars( browser
, false , true ) ) ;
170 verify_noerr(::SetDataBrowserTableViewHiliteStyle( browser
, kDataBrowserTableViewFillHilite
) ) ;
171 verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( browser
, 0 ) ) ;
172 DataBrowserCallbacks callbacks
;
174 callbacks
.version
= kDataBrowserLatestCallbacks
;
176 InitDataBrowserCallbacks(&callbacks
);
178 callbacks
.u
.v1
.itemDataCallback
=
179 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
181 SetDataBrowserCallbacks(browser
, &callbacks
);
183 MacPostControlCreate(pos
,size
) ;
185 for ( int i
= 0 ; i
< n
; i
++ )
187 Append( choices
[i
] ) ;
193 wxListBox::~wxListBox()
195 SetControlReference( (ControlRef
) m_macControl
, NULL
) ;
197 // avoid access during destruction
204 void wxListBox::FreeData()
206 #if wxUSE_OWNER_DRAWN
207 if ( m_windowStyle
& wxLB_OWNERDRAW
)
209 size_t uiCount
= m_aItems
.Count();
210 while ( uiCount
-- != 0 ) {
211 delete m_aItems
[uiCount
];
212 m_aItems
[uiCount
] = NULL
;
218 #endif // wxUSE_OWNER_DRAWN
219 if ( HasClientObjectData() )
221 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
223 delete GetClientObject(n
);
228 void wxListBox::DoSetSize(int x
, int y
,
229 int width
, int height
,
232 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
235 void wxListBox::DoSetFirstItem(int N
)
240 void wxListBox::Delete(int N
)
242 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
243 wxT("invalid index in wxListBox::Delete") );
245 #if wxUSE_OWNER_DRAWN
247 m_aItems
.RemoveAt(N
);
248 #else // !wxUSE_OWNER_DRAWN
249 if ( HasClientObjectData() )
251 delete GetClientObject(N
);
253 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
254 m_stringArray
.RemoveAt( N
) ;
255 m_dataArray
.RemoveAt( N
) ;
261 int wxListBox::DoAppend(const wxString
& item
)
263 int index
= m_noItems
;
264 m_stringArray
.Add( item
) ;
265 m_dataArray
.Add( NULL
);
267 DoSetItemClientData( index
, NULL
) ;
273 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
276 int n
= choices
.GetCount();
278 for( int i
= 0 ; i
< n
; ++i
)
282 #if wxUSE_OWNER_DRAWN
283 wxASSERT_MSG(clientData
[i
] == NULL
,
284 wxT("Can't use client data with owner-drawn listboxes"));
285 #else // !wxUSE_OWNER_DRAWN
286 Append( choices
[i
] , clientData
[i
] ) ;
290 Append( choices
[i
] ) ;
293 #if wxUSE_OWNER_DRAWN
294 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
295 // first delete old items
296 size_t ui
= m_aItems
.Count();
297 while ( ui
-- != 0 ) {
303 // then create new ones
304 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
305 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
306 pNewItem
->SetName(choices
[ui
]);
307 m_aItems
.Add(pNewItem
);
310 #endif // wxUSE_OWNER_DRAWN
313 bool wxListBox::HasMultipleSelection() const
315 return (m_windowStyle
& wxLB_MULTIPLE
) || (m_windowStyle
& wxLB_EXTENDED
);
318 int wxListBox::FindString(const wxString
& s
) const
321 if ( s
.Right(1) == wxT("*") )
323 wxString search
= s
.Left( s
.Length() - 1 ) ;
324 int len
= search
.Length() ;
326 wxMacStringToPascal( search
, s2
) ;
328 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
330 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
332 if ( EqualString( s1
, s2
, false , false ) )
335 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
339 for ( int i
= 0 ; i
< m_noItems
; ++i
)
341 if ( GetString(i
).Lower().Matches(st
) )
351 wxMacStringToPascal( s
, s2
) ;
353 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
355 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
357 if ( EqualString( s1
, s2
, false , false ) )
364 void wxListBox::Clear()
368 m_stringArray
.Empty() ;
369 m_dataArray
.Empty() ;
373 void wxListBox::SetSelection(int N
, bool select
)
375 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
376 wxT("invalid index in wxListBox::SetSelection") );
377 MacSetSelection( N
, select
) ;
378 GetSelections( m_selectionPreImage
) ;
381 bool wxListBox::IsSelected(int N
) const
383 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
384 wxT("invalid index in wxListBox::Selected") );
386 return MacIsSelected( N
) ;
389 void *wxListBox::DoGetItemClientData(int N
) const
391 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
392 wxT("invalid index in wxListBox::GetClientData"));
394 return (void *)m_dataArray
[N
];
397 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
399 return (wxClientData
*) DoGetItemClientData( N
) ;
402 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
404 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
405 wxT("invalid index in wxListBox::SetClientData") );
407 #if wxUSE_OWNER_DRAWN
408 if ( m_windowStyle
& wxLB_OWNERDRAW
)
410 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
411 // in OnMeasure/OnDraw.
412 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
414 #endif // wxUSE_OWNER_DRAWN
415 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
417 if ( m_dataArray
.GetCount() > (size_t) N
)
419 m_dataArray
[N
] = (char*) Client_data
;
423 m_dataArray
.Add( (char*) Client_data
) ;
427 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
429 DoSetItemClientData(n
, clientData
);
432 // Return number of selections and an array of selected integers
433 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
435 return MacGetSelections( aSelections
) ;
438 // Get single selection, for single choice list items
439 int wxListBox::GetSelection() const
441 return MacGetSelection() ;
444 // Find string for position
445 wxString
wxListBox::GetString(int N
) const
447 return m_stringArray
[N
] ;
450 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
452 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
453 wxT("invalid index in wxListBox::InsertItems") );
455 int nItems
= items
.GetCount();
457 for ( int i
= 0 ; i
< nItems
; i
++ )
459 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
460 m_dataArray
.Insert( NULL
, pos
+ i
) ;
461 MacInsert( pos
+ i
, items
[i
] ) ;
467 void wxListBox::SetString(int N
, const wxString
& s
)
469 m_stringArray
[N
] = s
;
473 wxSize
wxListBox::DoGetBestSize() const
475 int lbWidth
= 100; // some defaults
480 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
484 ::TextFont( m_font
.MacGetFontNum() ) ;
485 ::TextSize( m_font
.MacGetFontSize() ) ;
486 ::TextFace( m_font
.MacGetFontStyle() ) ;
490 ::TextFont( kFontIDMonaco
) ;
495 // Find the widest line
496 for(int i
= 0; i
< GetCount(); i
++) {
497 wxString
str(GetString(i
));
501 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
502 kThemeCurrentPortFont
,
509 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
511 lbWidth
= wxMax(lbWidth
, wLine
);
514 // Add room for the scrollbar
515 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
517 // And just a bit more
519 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
522 // don't make the listbox too tall (limit height to around 10 items) but don't
523 // make it too small neither
524 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
527 return wxSize(lbWidth
, lbHeight
);
530 int wxListBox::GetCount() const
535 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
537 wxControl::Refresh( eraseBack
, rect
) ;
538 // MacRedrawControl() ;
541 #if wxUSE_OWNER_DRAWN
543 class wxListBoxItem
: public wxOwnerDrawn
546 wxListBoxItem(const wxString
& str
= "");
549 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
551 // no bitmaps/checkmarks
555 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
557 return new wxListBoxItem();
560 #endif //USE_OWNER_DRAWN
562 // ============================================================================
563 // list box control implementation
564 // ============================================================================
566 void wxListBox::MacDelete( int N
)
568 UInt32 id
= m_idArray
[N
] ;
569 verify_noerr(::RemoveDataBrowserItems((ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
570 m_idArray
.RemoveAt( N
) ;
573 void wxListBox::MacInsert( int n
, const wxString
& text
)
575 verify_noerr(::AddDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &m_nextId
, kDataBrowserItemNoProperty
) ) ;
576 m_idArray
.Insert( m_nextId
, n
) ;
580 void wxListBox::MacAppend( const wxString
& text
)
582 verify_noerr(::AddDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &m_nextId
, kDataBrowserItemNoProperty
) ) ;
583 m_idArray
.Add( m_nextId
) ;
587 void wxListBox::MacClear()
589 verify_noerr(::RemoveDataBrowserItems((ControlRef
) m_macControl
, kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
590 m_dataArray
.Empty() ;
593 void wxListBox::MacSetSelection( int n
, bool select
)
595 UInt32 id
= m_idArray
[n
] ;
596 if ( ::IsDataBrowserItemSelected( (ControlRef
) m_macControl
, id
) != select
)
598 verify_noerr(::SetDataBrowserSelectedItems((ControlRef
) m_macControl
, 1 , & id
, kDataBrowserItemsToggle
) ) ;
603 bool wxListBox::MacIsSelected( int n
) const
605 return ::IsDataBrowserItemSelected( (ControlRef
) m_macControl
, m_idArray
[n
] ) ;
608 int wxListBox::MacGetSelection() const
610 for ( size_t i
= 0 ; i
< m_idArray
.GetCount() ; ++i
)
612 if ( ::IsDataBrowserItemSelected((ControlRef
) m_macControl
, m_idArray
[i
] ) )
620 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
625 for ( size_t i
= 0 ; i
< m_idArray
.GetCount() ; ++i
)
627 if ( ::IsDataBrowserItemSelected((ControlRef
) m_macControl
, m_idArray
[i
] ) )
629 aSelections
.Add( i
) ;
636 void wxListBox::MacSet( int n
, const wxString
& text
)
638 // as we don't store the strings we only have to issue a redraw
639 UInt32 id
= m_idArray
[n
] ;
640 verify_noerr( ::UpdateDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
643 void wxListBox::MacScrollTo( int n
)
645 // TODO implement scrolling
648 void wxListBox::OnSize( wxSizeEvent
&event
)
652 void wxListBox::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
654 Boolean wasDoubleClick
= false ;
657 ::GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxDoubleClickTag
, sizeof( wasDoubleClick
) , (char*) &wasDoubleClick
, &result
) ;
658 if ( !wasDoubleClick
)
668 void wxListBox::MacSetRedraw( bool doDraw
)
670 // nothing to do in compositing mode
673 void wxListBox::MacDoClick()
675 wxArrayInt aSelections
;
677 size_t count
= GetSelections(aSelections
);
679 if ( count
== m_selectionPreImage
.GetCount() )
681 bool hasChanged
= false ;
682 for ( size_t i
= 0 ; i
< count
; ++i
)
684 if ( aSelections
[i
] != m_selectionPreImage
[i
] )
696 m_selectionPreImage
= aSelections
;
698 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
699 event
.SetEventObject( this );
704 if ( HasClientObjectData() )
705 event
.SetClientObject( GetClientObject(n
) );
706 else if ( HasClientUntypedData() )
707 event
.SetClientData( GetClientData(n
) );
708 event
.SetString( GetString(n
) );
715 event
.m_commandInt
= n
;
717 GetEventHandler()->ProcessEvent(event
);
720 void wxListBox::MacDoDoubleClick()
722 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, m_windowId
);
723 event
.SetEventObject( this );
724 GetEventHandler()->ProcessEvent(event
) ;
727 void wxListBox::OnChar(wxKeyEvent
& event
)
729 // todo trigger proper events here
733 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
735 wxWindow
* parent
= GetParent() ;
736 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
737 parent
= parent
->GetParent() ;
739 if ( parent
&& parent
->GetDefaultItem() )
741 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
743 if ( def
&& def
->IsEnabled() )
745 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
746 event
.SetEventObject(def
);
753 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
754 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
756 // FIXME: look in ancestors, not just parent.
757 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
760 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
761 new_event
.SetEventObject( win
);
762 win
->GetEventHandler()->ProcessEvent( new_event
);
765 else if ( event
.GetKeyCode() == WXK_TAB
)
767 wxNavigationKeyEvent new_event
;
768 new_event
.SetEventObject( this );
769 new_event
.SetDirection( !event
.ShiftDown() );
770 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
771 new_event
.SetWindowChange( event
.ControlDown() );
772 new_event
.SetCurrentFocus( this );
773 if ( !GetEventHandler()->ProcessEvent( new_event
) )
776 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
778 // perform the default key handling first
779 wxControl::OnKeyDown( event
) ;
781 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
782 event
.SetEventObject( this );
784 wxArrayInt aSelections
;
785 int n
, count
= GetSelections(aSelections
);
789 if ( HasClientObjectData() )
790 event
.SetClientObject( GetClientObject(n
) );
791 else if ( HasClientUntypedData() )
792 event
.SetClientData( GetClientData(n
) );
793 event
.SetString( GetString(n
) );
800 event
.m_commandInt
= n
;
802 GetEventHandler()->ProcessEvent(event
);
806 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
808 m_typeIn
= wxEmptyString
;
810 m_lastTypeIn
= event
.GetTimestamp() ;
811 m_typeIn
+= (char) event
.GetKeyCode() ;
812 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
815 if ( GetSelection() != line
)
818 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
819 event
.SetEventObject( this );
821 if ( HasClientObjectData() )
822 event
.SetClientObject( GetClientObject( line
) );
823 else if ( HasClientUntypedData() )
824 event
.SetClientData( GetClientData(line
) );
825 event
.SetString( GetString(line
) );
827 event
.m_commandInt
= line
;
829 GetEventHandler()->ProcessEvent(event
);
837 // old carbon version
839 const short kwxMacListItemHeight
= 19 ;
843 static pascal void wxMacListDefinition( short message
, Boolean isSelected
, Rect
*drawRect
,
844 Cell cell
, short dataOffset
, short dataLength
,
845 ListHandle listHandle
) ;
848 static pascal void wxMacListDefinition( short message
, Boolean isSelected
, Rect
*d
,
849 Cell cell
, short dataOffset
, short dataLength
,
850 ListHandle listHandle
)
854 Rect
* drawRect
= &r
;
856 list
= (wxListBox
*) GetControlReference( (ControlRef
) GetListRefCon(listHandle
) );
857 if ( list
== NULL
|| list
->GetHandle() == NULL
|| GetControlReference( ( ControlRef
)list
->GetHandle() ) == NULL
)
860 // the bounds passed in are not correct, adjust the right border
863 GetControlBounds( (ControlRef
) list
->GetHandle() , &bounds
) ;
864 r
.right
= r
.left
+ (bounds
.right
- bounds
.left
) - 16 ;
868 RgnHandle savedClipRegion
;
871 SetPort((**listHandle
).port
);
872 grafPtr
= (**listHandle
).port
;
873 // typecast our refCon
875 // Calculate the cell rect.
886 const wxString linetext
= list
->m_stringArray
[cell
.v
] ;
888 // Save the current clip region, and set the clip region to the area we are about
891 savedClipRegion
= NewRgn();
892 GetClip( savedClipRegion
);
894 ClipRect( drawRect
);
895 EraseRect( drawRect
);
897 const wxFont
& font
= list
->GetFont();
900 ::TextFont( font
.MacGetFontNum() ) ;
901 ::TextSize( font
.MacGetFontSize() ) ;
902 ::TextFace( font
.MacGetFontStyle() ) ;
906 ::TextFont( kFontIDMonaco
) ;
912 Rect frame
= { drawRect
->top
, drawRect
->left
+ 4,
913 drawRect
->top
+ kwxMacListItemHeight
, drawRect
->right
+ 10000 } ;
914 CFMutableStringRef mString
= CFStringCreateMutableCopy( NULL
, 0 , wxMacCFStringHolder(linetext
, list
->GetFont().GetEncoding()) ) ;
915 ::TruncateThemeText( mString
, kThemeCurrentPortFont
, kThemeStateActive
, drawRect
->right
- drawRect
->left
, truncEnd
, NULL
) ;
917 ::DrawThemeTextBox( mString
,
918 kThemeCurrentPortFont
,
925 CFRelease( mString
) ;
928 // If the cell is hilited, do the hilite now. Paint the cell contents with the
929 // appropriate QuickDraw transform mode.
932 savedPenMode
= GetPortPenMode( (CGrafPtr
) grafPtr
);
933 SetPortPenMode( (CGrafPtr
)grafPtr
, hilitetransfermode
);
934 PaintRect( drawRect
);
935 SetPortPenMode( (CGrafPtr
)grafPtr
, savedPenMode
);
938 // Restore the saved clip region.
940 SetClip( savedClipRegion
);
941 DisposeRgn( savedClipRegion
);
946 // Hilite or unhilite the cell. Paint the cell contents with the
947 // appropriate QuickDraw transform mode.
950 savedPenMode
= GetPortPenMode( (CGrafPtr
)grafPtr
);
951 SetPortPenMode( (CGrafPtr
)grafPtr
, hilitetransfermode
);
952 PaintRect( drawRect
);
953 SetPortPenMode( (CGrafPtr
)grafPtr
, savedPenMode
);
961 extern "C" void MacDrawStringCell(Rect
*cellRect
, Cell lCell
, ListHandle theList
, long refCon
) ;
962 // resources ldef ids
963 const short kwxMacListWithVerticalScrollbar
= 128 ;
964 const short kwxMacListWithVerticalAndHorizontalScrollbar
= 129 ;
966 // ============================================================================
967 // list box control implementation
968 // ============================================================================
971 wxListBox::wxListBox()
978 static ListDefUPP macListDefUPP
= NULL
;
980 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
983 const wxArrayString
& choices
,
985 const wxValidator
& validator
,
986 const wxString
& name
)
988 wxCArrayString
chs(choices
);
990 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
991 style
, validator
, name
);
994 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
997 int n
, const wxString choices
[],
999 const wxValidator
& validator
,
1000 const wxString
& name
)
1002 m_macIsUserPane
= FALSE
;
1004 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
1007 m_noItems
= 0 ; // this will be increased by our append command
1010 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
1012 ListDefSpec listDef
;
1013 listDef
.defType
= kListDefUserProcType
;
1014 if ( macListDefUPP
== NULL
)
1016 macListDefUPP
= NewListDefUPP( wxMacListDefinition
);
1018 listDef
.u
.userProc
= macListDefUPP
;
1024 GetThemeFont(kThemeViewsFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1026 SetFont( wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) ) ) ;
1031 CreateListBoxControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, false, 0, 1, (style
& wxLB_HSCROLL
), true,
1032 kwxMacListItemHeight
, kwxMacListItemHeight
, false, &listDef
, (ControlRef
*)&m_macControl
);
1034 GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxListHandleTag
,
1035 sizeof(ListHandle
), (Ptr
) &m_macList
, &asize
);
1037 SetControlReference( (ControlRef
) m_macControl
, (long) this);
1040 OptionBits options
= 0;
1041 if ( style
& wxLB_MULTIPLE
)
1043 options
+= lExtendDrag
+ lUseSense
;
1045 else if ( style
& wxLB_EXTENDED
)
1047 // default behaviour
1051 options
= (OptionBits
) lOnlyOne
;
1053 SetListSelectionFlags((ListHandle
)m_macList
, options
);
1055 for ( int i
= 0 ; i
< n
; i
++ )
1057 Append( choices
[i
] ) ;
1060 MacPostControlCreate(pos
,size
) ;
1062 LSetDrawingMode( true , (ListHandle
)m_macList
) ;
1067 wxListBox::~wxListBox()
1069 SetControlReference( (ControlRef
) m_macControl
, NULL
) ;
1071 // avoid access during destruction
1078 void wxListBox::FreeData()
1080 #if wxUSE_OWNER_DRAWN
1081 if ( m_windowStyle
& wxLB_OWNERDRAW
)
1083 size_t uiCount
= m_aItems
.Count();
1084 while ( uiCount
-- != 0 ) {
1085 delete m_aItems
[uiCount
];
1086 m_aItems
[uiCount
] = NULL
;
1092 #endif // wxUSE_OWNER_DRAWN
1093 if ( HasClientObjectData() )
1095 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
1097 delete GetClientObject(n
);
1102 void wxListBox::DoSetSize(int x
, int y
,
1103 int width
, int height
,
1106 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
1109 GetControlBounds( (ControlRef
) m_macControl
, &bounds
) ;
1110 ControlRef control
= GetListVerticalScrollBar( (ListHandle
)m_macList
) ;
1114 GetControlBounds( control
, &scrollbounds
) ;
1115 if( scrollbounds
.right
!= bounds
.right
+ 1 )
1117 UMAMoveControl( control
, bounds
.right
- (scrollbounds
.right
- scrollbounds
.left
) + 1 ,
1118 scrollbounds
.top
) ;
1123 void wxListBox::DoSetFirstItem(int N
)
1128 void wxListBox::Delete(int N
)
1130 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1131 wxT("invalid index in wxListBox::Delete") );
1133 #if wxUSE_OWNER_DRAWN
1135 m_aItems
.RemoveAt(N
);
1136 #else // !wxUSE_OWNER_DRAWN
1137 if ( HasClientObjectData() )
1139 delete GetClientObject(N
);
1141 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
1142 m_stringArray
.RemoveAt( N
) ;
1143 m_dataArray
.RemoveAt( N
) ;
1149 int wxListBox::DoAppend(const wxString
& item
)
1151 int index
= m_noItems
;
1152 m_stringArray
.Add( item
) ;
1153 m_dataArray
.Add( NULL
);
1155 DoSetItemClientData( index
, NULL
) ;
1161 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
1163 MacSetRedraw( false ) ;
1165 int n
= choices
.GetCount();
1167 for( int i
= 0 ; i
< n
; ++i
)
1171 #if wxUSE_OWNER_DRAWN
1172 wxASSERT_MSG(clientData
[i
] == NULL
,
1173 wxT("Can't use client data with owner-drawn listboxes"));
1174 #else // !wxUSE_OWNER_DRAWN
1175 Append( choices
[i
] , clientData
[i
] ) ;
1179 Append( choices
[i
] ) ;
1182 #if wxUSE_OWNER_DRAWN
1183 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
1184 // first delete old items
1185 size_t ui
= m_aItems
.Count();
1186 while ( ui
-- != 0 ) {
1187 delete m_aItems
[ui
];
1188 m_aItems
[ui
] = NULL
;
1192 // then create new ones
1193 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
1194 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
1195 pNewItem
->SetName(choices
[ui
]);
1196 m_aItems
.Add(pNewItem
);
1199 #endif // wxUSE_OWNER_DRAWN
1200 MacSetRedraw( true ) ;
1203 bool wxListBox::HasMultipleSelection() const
1205 return (m_windowStyle
& wxLB_MULTIPLE
) || (m_windowStyle
& wxLB_EXTENDED
);
1208 int wxListBox::FindString(const wxString
& s
) const
1211 if ( s
.Right(1) == wxT("*") )
1213 wxString search
= s
.Left( s
.Length() - 1 ) ;
1214 int len
= search
.Length() ;
1216 wxMacStringToPascal( search
, s2
) ;
1218 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
1220 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
1222 if ( EqualString( s1
, s2
, false , false ) )
1225 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
1229 for ( int i
= 0 ; i
< m_noItems
; ++i
)
1231 if ( GetString(i
).Lower().Matches(st
) )
1241 wxMacStringToPascal( s
, s2
) ;
1243 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
1245 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
1247 if ( EqualString( s1
, s2
, false , false ) )
1254 void wxListBox::Clear()
1258 m_stringArray
.Empty() ;
1259 m_dataArray
.Empty() ;
1263 void wxListBox::SetSelection(int N
, bool select
)
1265 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1266 wxT("invalid index in wxListBox::SetSelection") );
1267 MacSetSelection( N
, select
) ;
1268 GetSelections( m_selectionPreImage
) ;
1271 bool wxListBox::IsSelected(int N
) const
1273 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
1274 wxT("invalid index in wxListBox::Selected") );
1276 return MacIsSelected( N
) ;
1279 void *wxListBox::DoGetItemClientData(int N
) const
1281 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
1282 wxT("invalid index in wxListBox::GetClientData"));
1284 return (void *)m_dataArray
[N
];
1287 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
1289 return (wxClientData
*) DoGetItemClientData( N
) ;
1292 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
1294 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1295 wxT("invalid index in wxListBox::SetClientData") );
1297 #if wxUSE_OWNER_DRAWN
1298 if ( m_windowStyle
& wxLB_OWNERDRAW
)
1300 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
1301 // in OnMeasure/OnDraw.
1302 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
1304 #endif // wxUSE_OWNER_DRAWN
1305 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
1307 if ( m_dataArray
.GetCount() > (size_t) N
)
1309 m_dataArray
[N
] = (char*) Client_data
;
1313 m_dataArray
.Add( (char*) Client_data
) ;
1317 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
1319 DoSetItemClientData(n
, clientData
);
1322 // Return number of selections and an array of selected integers
1323 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
1325 return MacGetSelections( aSelections
) ;
1328 // Get single selection, for single choice list items
1329 int wxListBox::GetSelection() const
1331 return MacGetSelection() ;
1334 // Find string for position
1335 wxString
wxListBox::GetString(int N
) const
1337 return m_stringArray
[N
] ;
1340 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
1342 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
1343 wxT("invalid index in wxListBox::InsertItems") );
1345 int nItems
= items
.GetCount();
1347 for ( int i
= 0 ; i
< nItems
; i
++ )
1349 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
1350 m_dataArray
.Insert( NULL
, pos
+ i
) ;
1351 MacInsert( pos
+ i
, items
[i
] ) ;
1354 m_noItems
+= nItems
;
1357 void wxListBox::SetString(int N
, const wxString
& s
)
1359 m_stringArray
[N
] = s
;
1363 wxSize
wxListBox::DoGetBestSize() const
1365 int lbWidth
= 100; // some defaults
1370 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
1374 ::TextFont( m_font
.MacGetFontNum() ) ;
1375 ::TextSize( m_font
.MacGetFontSize() ) ;
1376 ::TextFace( m_font
.MacGetFontStyle() ) ;
1380 ::TextFont( kFontIDMonaco
) ;
1385 // Find the widest line
1386 for(int i
= 0; i
< GetCount(); i
++) {
1387 wxString
str(GetString(i
));
1389 Point bounds
={0,0} ;
1391 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
1392 kThemeCurrentPortFont
,
1399 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
1401 lbWidth
= wxMax(lbWidth
, wLine
);
1404 // Add room for the scrollbar
1405 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
1407 // And just a bit more
1409 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
1412 // don't make the listbox too tall (limit height to around 10 items) but don't
1413 // make it too small neither
1414 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
1417 return wxSize(lbWidth
, lbHeight
);
1420 int wxListBox::GetCount() const
1425 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
1427 wxControl::Refresh( eraseBack
, rect
) ;
1428 // MacRedrawControl() ;
1431 #if wxUSE_OWNER_DRAWN
1433 class wxListBoxItem
: public wxOwnerDrawn
1436 wxListBoxItem(const wxString
& str
= "");
1439 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
1441 // no bitmaps/checkmarks
1445 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
1447 return new wxListBoxItem();
1450 #endif //USE_OWNER_DRAWN
1452 // ============================================================================
1453 // list box control implementation
1454 // ============================================================================
1457 void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
1460 // typecast our refCon
1461 list = (wxListBox*)refCon;
1463 MoveTo(cellRect->left + 4 , cellRect->top + 10 );
1464 const wxString text = list->m_stringArray[lCell.v] ;
1465 ::TextFont( kFontIDMonaco ) ;
1468 DrawText(text, 0 , text.Length());
1472 void wxListBox::MacDelete( int N
)
1474 LDelRow( 1 , N
, (ListHandle
)m_macList
) ;
1478 void wxListBox::MacInsert( int n
, const wxString
& text
)
1480 Cell cell
= { 0 , 0 } ;
1482 LAddRow( 1 , cell
.v
, (ListHandle
)m_macList
) ;
1483 // LSetCell(text, strlen(text), cell, m_macList);
1487 void wxListBox::MacAppend( const wxString
& text
)
1489 Cell cell
= { 0 , 0 } ;
1490 cell
.v
= (**(ListHandle
)m_macList
).dataBounds
.bottom
;
1491 LAddRow( 1 , cell
.v
, (ListHandle
)m_macList
) ;
1492 // LSetCell(text, strlen(text), cell, m_macList);
1496 void wxListBox::MacClear()
1498 LDelRow( (**(ListHandle
)m_macList
).dataBounds
.bottom
, 0 ,(ListHandle
) m_macList
) ;
1502 void wxListBox::MacSetSelection( int n
, bool select
)
1504 Cell cell
= { 0 , 0 } ;
1505 if ( ! (m_windowStyle
& wxLB_MULTIPLE
) )
1507 if ( LGetSelect( true , &cell
, (ListHandle
)m_macList
) )
1509 LSetSelect( false , cell
, (ListHandle
)m_macList
) ;
1514 LSetSelect( select
, cell
, (ListHandle
)m_macList
) ;
1515 LAutoScroll( (ListHandle
)m_macList
) ;
1519 bool wxListBox::MacIsSelected( int n
) const
1521 Cell cell
= { 0 , 0 } ;
1523 return LGetSelect( false , &cell
, (ListHandle
)m_macList
) ;
1526 int wxListBox::MacGetSelection() const
1528 Cell cell
= { 0 , 0 } ;
1529 if ( LGetSelect( true , &cell
, (ListHandle
)m_macList
) )
1535 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
1539 aSelections
.Empty();
1541 Cell cell
= { 0 , 0 } ;
1544 while ( LGetSelect( true , &cell
,(ListHandle
) m_macList
) )
1546 aSelections
.Add( cell
.v
) ;
1553 void wxListBox::MacSet( int n
, const wxString
& text
)
1555 // our implementation does not store anything in the list
1556 // so we just have to redraw
1557 Cell cell
= { 0 , 0 } ;
1559 // LSetCell(text, strlen(text), cell, m_macList);
1563 void wxListBox::MacScrollTo( int n
)
1565 // TODO implement scrolling
1568 void wxListBox::OnSize( wxSizeEvent
&event
)
1573 GetListCellSize((ListHandle
)m_macList
, &pt
);
1575 pt
= (**(ListHandle
)m_macList
).cellSize
;
1578 GetSize( &w
, &h
) ;
1580 LCellSize( pt
, (ListHandle
)m_macList
) ;
1583 void wxListBox::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
1585 Boolean wasDoubleClick
= false ;
1588 ::GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxDoubleClickTag
, sizeof( wasDoubleClick
) , (char*) &wasDoubleClick
, &result
) ;
1589 if ( !wasDoubleClick
)
1595 MacDoDoubleClick() ;
1599 void wxListBox::MacSetRedraw( bool doDraw
)
1601 LSetDrawingMode( doDraw
, (ListHandle
)m_macList
) ;
1605 void wxListBox::MacDoClick()
1607 wxArrayInt aSelections
;
1609 size_t count
= GetSelections(aSelections
);
1611 if ( count
== m_selectionPreImage
.GetCount() )
1613 bool hasChanged
= false ;
1614 for ( size_t i
= 0 ; i
< count
; ++i
)
1616 if ( aSelections
[i
] != m_selectionPreImage
[i
] )
1628 m_selectionPreImage
= aSelections
;
1630 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1631 event
.SetEventObject( this );
1636 if ( HasClientObjectData() )
1637 event
.SetClientObject( GetClientObject(n
) );
1638 else if ( HasClientUntypedData() )
1639 event
.SetClientData( GetClientData(n
) );
1640 event
.SetString( GetString(n
) );
1647 event
.m_commandInt
= n
;
1649 GetEventHandler()->ProcessEvent(event
);
1652 void wxListBox::MacDoDoubleClick()
1654 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, m_windowId
);
1655 event
.SetEventObject( this );
1656 GetEventHandler()->ProcessEvent(event
) ;
1659 void wxListBox::OnChar(wxKeyEvent
& event
)
1661 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
1663 wxWindow
* parent
= GetParent() ;
1664 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
1665 parent
= parent
->GetParent() ;
1667 if ( parent
&& parent
->GetDefaultItem() )
1669 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
1671 if ( def
&& def
->IsEnabled() )
1673 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
1674 event
.SetEventObject(def
);
1675 def
->Command(event
);
1681 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
1682 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
1684 // FIXME: look in ancestors, not just parent.
1685 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
1688 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
1689 new_event
.SetEventObject( win
);
1690 win
->GetEventHandler()->ProcessEvent( new_event
);
1693 else if ( event
.GetKeyCode() == WXK_TAB
)
1695 wxNavigationKeyEvent new_event
;
1696 new_event
.SetEventObject( this );
1697 new_event
.SetDirection( !event
.ShiftDown() );
1698 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
1699 new_event
.SetWindowChange( event
.ControlDown() );
1700 new_event
.SetCurrentFocus( this );
1701 if ( !GetEventHandler()->ProcessEvent( new_event
) )
1704 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
1706 // perform the default key handling first
1707 wxControl::OnKeyDown( event
) ;
1709 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1710 event
.SetEventObject( this );
1712 wxArrayInt aSelections
;
1713 int n
, count
= GetSelections(aSelections
);
1717 if ( HasClientObjectData() )
1718 event
.SetClientObject( GetClientObject(n
) );
1719 else if ( HasClientUntypedData() )
1720 event
.SetClientData( GetClientData(n
) );
1721 event
.SetString( GetString(n
) );
1728 event
.m_commandInt
= n
;
1730 GetEventHandler()->ProcessEvent(event
);
1734 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
1736 m_typeIn
= wxEmptyString
;
1738 m_lastTypeIn
= event
.GetTimestamp() ;
1739 m_typeIn
+= (char) event
.GetKeyCode() ;
1740 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
1743 if ( GetSelection() != line
)
1745 SetSelection(line
) ;
1746 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1747 event
.SetEventObject( this );
1749 if ( HasClientObjectData() )
1750 event
.SetClientObject( GetClientObject( line
) );
1751 else if ( HasClientUntypedData() )
1752 event
.SetClientData( GetClientData(line
) );
1753 event
.SetString( GetString(line
) );
1755 event
.m_commandInt
= line
;
1757 GetEventHandler()->ProcessEvent(event
);