1 ///////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "listbox.h"
16 #include "wx/wxprec.h"
19 #include "wx/listbox.h"
20 #include "wx/button.h"
21 #include "wx/settings.h"
22 #include "wx/toplevel.h"
23 #include "wx/dynarray.h"
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
31 BEGIN_EVENT_TABLE(wxListBox
, wxControl
)
33 // EVT_SIZE( wxListBox::OnSize )
34 EVT_CHAR( wxListBox::OnChar
)
39 #include "wx/mac/uma.h"
41 const short kTextColumnId
= 1024 ;
43 // new databrowserbased version
44 // because of the limited insert
45 // functionality of DataBrowser,
46 // we just introduce id s corresponding
49 #if TARGET_API_MAC_OSX
50 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
51 DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
53 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
54 DataBrowserItemNotification message
)
57 long ref
= GetControlReference( browser
) ;
60 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
62 if (i
>= 0 && i
< list
->GetCount() )
64 bool trigger
= false ;
66 wxEVT_COMMAND_LISTBOX_SELECTED
, list
->GetId() );
69 case kDataBrowserItemDeselected
:
70 if ( list
->HasMultipleSelection() )
71 trigger
= !list
->MacIsSelectionSuppressed() ;
73 case kDataBrowserItemSelected
:
74 trigger
= !list
->MacIsSelectionSuppressed() ;
76 case kDataBrowserItemDoubleClicked
:
77 event
.SetEventType(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
) ;
85 event
.SetEventObject( list
);
86 if ( list
->HasClientObjectData() )
87 event
.SetClientObject( list
->GetClientObject(i
) );
88 else if ( list
->HasClientUntypedData() )
89 event
.SetClientData( list
->GetClientData(i
) );
90 event
.SetString( list
->GetString(i
) );
92 event
.SetExtraLong( list
->HasMultipleSelection() ? message
== kDataBrowserItemSelected
: TRUE
);
93 wxPostEvent( list
->GetEventHandler() , event
) ;
94 // direct notification is not always having the listbox GetSelection() having in synch with event
95 // list->GetEventHandler()->ProcessEvent(event) ;
101 static pascal OSStatus
ListBoxGetSetItemData(ControlRef browser
,
102 DataBrowserItemID itemID
, DataBrowserPropertyID property
,
103 DataBrowserItemDataRef itemData
, Boolean changeValue
)
105 OSStatus err
= errDataBrowserPropertyNotSupported
;
114 long ref
= GetControlReference( browser
) ;
117 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
119 if (i
>= 0 && i
< list
->GetCount() )
121 wxMacCFStringHolder
cf( list
->GetString(i
) , list
->GetFont().GetEncoding() ) ;
122 verify_noerr( ::SetDataBrowserItemDataText( itemData
, cf
) ) ;
140 wxListBox::wxListBox()
145 m_suppressSelection
= false ;
148 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
151 const wxArrayString
& choices
,
153 const wxValidator
& validator
,
154 const wxString
& name
)
156 wxCArrayString
chs(choices
);
158 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
159 style
, validator
, name
);
162 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
165 int n
, const wxString choices
[],
167 const wxValidator
& validator
,
168 const wxString
& name
)
170 m_macIsUserPane
= FALSE
;
172 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
173 _T("only one of listbox selection modes can be specified") );
175 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
178 m_noItems
= 0 ; // this will be increased by our append command
181 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
183 m_peer
= new wxMacControl() ;
184 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, m_peer
->GetControlRefAddr() ) );
186 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
187 if ( style
& wxLB_MULTIPLE
)
189 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
191 else if ( style
& wxLB_EXTENDED
)
197 options
+= kDataBrowserSelectOnlyOne
;
199 verify_noerr(m_peer
->SetSelectionFlags( options
) );
201 DataBrowserListViewColumnDesc columnDesc
;
202 columnDesc
.headerBtnDesc
.titleOffset
= 0;
203 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
205 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
206 kControlUseFontMask
| kControlUseJustMask
;
208 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
209 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
210 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
211 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
212 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
214 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
215 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
216 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
218 columnDesc
.propertyDesc
.propertyID
= kTextColumnId
;
219 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
220 columnDesc
.propertyDesc
.propertyFlags
=
221 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
222 kDataBrowserListViewTypeSelectColumn
|
224 kDataBrowserTableViewSelectionColumn
;
227 verify_noerr(m_peer
->AddListViewColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
228 verify_noerr(m_peer
->AutoSizeListViewColumns() ) ;
229 verify_noerr(m_peer
->SetHasScrollBars(false , true ) ) ;
230 verify_noerr(m_peer
->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite
) ) ;
231 verify_noerr(m_peer
->SetListViewHeaderBtnHeight( 0 ) ) ;
232 DataBrowserCallbacks callbacks
;
234 callbacks
.version
= kDataBrowserLatestCallbacks
;
236 InitDataBrowserCallbacks(&callbacks
);
238 callbacks
.u
.v1
.itemDataCallback
=
239 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
241 callbacks
.u
.v1
.itemNotificationCallback
=
242 #if TARGET_API_MAC_OSX
243 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
) ;
245 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
) ;
247 m_peer
->SetCallbacks( &callbacks
);
249 #if TARGET_API_MAC_OSX
250 // there is a redraw bug in 10.2.X
251 if ( UMAGetSystemVersion() < 0x1030 )
252 m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
254 MacPostControlCreate(pos
,size
) ;
256 for ( int i
= 0 ; i
< n
; i
++ )
258 Append( choices
[i
] ) ;
261 SetBestSize(size
); // Needed because it is a wxControlWithItems
266 wxListBox::~wxListBox()
268 m_peer
->SetReference( 0 ) ;
270 // avoid access during destruction
277 void wxListBox::FreeData()
279 #if wxUSE_OWNER_DRAWN
280 if ( m_windowStyle
& wxLB_OWNERDRAW
)
282 size_t uiCount
= m_aItems
.Count();
283 while ( uiCount
-- != 0 ) {
284 delete m_aItems
[uiCount
];
285 m_aItems
[uiCount
] = NULL
;
291 #endif // wxUSE_OWNER_DRAWN
292 if ( HasClientObjectData() )
294 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
296 delete GetClientObject(n
);
301 void wxListBox::DoSetSize(int x
, int y
,
302 int width
, int height
,
305 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
308 void wxListBox::DoSetFirstItem(int N
)
313 void wxListBox::Delete(int N
)
315 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
316 wxT("invalid index in wxListBox::Delete") );
318 #if wxUSE_OWNER_DRAWN
320 m_aItems
.RemoveAt(N
);
321 #else // !wxUSE_OWNER_DRAWN
322 if ( HasClientObjectData() )
324 delete GetClientObject(N
);
326 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
327 m_stringArray
.RemoveAt( N
) ;
328 m_dataArray
.RemoveAt( N
) ;
334 int wxListBox::DoAppend(const wxString
& item
)
336 InvalidateBestSize();
338 int index
= m_noItems
;
339 m_stringArray
.Add( item
) ;
340 m_dataArray
.Add( NULL
);
342 DoSetItemClientData( index
, NULL
) ;
348 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
351 int n
= choices
.GetCount();
353 for( int i
= 0 ; i
< n
; ++i
)
357 #if wxUSE_OWNER_DRAWN
358 wxASSERT_MSG(clientData
[i
] == NULL
,
359 wxT("Can't use client data with owner-drawn listboxes"));
360 #else // !wxUSE_OWNER_DRAWN
361 Append( choices
[i
] , clientData
[i
] ) ;
365 Append( choices
[i
] ) ;
368 #if wxUSE_OWNER_DRAWN
369 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
370 // first delete old items
371 size_t ui
= m_aItems
.Count();
372 while ( ui
-- != 0 ) {
378 // then create new ones
379 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
380 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
381 pNewItem
->SetName(choices
[ui
]);
382 m_aItems
.Add(pNewItem
);
385 #endif // wxUSE_OWNER_DRAWN
388 int wxListBox::FindString(const wxString
& s
) const
391 if ( s
.Right(1) == wxT("*") )
393 wxString search
= s
.Left( s
.Length() - 1 ) ;
394 int len
= search
.Length() ;
396 wxMacStringToPascal( search
, s2
) ;
398 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
400 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
402 if ( EqualString( s1
, s2
, false , false ) )
405 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
409 for ( int i
= 0 ; i
< m_noItems
; ++i
)
411 if ( GetString(i
).Lower().Matches(st
) )
421 wxMacStringToPascal( s
, s2
) ;
423 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
425 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
427 if ( EqualString( s1
, s2
, false , false ) )
434 void wxListBox::Clear()
438 m_stringArray
.Empty() ;
439 m_dataArray
.Empty() ;
443 void wxListBox::DoSetSelection(int N
, bool select
)
445 wxCHECK_RET( N
== wxNOT_FOUND
|| (N
>= 0 && N
< m_noItems
) ,
446 wxT("invalid index in wxListBox::SetSelection") );
448 if ( N
== wxNOT_FOUND
)
451 MacSetSelection( N
, select
) ;
454 bool wxListBox::IsSelected(int N
) const
456 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
457 wxT("invalid index in wxListBox::Selected") );
459 return MacIsSelected( N
) ;
462 void *wxListBox::DoGetItemClientData(int N
) const
464 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
465 wxT("invalid index in wxListBox::GetClientData"));
467 return (void *)m_dataArray
[N
];
470 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
472 return (wxClientData
*) DoGetItemClientData( N
) ;
475 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
477 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
478 wxT("invalid index in wxListBox::SetClientData") );
480 #if wxUSE_OWNER_DRAWN
481 if ( m_windowStyle
& wxLB_OWNERDRAW
)
483 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
484 // in OnMeasure/OnDraw.
485 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
487 #endif // wxUSE_OWNER_DRAWN
488 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
490 if ( m_dataArray
.GetCount() > (size_t) N
)
492 m_dataArray
[N
] = (char*) Client_data
;
496 m_dataArray
.Add( (char*) Client_data
) ;
500 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
502 DoSetItemClientData(n
, clientData
);
505 // Return number of selections and an array of selected integers
506 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
508 return MacGetSelections( aSelections
) ;
511 // Get single selection, for single choice list items
512 int wxListBox::GetSelection() const
514 return MacGetSelection() ;
517 // Find string for position
518 wxString
wxListBox::GetString(int N
) const
520 return m_stringArray
[N
] ;
523 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
525 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
526 wxT("invalid index in wxListBox::InsertItems") );
528 InvalidateBestSize();
530 int nItems
= items
.GetCount();
532 for ( int i
= 0 ; i
< nItems
; i
++ )
534 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
535 m_dataArray
.Insert( NULL
, pos
+ i
) ;
537 MacInsert( pos
+ i
, items
[i
] ) ;
541 void wxListBox::SetString(int N
, const wxString
& s
)
543 m_stringArray
[N
] = s
;
547 wxSize
wxListBox::DoGetBestSize() const
549 int lbWidth
= 100; // some defaults
554 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
558 ::TextFont( m_font
.MacGetFontNum() ) ;
559 ::TextSize( m_font
.MacGetFontSize() ) ;
560 ::TextFace( m_font
.MacGetFontStyle() ) ;
564 ::TextFont( kFontIDMonaco
) ;
569 // Find the widest line
570 for(int i
= 0; i
< GetCount(); i
++) {
571 wxString
str(GetString(i
));
575 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
576 kThemeCurrentPortFont
,
583 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
585 lbWidth
= wxMax(lbWidth
, wLine
);
588 // Add room for the scrollbar
589 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
591 // And just a bit more
593 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
596 // don't make the listbox too tall (limit height to around 10 items) but don't
597 // make it too small neither
598 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
601 return wxSize(lbWidth
, lbHeight
);
604 int wxListBox::GetCount() const
609 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
611 wxControl::Refresh( eraseBack
, rect
) ;
614 #if wxUSE_OWNER_DRAWN
616 class wxListBoxItem
: public wxOwnerDrawn
619 wxListBoxItem(const wxString
& str
= "");
622 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
624 // no bitmaps/checkmarks
628 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
630 return new wxListBoxItem();
633 #endif //USE_OWNER_DRAWN
636 // Some custom controls depend on this
637 /* static */ wxVisualAttributes
638 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
640 wxVisualAttributes attr
;
641 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
642 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
643 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
647 // ============================================================================
648 // list box control implementation
649 // ============================================================================
651 void wxListBox::MacDelete( int n
)
653 wxArrayInt selectionBefore
;
654 MacGetSelections( selectionBefore
) ;
656 UInt32 id
= m_noItems
+1 ;
657 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
658 for ( size_t i
= 0 ; i
< selectionBefore
.GetCount() ; ++i
)
660 int current
= selectionBefore
[i
] ;
663 // selection was deleted
664 MacSetSelection( current
, false ) ;
666 else if ( current
> n
)
668 // something behind the deleted item was selected -> move up
669 MacSetSelection( current
- 1 , true ) ;
670 MacSetSelection( current
, false ) ;
674 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
677 void wxListBox::MacInsert( int n
, const wxString
& text
)
679 wxArrayInt selectionBefore
;
680 MacGetSelections( selectionBefore
) ;
682 UInt32 id
= m_noItems
; // this has already been increased
683 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
685 for ( int i
= selectionBefore
.GetCount()-1 ; i
>= 0 ; --i
)
687 int current
= selectionBefore
[i
] ;
690 MacSetSelection( current
+ 1 , true ) ;
691 MacSetSelection( current
, false ) ;
696 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
699 void wxListBox::MacAppend( const wxString
& text
)
701 UInt32 id
= m_noItems
; // this has already been increased
702 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
703 // no need to deal with selections nor refreshed, as we have appended
706 void wxListBox::MacClear()
708 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
711 void wxListBox::MacDeselectAll()
713 bool former
= MacSuppressSelection( true ) ;
714 verify_noerr(m_peer
->SetSelectedItems( 0 , NULL
, kDataBrowserItemsRemove
) ) ;
715 MacSuppressSelection( former
) ;
718 void wxListBox::MacSetSelection( int n
, bool select
)
720 bool former
= MacSuppressSelection( true ) ;
723 if ( m_peer
->IsItemSelected( id
) != select
)
726 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, HasMultipleSelection() ? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
) ) ;
728 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsRemove
) ) ;
731 MacSuppressSelection( former
) ;
734 bool wxListBox::MacSuppressSelection( bool suppress
)
736 bool former
= m_suppressSelection
;
737 m_suppressSelection
= suppress
;
741 bool wxListBox::MacIsSelected( int n
) const
743 return m_peer
->IsItemSelected( n
+ 1 ) ;
746 int wxListBox::MacGetSelection() const
748 for ( int i
= 0 ; i
< GetCount() ; ++i
)
750 if ( m_peer
->IsItemSelected( i
+ 1 ) )
758 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
764 UInt32 first
, last
;
765 m_peer
->GetSelectionAnchor( &first
, &last
) ;
766 if ( first
!= kDataBrowserNoItem
)
768 for ( size_t i
= first
; i
<= last
; ++i
)
770 if ( m_peer
->IsItemSelected( i
) )
772 aSelections
.Add( i
- 1 ) ;
780 void wxListBox::MacSet( int n
, const wxString
& text
)
782 // as we don't store the strings we only have to issue a redraw
784 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
787 void wxListBox::MacScrollTo( int n
)
790 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
793 #if !TARGET_API_MAC_OSX
795 void wxListBox::OnChar(wxKeyEvent
& event
)
797 // todo trigger proper events here
801 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
803 wxWindow
* parent
= GetParent() ;
804 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
805 parent
= parent
->GetParent() ;
807 if ( parent
&& parent
->GetDefaultItem() )
809 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
811 if ( def
&& def
->IsEnabled() )
813 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
814 event
.SetEventObject(def
);
821 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
822 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
824 // FIXME: look in ancestors, not just parent.
825 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
828 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
829 new_event
.SetEventObject( win
);
830 win
->GetEventHandler()->ProcessEvent( new_event
);
833 else if ( event
.GetKeyCode() == WXK_TAB
)
835 wxNavigationKeyEvent new_event
;
836 new_event
.SetEventObject( this );
837 new_event
.SetDirection( !event
.ShiftDown() );
838 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
839 new_event
.SetWindowChange( event
.ControlDown() );
840 new_event
.SetCurrentFocus( this );
841 if ( !GetEventHandler()->ProcessEvent( new_event
) )
844 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
846 // perform the default key handling first
847 wxControl::OnKeyDown( event
) ;
849 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
850 event
.SetEventObject( this );
852 wxArrayInt aSelections
;
853 int n
, count
= GetSelections(aSelections
);
857 if ( HasClientObjectData() )
858 event
.SetClientObject( GetClientObject(n
) );
859 else if ( HasClientUntypedData() )
860 event
.SetClientData( GetClientData(n
) );
861 event
.SetString( GetString(n
) );
870 GetEventHandler()->ProcessEvent(event
);
874 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
876 m_typeIn
= wxEmptyString
;
878 m_lastTypeIn
= event
.GetTimestamp() ;
879 m_typeIn
+= (char) event
.GetKeyCode() ;
880 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
883 if ( GetSelection() != line
)
886 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
887 event
.SetEventObject( this );
889 if ( HasClientObjectData() )
890 event
.SetClientObject( GetClientObject( line
) );
891 else if ( HasClientUntypedData() )
892 event
.SetClientData( GetClientData(line
) );
893 event
.SetString( GetString(line
) );
897 GetEventHandler()->ProcessEvent(event
);
903 #endif // !TARGET_API_MAC_OSX