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
)
31 // EVT_SIZE( wxListBox::OnSize )
32 EVT_CHAR( wxListBox::OnChar
)
37 #include "wx/mac/uma.h"
39 const short kTextColumnId
= 1024 ;
41 // new databrowserbased version
42 // because of the limited insert
43 // functionality of DataBrowser,
44 // we just introduce id s corresponding
47 #if TARGET_API_MAC_OSX
48 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
49 DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
51 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
52 DataBrowserItemNotification message
)
55 long ref
= GetControlReference( browser
) ;
58 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
60 if (i
>= 0 && i
< list
->GetCount() )
62 bool trigger
= false ;
64 wxEVT_COMMAND_LISTBOX_SELECTED
, list
->GetId() );
67 case kDataBrowserItemDeselected
:
68 if ( list
->HasMultipleSelection() )
69 trigger
= !list
->MacIsSelectionSuppressed() ;
71 case kDataBrowserItemSelected
:
72 trigger
= !list
->MacIsSelectionSuppressed() ;
74 case kDataBrowserItemDoubleClicked
:
75 event
.SetEventType(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
) ;
83 event
.SetEventObject( list
);
84 if ( list
->HasClientObjectData() )
85 event
.SetClientObject( list
->GetClientObject(i
) );
86 else if ( list
->HasClientUntypedData() )
87 event
.SetClientData( list
->GetClientData(i
) );
88 event
.SetString( list
->GetString(i
) );
90 event
.SetExtraLong( list
->HasMultipleSelection() ? message
== kDataBrowserItemSelected
: TRUE
);
91 wxPostEvent( list
->GetEventHandler() , event
) ;
92 // direct notification is not always having the listbox GetSelection() having in synch with event
93 // list->GetEventHandler()->ProcessEvent(event) ;
99 static pascal OSStatus
ListBoxGetSetItemData(ControlRef browser
,
100 DataBrowserItemID itemID
, DataBrowserPropertyID property
,
101 DataBrowserItemDataRef itemData
, Boolean changeValue
)
103 OSStatus err
= errDataBrowserPropertyNotSupported
;
112 long ref
= GetControlReference( browser
) ;
115 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
117 if (i
>= 0 && i
< list
->GetCount() )
119 wxMacCFStringHolder
cf( list
->GetString(i
) , list
->GetFont().GetEncoding() ) ;
120 verify_noerr( ::SetDataBrowserItemDataText( itemData
, cf
) ) ;
138 wxListBox::wxListBox()
143 m_suppressSelection
= false ;
146 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
149 const wxArrayString
& choices
,
151 const wxValidator
& validator
,
152 const wxString
& name
)
154 wxCArrayString
chs(choices
);
156 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
157 style
, validator
, name
);
160 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
163 int n
, const wxString choices
[],
165 const wxValidator
& validator
,
166 const wxString
& name
)
168 m_macIsUserPane
= FALSE
;
170 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
171 _T("only one of listbox selection modes can be specified") );
173 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
176 m_noItems
= 0 ; // this will be increased by our append command
179 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
181 m_peer
= new wxMacControl() ;
182 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, m_peer
->GetControlRefAddr() ) );
184 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
185 if ( style
& wxLB_MULTIPLE
)
187 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
189 else if ( style
& wxLB_EXTENDED
)
195 options
+= kDataBrowserSelectOnlyOne
;
197 verify_noerr(m_peer
->SetSelectionFlags( options
) );
199 DataBrowserListViewColumnDesc columnDesc
;
200 columnDesc
.headerBtnDesc
.titleOffset
= 0;
201 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
203 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
204 kControlUseFontMask
| kControlUseJustMask
;
206 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
207 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
208 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
209 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
210 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
212 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
213 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
214 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
216 columnDesc
.propertyDesc
.propertyID
= kTextColumnId
;
217 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
218 columnDesc
.propertyDesc
.propertyFlags
=
219 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
220 kDataBrowserListViewTypeSelectColumn
|
222 kDataBrowserTableViewSelectionColumn
;
225 verify_noerr(m_peer
->AddListViewColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
226 verify_noerr(m_peer
->AutoSizeListViewColumns() ) ;
227 verify_noerr(m_peer
->SetHasScrollBars(false , true ) ) ;
228 verify_noerr(m_peer
->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite
) ) ;
229 verify_noerr(m_peer
->SetListViewHeaderBtnHeight( 0 ) ) ;
230 DataBrowserCallbacks callbacks
;
232 callbacks
.version
= kDataBrowserLatestCallbacks
;
234 InitDataBrowserCallbacks(&callbacks
);
236 callbacks
.u
.v1
.itemDataCallback
=
237 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
239 callbacks
.u
.v1
.itemNotificationCallback
=
240 #if TARGET_API_MAC_OSX
241 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
) ;
243 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
) ;
245 m_peer
->SetCallbacks( &callbacks
);
247 #if TARGET_API_MAC_OSX
248 // there is a redraw bug in 10.2.X
249 if ( UMAGetSystemVersion() < 0x1030 )
250 m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
252 MacPostControlCreate(pos
,size
) ;
254 for ( int i
= 0 ; i
< n
; i
++ )
256 Append( choices
[i
] ) ;
259 SetBestSize(size
); // Needed because it is a wxControlWithItems
264 wxListBox::~wxListBox()
266 m_peer
->SetReference( NULL
) ;
268 // avoid access during destruction
275 void wxListBox::FreeData()
277 #if wxUSE_OWNER_DRAWN
278 if ( m_windowStyle
& wxLB_OWNERDRAW
)
280 size_t uiCount
= m_aItems
.Count();
281 while ( uiCount
-- != 0 ) {
282 delete m_aItems
[uiCount
];
283 m_aItems
[uiCount
] = NULL
;
289 #endif // wxUSE_OWNER_DRAWN
290 if ( HasClientObjectData() )
292 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
294 delete GetClientObject(n
);
299 void wxListBox::DoSetSize(int x
, int y
,
300 int width
, int height
,
303 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
306 void wxListBox::DoSetFirstItem(int N
)
311 void wxListBox::Delete(int N
)
313 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
314 wxT("invalid index in wxListBox::Delete") );
316 #if wxUSE_OWNER_DRAWN
318 m_aItems
.RemoveAt(N
);
319 #else // !wxUSE_OWNER_DRAWN
320 if ( HasClientObjectData() )
322 delete GetClientObject(N
);
324 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
325 m_stringArray
.RemoveAt( N
) ;
326 m_dataArray
.RemoveAt( N
) ;
332 int wxListBox::DoAppend(const wxString
& item
)
334 InvalidateBestSize();
336 int index
= m_noItems
;
337 m_stringArray
.Add( item
) ;
338 m_dataArray
.Add( NULL
);
340 DoSetItemClientData( index
, NULL
) ;
346 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
349 int n
= choices
.GetCount();
351 for( int i
= 0 ; i
< n
; ++i
)
355 #if wxUSE_OWNER_DRAWN
356 wxASSERT_MSG(clientData
[i
] == NULL
,
357 wxT("Can't use client data with owner-drawn listboxes"));
358 #else // !wxUSE_OWNER_DRAWN
359 Append( choices
[i
] , clientData
[i
] ) ;
363 Append( choices
[i
] ) ;
366 #if wxUSE_OWNER_DRAWN
367 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
368 // first delete old items
369 size_t ui
= m_aItems
.Count();
370 while ( ui
-- != 0 ) {
376 // then create new ones
377 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
378 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
379 pNewItem
->SetName(choices
[ui
]);
380 m_aItems
.Add(pNewItem
);
383 #endif // wxUSE_OWNER_DRAWN
386 int wxListBox::FindString(const wxString
& s
) const
389 if ( s
.Right(1) == wxT("*") )
391 wxString search
= s
.Left( s
.Length() - 1 ) ;
392 int len
= search
.Length() ;
394 wxMacStringToPascal( search
, s2
) ;
396 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
398 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
400 if ( EqualString( s1
, s2
, false , false ) )
403 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
407 for ( int i
= 0 ; i
< m_noItems
; ++i
)
409 if ( GetString(i
).Lower().Matches(st
) )
419 wxMacStringToPascal( s
, s2
) ;
421 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
423 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
425 if ( EqualString( s1
, s2
, false , false ) )
432 void wxListBox::Clear()
436 m_stringArray
.Empty() ;
437 m_dataArray
.Empty() ;
441 void wxListBox::SetSelection(int N
, bool select
)
443 wxCHECK_RET( N
== wxNOT_FOUND
|| (N
>= 0 && N
< m_noItems
) ,
444 wxT("invalid index in wxListBox::SetSelection") );
446 if ( N
== wxNOT_FOUND
)
449 MacSetSelection( N
, select
) ;
452 bool wxListBox::IsSelected(int N
) const
454 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
455 wxT("invalid index in wxListBox::Selected") );
457 return MacIsSelected( N
) ;
460 void *wxListBox::DoGetItemClientData(int N
) const
462 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
463 wxT("invalid index in wxListBox::GetClientData"));
465 return (void *)m_dataArray
[N
];
468 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
470 return (wxClientData
*) DoGetItemClientData( N
) ;
473 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
475 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
476 wxT("invalid index in wxListBox::SetClientData") );
478 #if wxUSE_OWNER_DRAWN
479 if ( m_windowStyle
& wxLB_OWNERDRAW
)
481 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
482 // in OnMeasure/OnDraw.
483 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
485 #endif // wxUSE_OWNER_DRAWN
486 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
488 if ( m_dataArray
.GetCount() > (size_t) N
)
490 m_dataArray
[N
] = (char*) Client_data
;
494 m_dataArray
.Add( (char*) Client_data
) ;
498 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
500 DoSetItemClientData(n
, clientData
);
503 // Return number of selections and an array of selected integers
504 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
506 return MacGetSelections( aSelections
) ;
509 // Get single selection, for single choice list items
510 int wxListBox::GetSelection() const
512 return MacGetSelection() ;
515 // Find string for position
516 wxString
wxListBox::GetString(int N
) const
518 return m_stringArray
[N
] ;
521 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
523 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
524 wxT("invalid index in wxListBox::InsertItems") );
526 InvalidateBestSize();
528 int nItems
= items
.GetCount();
530 for ( int i
= 0 ; i
< nItems
; i
++ )
532 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
533 m_dataArray
.Insert( NULL
, pos
+ i
) ;
535 MacInsert( pos
+ i
, items
[i
] ) ;
539 void wxListBox::SetString(int N
, const wxString
& s
)
541 m_stringArray
[N
] = s
;
545 wxSize
wxListBox::DoGetBestSize() const
547 int lbWidth
= 100; // some defaults
552 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
556 ::TextFont( m_font
.MacGetFontNum() ) ;
557 ::TextSize( m_font
.MacGetFontSize() ) ;
558 ::TextFace( m_font
.MacGetFontStyle() ) ;
562 ::TextFont( kFontIDMonaco
) ;
567 // Find the widest line
568 for(int i
= 0; i
< GetCount(); i
++) {
569 wxString
str(GetString(i
));
573 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
574 kThemeCurrentPortFont
,
581 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
583 lbWidth
= wxMax(lbWidth
, wLine
);
586 // Add room for the scrollbar
587 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
589 // And just a bit more
591 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
594 // don't make the listbox too tall (limit height to around 10 items) but don't
595 // make it too small neither
596 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
599 return wxSize(lbWidth
, lbHeight
);
602 int wxListBox::GetCount() const
607 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
609 wxControl::Refresh( eraseBack
, rect
) ;
610 // MacRedrawControl() ;
613 #if wxUSE_OWNER_DRAWN
615 class wxListBoxItem
: public wxOwnerDrawn
618 wxListBoxItem(const wxString
& str
= "");
621 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
623 // no bitmaps/checkmarks
627 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
629 return new wxListBoxItem();
632 #endif //USE_OWNER_DRAWN
635 // Some custom controls depend on this
636 /* static */ wxVisualAttributes
637 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
639 wxVisualAttributes attr
;
640 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
641 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
642 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
646 // ============================================================================
647 // list box control implementation
648 // ============================================================================
650 void wxListBox::MacDelete( int n
)
652 wxArrayInt selectionBefore
;
653 MacGetSelections( selectionBefore
) ;
655 UInt32 id
= m_noItems
+1 ;
656 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
657 for ( size_t i
= 0 ; i
< selectionBefore
.GetCount() ; ++i
)
659 int current
= selectionBefore
[i
] ;
662 // selection was deleted
663 MacSetSelection( current
, false ) ;
665 else if ( current
> n
)
667 // something behind the deleted item was selected -> move up
668 MacSetSelection( current
- 1 , true ) ;
669 MacSetSelection( current
, false ) ;
673 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
676 void wxListBox::MacInsert( int n
, const wxString
& text
)
678 wxArrayInt selectionBefore
;
679 MacGetSelections( selectionBefore
) ;
681 UInt32 id
= m_noItems
; // this has already been increased
682 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
684 for ( int i
= selectionBefore
.GetCount()-1 ; i
>= 0 ; --i
)
686 int current
= selectionBefore
[i
] ;
689 MacSetSelection( current
+ 1 , true ) ;
690 MacSetSelection( current
, false ) ;
695 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
698 void wxListBox::MacAppend( const wxString
& text
)
700 UInt32 id
= m_noItems
; // this has already been increased
701 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
702 // no need to deal with selections nor refreshed, as we have appended
705 void wxListBox::MacClear()
707 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
710 void wxListBox::MacDeselectAll()
712 bool former
= MacSuppressSelection( true ) ;
713 verify_noerr(m_peer
->SetSelectedItems( 0 , NULL
, kDataBrowserItemsRemove
) ) ;
714 MacSuppressSelection( former
) ;
717 void wxListBox::MacSetSelection( int n
, bool select
)
719 bool former
= MacSuppressSelection( true ) ;
722 if ( m_peer
->IsItemSelected( id
) != select
)
725 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, HasMultipleSelection() ? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
) ) ;
727 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsRemove
) ) ;
730 MacSuppressSelection( former
) ;
733 bool wxListBox::MacSuppressSelection( bool suppress
)
735 bool former
= m_suppressSelection
;
736 m_suppressSelection
= suppress
;
740 bool wxListBox::MacIsSelected( int n
) const
742 return m_peer
->IsItemSelected( n
+ 1 ) ;
745 int wxListBox::MacGetSelection() const
747 for ( int i
= 0 ; i
< GetCount() ; ++i
)
749 if ( m_peer
->IsItemSelected( i
+ 1 ) )
757 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
763 UInt32 first
, last
;
764 m_peer
->GetSelectionAnchor( &first
, &last
) ;
765 if ( first
!= kDataBrowserNoItem
)
767 for ( size_t i
= first
; i
<= last
; ++i
)
769 if ( m_peer
->IsItemSelected( i
) )
771 aSelections
.Add( i
- 1 ) ;
779 void wxListBox::MacSet( int n
, const wxString
& text
)
781 // as we don't store the strings we only have to issue a redraw
783 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
786 void wxListBox::MacScrollTo( int n
)
789 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
792 #if !TARGET_API_MAC_OSX
794 void wxListBox::OnChar(wxKeyEvent
& event
)
796 // todo trigger proper events here
800 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
802 wxWindow
* parent
= GetParent() ;
803 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
804 parent
= parent
->GetParent() ;
806 if ( parent
&& parent
->GetDefaultItem() )
808 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
810 if ( def
&& def
->IsEnabled() )
812 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
813 event
.SetEventObject(def
);
820 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
821 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
823 // FIXME: look in ancestors, not just parent.
824 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
827 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
828 new_event
.SetEventObject( win
);
829 win
->GetEventHandler()->ProcessEvent( new_event
);
832 else if ( event
.GetKeyCode() == WXK_TAB
)
834 wxNavigationKeyEvent new_event
;
835 new_event
.SetEventObject( this );
836 new_event
.SetDirection( !event
.ShiftDown() );
837 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
838 new_event
.SetWindowChange( event
.ControlDown() );
839 new_event
.SetCurrentFocus( this );
840 if ( !GetEventHandler()->ProcessEvent( new_event
) )
843 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
845 // perform the default key handling first
846 wxControl::OnKeyDown( event
) ;
848 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
849 event
.SetEventObject( this );
851 wxArrayInt aSelections
;
852 int n
, count
= GetSelections(aSelections
);
856 if ( HasClientObjectData() )
857 event
.SetClientObject( GetClientObject(n
) );
858 else if ( HasClientUntypedData() )
859 event
.SetClientData( GetClientData(n
) );
860 event
.SetString( GetString(n
) );
867 event
.m_commandInt
= n
;
869 GetEventHandler()->ProcessEvent(event
);
873 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
875 m_typeIn
= wxEmptyString
;
877 m_lastTypeIn
= event
.GetTimestamp() ;
878 m_typeIn
+= (char) event
.GetKeyCode() ;
879 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
882 if ( GetSelection() != line
)
885 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
886 event
.SetEventObject( this );
888 if ( HasClientObjectData() )
889 event
.SetClientObject( GetClientObject( line
) );
890 else if ( HasClientUntypedData() )
891 event
.SetClientData( GetClientData(line
) );
892 event
.SetString( GetString(line
) );
894 event
.m_commandInt
= line
;
896 GetEventHandler()->ProcessEvent(event
);