2011-03-20 18:05:19 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/generic/srchctlg.h
|
|
|
|
// Purpose: generic wxSearchCtrl class
|
|
|
|
// Author: Vince Harron
|
|
|
|
// Created: 2006-02-19
|
|
|
|
// Copyright: Vince Harron
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GENERIC_SEARCHCTRL_H_
|
|
|
|
#define _WX_GENERIC_SEARCHCTRL_H_
|
|
|
|
|
|
|
|
#if wxUSE_SEARCHCTRL
|
|
|
|
|
|
|
|
#include "wx/bitmap.h"
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSearchButton;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSearchTextCtrl;
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSearchCtrl is a combination of wxTextCtrl and wxSearchButton
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// creation
|
|
|
|
// --------
|
|
|
|
|
|
|
|
wxSearchCtrl();
|
|
|
|
wxSearchCtrl(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxSearchCtrlNameStr);
|
|
|
|
|
|
|
|
virtual ~wxSearchCtrl();
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxSearchCtrlNameStr);
|
|
|
|
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
// get/set search button menu
|
|
|
|
// --------------------------
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetMenu( wxMenu* menu ) wxOVERRIDE;
|
|
|
|
virtual wxMenu* GetMenu() wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
// get/set search options
|
|
|
|
// ----------------------
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void ShowSearchButton( bool show ) wxOVERRIDE;
|
|
|
|
virtual bool IsSearchButtonVisible() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void ShowCancelButton( bool show ) wxOVERRIDE;
|
|
|
|
virtual bool IsCancelButtonVisible() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// TODO: In 2.9 these should probably be virtual, and declared in the base class...
|
|
|
|
void SetDescriptiveText(const wxString& text);
|
|
|
|
wxString GetDescriptiveText() const;
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
// ---------
|
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual wxString GetRange(long from, long to) const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual int GetLineLength(long lineNo) const wxOVERRIDE;
|
|
|
|
virtual wxString GetLineText(long lineNo) const wxOVERRIDE;
|
|
|
|
virtual int GetNumberOfLines() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool IsModified() const wxOVERRIDE;
|
|
|
|
virtual bool IsEditable() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// more readable flag testing methods
|
|
|
|
virtual bool IsSingleLine() const;
|
|
|
|
virtual bool IsMultiLine() const;
|
|
|
|
|
|
|
|
// If the return values from and to are the same, there is no selection.
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void GetSelection(long* from, long* to) const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual wxString GetStringSelection() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// operations
|
|
|
|
// ----------
|
|
|
|
|
|
|
|
// editing
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void Clear() wxOVERRIDE;
|
|
|
|
virtual void Replace(long from, long to, const wxString& value) wxOVERRIDE;
|
|
|
|
virtual void Remove(long from, long to) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// load/save the controls contents from/to the file
|
|
|
|
virtual bool LoadFile(const wxString& file);
|
|
|
|
virtual bool SaveFile(const wxString& file = wxEmptyString);
|
|
|
|
|
|
|
|
// sets/clears the dirty flag
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void MarkDirty() wxOVERRIDE;
|
|
|
|
virtual void DiscardEdits() wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// set the max number of characters which may be entered in a single line
|
|
|
|
// text control
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetMaxLength(unsigned long WXUNUSED(len)) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// writing text inserts it at the current position, appending always
|
|
|
|
// inserts it at the end
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void WriteText(const wxString& text) wxOVERRIDE;
|
|
|
|
virtual void AppendText(const wxString& text) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// insert the character which would have resulted from this key event,
|
|
|
|
// return true if anything has been inserted
|
|
|
|
virtual bool EmulateKeyPress(const wxKeyEvent& event);
|
|
|
|
|
|
|
|
// text control under some platforms supports the text styles: these
|
|
|
|
// methods allow to apply the given text style to the given selection or to
|
|
|
|
// set/get the style which will be used for all appended text
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool SetStyle(long start, long end, const wxTextAttr& style) wxOVERRIDE;
|
|
|
|
virtual bool GetStyle(long position, wxTextAttr& style) wxOVERRIDE;
|
|
|
|
virtual bool SetDefaultStyle(const wxTextAttr& style) wxOVERRIDE;
|
|
|
|
virtual const wxTextAttr& GetDefaultStyle() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// translate between the position (which is just an index in the text ctrl
|
|
|
|
// considering all its contents as a single strings) and (x, y) coordinates
|
|
|
|
// which represent column and line.
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual long XYToPosition(long x, long y) const wxOVERRIDE;
|
|
|
|
virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void ShowPosition(long pos) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// find the character at position given in pixels
|
|
|
|
//
|
|
|
|
// NB: pt is in device coords (not adjusted for the client area origin nor
|
|
|
|
// scrolling)
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
|
|
|
wxTextCoord *col,
|
2016-06-26 05:25:29 +00:00
|
|
|
wxTextCoord *row) const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// Clipboard operations
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void Copy() wxOVERRIDE;
|
|
|
|
virtual void Cut() wxOVERRIDE;
|
|
|
|
virtual void Paste() wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool CanCopy() const wxOVERRIDE;
|
|
|
|
virtual bool CanCut() const wxOVERRIDE;
|
|
|
|
virtual bool CanPaste() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// Undo/redo
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void Undo() wxOVERRIDE;
|
|
|
|
virtual void Redo() wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool CanUndo() const wxOVERRIDE;
|
|
|
|
virtual bool CanRedo() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// Insertion point
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetInsertionPoint(long pos) wxOVERRIDE;
|
|
|
|
virtual void SetInsertionPointEnd() wxOVERRIDE;
|
|
|
|
virtual long GetInsertionPoint() const wxOVERRIDE;
|
|
|
|
virtual wxTextPos GetLastPosition() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void SetSelection(long from, long to) wxOVERRIDE;
|
|
|
|
virtual void SelectAll() wxOVERRIDE;
|
|
|
|
virtual void SetEditable(bool editable) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
// override streambuf method
|
|
|
|
#if wxHAS_TEXT_WINDOW_STREAM
|
|
|
|
int overflow(int i);
|
|
|
|
#endif // wxHAS_TEXT_WINDOW_STREAM
|
|
|
|
|
|
|
|
// stream-like insertion operators: these are always available, whether we
|
|
|
|
// were, or not, compiled with streambuf support
|
|
|
|
wxTextCtrl& operator<<(const wxString& s);
|
|
|
|
wxTextCtrl& operator<<(int i);
|
|
|
|
wxTextCtrl& operator<<(long i);
|
|
|
|
wxTextCtrl& operator<<(float f);
|
|
|
|
wxTextCtrl& operator<<(double d);
|
2016-06-26 05:25:29 +00:00
|
|
|
wxTextCtrl& operator<<(wxChar c);
|
2011-03-20 18:05:19 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// do the window-specific processing after processing the update event
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool ShouldInheritColours() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// wxWindow overrides
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool SetFont(const wxFont& font) wxOVERRIDE;
|
|
|
|
virtual bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// search control generic only
|
|
|
|
void SetSearchBitmap( const wxBitmap& bitmap );
|
|
|
|
void SetCancelBitmap( const wxBitmap& bitmap );
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
void SetSearchMenuBitmap( const wxBitmap& bitmap );
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
protected:
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual void DoSetValue(const wxString& value, int flags) wxOVERRIDE;
|
|
|
|
virtual wxString DoGetValue() const wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual bool DoLoadFile(const wxString& file, int fileType) wxOVERRIDE;
|
|
|
|
virtual bool DoSaveFile(const wxString& file, int fileType) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
// override the base class virtuals involved into geometry calculations
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
virtual void RecalcBitmaps();
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop );
|
|
|
|
virtual wxBitmap RenderCancelBitmap( int x, int y );
|
|
|
|
|
2013-09-22 22:44:55 +00:00
|
|
|
void OnCancelButton( wxCommandEvent& event );
|
2011-03-20 18:05:19 +00:00
|
|
|
|
|
|
|
void OnSetFocus( wxFocusEvent& event );
|
|
|
|
void OnSize( wxSizeEvent& event );
|
|
|
|
|
|
|
|
bool HasMenu() const
|
|
|
|
{
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
return m_menu != NULL;
|
|
|
|
#else // !wxUSE_MENUS
|
|
|
|
return false;
|
|
|
|
#endif // wxUSE_MENUS/!wxUSE_MENUS
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class wxSearchButton;
|
|
|
|
|
2012-03-18 01:12:27 +00:00
|
|
|
// Implement pure virtual function inherited from wxCompositeWindow.
|
2016-06-26 05:25:29 +00:00
|
|
|
virtual wxWindowList GetCompositeWindowParts() const wxOVERRIDE;
|
|
|
|
|
|
|
|
// Position the child controls using the current window size.
|
|
|
|
void LayoutControls();
|
2012-03-18 01:12:27 +00:00
|
|
|
|
2011-03-20 18:05:19 +00:00
|
|
|
#if wxUSE_MENUS
|
|
|
|
void PopupSearchMenu();
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
// the subcontrols
|
|
|
|
wxSearchTextCtrl *m_text;
|
|
|
|
wxSearchButton *m_searchButton;
|
|
|
|
wxSearchButton *m_cancelButton;
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
wxMenu *m_menu;
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
bool m_searchButtonVisible;
|
|
|
|
bool m_cancelButtonVisible;
|
|
|
|
|
|
|
|
bool m_searchBitmapUser;
|
|
|
|
bool m_cancelBitmapUser;
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
bool m_searchMenuBitmapUser;
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
wxBitmap m_searchBitmap;
|
|
|
|
wxBitmap m_cancelBitmap;
|
|
|
|
#if wxUSE_MENUS
|
|
|
|
wxBitmap m_searchMenuBitmap;
|
|
|
|
#endif // wxUSE_MENUS
|
|
|
|
|
|
|
|
private:
|
2016-06-26 05:25:29 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxSearchCtrl);
|
2011-03-20 18:05:19 +00:00
|
|
|
|
2016-06-26 05:25:29 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
2011-03-20 18:05:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // wxUSE_SEARCHCTRL
|
|
|
|
|
|
|
|
#endif // _WX_GENERIC_SEARCHCTRL_H_
|
|
|
|
|