2007-09-26 00:30:22 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gtk/textentry.h
|
|
|
|
// Purpose: wxGTK-specific wxTextEntry implementation
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Created: 2007-09-24
|
2019-04-22 12:12:05 +00:00
|
|
|
// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwidgets.org>
|
2007-09-26 00:30:22 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_GTK_TEXTENTRY_H_
|
|
|
|
#define _WX_GTK_TEXTENTRY_H_
|
|
|
|
|
2013-03-22 14:13:02 +00:00
|
|
|
typedef struct _GdkEventKey GdkEventKey;
|
2007-09-26 00:30:22 +00:00
|
|
|
typedef struct _GtkEditable GtkEditable;
|
2009-09-05 12:39:12 +00:00
|
|
|
typedef struct _GtkEntry GtkEntry;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2018-01-26 22:43:33 +00:00
|
|
|
class wxTextAutoCompleteData; // private class used only by wxTextEntry itself
|
2019-07-10 00:14:21 +00:00
|
|
|
class wxTextCoalesceData; // another private class
|
2018-01-26 22:43:33 +00:00
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxTextEntry: roughly corresponds to GtkEditable
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxTextEntry : public wxTextEntryBase
|
|
|
|
{
|
|
|
|
public:
|
2018-01-26 22:43:33 +00:00
|
|
|
wxTextEntry();
|
|
|
|
virtual ~wxTextEntry();
|
2007-09-26 00:30:22 +00:00
|
|
|
|
|
|
|
// implement wxTextEntryBase pure virtual methods
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void WriteText(const wxString& text) wxOVERRIDE;
|
|
|
|
virtual void Remove(long from, long to) wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void Copy() wxOVERRIDE;
|
|
|
|
virtual void Cut() wxOVERRIDE;
|
|
|
|
virtual void Paste() wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void Undo() wxOVERRIDE;
|
|
|
|
virtual void Redo() wxOVERRIDE;
|
|
|
|
virtual bool CanUndo() const wxOVERRIDE;
|
|
|
|
virtual bool CanRedo() const wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetInsertionPoint(long pos) wxOVERRIDE;
|
|
|
|
virtual long GetInsertionPoint() const wxOVERRIDE;
|
|
|
|
virtual long GetLastPosition() const wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetSelection(long from, long to) wxOVERRIDE;
|
|
|
|
virtual void GetSelection(long *from, long *to) const wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool IsEditable() const wxOVERRIDE;
|
|
|
|
virtual void SetEditable(bool editable) wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void SetMaxLength(unsigned long len) wxOVERRIDE;
|
2015-11-25 02:40:40 +00:00
|
|
|
virtual void ForceUpper() wxOVERRIDE;
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2013-12-02 17:46:27 +00:00
|
|
|
#ifdef __WXGTK3__
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool SetHint(const wxString& hint) wxOVERRIDE;
|
|
|
|
virtual wxString GetHint() const wxOVERRIDE;
|
2013-12-02 17:46:27 +00:00
|
|
|
#endif
|
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
// implementation only from now on
|
|
|
|
void SendMaxLenEvent();
|
2013-03-21 22:37:09 +00:00
|
|
|
bool GTKEntryOnInsertText(const char* text);
|
2015-11-25 02:40:40 +00:00
|
|
|
bool GTKIsUpperCase() const { return m_isUpperCase; }
|
2007-09-26 00:30:22 +00:00
|
|
|
|
2019-07-10 00:14:21 +00:00
|
|
|
// Called from "changed" signal handler (or, possibly, slightly later, when
|
|
|
|
// coalescing several "changed" signals into a single event) for GtkEntry.
|
2019-07-08 13:58:12 +00:00
|
|
|
//
|
|
|
|
// By default just generates a wxEVT_TEXT, but overridden to do more things
|
|
|
|
// in wxTextCtrl.
|
|
|
|
virtual void GTKOnTextChanged() { SendTextUpdatedEvent(); }
|
|
|
|
|
2019-07-10 00:14:21 +00:00
|
|
|
// Helper functions only used internally.
|
|
|
|
wxTextCoalesceData* GTKGetCoalesceData() const { return m_coalesceData; }
|
|
|
|
|
2009-03-02 13:31:29 +00:00
|
|
|
protected:
|
2012-07-29 22:08:15 +00:00
|
|
|
// This method must be called from the derived class Create() to connect
|
|
|
|
// the handlers for the clipboard (cut/copy/paste) events.
|
|
|
|
void GTKConnectClipboardSignals(GtkWidget* entry);
|
|
|
|
|
2013-03-21 22:37:09 +00:00
|
|
|
// And this one to connect "insert-text" signal.
|
|
|
|
void GTKConnectInsertTextSignal(GtkEntry* entry);
|
|
|
|
|
2019-07-08 14:04:24 +00:00
|
|
|
// Finally this one connects to the "changed" signal on the object returned
|
|
|
|
// by GetTextObject().
|
|
|
|
void GTKConnectChangedSignal();
|
|
|
|
|
2013-03-21 22:37:09 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual void DoSetValue(const wxString& value, int flags) wxOVERRIDE;
|
|
|
|
virtual wxString DoGetValue() const wxOVERRIDE;
|
2009-03-02 13:31:29 +00:00
|
|
|
|
2009-09-05 12:39:12 +00:00
|
|
|
// margins functions
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool DoSetMargins(const wxPoint& pt) wxOVERRIDE;
|
|
|
|
virtual wxPoint DoGetMargins() const wxOVERRIDE;
|
2009-09-05 12:39:12 +00:00
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool DoAutoCompleteStrings(const wxArrayString& choices) wxOVERRIDE;
|
2018-01-26 22:43:33 +00:00
|
|
|
virtual bool DoAutoCompleteCustom(wxTextCompleter *completer) wxOVERRIDE;
|
2011-04-16 17:27:04 +00:00
|
|
|
|
2019-07-09 17:37:21 +00:00
|
|
|
// Call this from the overridden wxWindow::GTKIMFilterKeypress() to use
|
|
|
|
// GtkEntry IM context.
|
|
|
|
int GTKEntryIMFilterKeypress(GdkEventKey* event) const;
|
2013-03-21 22:37:09 +00:00
|
|
|
|
2019-07-10 00:14:21 +00:00
|
|
|
// If GTKEntryIMFilterKeypress() is not called (as multiline wxTextCtrl
|
|
|
|
// uses its own IM), call this method instead to still notify wxTextEntry
|
|
|
|
// about the key press events in the given widget.
|
|
|
|
void GTKEntryOnKeypress(GtkWidget* widget) const;
|
|
|
|
|
|
|
|
|
2018-10-10 23:05:43 +00:00
|
|
|
static int GTKGetEntryTextLength(GtkEntry* entry);
|
2017-07-31 19:36:02 +00:00
|
|
|
|
2019-07-08 14:04:24 +00:00
|
|
|
// Block/unblock the corresponding GTK signal.
|
|
|
|
//
|
|
|
|
// Note that we make it protected in wxGTK as it is called from wxComboBox
|
|
|
|
// currently.
|
|
|
|
virtual void EnableTextChangedEvents(bool enable) wxOVERRIDE;
|
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
private:
|
|
|
|
// implement this to return the associated GtkEntry or another widget
|
|
|
|
// implementing GtkEditable
|
|
|
|
virtual GtkEditable *GetEditable() const = 0;
|
2009-09-05 12:39:12 +00:00
|
|
|
|
|
|
|
// implement this to return the associated GtkEntry
|
|
|
|
virtual GtkEntry *GetEntry() const = 0;
|
2015-11-25 02:40:40 +00:00
|
|
|
|
2019-07-08 14:04:24 +00:00
|
|
|
// This one exists in order to be overridden by wxTextCtrl which uses
|
|
|
|
// either GtkEditable or GtkTextBuffer depending on whether it is single-
|
|
|
|
// or multi-line.
|
|
|
|
virtual void *GetTextObject() const { return GetEntry(); }
|
|
|
|
|
|
|
|
|
2018-01-26 22:43:33 +00:00
|
|
|
// Various auto-completion-related stuff, only used if any of AutoComplete()
|
2018-01-27 00:07:18 +00:00
|
|
|
// methods are called.
|
2018-01-26 22:43:33 +00:00
|
|
|
wxTextAutoCompleteData *m_autoCompleteData;
|
|
|
|
|
2018-01-27 00:07:18 +00:00
|
|
|
// It needs to call our GetEntry() method.
|
2018-01-26 22:43:33 +00:00
|
|
|
friend class wxTextAutoCompleteData;
|
|
|
|
|
2019-07-10 00:14:21 +00:00
|
|
|
// Data used for coalescing "changed" events resulting from a single user
|
|
|
|
// action.
|
|
|
|
mutable wxTextCoalesceData* m_coalesceData;
|
|
|
|
|
2015-11-25 02:40:40 +00:00
|
|
|
bool m_isUpperCase;
|
2007-09-26 00:30:22 +00:00
|
|
|
};
|
|
|
|
|
2015-11-25 02:40:40 +00:00
|
|
|
// We don't need the generic version.
|
|
|
|
#define wxHAS_NATIVE_TEXT_FORCEUPPER
|
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
#endif // _WX_GTK_TEXTENTRY_H_
|
|
|
|
|