// Created: 2006-02-19
// RCS-ID: $Id$
// Copyright: Vince Harron
-// License: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
return m_descriptiveText;
}
+
+ // provide access to the base class protected methods to wxSearchCtrl which
+ // needs to forward to them
+ void DoSetValue(const wxString& value, int flags)
+ {
+ wxTextCtrl::DoSetValue(value, flags);
+ }
+
+ bool DoLoadFile(const wxString& file, int fileType)
+ {
+ return wxTextCtrl::DoLoadFile(file, fileType);
+ }
+
+ bool DoSaveFile(const wxString& file, int fileType)
+ {
+ return wxTextCtrl::DoSaveFile(file, fileType);
+ }
+
protected:
void OnText(wxCommandEvent& eventText)
{
wxCommandEvent event(m_eventType, m_search->GetId());
event.SetEventObject(m_search);
+ if ( m_eventType == wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN )
+ {
+ // it's convenient to have the string to search for directly in the
+ // event instead of having to retrieve it from the control in the
+ // event handler code later, so provide it here
+ event.SetString(m_search->GetValue());
+ }
+
GetEventHandler()->ProcessEvent(event);
m_search->SetFocus();
#else
style |= wxBORDER_SIMPLE;
#endif
- if ( !wxTextCtrlBase::Create(parent, id, pos, size, style, validator, name) )
+ if ( !wxSearchCtrlBaseBaseClass::Create(parent, id, pos, size,
+ style, validator, name) )
{
return false;
}
m_text = new wxSearchTextCtrl(this, value, style & ~wxBORDER_MASK);
m_text->SetDescriptiveText(_("Search"));
- wxSize sizeText = m_text->GetBestSize();
-
m_searchButton = new wxSearchButton(this,
wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN,
m_searchBitmap);
y += BORDER;
width -= horizontalBorder*2;
height -= BORDER*2;
+ if (width < 0) width = 0;
+ if (height < 0) height = 0;
wxSize sizeSearch(0,0);
wxSize sizeCancel(0,0);
searchMargin = 0;
cancelMargin = 0;
}
- wxCoord textWidth = width - sizeSearch.x - sizeCancel.x - searchMargin - cancelMargin;
+ wxCoord textWidth = width - sizeSearch.x - sizeCancel.x - searchMargin - cancelMargin - 1;
+ if (textWidth < 0) textWidth = 0;
// position the subcontrols inside the client area
// accessors
// ---------
-wxString wxSearchCtrl::GetValue() const
+wxString wxSearchCtrl::DoGetValue() const
{
wxString value = m_text->GetValue();
if (value == m_text->GetDescriptiveText())
else
return value;
}
-void wxSearchCtrl::SetValue(const wxString& value)
-{
- m_text->SetValue(value);
-}
-
wxString wxSearchCtrl::GetRange(long from, long to) const
{
return m_text->GetRange(from, to);
{
return m_text->GetInsertionPoint();
}
-wxTextPos wxSearchCtrl::GetLastPosition() const
+long wxSearchCtrl::GetLastPosition() const
{
return m_text->GetLastPosition();
}
void wxSearchCtrl::DoSetValue(const wxString& value, int flags)
{
- m_text->ChangeValue( value );
- if ( flags & SetValue_SendEvent )
- SendTextUpdatedEvent();
+ m_text->DoSetValue(value, flags);
+}
+
+bool wxSearchCtrl::DoLoadFile(const wxString& file, int fileType)
+{
+ return m_text->DoLoadFile(file, fileType);
+}
+
+bool wxSearchCtrl::DoSaveFile(const wxString& file, int fileType)
+{
+ return m_text->DoSaveFile(file, fileType);
}
// do the window-specific processing after processing the update event
m_cancelBitmap.GetWidth() != bitmapHeight
)
{
- m_cancelBitmap = RenderCancelBitmap(bitmapHeight-BORDER,bitmapHeight-BORDER); // square
+ m_cancelBitmap = RenderCancelBitmap(bitmapHeight-BORDER-1,bitmapHeight-BORDER-1); // square
m_cancelButton->SetBitmapLabel(m_cancelBitmap);
}
// else this bitmap was set by user, don't alter