X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82434104d567dc8016f74843aa38bb131fb5b116..333e57d578e9e0fb6555452b5a53698ffd85ee69:/include/wx/x11/textctrl.h?ds=sidebyside diff --git a/include/wx/x11/textctrl.h b/include/wx/x11/textctrl.h index 894ae98c88..c0c750baa1 100644 --- a/include/wx/x11/textctrl.h +++ b/include/wx/x11/textctrl.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: textctrl.h +// Name: wx/x11/textctrl.h // Purpose: // Author: Robert Roebling // Created: 01/02/97 @@ -11,19 +11,23 @@ #ifndef __X11TEXTCTRLH__ #define __X11TEXTCTRLH__ -#ifdef __GNUG__ - #pragma interface "textctrl.h" -#endif +// Set to 1 to use wxUniv's implementation, 0 +// to use wxX11's. +#define wxUSE_UNIV_TEXTCTRL 1 + +#if wxUSE_UNIV_TEXTCTRL +#include "wx/univ/textctrl.h" +#else #include "wx/scrolwin.h" -#include "wx/dynarray.h" +#include "wx/arrstr.h" #include "wx/datetime.h" //----------------------------------------------------------------------------- // classes //----------------------------------------------------------------------------- -class wxTextCtrl; +class WXDLLIMPEXP_FWD_CORE wxTextCtrl; //----------------------------------------------------------------------------- // helpers @@ -43,9 +47,9 @@ class wxSourceUndoStep: public wxObject { public: wxSourceUndoStep( wxSourceUndo type, int y1, int y2, wxTextCtrl *owner ); - + void Undo(); - + wxSourceUndo m_type; int m_y1; int m_y2; @@ -63,7 +67,7 @@ public: { m_text = text; } - + wxString m_text; }; @@ -81,7 +85,7 @@ enum wxSourceLanguage // wxTextCtrl //----------------------------------------------------------------------------- -class wxTextCtrl: public wxTextCtrlBase, public wxScrollHelper +class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase, public wxScrollHelper { public: wxTextCtrl() { Init(); } @@ -93,6 +97,7 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString &name = wxTextCtrlNameStr); + virtual ~wxTextCtrl(); bool Create(wxWindow *parent, wxWindowID id, @@ -102,17 +107,16 @@ public: long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString &name = wxTextCtrlNameStr); - + // required for scrolling with wxScrollHelper // ------------------------------------------ virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); } - + // implement base class pure virtuals // ---------------------------------- - virtual wxString GetValue() const; - virtual void SetValue(const wxString& value); + virtual void ChangeValue(const wxString &value); virtual int GetLineLength(long lineNo) const; virtual wxString GetLineText(long lineNo) const; @@ -123,11 +127,10 @@ public: // more readable flag testing methods // ---------------------------------- - - bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); } + bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; } - bool WrapLines() const { return FALSE; } - + bool WrapLines() const { return false; } + // If the return values from and to are the same, there is no selection. virtual void GetSelection(long* from, long* to) const; @@ -171,18 +174,18 @@ public: virtual void Redo() {} virtual bool CanUndo() const { return (m_undos.GetCount() > 0); } - virtual bool CanRedo() const { return FALSE; } + virtual bool CanRedo() const { return false; } // Insertion point virtual void SetInsertionPoint(long pos); virtual void SetInsertionPointEnd(); virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; + virtual wxTextPos GetLastPosition() const; virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); - virtual bool Enable( bool enable ); + virtual bool Enable( bool enable = true ); void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); @@ -200,7 +203,7 @@ public: bool SetForegroundColour(const wxColour& colour); bool SetBackgroundColour(const wxColour& colour); - void SetModified() { m_modified = TRUE; } + void SetModified() { m_modified = true; } virtual void Freeze(); virtual void Thaw(); @@ -211,51 +214,60 @@ public: // not part of the wxTextCtrl API from now on.. + void SetLanguage( wxSourceLanguage lang = wxSOURCE_LANG_NONE ); + void Delete(); void DeleteLine(); - + void Indent(); void Unindent(); - + bool HasSelection(); void ClearSelection(); - + int GetCursorX() { return m_cursorX; } int GetCursorY() { return m_cursorY; } bool IsModified() { return m_modified; } bool OverwriteMode() { return m_overwrite; } // implementation from now on... - + int PosToPixel( int line, int pos ); int PixelToPos( int line, int pixel ); void SearchForBrackets(); - + void DoChar( char c ); void DoBack(); void DoDelete(); void DoReturn(); void DoDClick(); - - wxString GetNextToken( wxString &line, int &pos ); + + wxString GetNextToken( wxString &line, size_t &pos ); + + void DrawLinePart( wxDC &dc, int x, int y, const wxString &toDraw, const wxString &origin, const wxColour &colour); void DrawLine( wxDC &dc, int x, int y, const wxString &line, int lineNum ); void OnPaint( wxPaintEvent &event ); + void OnEraseBackground( wxEraseEvent &event ); void OnMouse( wxMouseEvent &event ); void OnChar( wxKeyEvent &event ); - void OnIdle( wxIdleEvent &event ); - + void OnSetFocus( wxFocusEvent& event ); + void OnKillFocus( wxFocusEvent& event ); + + void OnInternalIdle(); void RefreshLine( int n ); void RefreshDown( int n ); - void MoveCursor( int new_x, int new_y, bool shift = FALSE, bool centre = FALSE ); + void MoveCursor( int new_x, int new_y, bool shift = false, bool centre = false ); void MyAdjustScrollbars(); - + protected: // common part of all ctors void Init(); virtual wxSize DoGetBestSize() const; + virtual void DoSetValue(const wxString& value, int flags = 0); + friend class wxSourceUndoStep; wxSourceLineArray m_lines; @@ -264,38 +276,38 @@ protected: wxColour m_sourceColour; wxColour m_commentColour; wxColour m_stringColour; - + int m_cursorX; int m_cursorY; - + int m_selStartX,m_selStartY; int m_selEndX,m_selEndY; - + int m_lineHeight; int m_charWidth; - + int m_longestLine; - + bool m_overwrite; bool m_modified; bool m_editable; bool m_ignoreInput; - + wxArrayString m_keywords; wxColour m_keywordColour; - + wxArrayString m_defines; wxColour m_defineColour; - + wxArrayString m_variables; wxColour m_variableColour; - + wxSourceLanguage m_lang; - + wxList m_undos; - + bool m_capturing; - + int m_bracketX; int m_bracketY; @@ -351,13 +363,6 @@ private: // wxTextCtrl types // ---------------------------------------------------------------------------- -// wxTextPos is the position in the text -typedef long wxTextPos; - -// wxTextCoord is the line or row number (which should have been unsigned but -// is long for backwards compatibility) -typedef long wxTextCoord; - class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler { public: @@ -365,10 +370,10 @@ public: virtual bool HandleKey(wxInputConsumer *consumer, const wxKeyEvent& event, - bool pressed) { return FALSE; } - virtual bool HandleMouse(wxInputConsumer *consumer, const wxMouseEvent& event) { return FALSE; } - virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) { return FALSE; } - virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) { return FALSE; } + bool pressed) { return false; } + virtual bool HandleMouse(wxInputConsumer *consumer, const wxMouseEvent& event) { return false; } + virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event) { return false; } + virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event) { return false; } protected: // get the position of the mouse click @@ -378,5 +383,8 @@ protected: wxTextCtrl *m_winCapture; }; -#endif // __GTKTEXTCTRLH__ +#endif +// wxUSE_UNIV_TEXTCTRL + +#endif // __X11TEXTCTRLH__