#ifndef _WX_UNIV_TEXTCTRL_H_
#define _WX_UNIV_TEXTCTRL_H_
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma interface "univtextctrl.h"
-#endif
-
-class WXDLLEXPORT wxCaret;
-class WXDLLEXPORT wxTextCtrlCommandProcessor;
+class WXDLLIMPEXP_FWD_CORE wxCaret;
+class WXDLLIMPEXP_FWD_CORE wxTextCtrlCommandProcessor;
#include "wx/scrolwin.h" // for wxScrollHelper
// ----------------------------------------------------------------------------
// cursor movement and also selection and delete operations
-#define wxACTION_TEXT_GOTO _T("goto") // to pos in numArg
-#define wxACTION_TEXT_FIRST _T("first") // go to pos 0
-#define wxACTION_TEXT_LAST _T("last") // go to last pos
-#define wxACTION_TEXT_HOME _T("home")
-#define wxACTION_TEXT_END _T("end")
-#define wxACTION_TEXT_LEFT _T("left")
-#define wxACTION_TEXT_RIGHT _T("right")
-#define wxACTION_TEXT_UP _T("up")
-#define wxACTION_TEXT_DOWN _T("down")
-#define wxACTION_TEXT_WORD_LEFT _T("wordleft")
-#define wxACTION_TEXT_WORD_RIGHT _T("wordright")
-#define wxACTION_TEXT_PAGE_UP _T("pageup")
-#define wxACTION_TEXT_PAGE_DOWN _T("pagedown")
+#define wxACTION_TEXT_GOTO wxT("goto") // to pos in numArg
+#define wxACTION_TEXT_FIRST wxT("first") // go to pos 0
+#define wxACTION_TEXT_LAST wxT("last") // go to last pos
+#define wxACTION_TEXT_HOME wxT("home")
+#define wxACTION_TEXT_END wxT("end")
+#define wxACTION_TEXT_LEFT wxT("left")
+#define wxACTION_TEXT_RIGHT wxT("right")
+#define wxACTION_TEXT_UP wxT("up")
+#define wxACTION_TEXT_DOWN wxT("down")
+#define wxACTION_TEXT_WORD_LEFT wxT("wordleft")
+#define wxACTION_TEXT_WORD_RIGHT wxT("wordright")
+#define wxACTION_TEXT_PAGE_UP wxT("pageup")
+#define wxACTION_TEXT_PAGE_DOWN wxT("pagedown")
// clipboard operations
-#define wxACTION_TEXT_COPY _T("copy")
-#define wxACTION_TEXT_CUT _T("cut")
-#define wxACTION_TEXT_PASTE _T("paste")
+#define wxACTION_TEXT_COPY wxT("copy")
+#define wxACTION_TEXT_CUT wxT("cut")
+#define wxACTION_TEXT_PASTE wxT("paste")
// insert text at the cursor position: the text is in strArg of PerformAction
-#define wxACTION_TEXT_INSERT _T("insert")
+#define wxACTION_TEXT_INSERT wxT("insert")
// if the action starts with either of these prefixes and the rest of the
// string is one of the movement commands, it means to select/delete text from
// the current cursor position to the new one
-#define wxACTION_TEXT_PREFIX_SEL _T("sel")
-#define wxACTION_TEXT_PREFIX_DEL _T("del")
+#define wxACTION_TEXT_PREFIX_SEL wxT("sel")
+#define wxACTION_TEXT_PREFIX_DEL wxT("del")
// mouse selection
-#define wxACTION_TEXT_ANCHOR_SEL _T("anchorsel")
-#define wxACTION_TEXT_EXTEND_SEL _T("extendsel")
-#define wxACTION_TEXT_SEL_WORD _T("wordsel")
-#define wxACTION_TEXT_SEL_LINE _T("linesel")
+#define wxACTION_TEXT_ANCHOR_SEL wxT("anchorsel")
+#define wxACTION_TEXT_EXTEND_SEL wxT("extendsel")
+#define wxACTION_TEXT_SEL_WORD wxT("wordsel")
+#define wxACTION_TEXT_SEL_LINE wxT("linesel")
// undo or redo
-#define wxACTION_TEXT_UNDO _T("undo")
-#define wxACTION_TEXT_REDO _T("redo")
+#define wxACTION_TEXT_UNDO wxT("undo")
+#define wxACTION_TEXT_REDO wxT("redo")
// ----------------------------------------------------------------------------
// wxTextCtrl
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase, public wxScrollHelper
+class WXDLLIMPEXP_CORE wxTextCtrl : public wxTextCtrlBase,
+ public wxScrollHelper
{
public:
// creation
// --------
- wxTextCtrl() { Init(); }
+ wxTextCtrl() : wxScrollHelper(this) { Init(); }
wxTextCtrl(wxWindow *parent,
wxWindowID id,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr)
+ : wxScrollHelper(this)
{
Init();
// implement base class pure virtuals
// ----------------------------------
- virtual wxString GetValue() const;
- virtual void SetValue(const wxString& value);
-
virtual int GetLineLength(wxTextCoord lineNo) const;
virtual wxString GetLineText(wxTextCoord lineNo) const;
virtual int GetNumberOfLines() const;
// -----------------------
// caret stuff
- virtual void ShowCaret(bool show = TRUE);
- void HideCaret() { ShowCaret(FALSE); }
+ virtual void ShowCaret(bool show = true);
+ void HideCaret() { ShowCaret(false); }
void CreateCaret(); // for the current font size
// helpers for cursor movement
void RemoveSelection();
wxString GetSelectionText() const;
+ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
wxTextCoord *col,
wxTextCoord *row) const;
virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const;
- // ensure we have correct default border
- virtual wxBorder GetDefaultBorder() const { return wxBORDER_SUNKEN; }
-
// perform an action
virtual bool PerformAction(const wxControlAction& action,
long numArg = -1,
const wxString& strArg = wxEmptyString);
+ static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
+ virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
+ {
+ return GetStdInputHandler(handlerDef);
+ }
+
// override these methods to handle the caret
virtual bool SetFont(const wxFont &font);
- virtual bool Enable(bool enable = TRUE);
+ virtual bool Enable(bool enable = true);
// more readable flag testing methods
- bool IsPassword() const { return (GetWindowStyle() & wxTE_PASSWORD) != 0; }
- bool WrapLines() const
- { return !IsSingleLine() && !(GetWindowStyle() & wxHSCROLL); }
+ bool IsPassword() const { return HasFlag(wxTE_PASSWORD); }
+ bool WrapLines() const { return m_wrapLines; }
// only for wxStdTextCtrlInputHandler
void RefreshSelection();
+ // override wxScrollHelper method to prevent (auto)scrolling beyond the end
+ // of line
+ virtual bool SendAutoScrollEvents(wxScrollWinEvent& event) const;
+
+ // idle processing
+ virtual void OnInternalIdle();
+
protected:
+ // ensure we have correct default border
+ virtual wxBorder GetDefaultBorder() const { return wxBORDER_SUNKEN; }
+
// override base class methods
virtual void DoDrawBorder(wxDC& dc, const wxRect& rect);
virtual void DoDraw(wxControlRenderer *renderer);
// calc the size from the text extent
virtual wxSize DoGetBestClientSize() const;
+ // implements Set/ChangeValue()
+ virtual void DoSetValue(const wxString& value, int flags = 0);
+ virtual wxString DoGetValue() const;
+
// common part of all ctors
void Init();
wxRect GetRealTextArea() const;
// refresh the text in the given (in logical coords) rect
- void RefreshTextRect(const wxRect& rect, bool textOnly = TRUE);
+ void RefreshTextRect(const wxRect& rect, bool textOnly = true);
// refresh the line wrap marks for the given range of lines (inclusive)
void RefreshLineWrapMarks(wxTextCoord rowFirst, wxTextCoord rowLast);
wxCoord *widthReal = NULL) const;
// get the start and end of the selection for this line: if the line is
- // outside the selection, both will be -1 and FALSE will be returned
+ // outside the selection, both will be -1 and false will be returned
bool GetSelectedPartOfLine(wxTextCoord line,
wxTextPos *start, wxTextPos *end) const;
wxTextCoord *colStart,
wxTextCoord *colEnd,
wxTextCoord *colRowStart,
- bool devCoords = TRUE) const;
+ bool devCoords = true) const;
// HitTest() version which takes the logical text coordinates and not the
// device ones
wxTextCoord *row) const;
// get the line and the row in this line corresponding to the given row,
- // return TRUE if ok and FALSE if row is out of range
+ // return true if ok and false if row is out of range
//
// NB: this function can only be called for controls which wrap lines
bool GetLineAndRow(wxTextCoord row,
wxCoord GetLineHeight() const
{
// this one should be already precalculated
- wxASSERT_MSG( m_heightLine != -1, _T("should have line height") );
+ wxASSERT_MSG( m_heightLine != -1, wxT("should have line height") );
return m_heightLine;
}
void OnChar(wxKeyEvent& event);
void OnSize(wxSizeEvent& event);
- // overrdie wxScrollHelper method to prevent (auto)scrolling beyond the end
- // of line
- virtual bool SendAutoScrollEvents(wxScrollWinEvent& event) const;
-
// return the struct containing control-type dependent data
struct wxTextSingleLineData& SData() { return *m_data.sdata; }
struct wxTextMultiLineData& MData() { return *m_data.mdata; }
bool DoCut();
bool DoPaste();
- // idle processing
- virtual void OnInternalIdle();
private:
// all these methods are for multiline text controls only
inline const wxArrayString& GetLines() const;
inline size_t GetLineCount() const;
- // replace a line (returns TRUE if the number of rows in thel ine changed)
+ // replace a line (returns true if the number of rows in thel ine changed)
bool ReplaceLine(wxTextCoord line, const wxString& text);
// remove a line
// flags
bool m_isModified:1,
m_isEditable:1,
- m_hasCaret:1;
+ m_hasCaret:1,
+ m_wrapLines:1; // can't be changed after creation
// the rectangle (in client coordinates) to draw text inside
wxRect m_rectText;
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
-};
-
-// ----------------------------------------------------------------------------
-// wxStdTextCtrlInputHandler: this control handles only the mouse/kbd actions
-// common to Win32 and GTK, platform-specific things are implemented elsewhere
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxStdTextCtrlInputHandler : public wxStdInputHandler
-{
-public:
- wxStdTextCtrlInputHandler(wxInputHandler *inphand);
-
- virtual bool HandleKey(wxInputConsumer *consumer,
- const wxKeyEvent& event,
- bool pressed);
- virtual bool HandleMouse(wxInputConsumer *consumer,
- const wxMouseEvent& event);
- virtual bool HandleMouseMove(wxInputConsumer *consumer,
- const wxMouseEvent& event);
- virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
-
-protected:
- // get the position of the mouse click
- static wxTextPos HitTest(const wxTextCtrl *text, const wxPoint& pos);
- // capture data
- wxTextCtrl *m_winCapture;
+ friend class wxWrappedLineData;
};
#endif // _WX_UNIV_TEXTCTRL_H_