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
= kDataBrowserListViewTypeSelectColumn
| kDataBrowserTableViewSelectionColumn
;
163 verify_noerr(::AddDataBrowserListViewColumn(browser
, &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
164 verify_noerr(::AutoSizeDataBrowserListViewColumns( browser
) ) ;
165 verify_noerr(::SetDataBrowserHasScrollBars( browser
, false , true ) ) ;
166 verify_noerr(::SetDataBrowserTableViewHiliteStyle( browser
, kDataBrowserTableViewFillHilite
) ) ;
167 verify_noerr(::SetDataBrowserListViewHeaderBtnHeight( browser
, 0 ) ) ;
168 DataBrowserCallbacks callbacks
;
170 callbacks
.version
= kDataBrowserLatestCallbacks
;
172 InitDataBrowserCallbacks(&callbacks
);
174 callbacks
.u
.v1
.itemDataCallback
=
175 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
177 SetDataBrowserCallbacks(browser
, &callbacks
);
179 MacPostControlCreate(pos
,size
) ;
181 for ( int i
= 0 ; i
< n
; i
++ )
183 Append( choices
[i
] ) ;
189 wxListBox::~wxListBox()
191 SetControlReference( (ControlRef
) m_macControl
, NULL
) ;
193 // avoid access during destruction
200 void wxListBox::FreeData()
202 #if wxUSE_OWNER_DRAWN
203 if ( m_windowStyle
& wxLB_OWNERDRAW
)
205 size_t uiCount
= m_aItems
.Count();
206 while ( uiCount
-- != 0 ) {
207 delete m_aItems
[uiCount
];
208 m_aItems
[uiCount
] = NULL
;
214 #endif // wxUSE_OWNER_DRAWN
215 if ( HasClientObjectData() )
217 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
219 delete GetClientObject(n
);
224 void wxListBox::DoSetSize(int x
, int y
,
225 int width
, int height
,
228 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
231 void wxListBox::DoSetFirstItem(int N
)
236 void wxListBox::Delete(int N
)
238 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
239 wxT("invalid index in wxListBox::Delete") );
241 #if wxUSE_OWNER_DRAWN
243 m_aItems
.RemoveAt(N
);
244 #else // !wxUSE_OWNER_DRAWN
245 if ( HasClientObjectData() )
247 delete GetClientObject(N
);
249 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
250 m_stringArray
.RemoveAt( N
) ;
251 m_dataArray
.RemoveAt( N
) ;
257 int wxListBox::DoAppend(const wxString
& item
)
259 int index
= m_noItems
;
260 m_stringArray
.Add( item
) ;
261 m_dataArray
.Add( NULL
);
263 DoSetItemClientData( index
, NULL
) ;
269 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
272 int n
= choices
.GetCount();
274 for( int i
= 0 ; i
< n
; ++i
)
278 #if wxUSE_OWNER_DRAWN
279 wxASSERT_MSG(clientData
[i
] == NULL
,
280 wxT("Can't use client data with owner-drawn listboxes"));
281 #else // !wxUSE_OWNER_DRAWN
282 Append( choices
[i
] , clientData
[i
] ) ;
286 Append( choices
[i
] ) ;
289 #if wxUSE_OWNER_DRAWN
290 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
291 // first delete old items
292 size_t ui
= m_aItems
.Count();
293 while ( ui
-- != 0 ) {
299 // then create new ones
300 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
301 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
302 pNewItem
->SetName(choices
[ui
]);
303 m_aItems
.Add(pNewItem
);
306 #endif // wxUSE_OWNER_DRAWN
309 bool wxListBox::HasMultipleSelection() const
311 return (m_windowStyle
& wxLB_MULTIPLE
) || (m_windowStyle
& wxLB_EXTENDED
);
314 int wxListBox::FindString(const wxString
& s
) const
317 if ( s
.Right(1) == wxT("*") )
319 wxString search
= s
.Left( s
.Length() - 1 ) ;
320 int len
= search
.Length() ;
322 wxMacStringToPascal( search
, s2
) ;
324 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
326 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
328 if ( EqualString( s1
, s2
, false , false ) )
331 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
335 for ( int i
= 0 ; i
< m_noItems
; ++i
)
337 if ( GetString(i
).Lower().Matches(st
) )
347 wxMacStringToPascal( s
, s2
) ;
349 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
351 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
353 if ( EqualString( s1
, s2
, false , false ) )
360 void wxListBox::Clear()
364 m_stringArray
.Empty() ;
365 m_dataArray
.Empty() ;
369 void wxListBox::SetSelection(int N
, bool select
)
371 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
372 wxT("invalid index in wxListBox::SetSelection") );
373 MacSetSelection( N
, select
) ;
374 GetSelections( m_selectionPreImage
) ;
377 bool wxListBox::IsSelected(int N
) const
379 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
380 wxT("invalid index in wxListBox::Selected") );
382 return MacIsSelected( N
) ;
385 void *wxListBox::DoGetItemClientData(int N
) const
387 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
388 wxT("invalid index in wxListBox::GetClientData"));
390 return (void *)m_dataArray
[N
];
393 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
395 return (wxClientData
*) DoGetItemClientData( N
) ;
398 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
400 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
401 wxT("invalid index in wxListBox::SetClientData") );
403 #if wxUSE_OWNER_DRAWN
404 if ( m_windowStyle
& wxLB_OWNERDRAW
)
406 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
407 // in OnMeasure/OnDraw.
408 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
410 #endif // wxUSE_OWNER_DRAWN
411 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
413 if ( m_dataArray
.GetCount() > (size_t) N
)
415 m_dataArray
[N
] = (char*) Client_data
;
419 m_dataArray
.Add( (char*) Client_data
) ;
423 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
425 DoSetItemClientData(n
, clientData
);
428 // Return number of selections and an array of selected integers
429 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
431 return MacGetSelections( aSelections
) ;
434 // Get single selection, for single choice list items
435 int wxListBox::GetSelection() const
437 return MacGetSelection() ;
440 // Find string for position
441 wxString
wxListBox::GetString(int N
) const
443 return m_stringArray
[N
] ;
446 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
448 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
449 wxT("invalid index in wxListBox::InsertItems") );
451 int nItems
= items
.GetCount();
453 for ( int i
= 0 ; i
< nItems
; i
++ )
455 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
456 m_dataArray
.Insert( NULL
, pos
+ i
) ;
457 MacInsert( pos
+ i
, items
[i
] ) ;
463 void wxListBox::SetString(int N
, const wxString
& s
)
465 m_stringArray
[N
] = s
;
469 wxSize
wxListBox::DoGetBestSize() const
471 int lbWidth
= 100; // some defaults
476 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
480 ::TextFont( m_font
.MacGetFontNum() ) ;
481 ::TextSize( m_font
.MacGetFontSize() ) ;
482 ::TextFace( m_font
.MacGetFontStyle() ) ;
486 ::TextFont( kFontIDMonaco
) ;
491 // Find the widest line
492 for(int i
= 0; i
< GetCount(); i
++) {
493 wxString
str(GetString(i
));
497 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
498 kThemeCurrentPortFont
,
505 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
507 lbWidth
= wxMax(lbWidth
, wLine
);
510 // Add room for the scrollbar
511 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
513 // And just a bit more
515 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
518 // don't make the listbox too tall (limit height to around 10 items) but don't
519 // make it too small neither
520 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
523 return wxSize(lbWidth
, lbHeight
);
526 int wxListBox::GetCount() const
531 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
533 wxControl::Refresh( eraseBack
, rect
) ;
534 // MacRedrawControl() ;
537 #if wxUSE_OWNER_DRAWN
539 class wxListBoxItem
: public wxOwnerDrawn
542 wxListBoxItem(const wxString
& str
= "");
545 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
547 // no bitmaps/checkmarks
551 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
553 return new wxListBoxItem();
556 #endif //USE_OWNER_DRAWN
558 // ============================================================================
559 // list box control implementation
560 // ============================================================================
562 void wxListBox::MacDelete( int N
)
564 UInt32 id
= m_idArray
[N
] ;
565 verify_noerr(::RemoveDataBrowserItems((ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
566 m_idArray
.RemoveAt( N
) ;
569 void wxListBox::MacInsert( int n
, const wxString
& text
)
571 verify_noerr(::AddDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &m_nextId
, kDataBrowserItemNoProperty
) ) ;
572 m_idArray
.Insert( m_nextId
, n
) ;
576 void wxListBox::MacAppend( const wxString
& text
)
578 verify_noerr(::AddDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , (UInt32
*) &m_nextId
, kDataBrowserItemNoProperty
) ) ;
579 m_idArray
.Add( m_nextId
) ;
583 void wxListBox::MacClear()
585 verify_noerr(::RemoveDataBrowserItems((ControlRef
) m_macControl
, kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
586 m_dataArray
.Empty() ;
589 void wxListBox::MacSetSelection( int n
, bool select
)
591 UInt32 id
= m_idArray
[n
] ;
592 if ( ::IsDataBrowserItemSelected( (ControlRef
) m_macControl
, id
) != select
)
594 verify_noerr(::SetDataBrowserSelectedItems((ControlRef
) m_macControl
, 1 , & id
, kDataBrowserItemsToggle
) ) ;
599 bool wxListBox::MacIsSelected( int n
) const
601 return ::IsDataBrowserItemSelected( (ControlRef
) m_macControl
, m_idArray
[n
] ) ;
604 int wxListBox::MacGetSelection() const
606 for ( size_t i
= 0 ; i
< m_idArray
.GetCount() ; ++i
)
608 if ( ::IsDataBrowserItemSelected((ControlRef
) m_macControl
, m_idArray
[i
] ) )
616 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
621 for ( size_t i
= 0 ; i
< m_idArray
.GetCount() ; ++i
)
623 if ( ::IsDataBrowserItemSelected((ControlRef
) m_macControl
, m_idArray
[i
] ) )
625 aSelections
.Add( i
) ;
632 void wxListBox::MacSet( int n
, const wxString
& text
)
634 // as we don't store the strings we only have to issue a redraw
635 UInt32 id
= m_idArray
[n
] ;
636 verify_noerr( ::UpdateDataBrowserItems( (ControlRef
) m_macControl
, kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
639 void wxListBox::MacScrollTo( int n
)
641 // TODO implement scrolling
644 void wxListBox::OnSize( wxSizeEvent
&event
)
648 void wxListBox::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
650 Boolean wasDoubleClick
= false ;
653 ::GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxDoubleClickTag
, sizeof( wasDoubleClick
) , (char*) &wasDoubleClick
, &result
) ;
654 if ( !wasDoubleClick
)
664 void wxListBox::MacSetRedraw( bool doDraw
)
666 // nothing to do in compositing mode
669 void wxListBox::MacDoClick()
671 wxArrayInt aSelections
;
673 size_t count
= GetSelections(aSelections
);
675 if ( count
== m_selectionPreImage
.GetCount() )
677 bool hasChanged
= false ;
678 for ( size_t i
= 0 ; i
< count
; ++i
)
680 if ( aSelections
[i
] != m_selectionPreImage
[i
] )
692 m_selectionPreImage
= aSelections
;
694 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
695 event
.SetEventObject( this );
700 if ( HasClientObjectData() )
701 event
.SetClientObject( GetClientObject(n
) );
702 else if ( HasClientUntypedData() )
703 event
.SetClientData( GetClientData(n
) );
704 event
.SetString( GetString(n
) );
711 event
.m_commandInt
= n
;
713 GetEventHandler()->ProcessEvent(event
);
716 void wxListBox::MacDoDoubleClick()
718 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, m_windowId
);
719 event
.SetEventObject( this );
720 GetEventHandler()->ProcessEvent(event
) ;
723 void wxListBox::OnChar(wxKeyEvent
& event
)
725 // todo trigger proper events here
729 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
731 wxWindow
* parent
= GetParent() ;
732 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
733 parent
= parent
->GetParent() ;
735 if ( parent
&& parent
->GetDefaultItem() )
737 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
739 if ( def
&& def
->IsEnabled() )
741 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
742 event
.SetEventObject(def
);
749 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
750 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
752 // FIXME: look in ancestors, not just parent.
753 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
756 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
757 new_event
.SetEventObject( win
);
758 win
->GetEventHandler()->ProcessEvent( new_event
);
761 else if ( event
.GetKeyCode() == WXK_TAB
)
763 wxNavigationKeyEvent new_event
;
764 new_event
.SetEventObject( this );
765 new_event
.SetDirection( !event
.ShiftDown() );
766 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
767 new_event
.SetWindowChange( event
.ControlDown() );
768 new_event
.SetCurrentFocus( this );
769 if ( !GetEventHandler()->ProcessEvent( new_event
) )
772 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
774 // perform the default key handling first
775 wxControl::OnKeyDown( event
) ;
777 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
778 event
.SetEventObject( this );
780 wxArrayInt aSelections
;
781 int n
, count
= GetSelections(aSelections
);
785 if ( HasClientObjectData() )
786 event
.SetClientObject( GetClientObject(n
) );
787 else if ( HasClientUntypedData() )
788 event
.SetClientData( GetClientData(n
) );
789 event
.SetString( GetString(n
) );
796 event
.m_commandInt
= n
;
798 GetEventHandler()->ProcessEvent(event
);
802 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
804 m_typeIn
= wxEmptyString
;
806 m_lastTypeIn
= event
.GetTimestamp() ;
807 m_typeIn
+= (char) event
.GetKeyCode() ;
808 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
811 if ( GetSelection() != line
)
814 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
815 event
.SetEventObject( this );
817 if ( HasClientObjectData() )
818 event
.SetClientObject( GetClientObject( line
) );
819 else if ( HasClientUntypedData() )
820 event
.SetClientData( GetClientData(line
) );
821 event
.SetString( GetString(line
) );
823 event
.m_commandInt
= line
;
825 GetEventHandler()->ProcessEvent(event
);
833 // old carbon version
835 const short kwxMacListItemHeight
= 19 ;
839 static pascal void wxMacListDefinition( short message
, Boolean isSelected
, Rect
*drawRect
,
840 Cell cell
, short dataOffset
, short dataLength
,
841 ListHandle listHandle
) ;
844 static pascal void wxMacListDefinition( short message
, Boolean isSelected
, Rect
*d
,
845 Cell cell
, short dataOffset
, short dataLength
,
846 ListHandle listHandle
)
850 Rect
* drawRect
= &r
;
852 list
= (wxListBox
*) GetControlReference( (ControlRef
) GetListRefCon(listHandle
) );
853 if ( list
== NULL
|| list
->GetHandle() == NULL
|| GetControlReference( ( ControlRef
)list
->GetHandle() ) == NULL
)
856 // the bounds passed in are not correct, adjust the right border
859 GetControlBounds( (ControlRef
) list
->GetHandle() , &bounds
) ;
860 r
.right
= r
.left
+ (bounds
.right
- bounds
.left
) - 16 ;
864 RgnHandle savedClipRegion
;
867 SetPort((**listHandle
).port
);
868 grafPtr
= (**listHandle
).port
;
869 // typecast our refCon
871 // Calculate the cell rect.
882 const wxString linetext
= list
->m_stringArray
[cell
.v
] ;
884 // Save the current clip region, and set the clip region to the area we are about
887 savedClipRegion
= NewRgn();
888 GetClip( savedClipRegion
);
890 ClipRect( drawRect
);
891 EraseRect( drawRect
);
893 const wxFont
& font
= list
->GetFont();
896 ::TextFont( font
.MacGetFontNum() ) ;
897 ::TextSize( font
.MacGetFontSize() ) ;
898 ::TextFace( font
.MacGetFontStyle() ) ;
902 ::TextFont( kFontIDMonaco
) ;
908 Rect frame
= { drawRect
->top
, drawRect
->left
+ 4,
909 drawRect
->top
+ kwxMacListItemHeight
, drawRect
->right
+ 10000 } ;
910 CFMutableStringRef mString
= CFStringCreateMutableCopy( NULL
, 0 , wxMacCFStringHolder(linetext
, list
->GetFont().GetEncoding()) ) ;
911 ::TruncateThemeText( mString
, kThemeCurrentPortFont
, kThemeStateActive
, drawRect
->right
- drawRect
->left
, truncEnd
, NULL
) ;
913 ::DrawThemeTextBox( mString
,
914 kThemeCurrentPortFont
,
921 CFRelease( mString
) ;
924 // If the cell is hilited, do the hilite now. Paint the cell contents with the
925 // appropriate QuickDraw transform mode.
928 savedPenMode
= GetPortPenMode( (CGrafPtr
) grafPtr
);
929 SetPortPenMode( (CGrafPtr
)grafPtr
, hilitetransfermode
);
930 PaintRect( drawRect
);
931 SetPortPenMode( (CGrafPtr
)grafPtr
, savedPenMode
);
934 // Restore the saved clip region.
936 SetClip( savedClipRegion
);
937 DisposeRgn( savedClipRegion
);
942 // Hilite or unhilite the cell. Paint the cell contents with the
943 // appropriate QuickDraw transform mode.
946 savedPenMode
= GetPortPenMode( (CGrafPtr
)grafPtr
);
947 SetPortPenMode( (CGrafPtr
)grafPtr
, hilitetransfermode
);
948 PaintRect( drawRect
);
949 SetPortPenMode( (CGrafPtr
)grafPtr
, savedPenMode
);
957 extern "C" void MacDrawStringCell(Rect
*cellRect
, Cell lCell
, ListHandle theList
, long refCon
) ;
958 // resources ldef ids
959 const short kwxMacListWithVerticalScrollbar
= 128 ;
960 const short kwxMacListWithVerticalAndHorizontalScrollbar
= 129 ;
962 // ============================================================================
963 // list box control implementation
964 // ============================================================================
967 wxListBox::wxListBox()
974 static ListDefUPP macListDefUPP
= NULL
;
976 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
979 const wxArrayString
& choices
,
981 const wxValidator
& validator
,
982 const wxString
& name
)
984 wxCArrayString
chs(choices
);
986 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
987 style
, validator
, name
);
990 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
993 int n
, const wxString choices
[],
995 const wxValidator
& validator
,
996 const wxString
& name
)
998 m_macIsUserPane
= FALSE
;
1000 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
1003 m_noItems
= 0 ; // this will be increased by our append command
1006 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
1008 ListDefSpec listDef
;
1009 listDef
.defType
= kListDefUserProcType
;
1010 if ( macListDefUPP
== NULL
)
1012 macListDefUPP
= NewListDefUPP( wxMacListDefinition
);
1014 listDef
.u
.userProc
= macListDefUPP
;
1020 GetThemeFont(kThemeViewsFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1022 SetFont( wxFont (fontSize
, wxSWISS
, wxNORMAL
, wxNORMAL
, false , wxMacMakeStringFromPascal( fontName
) ) ) ;
1027 CreateListBoxControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, false, 0, 1, (style
& wxLB_HSCROLL
), true,
1028 kwxMacListItemHeight
, kwxMacListItemHeight
, false, &listDef
, (ControlRef
*)&m_macControl
);
1030 GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxListHandleTag
,
1031 sizeof(ListHandle
), (Ptr
) &m_macList
, &asize
);
1033 SetControlReference( (ControlRef
) m_macControl
, (long) this);
1036 OptionBits options
= 0;
1037 if ( style
& wxLB_MULTIPLE
)
1039 options
+= lExtendDrag
+ lUseSense
;
1041 else if ( style
& wxLB_EXTENDED
)
1043 // default behaviour
1047 options
= (OptionBits
) lOnlyOne
;
1049 SetListSelectionFlags((ListHandle
)m_macList
, options
);
1051 for ( int i
= 0 ; i
< n
; i
++ )
1053 Append( choices
[i
] ) ;
1056 MacPostControlCreate(pos
,size
) ;
1058 LSetDrawingMode( true , (ListHandle
)m_macList
) ;
1063 wxListBox::~wxListBox()
1065 SetControlReference( (ControlRef
) m_macControl
, NULL
) ;
1067 // avoid access during destruction
1074 void wxListBox::FreeData()
1076 #if wxUSE_OWNER_DRAWN
1077 if ( m_windowStyle
& wxLB_OWNERDRAW
)
1079 size_t uiCount
= m_aItems
.Count();
1080 while ( uiCount
-- != 0 ) {
1081 delete m_aItems
[uiCount
];
1082 m_aItems
[uiCount
] = NULL
;
1088 #endif // wxUSE_OWNER_DRAWN
1089 if ( HasClientObjectData() )
1091 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
1093 delete GetClientObject(n
);
1098 void wxListBox::DoSetSize(int x
, int y
,
1099 int width
, int height
,
1102 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
1105 GetControlBounds( (ControlRef
) m_macControl
, &bounds
) ;
1106 ControlRef control
= GetListVerticalScrollBar( (ListHandle
)m_macList
) ;
1110 GetControlBounds( control
, &scrollbounds
) ;
1111 if( scrollbounds
.right
!= bounds
.right
+ 1 )
1113 UMAMoveControl( control
, bounds
.right
- (scrollbounds
.right
- scrollbounds
.left
) + 1 ,
1114 scrollbounds
.top
) ;
1119 void wxListBox::DoSetFirstItem(int N
)
1124 void wxListBox::Delete(int N
)
1126 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1127 wxT("invalid index in wxListBox::Delete") );
1129 #if wxUSE_OWNER_DRAWN
1131 m_aItems
.RemoveAt(N
);
1132 #else // !wxUSE_OWNER_DRAWN
1133 if ( HasClientObjectData() )
1135 delete GetClientObject(N
);
1137 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
1138 m_stringArray
.RemoveAt( N
) ;
1139 m_dataArray
.RemoveAt( N
) ;
1145 int wxListBox::DoAppend(const wxString
& item
)
1147 int index
= m_noItems
;
1148 m_stringArray
.Add( item
) ;
1149 m_dataArray
.Add( NULL
);
1151 DoSetItemClientData( index
, NULL
) ;
1157 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
1159 MacSetRedraw( false ) ;
1161 int n
= choices
.GetCount();
1163 for( int i
= 0 ; i
< n
; ++i
)
1167 #if wxUSE_OWNER_DRAWN
1168 wxASSERT_MSG(clientData
[i
] == NULL
,
1169 wxT("Can't use client data with owner-drawn listboxes"));
1170 #else // !wxUSE_OWNER_DRAWN
1171 Append( choices
[i
] , clientData
[i
] ) ;
1175 Append( choices
[i
] ) ;
1178 #if wxUSE_OWNER_DRAWN
1179 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
1180 // first delete old items
1181 size_t ui
= m_aItems
.Count();
1182 while ( ui
-- != 0 ) {
1183 delete m_aItems
[ui
];
1184 m_aItems
[ui
] = NULL
;
1188 // then create new ones
1189 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
1190 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
1191 pNewItem
->SetName(choices
[ui
]);
1192 m_aItems
.Add(pNewItem
);
1195 #endif // wxUSE_OWNER_DRAWN
1196 MacSetRedraw( true ) ;
1199 bool wxListBox::HasMultipleSelection() const
1201 return (m_windowStyle
& wxLB_MULTIPLE
) || (m_windowStyle
& wxLB_EXTENDED
);
1204 int wxListBox::FindString(const wxString
& s
) const
1207 if ( s
.Right(1) == wxT("*") )
1209 wxString search
= s
.Left( s
.Length() - 1 ) ;
1210 int len
= search
.Length() ;
1212 wxMacStringToPascal( search
, s2
) ;
1214 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
1216 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
1218 if ( EqualString( s1
, s2
, false , false ) )
1221 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
1225 for ( int i
= 0 ; i
< m_noItems
; ++i
)
1227 if ( GetString(i
).Lower().Matches(st
) )
1237 wxMacStringToPascal( s
, s2
) ;
1239 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
1241 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
1243 if ( EqualString( s1
, s2
, false , false ) )
1250 void wxListBox::Clear()
1254 m_stringArray
.Empty() ;
1255 m_dataArray
.Empty() ;
1259 void wxListBox::SetSelection(int N
, bool select
)
1261 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1262 wxT("invalid index in wxListBox::SetSelection") );
1263 MacSetSelection( N
, select
) ;
1264 GetSelections( m_selectionPreImage
) ;
1267 bool wxListBox::IsSelected(int N
) const
1269 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
1270 wxT("invalid index in wxListBox::Selected") );
1272 return MacIsSelected( N
) ;
1275 void *wxListBox::DoGetItemClientData(int N
) const
1277 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
1278 wxT("invalid index in wxListBox::GetClientData"));
1280 return (void *)m_dataArray
[N
];
1283 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
1285 return (wxClientData
*) DoGetItemClientData( N
) ;
1288 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
1290 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
1291 wxT("invalid index in wxListBox::SetClientData") );
1293 #if wxUSE_OWNER_DRAWN
1294 if ( m_windowStyle
& wxLB_OWNERDRAW
)
1296 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
1297 // in OnMeasure/OnDraw.
1298 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
1300 #endif // wxUSE_OWNER_DRAWN
1301 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
1303 if ( m_dataArray
.GetCount() > (size_t) N
)
1305 m_dataArray
[N
] = (char*) Client_data
;
1309 m_dataArray
.Add( (char*) Client_data
) ;
1313 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
1315 DoSetItemClientData(n
, clientData
);
1318 // Return number of selections and an array of selected integers
1319 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
1321 return MacGetSelections( aSelections
) ;
1324 // Get single selection, for single choice list items
1325 int wxListBox::GetSelection() const
1327 return MacGetSelection() ;
1330 // Find string for position
1331 wxString
wxListBox::GetString(int N
) const
1333 return m_stringArray
[N
] ;
1336 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
1338 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
1339 wxT("invalid index in wxListBox::InsertItems") );
1341 int nItems
= items
.GetCount();
1343 for ( int i
= 0 ; i
< nItems
; i
++ )
1345 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
1346 m_dataArray
.Insert( NULL
, pos
+ i
) ;
1347 MacInsert( pos
+ i
, items
[i
] ) ;
1350 m_noItems
+= nItems
;
1353 void wxListBox::SetString(int N
, const wxString
& s
)
1355 m_stringArray
[N
] = s
;
1359 wxSize
wxListBox::DoGetBestSize() const
1361 int lbWidth
= 100; // some defaults
1366 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
1370 ::TextFont( m_font
.MacGetFontNum() ) ;
1371 ::TextSize( m_font
.MacGetFontSize() ) ;
1372 ::TextFace( m_font
.MacGetFontStyle() ) ;
1376 ::TextFont( kFontIDMonaco
) ;
1381 // Find the widest line
1382 for(int i
= 0; i
< GetCount(); i
++) {
1383 wxString
str(GetString(i
));
1385 Point bounds
={0,0} ;
1387 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
1388 kThemeCurrentPortFont
,
1395 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
1397 lbWidth
= wxMax(lbWidth
, wLine
);
1400 // Add room for the scrollbar
1401 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
1403 // And just a bit more
1405 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
1408 // don't make the listbox too tall (limit height to around 10 items) but don't
1409 // make it too small neither
1410 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
1413 return wxSize(lbWidth
, lbHeight
);
1416 int wxListBox::GetCount() const
1421 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
1423 wxControl::Refresh( eraseBack
, rect
) ;
1424 // MacRedrawControl() ;
1427 #if wxUSE_OWNER_DRAWN
1429 class wxListBoxItem
: public wxOwnerDrawn
1432 wxListBoxItem(const wxString
& str
= "");
1435 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
1437 // no bitmaps/checkmarks
1441 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
1443 return new wxListBoxItem();
1446 #endif //USE_OWNER_DRAWN
1448 // ============================================================================
1449 // list box control implementation
1450 // ============================================================================
1453 void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
1456 // typecast our refCon
1457 list = (wxListBox*)refCon;
1459 MoveTo(cellRect->left + 4 , cellRect->top + 10 );
1460 const wxString text = list->m_stringArray[lCell.v] ;
1461 ::TextFont( kFontIDMonaco ) ;
1464 DrawText(text, 0 , text.Length());
1468 void wxListBox::MacDelete( int N
)
1470 LDelRow( 1 , N
, (ListHandle
)m_macList
) ;
1474 void wxListBox::MacInsert( int n
, const wxString
& text
)
1476 Cell cell
= { 0 , 0 } ;
1478 LAddRow( 1 , cell
.v
, (ListHandle
)m_macList
) ;
1479 // LSetCell(text, strlen(text), cell, m_macList);
1483 void wxListBox::MacAppend( const wxString
& text
)
1485 Cell cell
= { 0 , 0 } ;
1486 cell
.v
= (**(ListHandle
)m_macList
).dataBounds
.bottom
;
1487 LAddRow( 1 , cell
.v
, (ListHandle
)m_macList
) ;
1488 // LSetCell(text, strlen(text), cell, m_macList);
1492 void wxListBox::MacClear()
1494 LDelRow( (**(ListHandle
)m_macList
).dataBounds
.bottom
, 0 ,(ListHandle
) m_macList
) ;
1498 void wxListBox::MacSetSelection( int n
, bool select
)
1500 Cell cell
= { 0 , 0 } ;
1501 if ( ! (m_windowStyle
& wxLB_MULTIPLE
) )
1503 if ( LGetSelect( true , &cell
, (ListHandle
)m_macList
) )
1505 LSetSelect( false , cell
, (ListHandle
)m_macList
) ;
1510 LSetSelect( select
, cell
, (ListHandle
)m_macList
) ;
1511 LAutoScroll( (ListHandle
)m_macList
) ;
1515 bool wxListBox::MacIsSelected( int n
) const
1517 Cell cell
= { 0 , 0 } ;
1519 return LGetSelect( false , &cell
, (ListHandle
)m_macList
) ;
1522 int wxListBox::MacGetSelection() const
1524 Cell cell
= { 0 , 0 } ;
1525 if ( LGetSelect( true , &cell
, (ListHandle
)m_macList
) )
1531 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
1535 aSelections
.Empty();
1537 Cell cell
= { 0 , 0 } ;
1540 while ( LGetSelect( true , &cell
,(ListHandle
) m_macList
) )
1542 aSelections
.Add( cell
.v
) ;
1549 void wxListBox::MacSet( int n
, const wxString
& text
)
1551 // our implementation does not store anything in the list
1552 // so we just have to redraw
1553 Cell cell
= { 0 , 0 } ;
1555 // LSetCell(text, strlen(text), cell, m_macList);
1559 void wxListBox::MacScrollTo( int n
)
1561 // TODO implement scrolling
1564 void wxListBox::OnSize( wxSizeEvent
&event
)
1569 GetListCellSize((ListHandle
)m_macList
, &pt
);
1571 pt
= (**(ListHandle
)m_macList
).cellSize
;
1574 GetSize( &w
, &h
) ;
1576 LCellSize( pt
, (ListHandle
)m_macList
) ;
1579 void wxListBox::MacHandleControlClick( WXWidget control
, wxInt16 controlpart
, bool WXUNUSED(mouseStillDown
))
1581 Boolean wasDoubleClick
= false ;
1584 ::GetControlData( (ControlRef
) m_macControl
, kControlNoPart
, kControlListBoxDoubleClickTag
, sizeof( wasDoubleClick
) , (char*) &wasDoubleClick
, &result
) ;
1585 if ( !wasDoubleClick
)
1591 MacDoDoubleClick() ;
1595 void wxListBox::MacSetRedraw( bool doDraw
)
1597 LSetDrawingMode( doDraw
, (ListHandle
)m_macList
) ;
1601 void wxListBox::MacDoClick()
1603 wxArrayInt aSelections
;
1605 size_t count
= GetSelections(aSelections
);
1607 if ( count
== m_selectionPreImage
.GetCount() )
1609 bool hasChanged
= false ;
1610 for ( size_t i
= 0 ; i
< count
; ++i
)
1612 if ( aSelections
[i
] != m_selectionPreImage
[i
] )
1624 m_selectionPreImage
= aSelections
;
1626 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1627 event
.SetEventObject( this );
1632 if ( HasClientObjectData() )
1633 event
.SetClientObject( GetClientObject(n
) );
1634 else if ( HasClientUntypedData() )
1635 event
.SetClientData( GetClientData(n
) );
1636 event
.SetString( GetString(n
) );
1643 event
.m_commandInt
= n
;
1645 GetEventHandler()->ProcessEvent(event
);
1648 void wxListBox::MacDoDoubleClick()
1650 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, m_windowId
);
1651 event
.SetEventObject( this );
1652 GetEventHandler()->ProcessEvent(event
) ;
1655 void wxListBox::OnChar(wxKeyEvent
& event
)
1657 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
1659 wxWindow
* parent
= GetParent() ;
1660 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
1661 parent
= parent
->GetParent() ;
1663 if ( parent
&& parent
->GetDefaultItem() )
1665 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
1667 if ( def
&& def
->IsEnabled() )
1669 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
1670 event
.SetEventObject(def
);
1671 def
->Command(event
);
1677 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
1678 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
1680 // FIXME: look in ancestors, not just parent.
1681 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
1684 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
1685 new_event
.SetEventObject( win
);
1686 win
->GetEventHandler()->ProcessEvent( new_event
);
1689 else if ( event
.GetKeyCode() == WXK_TAB
)
1691 wxNavigationKeyEvent new_event
;
1692 new_event
.SetEventObject( this );
1693 new_event
.SetDirection( !event
.ShiftDown() );
1694 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
1695 new_event
.SetWindowChange( event
.ControlDown() );
1696 new_event
.SetCurrentFocus( this );
1697 if ( !GetEventHandler()->ProcessEvent( new_event
) )
1700 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
1702 // perform the default key handling first
1703 wxControl::OnKeyDown( event
) ;
1705 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1706 event
.SetEventObject( this );
1708 wxArrayInt aSelections
;
1709 int n
, count
= GetSelections(aSelections
);
1713 if ( HasClientObjectData() )
1714 event
.SetClientObject( GetClientObject(n
) );
1715 else if ( HasClientUntypedData() )
1716 event
.SetClientData( GetClientData(n
) );
1717 event
.SetString( GetString(n
) );
1724 event
.m_commandInt
= n
;
1726 GetEventHandler()->ProcessEvent(event
);
1730 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
1732 m_typeIn
= wxEmptyString
;
1734 m_lastTypeIn
= event
.GetTimestamp() ;
1735 m_typeIn
+= (char) event
.GetKeyCode() ;
1736 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
1739 if ( GetSelection() != line
)
1741 SetSelection(line
) ;
1742 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
1743 event
.SetEventObject( this );
1745 if ( HasClientObjectData() )
1746 event
.SetClientObject( GetClientObject( line
) );
1747 else if ( HasClientUntypedData() )
1748 event
.SetClientData( GetClientData(line
) );
1749 event
.SetString( GetString(line
) );
1751 event
.m_commandInt
= line
;
1753 GetEventHandler()->ProcessEvent(event
);