1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/listbox.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.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 IMPLEMENT_DYNAMIC_CLASS(wxListBox
, wxControl
)
28 BEGIN_EVENT_TABLE(wxListBox
, wxControl
)
30 // EVT_SIZE( wxListBox::OnSize )
31 EVT_CHAR( wxListBox::OnChar
)
35 #include "wx/mac/uma.h"
37 const short kTextColumnId
= 1024 ;
39 // new databrowserbased version
40 // because of the limited insert
41 // functionality of DataBrowser,
42 // we just introduce id s corresponding
45 DataBrowserItemDataUPP gDataBrowserItemDataUPP
= NULL
;
46 DataBrowserItemNotificationUPP gDataBrowserItemNotificationUPP
= NULL
;
47 DataBrowserDrawItemUPP gDataBrowserDrawItemUPP
= NULL
;
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
) ) ;
138 static pascal void ListBoxDrawProc( ControlRef browser
, DataBrowserItemID item
, DataBrowserPropertyID property
,
139 DataBrowserItemState itemState
, const Rect
*itemRect
, SInt16 depth
, Boolean isColorDevice
)
142 CFStringRef cfString
;
145 cfString
= CFStringCreateWithFormat( NULL
, NULL
, CFSTR("Row %d"), item
);
147 ThemeDrawingState themeState
;
148 GetThemeDrawingState( &themeState
) ;
150 if ( itemState
== kDataBrowserItemIsSelected
) // In this sample we handle the "selected" state, all others fall through to our "active" state
152 Gestalt( gestaltSystemVersion
, &systemVersion
);
153 if ( (systemVersion
>= 0x00001030) && (IsControlActive( browser
) == false) ) // Panther DB starts using kThemeBrushSecondaryHighlightColor for inactive browser hilighting
154 SetThemePen( kThemeBrushSecondaryHighlightColor
, 32, true );
156 SetThemePen( kThemeBrushPrimaryHighlightColor
, 32, true );
158 PaintRect( itemRect
); // First paint the hilite rect, then the text on top
159 SetThemeDrawingState( themeState
, false ) ;
161 DrawThemeTextBox( cfString
, kThemeApplicationFont
, kThemeStateActive
, true, itemRect
, teFlushDefault
, NULL
);
162 if ( cfString
!= NULL
)
163 CFRelease( cfString
);
164 SetThemeDrawingState( themeState
, true ) ;
168 wxListBox::wxListBox()
173 m_suppressSelection
= false ;
176 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
179 const wxArrayString
& choices
,
181 const wxValidator
& validator
,
182 const wxString
& name
)
184 wxCArrayString
chs(choices
);
186 return Create(parent
, id
, pos
, size
, chs
.GetCount(), chs
.GetStrings(),
187 style
, validator
, name
);
190 bool wxListBox::Create(wxWindow
*parent
, wxWindowID id
,
193 int n
, const wxString choices
[],
195 const wxValidator
& validator
,
196 const wxString
& name
)
198 m_macIsUserPane
= FALSE
;
200 wxASSERT_MSG( !(style
& wxLB_MULTIPLE
) || !(style
& wxLB_EXTENDED
),
201 _T("only one of listbox selection modes can be specified") );
203 if ( !wxListBoxBase::Create(parent
, id
, pos
, size
, style
& ~(wxHSCROLL
|wxVSCROLL
), validator
, name
) )
206 m_noItems
= 0 ; // this will be increased by our append command
209 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
211 m_peer
= new wxMacControl(this) ;
212 verify_noerr( ::CreateDataBrowserControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
, kDataBrowserListView
, m_peer
->GetControlRefAddr() ) );
214 DataBrowserSelectionFlags options
= kDataBrowserDragSelect
;
215 if ( style
& wxLB_MULTIPLE
)
217 options
+= kDataBrowserAlwaysExtendSelection
+ kDataBrowserCmdTogglesSelection
;
219 else if ( style
& wxLB_EXTENDED
)
225 options
+= kDataBrowserSelectOnlyOne
;
227 verify_noerr(m_peer
->SetSelectionFlags( options
) );
229 if ( gDataBrowserItemDataUPP
== NULL
) gDataBrowserItemDataUPP
= NewDataBrowserItemDataUPP(ListBoxGetSetItemData
) ;
230 if ( gDataBrowserItemNotificationUPP
== NULL
)
232 gDataBrowserItemNotificationUPP
=
233 #if TARGET_API_MAC_OSX
234 (DataBrowserItemNotificationUPP
) NewDataBrowserItemNotificationWithItemUPP(DataBrowserItemNotificationProc
) ;
236 NewDataBrowserItemNotificationUPP(DataBrowserItemNotificationProc
) ;
239 if ( gDataBrowserDrawItemUPP
== NULL
) gDataBrowserDrawItemUPP
= NewDataBrowserDrawItemUPP(ListBoxDrawProc
) ;
241 DataBrowserCallbacks callbacks
;
242 InitializeDataBrowserCallbacks( &callbacks
, kDataBrowserLatestCallbacks
) ;
244 callbacks
.u
.v1
.itemDataCallback
= gDataBrowserItemDataUPP
;
245 callbacks
.u
.v1
.itemNotificationCallback
= gDataBrowserItemNotificationUPP
;
246 m_peer
->SetCallbacks( &callbacks
);
248 DataBrowserCustomCallbacks customCallbacks
;
249 InitializeDataBrowserCustomCallbacks( &customCallbacks
, kDataBrowserLatestCustomCallbacks
) ;
251 customCallbacks
.u
.v1
.drawItemCallback
= gDataBrowserDrawItemUPP
;
253 SetDataBrowserCustomCallbacks( m_peer
->GetControlRef() , &customCallbacks
) ;
255 DataBrowserListViewColumnDesc columnDesc
;
256 columnDesc
.headerBtnDesc
.titleOffset
= 0;
257 columnDesc
.headerBtnDesc
.version
= kDataBrowserListViewLatestHeaderDesc
;
259 columnDesc
.headerBtnDesc
.btnFontStyle
.flags
=
260 kControlUseFontMask
| kControlUseJustMask
;
262 columnDesc
.headerBtnDesc
.btnContentInfo
.contentType
= kControlNoContent
;
263 columnDesc
.headerBtnDesc
.btnFontStyle
.just
= teFlushDefault
;
264 columnDesc
.headerBtnDesc
.minimumWidth
= 0;
265 columnDesc
.headerBtnDesc
.maximumWidth
= 10000;
267 columnDesc
.headerBtnDesc
.btnFontStyle
.font
= kControlFontViewSystemFont
;
268 columnDesc
.headerBtnDesc
.btnFontStyle
.style
= normal
;
269 columnDesc
.headerBtnDesc
.titleString
= NULL
; // CFSTR( "" );
271 columnDesc
.propertyDesc
.propertyID
= kTextColumnId
;
272 columnDesc
.propertyDesc
.propertyType
= kDataBrowserTextType
; // kDataBrowserCustomType;
273 columnDesc
.propertyDesc
.propertyFlags
=
274 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
275 kDataBrowserListViewTypeSelectColumn
|
277 kDataBrowserTableViewSelectionColumn
;
279 verify_noerr(m_peer
->AddListViewColumn( &columnDesc
, kDataBrowserListViewAppendColumn
) ) ;
280 verify_noerr(m_peer
->AutoSizeListViewColumns() ) ;
281 verify_noerr(m_peer
->SetHasScrollBars(false , true ) ) ;
282 verify_noerr(m_peer
->SetTableViewHiliteStyle(kDataBrowserTableViewFillHilite
) ) ;
283 verify_noerr(m_peer
->SetListViewHeaderBtnHeight( 0 ) ) ;
286 // shouldn't be necessary anymore under 10.2
287 m_peer
->SetData( kControlNoPart
, kControlDataBrowserIncludesFrameAndFocusTag
, (Boolean
) false ) ;
288 m_peer
->SetNeedsFocusRect( true ) ;
291 MacPostControlCreate(pos
,size
) ;
293 for ( int i
= 0 ; i
< n
; i
++ )
295 Append( choices
[i
] ) ;
298 SetBestSize(size
); // Needed because it is a wxControlWithItems
303 wxListBox::~wxListBox()
305 m_peer
->SetReference( 0 ) ;
307 // avoid access during destruction
314 void wxListBox::FreeData()
316 if ( HasClientObjectData() )
318 for ( size_t n
= 0; n
< (size_t)m_noItems
; n
++ )
320 delete GetClientObject(n
);
325 void wxListBox::DoSetSize(int x
, int y
,
326 int width
, int height
,
329 wxControl::DoSetSize( x
, y
, width
, height
, sizeFlags
) ;
332 void wxListBox::DoSetFirstItem(int N
)
337 void wxListBox::Delete(int N
)
339 wxCHECK_RET( N
>= 0 && N
< m_noItems
,
340 wxT("invalid index in wxListBox::Delete") );
342 if ( HasClientObjectData() )
344 delete GetClientObject(N
);
346 m_stringArray
.RemoveAt( N
) ;
347 m_dataArray
.RemoveAt( N
) ;
353 int wxListBox::DoAppend(const wxString
& item
)
355 InvalidateBestSize();
357 int index
= m_noItems
;
358 m_stringArray
.Add( item
) ;
359 m_dataArray
.Add( NULL
);
361 DoSetItemClientData( index
, NULL
) ;
367 void wxListBox::DoSetItems(const wxArrayString
& choices
, void** clientData
)
370 int n
= choices
.GetCount();
372 for( int i
= 0 ; i
< n
; ++i
)
376 Append( choices
[i
] , clientData
[i
] ) ;
379 Append( choices
[i
] ) ;
383 int wxListBox::FindString(const wxString
& s
, bool bCase
) const
385 if ( s
.Right(1) == wxT("*") )
387 wxString search
= s
.Left( s
.Length() - 1 ) ;
388 int len
= search
.Length() ;
390 wxMacStringToPascal( search
, s2
) ;
392 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
394 wxMacStringToPascal( m_stringArray
[i
].Left( len
) , s1
) ;
396 if ( EqualString( s1
, s2
, bCase
, false ) )
399 if ( s
.Left(1) == wxT("*") && s
.Length() > 1 )
403 for ( int i
= 0 ; i
< m_noItems
; ++i
)
405 if ( GetString(i
).Lower().Matches(st
) )
415 wxMacStringToPascal( s
, s2
) ;
417 for ( int i
= 0 ; i
< m_noItems
; ++ i
)
419 wxMacStringToPascal( m_stringArray
[i
] , s1
) ;
421 if ( EqualString( s1
, s2
, bCase
, false ) )
428 void wxListBox::Clear()
432 m_stringArray
.Empty() ;
433 m_dataArray
.Empty() ;
437 void wxListBox::DoSetSelection(int N
, bool select
)
439 wxCHECK_RET( N
== wxNOT_FOUND
|| (N
>= 0 && N
< m_noItems
) ,
440 wxT("invalid index in wxListBox::SetSelection") );
442 if ( N
== wxNOT_FOUND
)
445 MacSetSelection( N
, select
) ;
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 wxASSERT_MSG( m_dataArray
.GetCount() >= (size_t) N
, wxT("invalid client_data array") ) ;
476 if ( m_dataArray
.GetCount() > (size_t) N
)
478 m_dataArray
[N
] = (char*) Client_data
;
482 m_dataArray
.Add( (char*) Client_data
) ;
486 void wxListBox::DoSetItemClientObject(int n
, wxClientData
* clientData
)
488 DoSetItemClientData(n
, clientData
);
491 // Return number of selections and an array of selected integers
492 int wxListBox::GetSelections(wxArrayInt
& aSelections
) const
494 return MacGetSelections( aSelections
) ;
497 // Get single selection, for single choice list items
498 int wxListBox::GetSelection() const
500 return MacGetSelection() ;
503 // Find string for position
504 wxString
wxListBox::GetString(int N
) const
506 wxCHECK_MSG( N
>= 0 && N
< m_noItems
, wxEmptyString
,
507 wxT("invalid index in wxListBox::GetString") );
509 return m_stringArray
[N
] ;
512 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
514 wxCHECK_RET( pos
>= 0 && pos
<= m_noItems
,
515 wxT("invalid index in wxListBox::InsertItems") );
517 InvalidateBestSize();
519 int nItems
= items
.GetCount();
521 for ( int i
= 0 ; i
< nItems
; i
++ )
523 m_stringArray
.Insert( items
[i
] , pos
+ i
) ;
524 m_dataArray
.Insert( NULL
, pos
+ i
) ;
526 MacInsert( pos
+ i
, items
[i
] ) ;
530 void wxListBox::SetString(int N
, const wxString
& s
)
532 m_stringArray
[N
] = s
;
536 wxSize
wxListBox::DoGetBestSize() const
538 int lbWidth
= 100; // some defaults
543 wxMacPortStateHelper
st( UMAGetWindowPort( (WindowRef
) MacGetTopLevelWindowRef() ) ) ;
547 ::TextFont( m_font
.MacGetFontNum() ) ;
548 ::TextSize( m_font
.MacGetFontSize() ) ;
549 ::TextFace( m_font
.MacGetFontStyle() ) ;
553 ::TextFont( kFontIDMonaco
) ;
558 // Find the widest line
559 for(int i
= 0; i
< GetCount(); i
++) {
560 wxString
str(GetString(i
));
564 ::GetThemeTextDimensions( wxMacCFStringHolder( str
, m_font
.GetEncoding() ) ,
565 kThemeCurrentPortFont
,
572 wLine
= ::TextWidth( str
.c_str() , 0 , str
.Length() ) ;
574 lbWidth
= wxMax(lbWidth
, wLine
);
577 // Add room for the scrollbar
578 lbWidth
+= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X
);
580 // And just a bit more
582 int cx
= ::TextWidth( "X" , 0 , 1 ) ;
585 // don't make the listbox too tall (limit height to around 10 items) but don't
586 // make it too small neither
587 lbHeight
= (cy
+4) * wxMin(wxMax(GetCount(), 3), 10);
590 return wxSize(lbWidth
, lbHeight
);
593 int wxListBox::GetCount() const
598 void wxListBox::Refresh(bool eraseBack
, const wxRect
*rect
)
600 wxControl::Refresh( eraseBack
, rect
) ;
604 // Some custom controls depend on this
605 /* static */ wxVisualAttributes
606 wxListBox::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
608 wxVisualAttributes attr
;
609 attr
.colFg
= wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT
);
610 attr
.colBg
= wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX
);
611 attr
.font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
615 // ============================================================================
616 // list box control implementation
617 // ============================================================================
619 void wxListBox::MacDelete( int n
)
621 wxArrayInt selectionBefore
;
622 MacGetSelections( selectionBefore
) ;
624 UInt32 id
= m_noItems
+1 ;
625 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
626 for ( size_t i
= 0 ; i
< selectionBefore
.GetCount() ; ++i
)
628 int current
= selectionBefore
[i
] ;
631 // selection was deleted
632 MacSetSelection( current
, false ) ;
634 else if ( current
> n
)
636 // something behind the deleted item was selected -> move up
637 MacSetSelection( current
- 1 , true ) ;
638 MacSetSelection( current
, false ) ;
642 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
645 void wxListBox::MacInsert( int n
, const wxString
& text
)
647 wxArrayInt selectionBefore
;
648 MacGetSelections( selectionBefore
) ;
650 UInt32 id
= m_noItems
; // this has already been increased
651 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
653 for ( int i
= selectionBefore
.GetCount()-1 ; i
>= 0 ; --i
)
655 int current
= selectionBefore
[i
] ;
658 MacSetSelection( current
+ 1 , true ) ;
659 MacSetSelection( current
, false ) ;
664 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , (UInt32
*) kDataBrowserNoItem
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
667 void wxListBox::MacAppend( const wxString
& text
)
669 UInt32 id
= m_noItems
; // this has already been increased
670 verify_noerr( m_peer
->AddItems( kDataBrowserNoItem
, 1 , (UInt32
*) &id
, kDataBrowserItemNoProperty
) ) ;
671 // no need to deal with selections nor refreshed, as we have appended
674 void wxListBox::MacClear()
676 verify_noerr( m_peer
->RemoveItems( kDataBrowserNoItem
, 0 , NULL
, kDataBrowserItemNoProperty
) ) ;
679 void wxListBox::MacDeselectAll()
681 bool former
= MacSuppressSelection( true ) ;
682 verify_noerr(m_peer
->SetSelectedItems( 0 , NULL
, kDataBrowserItemsRemove
) ) ;
683 MacSuppressSelection( former
) ;
686 void wxListBox::MacSetSelection( int n
, bool select
)
688 bool former
= MacSuppressSelection( true ) ;
691 if ( m_peer
->IsItemSelected( id
) != select
)
694 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, HasMultipleSelection() ? kDataBrowserItemsAdd
: kDataBrowserItemsAssign
) ) ;
696 verify_noerr(m_peer
->SetSelectedItems( 1 , & id
, kDataBrowserItemsRemove
) ) ;
699 MacSuppressSelection( former
) ;
702 bool wxListBox::MacSuppressSelection( bool suppress
)
704 bool former
= m_suppressSelection
;
705 m_suppressSelection
= suppress
;
709 bool wxListBox::MacIsSelected( int n
) const
711 return m_peer
->IsItemSelected( n
+ 1 ) ;
714 int wxListBox::MacGetSelection() const
716 for ( int i
= 0 ; i
< GetCount() ; ++i
)
718 if ( m_peer
->IsItemSelected( i
+ 1 ) )
726 int wxListBox::MacGetSelections( wxArrayInt
& aSelections
) const
732 UInt32 first
, last
;
733 m_peer
->GetSelectionAnchor( &first
, &last
) ;
734 if ( first
!= kDataBrowserNoItem
)
736 for ( size_t i
= first
; i
<= last
; ++i
)
738 if ( m_peer
->IsItemSelected( i
) )
740 aSelections
.Add( i
- 1 ) ;
748 void wxListBox::MacSet( int n
, const wxString
& text
)
750 // as we don't store the strings we only have to issue a redraw
752 verify_noerr( m_peer
->UpdateItems( kDataBrowserNoItem
, 1 , &id
, kDataBrowserItemNoProperty
, kDataBrowserItemNoProperty
) ) ;
755 void wxListBox::MacScrollTo( int n
)
758 verify_noerr( m_peer
->RevealItem( id
, kTextColumnId
, kDataBrowserRevealWithoutSelecting
) ) ;
761 #if !TARGET_API_MAC_OSX
763 void wxListBox::OnChar(wxKeyEvent
& event
)
765 // todo trigger proper events here
769 if ( event
.GetKeyCode() == WXK_RETURN
|| event
.GetKeyCode() == WXK_NUMPAD_ENTER
)
771 wxWindow
* parent
= GetParent() ;
772 while( parent
&& !parent
->IsTopLevel() && parent
->GetDefaultItem() == NULL
)
773 parent
= parent
->GetParent() ;
775 if ( parent
&& parent
->GetDefaultItem() )
777 wxButton
*def
= wxDynamicCast(parent
->GetDefaultItem(),
779 if ( def
&& def
->IsEnabled() )
781 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
782 event
.SetEventObject(def
);
789 /* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
790 else if (event
.GetKeyCode() == WXK_ESCAPE
|| (event
.GetKeyCode() == '.' && event
.MetaDown() ) )
792 // FIXME: look in ancestors, not just parent.
793 wxWindow
* win
= GetParent()->FindWindow( wxID_CANCEL
) ;
796 wxCommandEvent
new_event(wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
797 new_event
.SetEventObject( win
);
798 win
->GetEventHandler()->ProcessEvent( new_event
);
801 else if ( event
.GetKeyCode() == WXK_TAB
)
803 wxNavigationKeyEvent new_event
;
804 new_event
.SetEventObject( this );
805 new_event
.SetDirection( !event
.ShiftDown() );
806 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
807 new_event
.SetWindowChange( event
.ControlDown() );
808 new_event
.SetCurrentFocus( this );
809 if ( !GetEventHandler()->ProcessEvent( new_event
) )
812 else if ( event
.GetKeyCode() == WXK_DOWN
|| event
.GetKeyCode() == WXK_UP
)
814 // perform the default key handling first
815 wxControl::OnKeyDown( event
) ;
817 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
818 event
.SetEventObject( this );
820 wxArrayInt aSelections
;
821 int n
, count
= GetSelections(aSelections
);
825 if ( HasClientObjectData() )
826 event
.SetClientObject( GetClientObject(n
) );
827 else if ( HasClientUntypedData() )
828 event
.SetClientData( GetClientData(n
) );
829 event
.SetString( GetString(n
) );
838 GetEventHandler()->ProcessEvent(event
);
842 if ( event
.GetTimestamp() > m_lastTypeIn
+ 60 )
844 m_typeIn
= wxEmptyString
;
846 m_lastTypeIn
= event
.GetTimestamp() ;
847 m_typeIn
+= (char) event
.GetKeyCode() ;
848 int line
= FindString(wxT("*")+m_typeIn
+wxT("*")) ;
851 if ( GetSelection() != line
)
854 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, m_windowId
);
855 event
.SetEventObject( this );
857 if ( HasClientObjectData() )
858 event
.SetClientObject( GetClientObject( line
) );
859 else if ( HasClientUntypedData() )
860 event
.SetClientData( GetClientData(line
) );
861 event
.SetString( GetString(line
) );
865 GetEventHandler()->ProcessEvent(event
);
871 #endif // !TARGET_API_MAC_OSX