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( NULL
) ;
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::SetSelection(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
) ;
612 // MacRedrawControl() ;
615 #if wxUSE_OWNER_DRAWN
617 class wxListBoxItem
: public wxOwnerDrawn
620 wxListBoxItem(const wxString
& str
= "");
623 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
625 // no bitmaps/checkmarks
629 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
631 return new wxListBoxItem();
634 #endif //USE_OWNER_DRAWN
637 // Some custom controls depend on this
638 /* static */ wxVisualAttributes
639 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
641 wxVisualAttributes attr
;
642 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
643 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
644 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
648 // ============================================================================
649 // list box control implementation
650 // ============================================================================
652 void wxListBox::MacDelete( int n
)
654 wxArrayInt selectionBefore
;
655 MacGetSelections( selectionBefore
) ;
657 UInt32 id
= m_noItems
+1 ;
658 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
659 for ( size_t i
= 0 ; i
< selectionBefore
.GetCount() ; ++i
)
661 int current
= selectionBefore
[i
] ;
664 // selection was deleted
665 MacSetSelection( current
, false ) ;
667 else if ( current
> n
)
669 // something behind the deleted item was selected -> move up
670 MacSetSelection( current
- 1 , true ) ;
671 MacSetSelection( current
, false ) ;
675 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
678 void wxListBox::MacInsert( int n
, const wxString
& text
)
680 wxArrayInt selectionBefore
;
681 MacGetSelections( selectionBefore
) ;
683 UInt32 id
= m_noItems
; // this has already been increased
684 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
686 for ( int i
= selectionBefore
.GetCount()-1 ; i
>= 0 ; --i
)
688 int current
= selectionBefore
[i
] ;
691 MacSetSelection( current
+ 1 , true ) ;
692 MacSetSelection( current
, false ) ;
697 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
700 void wxListBox::MacAppend( const wxString
& text
)
702 UInt32 id
= m_noItems
; // this has already been increased
703 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
704 // no need to deal with selections nor refreshed, as we have appended
707 void wxListBox::MacClear()
709 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
712 void wxListBox::MacDeselectAll()
714 bool former
= MacSuppressSelection( true ) ;
715 verify_noerr(m_peer
->SetSelectedItems( 0 , NULL
, kDataBrowserItemsRemove
) ) ;
716 MacSuppressSelection( former
) ;
719 void wxListBox::MacSetSelection( int n
, bool select
)
721 bool former
= MacSuppressSelection( true ) ;
724 if ( m_peer
->IsItemSelected( id
) != select
)
727 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, HasMultipleSelection() ? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
) ) ;
729 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsRemove
) ) ;
732 MacSuppressSelection( former
) ;
735 bool wxListBox::MacSuppressSelection( bool suppress
)
737 bool former
= m_suppressSelection
;
738 m_suppressSelection
= suppress
;
742 bool wxListBox::MacIsSelected( int n
) const
744 return m_peer
->IsItemSelected( n
+ 1 ) ;
747 int wxListBox::MacGetSelection() const
749 for ( int i
= 0 ; i
< GetCount() ; ++i
)
751 if ( m_peer
->IsItemSelected( i
+ 1 ) )
759 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
765 UInt32 first
, last
;
766 m_peer
->GetSelectionAnchor( &first
, &last
) ;
767 if ( first
!= kDataBrowserNoItem
)
769 for ( size_t i
= first
; i
<= last
; ++i
)
771 if ( m_peer
->IsItemSelected( i
) )
773 aSelections
.Add( i
- 1 ) ;
781 void wxListBox::MacSet( int n
, const wxString
& text
)
783 // as we don't store the strings we only have to issue a redraw
785 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
788 void wxListBox::MacScrollTo( int n
)
791 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
794 #if !TARGET_API_MAC_OSX
796 void wxListBox::OnChar(wxKeyEvent
& event
)
798 // todo trigger proper events here
802 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
804 wxWindow
* parent
= GetParent() ;
805 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
806 parent
= parent
->GetParent() ;
808 if ( parent
&& parent
->GetDefaultItem() )
810 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
812 if ( def
&& def
->IsEnabled() )
814 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
815 event
.SetEventObject(def
);
822 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
823 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
825 // FIXME: look in ancestors, not just parent.
826 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
829 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
830 new_event
.SetEventObject( win
);
831 win
->GetEventHandler()->ProcessEvent( new_event
);
834 else if ( event
.GetKeyCode() == WXK_TAB
)
836 wxNavigationKeyEvent new_event
;
837 new_event
.SetEventObject( this );
838 new_event
.SetDirection( !event
.ShiftDown() );
839 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
840 new_event
.SetWindowChange( event
.ControlDown() );
841 new_event
.SetCurrentFocus( this );
842 if ( !GetEventHandler()->ProcessEvent( new_event
) )
845 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
847 // perform the default key handling first
848 wxControl::OnKeyDown( event
) ;
850 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
851 event
.SetEventObject( this );
853 wxArrayInt aSelections
;
854 int n
, count
= GetSelections(aSelections
);
858 if ( HasClientObjectData() )
859 event
.SetClientObject( GetClientObject(n
) );
860 else if ( HasClientUntypedData() )
861 event
.SetClientData( GetClientData(n
) );
862 event
.SetString( GetString(n
) );
871 GetEventHandler()->ProcessEvent(event
);
875 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
877 m_typeIn
= wxEmptyString
;
879 m_lastTypeIn
= event
.GetTimestamp() ;
880 m_typeIn
+= (char) event
.GetKeyCode() ;
881 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
884 if ( GetSelection() != line
)
887 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
888 event
.SetEventObject( this );
890 if ( HasClientObjectData() )
891 event
.SetClientObject( GetClientObject( line
) );
892 else if ( HasClientUntypedData() )
893 event
.SetClientData( GetClientData(line
) );
894 event
.SetString( GetString(line
) );
898 GetEventHandler()->ProcessEvent(event
);