Files
wxWidgets/src/osx/srchctrl_osx.cpp
Dimitri Schoolwerth b5b208a179 Set svn properties on .cpp files.
Add missing svn:eol-style property to all .cpp files. Also set svn:keywords for .cpp files which don't have that property yet to Id, including src/osx/core/glgrab.cpp for consistency (it doesn't make use of the property).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65561 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-09-17 11:17:55 +00:00

225 lines
4.9 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Name: src/osx/srchctrl_osx.cpp
// Purpose: implements mac carbon wxSearchCtrl
// Author: Vince Harron
// Created: 2006-02-19
// RCS-ID: $Id$
// Copyright: Vince Harron
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_SEARCHCTRL
#include "wx/srchctrl.h"
#ifndef WX_PRECOMP
#include "wx/menu.h"
#endif //WX_PRECOMP
#if wxUSE_NATIVE_SEARCH_CONTROL
#include "wx/osx/private.h"
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxSearchCtrl, wxSearchCtrlBase)
#endif // wxUSE_NATIVE_SEARCH_CONTROL
// ----------------------------------------------------------------------------
// 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;
}
wxSearchWidgetImpl* wxSearchCtrl::GetSearchPeer() const
{
return dynamic_cast<wxSearchWidgetImpl*> (m_peer);
}
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 );
}
GetSearchPeer()->SetSearchMenu( m_menu );
}
wxMenu* wxSearchCtrl::GetMenu()
{
return m_menu;
}
void wxSearchCtrl::ShowSearchButton( bool show )
{
if ( IsSearchButtonVisible() == show )
{
// no change
return;
}
GetSearchPeer()->ShowSearchButton( show );
}
bool wxSearchCtrl::IsSearchButtonVisible() const
{
return GetSearchPeer()->IsSearchButtonVisible();
}
void wxSearchCtrl::ShowCancelButton( bool show )
{
if ( IsCancelButtonVisible() == show )
{
// no change
return;
}
GetSearchPeer()->ShowCancelButton( show );
}
bool wxSearchCtrl::IsCancelButtonVisible() const
{
return GetSearchPeer()->IsCancelButtonVisible();
}
void wxSearchCtrl::SetDescriptiveText(const wxString& text)
{
m_descriptiveText = text;
GetSearchPeer()->SetDescriptiveText(text);
}
wxString wxSearchCtrl::GetDescriptiveText() const
{
return m_descriptiveText;
}
bool wxSearchCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
m_macIsUserPane = false ;
m_editable = true ;
if ( ! (style & wxNO_BORDER) )
style = (style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
if ( !wxTextCtrlBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
return false;
if ( m_windowStyle & wxTE_MULTILINE )
{
// always turn on this style for multi-line controls
m_windowStyle |= wxTE_PROCESS_ENTER;
style |= wxTE_PROCESS_ENTER ;
}
m_peer = wxWidgetImpl::CreateSearchControl( this, GetParent(), GetId(), value, pos, size, style, GetExtraStyle() );
MacPostControlCreate(pos, size) ;
// only now the embedding is correct and we can do a positioning update
MacSuperChangedPosition() ;
if ( m_windowStyle & wxTE_READONLY)
SetEditable( false ) ;
SetCursor( wxCursor( wxCURSOR_IBEAM ) ) ;
return true;
}
bool wxSearchCtrl::HandleSearchFieldSearchHit()
{
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, m_windowId );
event.SetEventObject(this);
// provide the string to search for directly in the event, this is more
// convenient than retrieving it from the control in event handler code
event.SetString(GetValue());
return ProcessCommand(event);
}
bool wxSearchCtrl::HandleSearchFieldCancelHit()
{
wxCommandEvent event(wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, m_windowId );
event.SetEventObject(this);
return ProcessCommand(event);
}
#endif // wxUSE_SEARCHCTRL