1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2002-06-04 18:09:20 +00:00
|
|
|
// Name: wx/gtk/textctrl.h
|
1998-05-20 14:01:55 +00:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Created: 01/02/97
|
2003-03-17 10:34:04 +00:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-12-09 06:21:15 +00:00
|
|
|
#ifndef _WX_GTK_TEXTCTRL_H_
|
|
|
|
#define _WX_GTK_TEXTCTRL_H_
|
|
|
|
|
|
|
|
typedef struct _GtkTextMark GtkTextMark;
|
1998-05-20 14:01:55 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
1999-07-14 22:55:57 +00:00
|
|
|
// wxTextCtrl
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 22:58:06 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1999-07-14 22:55:57 +00:00
|
|
|
public:
|
2000-10-20 14:11:42 +00:00
|
|
|
wxTextCtrl() { Init(); }
|
1999-12-30 17:51:26 +00:00
|
|
|
wxTextCtrl(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 = wxTextCtrlNameStr);
|
|
|
|
|
2012-11-20 12:49:03 +00:00
|
|
|
virtual ~wxTextCtrl();
|
2005-02-19 02:55:32 +00:00
|
|
|
|
1999-12-30 17:51:26 +00:00
|
|
|
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 = wxTextCtrlNameStr);
|
1999-07-14 22:55:57 +00:00
|
|
|
|
|
|
|
// implement base class pure virtuals
|
|
|
|
// ----------------------------------
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void WriteText(const wxString& text) wxOVERRIDE;
|
|
|
|
virtual wxString GetValue() const wxOVERRIDE;
|
2006-10-08 17:52:39 +00:00
|
|
|
virtual bool IsEmpty() const;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual int GetLineLength(long lineNo) const wxOVERRIDE;
|
|
|
|
virtual wxString GetLineText(long lineNo) const wxOVERRIDE;
|
|
|
|
virtual int GetNumberOfLines() const wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsModified() const wxOVERRIDE;
|
|
|
|
virtual bool IsEditable() const wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void GetSelection(long* from, long* to) const wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void Remove(long from, long to) wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void MarkDirty() wxOVERRIDE;
|
|
|
|
virtual void DiscardEdits() wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool SetStyle(long start, long end, const wxTextAttr& style) wxOVERRIDE;
|
|
|
|
virtual bool GetStyle(long position, wxTextAttr& style) wxOVERRIDE;
|
2001-06-18 17:41:33 +00:00
|
|
|
|
1999-07-14 22:55:57 +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.
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual long XYToPosition(long x, long y) const wxOVERRIDE;
|
|
|
|
virtual bool PositionToXY(long pos, long *x, long *y) const wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void ShowPosition(long pos) wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const wxOVERRIDE;
|
2004-07-23 20:26:25 +00:00
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
|
|
|
wxTextCoord *col,
|
2014-03-30 00:02:23 +00:00
|
|
|
wxTextCoord *row) const wxOVERRIDE
|
2004-07-23 20:26:25 +00:00
|
|
|
{
|
|
|
|
return wxTextCtrlBase::HitTest(pt, col, row);
|
|
|
|
}
|
2004-07-23 19:59:00 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// Clipboard operations
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void Copy() wxOVERRIDE;
|
|
|
|
virtual void Cut() wxOVERRIDE;
|
|
|
|
virtual void Paste() wxOVERRIDE;
|
1998-07-23 16:07:55 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// Insertion point
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetInsertionPoint(long pos) wxOVERRIDE;
|
|
|
|
virtual long GetInsertionPoint() const wxOVERRIDE;
|
|
|
|
virtual wxTextPos GetLastPosition() const wxOVERRIDE;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetSelection(long from, long to) wxOVERRIDE;
|
|
|
|
virtual void SetEditable(bool editable) wxOVERRIDE;
|
1999-04-06 16:32:33 +00:00
|
|
|
|
2006-12-04 12:39:52 +00:00
|
|
|
// Overridden wxWindow methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetWindowStyleFlag( long style ) wxOVERRIDE;
|
|
|
|
virtual bool Enable( bool enable = true ) wxOVERRIDE;
|
2000-02-02 17:59:12 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// Implementation from now on
|
|
|
|
void OnDropFiles( wxDropFilesEvent &event );
|
1998-05-20 14:01:55 +00:00
|
|
|
void OnChar( wxKeyEvent &event );
|
1998-07-23 16:07:55 +00:00
|
|
|
|
1999-04-07 21:33:22 +00:00
|
|
|
void OnCut(wxCommandEvent& event);
|
|
|
|
void OnCopy(wxCommandEvent& event);
|
|
|
|
void OnPaste(wxCommandEvent& event);
|
|
|
|
void OnUndo(wxCommandEvent& event);
|
|
|
|
void OnRedo(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnUpdateCut(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateCopy(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdatePaste(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUndo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateRedo(wxUpdateUIEvent& event);
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
bool SetFont(const wxFont& font) wxOVERRIDE;
|
|
|
|
bool SetForegroundColour(const wxColour& colour) wxOVERRIDE;
|
|
|
|
bool SetBackgroundColour(const wxColour& colour) wxOVERRIDE;
|
1998-10-19 14:18:56 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
GtkWidget* GetConnectWidget() wxOVERRIDE;
|
2004-07-23 19:59:00 +00:00
|
|
|
|
|
|
|
void SetUpdateFont(bool WXUNUSED(update)) { }
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2001-08-16 13:18:51 +00:00
|
|
|
// implementation only from now on
|
|
|
|
|
|
|
|
// tell the control to ignore next text changed signal
|
2006-10-08 17:46:12 +00:00
|
|
|
void IgnoreNextTextUpdate(int n = 1) { m_countUpdatesToIgnore = n; }
|
2001-08-16 13:18:51 +00:00
|
|
|
|
|
|
|
// should we ignore the changed signal? always resets the flag
|
|
|
|
bool IgnoreTextUpdate();
|
|
|
|
|
2006-05-17 00:20:20 +00:00
|
|
|
// call this to indicate that the control is about to be changed
|
|
|
|
// programmatically and so m_modified flag shouldn't be set
|
|
|
|
void DontMarkDirtyOnNextChange() { m_dontMarkDirty = true; }
|
|
|
|
|
|
|
|
// should we mark the control as dirty? always resets the flag
|
|
|
|
bool MarkDirtyOnChange();
|
|
|
|
|
2006-09-01 22:23:51 +00:00
|
|
|
// always let GTK have mouse release events for multiline controls
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool GTKProcessEvent(wxEvent& event) const wxOVERRIDE;
|
2006-09-01 22:23:51 +00:00
|
|
|
|
2006-05-17 00:20:20 +00:00
|
|
|
|
2004-05-06 17:26:25 +00:00
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
2005-01-19 16:25:34 +00:00
|
|
|
|
1999-11-19 21:01:20 +00:00
|
|
|
protected:
|
2007-09-26 00:30:22 +00:00
|
|
|
// overridden wxWindow virtual methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
|
|
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style) wxOVERRIDE;
|
|
|
|
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const wxOVERRIDE;
|
1999-11-19 21:01:20 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const wxOVERRIDE;
|
2012-11-09 21:11:37 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void DoFreeze() wxOVERRIDE;
|
|
|
|
virtual void DoThaw() wxOVERRIDE;
|
2008-01-05 00:21:31 +00:00
|
|
|
|
2004-05-06 17:26:25 +00:00
|
|
|
// Widgets that use the style->base colour for the BG colour should
|
|
|
|
// override this and return true.
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool UseGTKStyleBase() const wxOVERRIDE { return true; }
|
2004-05-06 17:26:25 +00:00
|
|
|
|
2014-12-25 01:32:00 +00:00
|
|
|
virtual wxString DoGetValue() const wxOVERRIDE;
|
2006-10-08 17:46:12 +00:00
|
|
|
|
2013-03-21 22:37:09 +00:00
|
|
|
// Override this to use either GtkEntry or GtkTextView IME depending on the
|
|
|
|
// kind of control we are.
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual int GTKIMFilterKeypress(GdkEventKey* event) const wxOVERRIDE;
|
2013-03-21 22:37:09 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxPoint DoPositionToCoords(long pos) const wxOVERRIDE;
|
2011-07-29 15:11:54 +00:00
|
|
|
|
2006-12-04 12:39:52 +00:00
|
|
|
// wrappers hiding the differences between functions doing the same thing
|
|
|
|
// for GtkTextView and GtkEntry (all of them use current window style to
|
|
|
|
// set the given characteristic)
|
|
|
|
void GTKSetEditable();
|
|
|
|
void GTKSetVisibility();
|
2007-11-04 16:34:36 +00:00
|
|
|
void GTKSetActivatesDefault();
|
2006-12-04 12:39:52 +00:00
|
|
|
void GTKSetWrapMode();
|
|
|
|
void GTKSetJustification();
|
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
private:
|
2012-10-02 15:57:03 +00:00
|
|
|
void Init();
|
|
|
|
|
2007-10-26 06:20:23 +00:00
|
|
|
// overridden wxTextEntry virtual methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual GtkEditable *GetEditable() const wxOVERRIDE;
|
|
|
|
virtual GtkEntry *GetEntry() const wxOVERRIDE;
|
|
|
|
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
|
2007-10-26 06:20:23 +00:00
|
|
|
|
2000-10-20 14:11:42 +00:00
|
|
|
// change the font for everything in this control
|
|
|
|
void ChangeFontGlobally();
|
|
|
|
|
2006-08-23 13:33:04 +00:00
|
|
|
// get the encoding which is used in this control: this looks at our font
|
|
|
|
// and default style but not the current style (i.e. the style for the
|
|
|
|
// current position); returns wxFONTENCODING_SYSTEM if we have no specific
|
|
|
|
// encoding
|
|
|
|
wxFontEncoding GetTextEncoding() const;
|
|
|
|
|
2007-08-19 19:05:56 +00:00
|
|
|
// returns either m_text or m_buffer depending on whether the control is
|
|
|
|
// single- or multi-line; convenient for the GTK+ functions which work with
|
|
|
|
// both
|
|
|
|
void *GetTextObject() const
|
|
|
|
{
|
2008-11-02 02:39:52 +00:00
|
|
|
return IsMultiLine() ? static_cast<void *>(m_buffer)
|
|
|
|
: static_cast<void *>(m_text);
|
2007-08-19 19:05:56 +00:00
|
|
|
}
|
|
|
|
|
2006-08-23 13:33:04 +00:00
|
|
|
|
2007-08-19 19:05:56 +00:00
|
|
|
// the widget used for single line controls
|
1998-08-14 22:53:21 +00:00
|
|
|
GtkWidget *m_text;
|
2001-08-16 13:18:51 +00:00
|
|
|
|
2017-12-05 14:41:08 +00:00
|
|
|
bool m_modified;
|
|
|
|
bool m_dontMarkDirty;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2006-10-08 17:46:12 +00:00
|
|
|
int m_countUpdatesToIgnore;
|
|
|
|
|
2004-12-01 20:52:36 +00:00
|
|
|
// Our text buffer. Convenient, and holds the buffer while using
|
2006-12-09 06:21:15 +00:00
|
|
|
// a dummy one when frozen
|
2004-12-01 20:52:36 +00:00
|
|
|
GtkTextBuffer *m_buffer;
|
|
|
|
|
2006-12-09 06:21:15 +00:00
|
|
|
GtkTextMark* m_showPositionOnThaw;
|
2011-03-28 06:27:49 +00:00
|
|
|
GSList* m_anonymousMarkList;
|
2005-02-19 02:55:32 +00:00
|
|
|
|
|
|
|
// For wxTE_AUTO_URL
|
|
|
|
void OnUrlMouseEvent(wxMouseEvent&);
|
2004-12-01 20:52:36 +00:00
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
2006-12-09 06:21:15 +00:00
|
|
|
#endif // _WX_GTK_TEXTCTRL_H_
|