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"
21 #include "wx/listbox.h"
22 #include "wx/button.h"
23 #include "wx/settings.h"
24 #include "wx/toplevel.h"
25 #include "wx/dynarray.h"
30 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
33 BEGIN_EVENT_TABLE(wxListBox
, wxControl
)
35 // EVT_SIZE( wxListBox::OnSize )
36 EVT_CHAR( wxListBox::OnChar
)
41 #include "wx/mac/uma.h"
43 const short kTextColumnId
= 1024 ;
45 // new databrowserbased version
46 // because of the limited insert
47 // functionality of DataBrowser,
48 // we just introduce id s corresponding
51 #if TARGET_API_MAC_OSX
52 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
53 DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
55 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
56 DataBrowserItemNotification message
)
59 long ref
= GetControlReference( browser
) ;
62 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
64 if (i
>= 0 && i
< list
->GetCount() )
66 bool trigger
= false ;
68 wxEVT_COMMAND_LISTBOX_SELECTED
, list
->GetId() );
71 case kDataBrowserItemDeselected
:
72 if ( list
->HasMultipleSelection() )
73 trigger
= !list
->MacIsSelectionSuppressed() ;
75 case kDataBrowserItemSelected
:
76 trigger
= !list
->MacIsSelectionSuppressed() ;
78 case kDataBrowserItemDoubleClicked
:
79 event
.SetEventType(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
) ;
87 event
.SetEventObject( list
);
88 if ( list
->HasClientObjectData() )
89 event
.SetClientObject( list
->GetClientObject(i
) );
90 else if ( list
->HasClientUntypedData() )
91 event
.SetClientData( list
->GetClientData(i
) );
92 event
.SetString( list
->GetString(i
) );
94 event
.SetExtraLong( list
->HasMultipleSelection() ? message
== kDataBrowserItemSelected
: TRUE
);
95 wxPostEvent( list
->GetEventHandler() , event
) ;
96 // direct notification is not always having the listbox GetSelection() having in synch with event
97 // list->GetEventHandler()->ProcessEvent(event) ;
103 static pascal OSStatus
ListBoxGetSetItemData(ControlRef browser
,
104 DataBrowserItemID itemID
, DataBrowserPropertyID property
,
105 DataBrowserItemDataRef itemData
, Boolean changeValue
)
107 OSStatus err
= errDataBrowserPropertyNotSupported
;
116 long ref
= GetControlReference( browser
) ;
119 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
121 if (i
>= 0 && i
< list
->GetCount() )
123 wxMacCFStringHolder
cf( list
->GetString(i
) , list
->GetFont().GetEncoding() ) ;
124 verify_noerr( ::SetDataBrowserItemDataText( itemData
, cf
) ) ;
142 wxListBox::wxListBox()
147 m_suppressSelection
= false ;
150 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
153 const wxArrayString
& choices
,
155 const wxValidator
& validator
,
156 const wxString
& name
)
158 wxCArrayString
chs(choices
);
160 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
161 style
, validator
, name
);
164 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
167 int n
, const wxString choices
[],
169 const wxValidator
& validator
,
170 const wxString
& name
)
172 m_macIsUserPane
= FALSE
;
174 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
175 _T("only one of listbox selection modes can be specified") );
177 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
180 m_noItems
= 0 ; // this will be increased by our append command
183 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
185 m_peer
= new wxMacControl(this) ;
186 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, m_peer
->GetControlRefAddr() ) );
188 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
189 if ( style
& wxLB_MULTIPLE
)
191 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
193 else if ( style
& wxLB_EXTENDED
)
199 options
+= kDataBrowserSelectOnlyOne
;
201 verify_noerr(m_peer
->SetSelectionFlags( options
) );
203 DataBrowserListViewColumnDesc columnDesc
;
204 columnDesc
.headerBtnDesc
.titleOffset
= 0;
205 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
207 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
208 kControlUseFontMask
| kControlUseJustMask
;
210 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
211 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
212 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
213 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
214 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
216 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
217 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
218 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
220 columnDesc
.propertyDesc
.propertyID
= kTextColumnId
;
221 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
222 columnDesc
.propertyDesc
.propertyFlags
=
223 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
224 kDataBrowserListViewTypeSelectColumn
|
226 kDataBrowserTableViewSelectionColumn
;
229 verify_noerr(m_peer
->AddListViewColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
230 verify_noerr(m_peer
->AutoSizeListViewColumns() ) ;
231 verify_noerr(m_peer
->SetHasScrollBars(false , true ) ) ;
232 verify_noerr(m_peer
->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite
) ) ;
233 verify_noerr(m_peer
->SetListViewHeaderBtnHeight( 0 ) ) ;
234 DataBrowserCallbacks callbacks
;
236 callbacks
.version
= kDataBrowserLatestCallbacks
;
238 InitDataBrowserCallbacks(&callbacks
);
240 callbacks
.u
.v1
.itemDataCallback
=
241 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
243 callbacks
.u
.v1
.itemNotificationCallback
=
244 #if TARGET_API_MAC_OSX
245 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
) ;
247 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
) ;
249 m_peer
->SetCallbacks( &callbacks
);
251 #if TARGET_API_MAC_OSX
252 // there is a redraw bug in 10.2.X
253 if ( UMAGetSystemVersion() < 0x1030 )
254 m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
256 MacPostControlCreate(pos
,size
) ;
258 for ( int i
= 0 ; i
< n
; i
++ )
260 Append( choices
[i
] ) ;
263 SetBestSize(size
); // Needed because it is a wxControlWithItems
268 wxListBox::~wxListBox()
270 m_peer
->SetReference( 0 ) ;
272 // avoid access during destruction
279 void wxListBox::FreeData()
281 #if wxUSE_OWNER_DRAWN
282 if ( m_windowStyle
& wxLB_OWNERDRAW
)
284 size_t uiCount
= m_aItems
.Count();
285 while ( uiCount
-- != 0 ) {
286 delete m_aItems
[uiCount
];
287 m_aItems
[uiCount
] = NULL
;
293 #endif // wxUSE_OWNER_DRAWN
294 if ( HasClientObjectData() )
296 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
298 delete GetClientObject(n
);
303 void wxListBox::DoSetSize(int x
, int y
,
304 int width
, int height
,
307 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
310 void wxListBox::DoSetFirstItem(int N
)
315 void wxListBox::Delete(int N
)
317 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
318 wxT("invalid index in wxListBox::Delete") );
320 #if wxUSE_OWNER_DRAWN
322 m_aItems
.RemoveAt(N
);
323 #else // !wxUSE_OWNER_DRAWN
324 if ( HasClientObjectData() )
326 delete GetClientObject(N
);
328 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
329 m_stringArray
.RemoveAt( N
) ;
330 m_dataArray
.RemoveAt( N
) ;
336 int wxListBox::DoAppend(const wxString
& item
)
338 InvalidateBestSize();
340 int index
= m_noItems
;
341 m_stringArray
.Add( item
) ;
342 m_dataArray
.Add( NULL
);
344 DoSetItemClientData( index
, NULL
) ;
350 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
353 int n
= choices
.GetCount();
355 for( int i
= 0 ; i
< n
; ++i
)
359 #if wxUSE_OWNER_DRAWN
360 wxASSERT_MSG(clientData
[i
] == NULL
,
361 wxT("Can't use client data with owner-drawn listboxes"));
362 #else // !wxUSE_OWNER_DRAWN
363 Append( choices
[i
] , clientData
[i
] ) ;
367 Append( choices
[i
] ) ;
370 #if wxUSE_OWNER_DRAWN
371 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
372 // first delete old items
373 size_t ui
= m_aItems
.Count();
374 while ( ui
-- != 0 ) {
380 // then create new ones
381 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
382 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
383 pNewItem
->SetName(choices
[ui
]);
384 m_aItems
.Add(pNewItem
);
387 #endif // wxUSE_OWNER_DRAWN
390 int wxListBox::FindString(const wxString
& s
) const
393 if ( s
.Right(1) == wxT("*") )
395 wxString search
= s
.Left( s
.Length() - 1 ) ;
396 int len
= search
.Length() ;
398 wxMacStringToPascal( search
, s2
) ;
400 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
402 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
404 if ( EqualString( s1
, s2
, false , false ) )
407 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
411 for ( int i
= 0 ; i
< m_noItems
; ++i
)
413 if ( GetString(i
).Lower().Matches(st
) )
423 wxMacStringToPascal( s
, s2
) ;
425 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
427 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
429 if ( EqualString( s1
, s2
, false , false ) )
436 void wxListBox::Clear()
440 m_stringArray
.Empty() ;
441 m_dataArray
.Empty() ;
445 void wxListBox::DoSetSelection(int N
, bool select
)
447 wxCHECK_RET( N
== wxNOT_FOUND
|| (N
>= 0 && N
< m_noItems
) ,
448 wxT("invalid index in wxListBox::SetSelection") );
450 if ( N
== wxNOT_FOUND
)
453 MacSetSelection( N
, select
) ;
456 bool wxListBox::IsSelected(int N
) const
458 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
459 wxT("invalid index in wxListBox::Selected") );
461 return MacIsSelected( N
) ;
464 void *wxListBox::DoGetItemClientData(int N
) const
466 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
467 wxT("invalid index in wxListBox::GetClientData"));
469 return (void *)m_dataArray
[N
];
472 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
474 return (wxClientData
*) DoGetItemClientData( N
) ;
477 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
479 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
480 wxT("invalid index in wxListBox::SetClientData") );
482 #if wxUSE_OWNER_DRAWN
483 if ( m_windowStyle
& wxLB_OWNERDRAW
)
485 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
486 // in OnMeasure/OnDraw.
487 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
489 #endif // wxUSE_OWNER_DRAWN
490 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
492 if ( m_dataArray
.GetCount() > (size_t) N
)
494 m_dataArray
[N
] = (char*) Client_data
;
498 m_dataArray
.Add( (char*) Client_data
) ;
502 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
504 DoSetItemClientData(n
, clientData
);
507 // Return number of selections and an array of selected integers
508 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
510 return MacGetSelections( aSelections
) ;
513 // Get single selection, for single choice list items
514 int wxListBox::GetSelection() const
516 return MacGetSelection() ;
519 // Find string for position
520 wxString
wxListBox::GetString(int N
) const
522 return m_stringArray
[N
] ;
525 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
527 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
528 wxT("invalid index in wxListBox::InsertItems") );
530 InvalidateBestSize();
532 int nItems
= items
.GetCount();
534 for ( int i
= 0 ; i
< nItems
; i
++ )
536 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
537 m_dataArray
.Insert( NULL
, pos
+ i
) ;
539 MacInsert( pos
+ i
, items
[i
] ) ;
543 void wxListBox::SetString(int N
, const wxString
& s
)
545 m_stringArray
[N
] = s
;
549 wxSize
wxListBox::DoGetBestSize() const
551 int lbWidth
= 100; // some defaults
556 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
560 ::TextFont( m_font
.MacGetFontNum() ) ;
561 ::TextSize( m_font
.MacGetFontSize() ) ;
562 ::TextFace( m_font
.MacGetFontStyle() ) ;
566 ::TextFont( kFontIDMonaco
) ;
571 // Find the widest line
572 for(int i
= 0; i
< GetCount(); i
++) {
573 wxString
str(GetString(i
));
577 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
578 kThemeCurrentPortFont
,
585 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
587 lbWidth
= wxMax(lbWidth
, wLine
);
590 // Add room for the scrollbar
591 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
593 // And just a bit more
595 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
598 // don't make the listbox too tall (limit height to around 10 items) but don't
599 // make it too small neither
600 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
603 return wxSize(lbWidth
, lbHeight
);
606 int wxListBox::GetCount() const
611 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
613 wxControl::Refresh( eraseBack
, rect
) ;
616 #if wxUSE_OWNER_DRAWN
618 class wxListBoxItem
: public wxOwnerDrawn
621 wxListBoxItem(const wxString
& str
= "");
624 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
626 // no bitmaps/checkmarks
630 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
632 return new wxListBoxItem();
635 #endif //USE_OWNER_DRAWN
638 // Some custom controls depend on this
639 /* static */ wxVisualAttributes
640 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
642 wxVisualAttributes attr
;
643 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
644 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
645 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
649 // ============================================================================
650 // list box control implementation
651 // ============================================================================
653 void wxListBox::MacDelete( int n
)
655 wxArrayInt selectionBefore
;
656 MacGetSelections( selectionBefore
) ;
658 UInt32 id
= m_noItems
+1 ;
659 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
660 for ( size_t i
= 0 ; i
< selectionBefore
.GetCount() ; ++i
)
662 int current
= selectionBefore
[i
] ;
665 // selection was deleted
666 MacSetSelection( current
, false ) ;
668 else if ( current
> n
)
670 // something behind the deleted item was selected -> move up
671 MacSetSelection( current
- 1 , true ) ;
672 MacSetSelection( current
, false ) ;
676 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
679 void wxListBox::MacInsert( int n
, const wxString
& text
)
681 wxArrayInt selectionBefore
;
682 MacGetSelections( selectionBefore
) ;
684 UInt32 id
= m_noItems
; // this has already been increased
685 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
687 for ( int i
= selectionBefore
.GetCount()-1 ; i
>= 0 ; --i
)
689 int current
= selectionBefore
[i
] ;
692 MacSetSelection( current
+ 1 , true ) ;
693 MacSetSelection( current
, false ) ;
698 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
701 void wxListBox::MacAppend( const wxString
& text
)
703 UInt32 id
= m_noItems
; // this has already been increased
704 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
705 // no need to deal with selections nor refreshed, as we have appended
708 void wxListBox::MacClear()
710 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
713 void wxListBox::MacDeselectAll()
715 bool former
= MacSuppressSelection( true ) ;
716 verify_noerr(m_peer
->SetSelectedItems( 0 , NULL
, kDataBrowserItemsRemove
) ) ;
717 MacSuppressSelection( former
) ;
720 void wxListBox::MacSetSelection( int n
, bool select
)
722 bool former
= MacSuppressSelection( true ) ;
725 if ( m_peer
->IsItemSelected( id
) != select
)
728 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, HasMultipleSelection() ? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
) ) ;
730 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsRemove
) ) ;
733 MacSuppressSelection( former
) ;
736 bool wxListBox::MacSuppressSelection( bool suppress
)
738 bool former
= m_suppressSelection
;
739 m_suppressSelection
= suppress
;
743 bool wxListBox::MacIsSelected( int n
) const
745 return m_peer
->IsItemSelected( n
+ 1 ) ;
748 int wxListBox::MacGetSelection() const
750 for ( int i
= 0 ; i
< GetCount() ; ++i
)
752 if ( m_peer
->IsItemSelected( i
+ 1 ) )
760 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
766 UInt32 first
, last
;
767 m_peer
->GetSelectionAnchor( &first
, &last
) ;
768 if ( first
!= kDataBrowserNoItem
)
770 for ( size_t i
= first
; i
<= last
; ++i
)
772 if ( m_peer
->IsItemSelected( i
) )
774 aSelections
.Add( i
- 1 ) ;
782 void wxListBox::MacSet( int n
, const wxString
& text
)
784 // as we don't store the strings we only have to issue a redraw
786 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
789 void wxListBox::MacScrollTo( int n
)
792 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
795 #if !TARGET_API_MAC_OSX
797 void wxListBox::OnChar(wxKeyEvent
& event
)
799 // todo trigger proper events here
803 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
805 wxWindow
* parent
= GetParent() ;
806 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
807 parent
= parent
->GetParent() ;
809 if ( parent
&& parent
->GetDefaultItem() )
811 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
813 if ( def
&& def
->IsEnabled() )
815 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
816 event
.SetEventObject(def
);
823 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
824 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
826 // FIXME: look in ancestors, not just parent.
827 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
830 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
831 new_event
.SetEventObject( win
);
832 win
->GetEventHandler()->ProcessEvent( new_event
);
835 else if ( event
.GetKeyCode() == WXK_TAB
)
837 wxNavigationKeyEvent new_event
;
838 new_event
.SetEventObject( this );
839 new_event
.SetDirection( !event
.ShiftDown() );
840 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
841 new_event
.SetWindowChange( event
.ControlDown() );
842 new_event
.SetCurrentFocus( this );
843 if ( !GetEventHandler()->ProcessEvent( new_event
) )
846 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
848 // perform the default key handling first
849 wxControl::OnKeyDown( event
) ;
851 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
852 event
.SetEventObject( this );
854 wxArrayInt aSelections
;
855 int n
, count
= GetSelections(aSelections
);
859 if ( HasClientObjectData() )
860 event
.SetClientObject( GetClientObject(n
) );
861 else if ( HasClientUntypedData() )
862 event
.SetClientData( GetClientData(n
) );
863 event
.SetString( GetString(n
) );
872 GetEventHandler()->ProcessEvent(event
);
876 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
878 m_typeIn
= wxEmptyString
;
880 m_lastTypeIn
= event
.GetTimestamp() ;
881 m_typeIn
+= (char) event
.GetKeyCode() ;
882 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
885 if ( GetSelection() != line
)
888 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
889 event
.SetEventObject( this );
891 if ( HasClientObjectData() )
892 event
.SetClientObject( GetClientObject( line
) );
893 else if ( HasClientUntypedData() )
894 event
.SetClientData( GetClientData(line
) );
895 event
.SetString( GetString(line
) );
899 GetEventHandler()->ProcessEvent(event
);
905 #endif // !TARGET_API_MAC_OSX