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
48 wxListBox::wxListBox()
55 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
58 const wxArrayString
& choices
,
60 const wxValidator
& validator
,
63 wxCArrayString
chs(choices
);
65 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
66 style
, validator
, name
);
69 #if TARGET_API_MAC_OSX
70 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
71 DataBrowserItemNotification message
, DataBrowserItemDataRef itemData
)
73 static pascal void DataBrowserItemNotificationProc(ControlRef browser
, DataBrowserItemID itemID
,
74 DataBrowserItemNotification message
)
77 long ref
= GetControlReference( browser
) ;
80 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
81 size_t i
= itemID
- 1 ;
82 if (i
>= 0 && i
< list
->GetCount() )
84 bool trigger
= false ;
86 wxEVT_COMMAND_LISTBOX_SELECTED
, list
->GetId() );
89 case kDataBrowserItemDeselected
:
90 if ( list
->HasMultipleSelection() )
93 case kDataBrowserItemSelected
:
96 case kDataBrowserItemDoubleClicked
:
97 event
.SetEventType(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
) ;
105 event
.SetEventObject( list
);
106 if ( list
->HasClientObjectData() )
107 event
.SetClientObject( list
->GetClientObject(i
) );
108 else if ( list
->HasClientUntypedData() )
109 event
.SetClientData( list
->GetClientData(i
) );
110 event
.SetString( list
->GetString(i
) );
112 event
.SetExtraLong( list
->HasMultipleSelection() ? message
== kDataBrowserItemSelected
: TRUE
);
113 wxPostEvent( list
->GetEventHandler() , event
) ;
114 // direct notification is not always having the listbox GetSelection() having in synch with event
115 // list->GetEventHandler()->ProcessEvent(event) ;
122 static pascal OSStatus
ListBoxGetSetItemData(ControlRef browser
,
123 DataBrowserItemID itemID
, DataBrowserPropertyID property
,
124 DataBrowserItemDataRef itemData
, Boolean changeValue
)
126 OSStatus err
= errDataBrowserPropertyNotSupported
;
135 long ref
= GetControlReference( browser
) ;
138 wxListBox
* list
= wxDynamicCast( (wxObject
*) ref
, wxListBox
) ;
139 size_t i
= itemID
- 1 ;
140 if (i
>= 0 && i
< list
->GetCount() )
142 wxMacCFStringHolder
cf( list
->GetString(i
) , list
->GetFont().GetEncoding() ) ;
143 verify_noerr( ::SetDataBrowserItemDataText( itemData
, cf
) ) ;
158 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
161 int n
, const wxString choices
[],
163 const wxValidator
& validator
,
164 const wxString
& name
)
166 m_macIsUserPane
= FALSE
;
168 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
169 _T("only one of listbox selection modes can be specified") );
171 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
174 m_noItems
= 0 ; // this will be increased by our append command
177 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
179 m_peer
= new wxMacControl() ;
180 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, m_peer
->GetControlRefAddr() ) );
182 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
183 if ( style
& wxLB_MULTIPLE
)
185 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
187 else if ( style
& wxLB_EXTENDED
)
193 options
+= kDataBrowserSelectOnlyOne
;
195 verify_noerr(m_peer
->SetSelectionFlags( options
) );
197 DataBrowserListViewColumnDesc columnDesc
;
198 columnDesc
.headerBtnDesc
.titleOffset
= 0;
199 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
201 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
202 kControlUseFontMask
| kControlUseJustMask
;
204 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
205 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
206 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
207 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
208 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
210 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
211 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
212 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
214 columnDesc
.propertyDesc
.propertyID
= kTextColumnId
;
215 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
;
216 columnDesc
.propertyDesc
.propertyFlags
=
217 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
218 kDataBrowserListViewTypeSelectColumn
|
220 kDataBrowserTableViewSelectionColumn
;
223 verify_noerr(m_peer
->AddListViewColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
224 verify_noerr(m_peer
->AutoSizeListViewColumns() ) ;
225 verify_noerr(m_peer
->SetHasScrollBars(false , true ) ) ;
226 verify_noerr(m_peer
->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite
) ) ;
227 verify_noerr(m_peer
->SetListViewHeaderBtnHeight( 0 ) ) ;
228 DataBrowserCallbacks callbacks
;
230 callbacks
.version
= kDataBrowserLatestCallbacks
;
232 InitDataBrowserCallbacks(&callbacks
);
234 callbacks
.u
.v1
.itemDataCallback
=
235 NewDataBrowserItemDataUPP(ListBoxGetSetItemData
);
237 callbacks
.u
.v1
.itemNotificationCallback
=
238 #if TARGET_API_MAC_OSX
239 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
) ;
241 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
) ;
243 m_peer
->SetCallbacks( &callbacks
);
245 #if TARGET_API_MAC_OSX
246 // there is a redraw bug in 10.2.X
247 if ( UMAGetSystemVersion() < 0x1030 )
248 m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
251 MacPostControlCreate(pos
,size
) ;
253 for ( int i
= 0 ; i
< n
; i
++ )
255 Append( choices
[i
] ) ;
258 SetBestSize(size
); // Needed because it is a wxControlWithItems
263 wxListBox::~wxListBox()
265 m_peer
->SetReference( NULL
) ;
267 // avoid access during destruction
274 void wxListBox::FreeData()
276 #if wxUSE_OWNER_DRAWN
277 if ( m_windowStyle
& wxLB_OWNERDRAW
)
279 size_t uiCount
= m_aItems
.Count();
280 while ( uiCount
-- != 0 ) {
281 delete m_aItems
[uiCount
];
282 m_aItems
[uiCount
] = NULL
;
288 #endif // wxUSE_OWNER_DRAWN
289 if ( HasClientObjectData() )
291 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
293 delete GetClientObject(n
);
298 void wxListBox::DoSetSize(int x
, int y
,
299 int width
, int height
,
302 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
305 void wxListBox::DoSetFirstItem(int N
)
310 void wxListBox::Delete(int N
)
312 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
313 wxT("invalid index in wxListBox::Delete") );
315 #if wxUSE_OWNER_DRAWN
317 m_aItems
.RemoveAt(N
);
318 #else // !wxUSE_OWNER_DRAWN
319 if ( HasClientObjectData() )
321 delete GetClientObject(N
);
323 #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
324 m_stringArray
.RemoveAt( N
) ;
325 m_dataArray
.RemoveAt( N
) ;
331 int wxListBox::DoAppend(const wxString
& item
)
333 InvalidateBestSize();
335 int index
= m_noItems
;
336 m_stringArray
.Add( item
) ;
337 m_dataArray
.Add( NULL
);
339 DoSetItemClientData( index
, NULL
) ;
345 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
348 int n
= choices
.GetCount();
350 for( int i
= 0 ; i
< n
; ++i
)
354 #if wxUSE_OWNER_DRAWN
355 wxASSERT_MSG(clientData
[i
] == NULL
,
356 wxT("Can't use client data with owner-drawn listboxes"));
357 #else // !wxUSE_OWNER_DRAWN
358 Append( choices
[i
] , clientData
[i
] ) ;
362 Append( choices
[i
] ) ;
365 #if wxUSE_OWNER_DRAWN
366 if ( m_windowStyle
& wxLB_OWNERDRAW
) {
367 // first delete old items
368 size_t ui
= m_aItems
.Count();
369 while ( ui
-- != 0 ) {
375 // then create new ones
376 for ( ui
= 0; ui
< (size_t)m_noItems
; ui
++ ) {
377 wxOwnerDrawn
*pNewItem
= CreateItem(ui
);
378 pNewItem
->SetName(choices
[ui
]);
379 m_aItems
.Add(pNewItem
);
382 #endif // wxUSE_OWNER_DRAWN
385 int wxListBox::FindString(const wxString
& s
) const
388 if ( s
.Right(1) == wxT("*") )
390 wxString search
= s
.Left( s
.Length() - 1 ) ;
391 int len
= search
.Length() ;
393 wxMacStringToPascal( search
, s2
) ;
395 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
397 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
399 if ( EqualString( s1
, s2
, false , false ) )
402 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
406 for ( int i
= 0 ; i
< m_noItems
; ++i
)
408 if ( GetString(i
).Lower().Matches(st
) )
418 wxMacStringToPascal( s
, s2
) ;
420 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
422 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
424 if ( EqualString( s1
, s2
, false , false ) )
431 void wxListBox::Clear()
435 m_stringArray
.Empty() ;
436 m_dataArray
.Empty() ;
440 void wxListBox::SetSelection(int N
, bool select
)
442 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
443 wxT("invalid index in wxListBox::SetSelection") );
444 MacSetSelection( N
, select
) ;
445 GetSelections( m_selectionPreImage
) ;
448 bool wxListBox::IsSelected(int N
) const
450 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, FALSE
,
451 wxT("invalid index in wxListBox::Selected") );
453 return MacIsSelected( N
) ;
456 void *wxListBox::DoGetItemClientData(int N
) const
458 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, NULL
,
459 wxT("invalid index in wxListBox::GetClientData"));
461 return (void *)m_dataArray
[N
];
464 wxClientData
*wxListBox::DoGetItemClientObject(int N
) const
466 return (wxClientData
*) DoGetItemClientData( N
) ;
469 void wxListBox::DoSetItemClientData(int N
, void *Client_data
)
471 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
472 wxT("invalid index in wxListBox::SetClientData") );
474 #if wxUSE_OWNER_DRAWN
475 if ( m_windowStyle
& wxLB_OWNERDRAW
)
477 // client data must be pointer to wxOwnerDrawn, otherwise we would crash
478 // in OnMeasure/OnDraw.
479 wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
481 #endif // wxUSE_OWNER_DRAWN
482 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
484 if ( m_dataArray
.GetCount() > (size_t) N
)
486 m_dataArray
[N
] = (char*) Client_data
;
490 m_dataArray
.Add( (char*) Client_data
) ;
494 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
496 DoSetItemClientData(n
, clientData
);
499 // Return number of selections and an array of selected integers
500 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
502 return MacGetSelections( aSelections
) ;
505 // Get single selection, for single choice list items
506 int wxListBox::GetSelection() const
508 return MacGetSelection() ;
511 // Find string for position
512 wxString
wxListBox::GetString(int N
) const
514 return m_stringArray
[N
] ;
517 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
519 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
520 wxT("invalid index in wxListBox::InsertItems") );
522 InvalidateBestSize();
524 int nItems
= items
.GetCount();
526 for ( int i
= 0 ; i
< nItems
; i
++ )
528 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
529 m_dataArray
.Insert( NULL
, pos
+ i
) ;
531 MacInsert( pos
+ i
, items
[i
] ) ;
535 void wxListBox::SetString(int N
, const wxString
& s
)
537 m_stringArray
[N
] = s
;
541 wxSize
wxListBox::DoGetBestSize() const
543 int lbWidth
= 100; // some defaults
548 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
552 ::TextFont( m_font
.MacGetFontNum() ) ;
553 ::TextSize( m_font
.MacGetFontSize() ) ;
554 ::TextFace( m_font
.MacGetFontStyle() ) ;
558 ::TextFont( kFontIDMonaco
) ;
563 // Find the widest line
564 for(int i
= 0; i
< GetCount(); i
++) {
565 wxString
str(GetString(i
));
569 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
570 kThemeCurrentPortFont
,
577 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
579 lbWidth
= wxMax(lbWidth
, wLine
);
582 // Add room for the scrollbar
583 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
585 // And just a bit more
587 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
590 // don't make the listbox too tall (limit height to around 10 items) but don't
591 // make it too small neither
592 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
595 return wxSize(lbWidth
, lbHeight
);
598 int wxListBox::GetCount() const
603 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
605 wxControl::Refresh( eraseBack
, rect
) ;
606 // MacRedrawControl() ;
609 #if wxUSE_OWNER_DRAWN
611 class wxListBoxItem
: public wxOwnerDrawn
614 wxListBoxItem(const wxString
& str
= "");
617 wxListBoxItem::wxListBoxItem(const wxString
& str
) : wxOwnerDrawn(str
, FALSE
)
619 // no bitmaps/checkmarks
623 wxOwnerDrawn
*wxListBox::CreateItem(size_t n
)
625 return new wxListBoxItem();
628 #endif //USE_OWNER_DRAWN
631 // Some custom controls depend on this
632 /* static */ wxVisualAttributes
633 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
635 wxVisualAttributes attr
;
636 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
637 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
638 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
642 // ============================================================================
643 // list box control implementation
644 // ============================================================================
646 void wxListBox::MacDelete( int N
)
648 UInt32 id
= m_noItems
+1 ;
649 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
650 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
653 void wxListBox::MacInsert( int n
, const wxString
& text
)
655 UInt32 id
= m_noItems
; // this has already been increased
656 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
657 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
660 void wxListBox::MacAppend( const wxString
& text
)
662 UInt32 id
= m_noItems
; // this has already been increased
663 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
666 void wxListBox::MacClear()
668 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
671 void wxListBox::MacSetSelection( int n
, bool select
)
674 if ( !(GetWindowStyle() & (wxLB_MULTIPLE
|wxLB_EXTENDED
) ) )
676 int n
= MacGetSelection() ;
679 UInt32 idOld
= n
+ 1 ;
680 m_peer
->SetSelectedItems( 1 , & idOld
, kDataBrowserItemsRemove
) ;
683 if ( m_peer
->IsItemSelected( id
) != select
)
685 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsToggle
) ) ;
690 bool wxListBox::MacIsSelected( int n
) const
692 return m_peer
->IsItemSelected( n
+ 1 ) ;
695 int wxListBox::MacGetSelection() const
697 for ( size_t i
= 0 ; i
< GetCount() ; ++i
)
699 if ( m_peer
->IsItemSelected( i
+ 1 ) )
707 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
712 for ( size_t i
= 0 ; i
< GetCount() ; ++i
)
714 if ( m_peer
->IsItemSelected( i
+ 1 ) )
716 aSelections
.Add( i
) ;
723 void wxListBox::MacSet( int n
, const wxString
& text
)
725 // as we don't store the strings we only have to issue a redraw
727 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
730 void wxListBox::MacScrollTo( int n
)
733 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
736 #if !TARGET_API_MAC_OSX
737 void wxListBox::OnSize( wxSizeEvent
&event
)
742 void wxListBox::MacSetRedraw( bool doDraw
)
744 // nothing to do in compositing mode
747 void wxListBox::MacDoClick()
749 wxArrayInt aSelections;
751 size_t count = GetSelections(aSelections);
753 if ( count == m_selectionPreImage.GetCount() )
755 bool hasChanged = false ;
756 for ( size_t i = 0 ; i < count ; ++i )
758 if ( aSelections[i] != m_selectionPreImage[i] )
770 m_selectionPreImage = aSelections;
772 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId);
773 event.SetEventObject( this );
778 if ( HasClientObjectData() )
779 event.SetClientObject( GetClientObject(n) );
780 else if ( HasClientUntypedData() )
781 event.SetClientData( GetClientData(n) );
782 event.SetString( GetString(n) );
789 event.m_commandInt = n;
791 GetEventHandler()->ProcessEvent(event);
795 void wxListBox::MacDoDoubleClick()
798 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, m_windowId);
799 event.SetEventObject( this );
800 GetEventHandler()->ProcessEvent(event) ;
804 #if !TARGET_API_MAC_OSX
806 void wxListBox::OnChar(wxKeyEvent
& event
)
808 // todo trigger proper events here
812 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
814 wxWindow
* parent
= GetParent() ;
815 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
816 parent
= parent
->GetParent() ;
818 if ( parent
&& parent
->GetDefaultItem() )
820 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
822 if ( def
&& def
->IsEnabled() )
824 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
825 event
.SetEventObject(def
);
832 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
833 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
835 // FIXME: look in ancestors, not just parent.
836 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
839 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
840 new_event
.SetEventObject( win
);
841 win
->GetEventHandler()->ProcessEvent( new_event
);
844 else if ( event
.GetKeyCode() == WXK_TAB
)
846 wxNavigationKeyEvent new_event
;
847 new_event
.SetEventObject( this );
848 new_event
.SetDirection( !event
.ShiftDown() );
849 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
850 new_event
.SetWindowChange( event
.ControlDown() );
851 new_event
.SetCurrentFocus( this );
852 if ( !GetEventHandler()->ProcessEvent( new_event
) )
855 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
857 // perform the default key handling first
858 wxControl::OnKeyDown( event
) ;
860 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
861 event
.SetEventObject( this );
863 wxArrayInt aSelections
;
864 int n
, count
= GetSelections(aSelections
);
868 if ( HasClientObjectData() )
869 event
.SetClientObject( GetClientObject(n
) );
870 else if ( HasClientUntypedData() )
871 event
.SetClientData( GetClientData(n
) );
872 event
.SetString( GetString(n
) );
879 event
.m_commandInt
= n
;
881 GetEventHandler()->ProcessEvent(event
);
885 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
887 m_typeIn
= wxEmptyString
;
889 m_lastTypeIn
= event
.GetTimestamp() ;
890 m_typeIn
+= (char) event
.GetKeyCode() ;
891 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
894 if ( GetSelection() != line
)
897 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
898 event
.SetEventObject( this );
900 if ( HasClientObjectData() )
901 event
.SetClientObject( GetClientObject( line
) );
902 else if ( HasClientUntypedData() )
903 event
.SetClientData( GetClientData(line
) );
904 event
.SetString( GetString(line
) );
906 event
.m_commandInt
= line
;
908 GetEventHandler()->ProcessEvent(event
);