-
-// ============================================================================
-// implementation
-// ============================================================================
-
-static pascal OSStatus wxMacSearchControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
-{
- OSStatus result = eventNotHandledErr ;
-
- wxMacCarbonEvent cEvent( event ) ;
-
- ControlRef controlRef ;
- wxSearchCtrl* thisWindow = (wxSearchCtrl*) data ;
- cEvent.GetParameter( kEventParamDirectObject , &controlRef ) ;
-
- switch( GetEventKind( event ) )
- {
- case kEventSearchFieldCancelClicked :
- thisWindow->MacSearchFieldCancelHit( handler , event ) ;
- break ;
- case kEventSearchFieldSearchClicked :
- thisWindow->MacSearchFieldSearchHit( handler , event ) ;
- break ;
- }
-
- return result ;
-}
-
-DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacSearchControlEventHandler )
-
-
-// ----------------------------------------------------------------------------
-// wxSearchCtrl creation
-// ----------------------------------------------------------------------------
-
-// creation
-// --------
-
-wxSearchCtrl::wxSearchCtrl()
-{
- Init();
-}
-
-wxSearchCtrl::wxSearchCtrl(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- Init();
-
- Create(parent, id, value, pos, size, style, validator, name);
-}
-
-void wxSearchCtrl::Init()
-{
- m_menu = 0;
-}
-
-bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxValidator& validator,
- const wxString& name)
-{
- if ( !wxTextCtrl::Create(parent, id, wxEmptyString, pos, size, wxBORDER_NONE | style, validator, name) )
- {
- return false;
- }
-
- EventHandlerRef searchEventHandler;
- InstallControlEventHandler( m_peer->GetControlRef(), GetwxMacSearchControlEventHandlerUPP(),
- GetEventTypeCount(eventList), eventList, this,
- (EventHandlerRef *)&searchEventHandler);
-
- SetValue(value);
-
- return true;
-}
-
-wxSearchCtrl::~wxSearchCtrl()
-{
- delete m_menu;
-}
-
-wxSize wxSearchCtrl::DoGetBestSize() const
-{
- wxSize size = wxWindow::DoGetBestSize();
- // it seems to return a default width of about 16, which is way too small here.
- if (size.GetWidth() < 100)
- size.SetWidth(100);
-
- return size;
-}
-
-
-// search control specific interfaces
-// wxSearchCtrl owns menu after this call
-void wxSearchCtrl::SetMenu( wxMenu* menu )
-{
- if ( menu == m_menu )
- {
- // no change
- return;
- }
-
- if ( m_menu )
- {
- m_menu->SetInvokingWindow( 0 );
- }
-
- delete m_menu;
- m_menu = menu;
-
- if ( m_menu )
- {
- m_menu->SetInvokingWindow( this );
- }
-
- GetPeer()->SetSearchMenu( m_menu );
-}
-
-wxMenu* wxSearchCtrl::GetMenu()