// Name: src/generic/srchctlg.cpp
// Purpose: implements wxSearchCtrl as a composite control
// Author: Vince Harron
-// Modified by:
// Created: 2006-02-19
-// RCS-ID:
+// RCS-ID: $Id$
// Copyright: Vince Harron
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "srchctlg.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#pragma hdrstop
#endif
+#if wxUSE_SEARCHCTRL
+
+#include "wx/srchctrl.h"
+
#ifndef WX_PRECOMP
#include "wx/button.h"
#include "wx/dcclient.h"
#include "wx/dcmemory.h"
#endif //WX_PRECOMP
-#if wxUSE_SEARCHCTRL
-
-#include "wx/srchctrl.h"
-
-#if !USE_NATIVE_SEARCH_CONTROL
+#if !wxUSE_NATIVE_SEARCH_CONTROL
#include "wx/image.h"
-#define WXMIN(a,b) (a)<(b)?(a):(b)
-#define WXMAX(a,b) (a)>(b)?(a):(b)
+#define WXMAX(a,b) ((a)>(b)?(a):(b))
// ----------------------------------------------------------------------------
// constants
style | wxNO_BORDER)
{
m_search = search;
-
+
// remove the default minsize, the searchctrl will have one instead
SetSizeHints(wxDefaultCoord,wxDefaultCoord);
}
// copy constructor is disabled for some reason?
//wxTextUrlEvent event(eventText);
wxTextUrlEvent event(
- m_search->GetId(),
+ m_search->GetId(),
eventText.GetMouseEvent(),
eventText.GetURLStart(),
eventText.GetURLEnd()
void SetBitmapLabel(const wxBitmap& label) { m_bmp = label; }
-
+
protected:
wxSize DoGetBestSize() const
{
return wxSize(m_bmp.GetWidth(), m_bmp.GetHeight());
}
-
+
void OnLeftUp(wxMouseEvent&)
{
wxCommandEvent event(m_eventType, m_search->GetId());
m_search->SetFocus();
- if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH )
+ if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN )
{
// this happens automatically, just like on Mac OS X
m_search->PopupSearchMenu();
dc.DrawBitmap(m_bmp, 0,0, true);
}
-
+
private:
wxSearchCtrl *m_search;
wxEventType m_eventType;
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxSearchCtrl, wxSearchCtrlBase)
- EVT_SEARCHCTRL_SEARCH(wxID_ANY, wxSearchCtrl::OnSearchButton)
+ EVT_SEARCHCTRL_SEARCH_BTN(wxID_ANY, wxSearchCtrl::OnSearchButton)
EVT_SET_FOCUS(wxSearchCtrl::OnSetFocus)
END_EVENT_TABLE()
// --------
wxSearchCtrl::wxSearchCtrl()
-{
+{
Init();
}
wxSize sizeText = m_text->GetBestSize();
- m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH,m_searchBitmap);
- m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL,m_cancelBitmap);
+ m_searchButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,m_searchBitmap);
+ m_cancelButton = new wxSearchButton(this,wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,m_cancelBitmap);
SetForegroundColour( m_text->GetForegroundColour() );
m_searchButton->SetForegroundColour( m_text->GetForegroundColour() );
// no change
return;
}
+ bool hadMenu = (m_menu != NULL);
delete m_menu;
- bool hadMenu = (m_menu!=0);
m_menu = menu;
if ( m_menu && !hadMenu )
return m_menu;
}
-void wxSearchCtrl::SetSearchButtonVisible( bool show )
+void wxSearchCtrl::ShowSearchButton( bool show )
{
if ( m_searchButtonVisible == show )
{
LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight());
}
-bool wxSearchCtrl::GetSearchButtonVisible() const
+bool wxSearchCtrl::IsSearchButtonVisible() const
{
return m_searchButtonVisible;
}
-void wxSearchCtrl::SetCancelButtonVisible( bool show )
+void wxSearchCtrl::ShowCancelButton( bool show )
{
if ( m_cancelButtonVisible == show )
{
LayoutControls(0, 0, rect.GetWidth(), rect.GetHeight());
}
-bool wxSearchCtrl::GetCancelButtonVisible() const
+bool wxSearchCtrl::IsCancelButtonVisible() const
{
return m_cancelButtonVisible;
}
bool result = wxSearchCtrlBase::SetFont(font);
if ( result && m_text )
{
- result &= m_text->SetFont(font);
+ result = m_text->SetFont(font);
}
RecalcBitmaps();
return result;
if ( !m_searchBitmapUser )
{
- if (
+ if (
!m_searchBitmap.Ok() ||
- m_searchBitmap.GetHeight() != bitmapHeight ||
+ m_searchBitmap.GetHeight() != bitmapHeight ||
m_searchBitmap.GetWidth() != bitmapWidth
)
{
if ( !m_searchMenuBitmapUser )
{
- if (
+ if (
!m_searchMenuBitmap.Ok() ||
- m_searchMenuBitmap.GetHeight() != bitmapHeight ||
+ m_searchMenuBitmap.GetHeight() != bitmapHeight ||
m_searchMenuBitmap.GetWidth() != bitmapWidth
)
{
if ( !m_cancelBitmapUser )
{
- if (
+ if (
!m_cancelBitmap.Ok() ||
- m_cancelBitmap.GetHeight() != bitmapHeight ||
+ m_cancelBitmap.GetHeight() != bitmapHeight ||
m_cancelBitmap.GetWidth() != bitmapHeight
)
{
}
}
-#endif // !USE_NATIVE_SEARCH_CONTROL
+#endif // !wxUSE_NATIVE_SEARCH_CONTROL
#endif // wxUSE_SEARCHCTRL