]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/textctrl.h
refactor wxStaticText::Ellipsize so it's a static public utility function; document...
[wxWidgets.git] / include / wx / textctrl.h
index 23f9a465493cd8963724a1f077b67bbab5f74c6a..74b3944339f71a44d7b74d8de40bc1adacb8b6dd 100644 (file)
@@ -53,7 +53,7 @@ typedef long wxTextCoord;
 // constants
 // ----------------------------------------------------------------------------
 
-extern WXDLLEXPORT_DATA(const char) wxTextCtrlNameStr[];
+extern WXDLLIMPEXP_DATA_CORE(const char) wxTextCtrlNameStr[];
 
 // this is intentionally not enum to avoid warning fixes with
 // typecasting from enum type to wxTextCoord
@@ -65,7 +65,6 @@ const wxTextCoord wxInvalidTextCoord    = -2;
 // ----------------------------------------------------------------------------
 
 #define wxTE_NO_VSCROLL     0x0002
-#define wxTE_AUTO_SCROLL    0x0008
 
 #define wxTE_READONLY       0x0010
 #define wxTE_MULTILINE      0x0020
@@ -108,6 +107,11 @@ const wxTextCoord wxInvalidTextCoord    = -2;
     #define wxTE_LINEWRAP       wxTE_CHARWRAP
 #endif // WXWIN_COMPATIBILITY_2_6
 
+#if WXWIN_COMPATIBILITY_2_8
+    // this style is (or at least should be) on by default now, don't use it
+    #define wxTE_AUTO_SCROLL    0
+#endif // WXWIN_COMPATIBILITY_2_8
+
 // force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for
 // wxTE_RICH controls - can be used together with or instead of wxTE_RICH
 #define wxTE_RICH2          0x8000
@@ -157,102 +161,114 @@ enum wxTextAttrAlignment
 };
 
 // Flags to indicate which attributes are being applied
-
-#define wxTEXT_ATTR_TEXT_COLOUR             0x00000001
-#define wxTEXT_ATTR_BACKGROUND_COLOUR       0x00000002
-#define wxTEXT_ATTR_FONT_FACE               0x00000004
-#define wxTEXT_ATTR_FONT_SIZE               0x00000008
-#define wxTEXT_ATTR_FONT_WEIGHT             0x00000010
-#define wxTEXT_ATTR_FONT_ITALIC             0x00000020
-#define wxTEXT_ATTR_FONT_UNDERLINE          0x00000040
-#define wxTEXT_ATTR_FONT_ENCODING           0x02000000
-#define wxTEXT_ATTR_FONT \
-  ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \
-    wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING )
-#define wxTEXT_ATTR_ALIGNMENT               0x00000080
-#define wxTEXT_ATTR_LEFT_INDENT             0x00000100
-#define wxTEXT_ATTR_RIGHT_INDENT            0x00000200
-#define wxTEXT_ATTR_TABS                    0x00000400
-
-#define wxTEXT_ATTR_PARA_SPACING_AFTER      0x00000800
-#define wxTEXT_ATTR_PARA_SPACING_BEFORE     0x00001000
-#define wxTEXT_ATTR_LINE_SPACING            0x00002000
-#define wxTEXT_ATTR_CHARACTER_STYLE_NAME    0x00004000
-#define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME    0x00008000
-#define wxTEXT_ATTR_LIST_STYLE_NAME         0x00010000
-#define wxTEXT_ATTR_BULLET_STYLE            0x00020000
-#define wxTEXT_ATTR_BULLET_NUMBER           0x00040000
-#define wxTEXT_ATTR_BULLET_TEXT             0x00080000
-#define wxTEXT_ATTR_BULLET_NAME             0x00100000
-#define wxTEXT_ATTR_URL                     0x00200000
-#define wxTEXT_ATTR_PAGE_BREAK              0x00400000
-#define wxTEXT_ATTR_EFFECTS                 0x00800000
-#define wxTEXT_ATTR_OUTLINE_LEVEL           0x01000000
-
-/*!
- * Character and paragraph combined styles
- */
-
-#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL)
-
-#define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
-    wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
-    wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\
-    wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL)
-
-#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
+enum wxTextAttrFlags
+{
+    wxTEXT_ATTR_TEXT_COLOUR          = 0x00000001,
+    wxTEXT_ATTR_BACKGROUND_COLOUR    = 0x00000002,
+    wxTEXT_ATTR_FONT_FACE            = 0x00000004,
+    wxTEXT_ATTR_FONT_SIZE            = 0x00000008,
+    wxTEXT_ATTR_FONT_WEIGHT          = 0x00000010,
+    wxTEXT_ATTR_FONT_ITALIC          = 0x00000020,
+    wxTEXT_ATTR_FONT_UNDERLINE       = 0x00000040,
+    wxTEXT_ATTR_FONT_ENCODING        = 0x02000000,
+    wxTEXT_ATTR_FONT = \
+        ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \
+            wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING ),
+
+    wxTEXT_ATTR_ALIGNMENT            = 0x00000080,
+    wxTEXT_ATTR_LEFT_INDENT          = 0x00000100,
+    wxTEXT_ATTR_RIGHT_INDENT         = 0x00000200,
+    wxTEXT_ATTR_TABS                 = 0x00000400,
+
+    wxTEXT_ATTR_PARA_SPACING_AFTER   = 0x00000800,
+    wxTEXT_ATTR_PARA_SPACING_BEFORE  = 0x00001000,
+    wxTEXT_ATTR_LINE_SPACING         = 0x00002000,
+    wxTEXT_ATTR_CHARACTER_STYLE_NAME = 0x00004000,
+    wxTEXT_ATTR_PARAGRAPH_STYLE_NAME = 0x00008000,
+    wxTEXT_ATTR_LIST_STYLE_NAME      = 0x00010000,
+    wxTEXT_ATTR_BULLET_STYLE         = 0x00020000,
+    wxTEXT_ATTR_BULLET_NUMBER        = 0x00040000,
+    wxTEXT_ATTR_BULLET_TEXT          = 0x00080000,
+    wxTEXT_ATTR_BULLET_NAME          = 0x00100000,
+    wxTEXT_ATTR_URL                  = 0x00200000,
+    wxTEXT_ATTR_PAGE_BREAK           = 0x00400000,
+    wxTEXT_ATTR_EFFECTS              = 0x00800000,
+    wxTEXT_ATTR_OUTLINE_LEVEL        = 0x01000000,
+
+    /*!
+    * Character and paragraph combined styles
+    */
+
+    wxTEXT_ATTR_CHARACTER = \
+        (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS| \
+            wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL),
+
+    wxTEXT_ATTR_PARAGRAPH = \
+        (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
+            wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
+            wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\
+            wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL),
+
+    wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
+};
 
 /*!
  * Styles for wxTextAttr::SetBulletStyle
  */
-
-#define wxTEXT_ATTR_BULLET_STYLE_NONE               0x00000000
-#define wxTEXT_ATTR_BULLET_STYLE_ARABIC             0x00000001
-#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER      0x00000002
-#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER      0x00000004
-#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER        0x00000008
-#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER        0x00000010
-#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL             0x00000020
-#define wxTEXT_ATTR_BULLET_STYLE_BITMAP             0x00000040
-#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES        0x00000080
-#define wxTEXT_ATTR_BULLET_STYLE_PERIOD             0x00000100
-#define wxTEXT_ATTR_BULLET_STYLE_STANDARD           0x00000200
-#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS  0x00000400
-#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE            0x00000800
-
-#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT         0x00000000
-#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT        0x00001000
-#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE       0x00002000
+enum wxTextAttrBulletStyle
+{
+    wxTEXT_ATTR_BULLET_STYLE_NONE            = 0x00000000,
+    wxTEXT_ATTR_BULLET_STYLE_ARABIC          = 0x00000001,
+    wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER   = 0x00000002,
+    wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER   = 0x00000004,
+    wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER     = 0x00000008,
+    wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER     = 0x00000010,
+    wxTEXT_ATTR_BULLET_STYLE_SYMBOL          = 0x00000020,
+    wxTEXT_ATTR_BULLET_STYLE_BITMAP          = 0x00000040,
+    wxTEXT_ATTR_BULLET_STYLE_PARENTHESES     = 0x00000080,
+    wxTEXT_ATTR_BULLET_STYLE_PERIOD          = 0x00000100,
+    wxTEXT_ATTR_BULLET_STYLE_STANDARD        = 0x00000200,
+    wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS = 0x00000400,
+    wxTEXT_ATTR_BULLET_STYLE_OUTLINE         = 0x00000800,
+
+    wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT      = 0x00000000,
+    wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT     = 0x00001000,
+    wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE    = 0x00002000
+};
 
 /*!
  * Styles for wxTextAttr::SetTextEffects
  */
-
-#define wxTEXT_ATTR_EFFECT_NONE                     0x00000000
-#define wxTEXT_ATTR_EFFECT_CAPITALS                 0x00000001
-#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS           0x00000002
-#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH            0x00000004
-#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH     0x00000008
-#define wxTEXT_ATTR_EFFECT_SHADOW                   0x00000010
-#define wxTEXT_ATTR_EFFECT_EMBOSS                   0x00000020
-#define wxTEXT_ATTR_EFFECT_OUTLINE                  0x00000040
-#define wxTEXT_ATTR_EFFECT_ENGRAVE                  0x00000080
-#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT              0x00000100
-#define wxTEXT_ATTR_EFFECT_SUBSCRIPT                0x00000200
+enum wxTextAttrEffects
+{
+    wxTEXT_ATTR_EFFECT_NONE                  = 0x00000000,
+    wxTEXT_ATTR_EFFECT_CAPITALS              = 0x00000001,
+    wxTEXT_ATTR_EFFECT_SMALL_CAPITALS        = 0x00000002,
+    wxTEXT_ATTR_EFFECT_STRIKETHROUGH         = 0x00000004,
+    wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH  = 0x00000008,
+    wxTEXT_ATTR_EFFECT_SHADOW                = 0x00000010,
+    wxTEXT_ATTR_EFFECT_EMBOSS                = 0x00000020,
+    wxTEXT_ATTR_EFFECT_OUTLINE               = 0x00000040,
+    wxTEXT_ATTR_EFFECT_ENGRAVE               = 0x00000080,
+    wxTEXT_ATTR_EFFECT_SUPERSCRIPT           = 0x00000100,
+    wxTEXT_ATTR_EFFECT_SUBSCRIPT             = 0x00000200
+};
 
 /*!
  * Line spacing values
  */
-
-#define wxTEXT_ATTR_LINE_SPACING_NORMAL         10
-#define wxTEXT_ATTR_LINE_SPACING_HALF           15
-#define wxTEXT_ATTR_LINE_SPACING_TWICE          20
+enum wxTextAttrLineSpacing
+{
+    wxTEXT_ATTR_LINE_SPACING_NORMAL         = 10,
+    wxTEXT_ATTR_LINE_SPACING_HALF           = 15,
+    wxTEXT_ATTR_LINE_SPACING_TWICE          = 20
+};
 
 // ----------------------------------------------------------------------------
 // wxTextAttr: a structure containing the visual attributes of a text
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxTextAttr
+class WXDLLIMPEXP_CORE wxTextAttr
 {
 public:
     // ctors
@@ -341,6 +357,8 @@ public:
     const wxString& GetListStyleName() const { return m_listStyleName; }
     int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
     int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
+
+    // TODO: should return the relative wxTextAttr* enumeration values
     int GetLineSpacing() const { return m_lineSpacing; }
     int GetBulletStyle() const { return m_bulletStyle; }
     int GetBulletNumber() const { return m_bulletNumber; }
@@ -591,7 +609,7 @@ private:
 // wxTextCtrl: a single or multiple line text zone where user can edit text
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxTextCtrlBase : public wxControl,
+class WXDLLIMPEXP_CORE wxTextCtrlBase : public wxControl,
 #if wxHAS_TEXT_WINDOW_STREAM
                                    public wxSTD streambuf,
 #endif
@@ -615,9 +633,10 @@ public:
     wxTextCtrl& operator<<(const wxString& s);
     wxTextCtrl& operator<<(int i);
     wxTextCtrl& operator<<(long i);
-    wxTextCtrl& operator<<(float f);
+    wxTextCtrl& operator<<(float f) { return *this << double(f); }
     wxTextCtrl& operator<<(double d);
-    wxTextCtrl& operator<<(const wxChar c);
+    wxTextCtrl& operator<<(char c) { return *this << wxString(c); }
+    wxTextCtrl& operator<<(wchar_t c) { return *this << wxString(c); }
 
     // insert the character which would have resulted from this key event,
     // return true if anything has been inserted
@@ -687,7 +706,7 @@ protected:
 #elif defined(__WXGTK__)
     #include "wx/gtk1/textctrl.h"
 #elif defined(__WXMAC__)
-    #include "wx/mac/textctrl.h"
+    #include "wx/osx/textctrl.h"
 #elif defined(__WXCOCOA__)
     #include "wx/cocoa/textctrl.h"
 #elif defined(__WXPM__)
@@ -705,14 +724,19 @@ extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_ENTER;
 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_URL;
 extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TEXT_MAXLEN;
 
-class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent
+class WXDLLIMPEXP_CORE wxTextUrlEvent : public wxCommandEvent
 {
 public:
     wxTextUrlEvent(int winid, const wxMouseEvent& evtMouse,
                    long start, long end)
-        : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid)
-        , m_evtMouse(evtMouse), m_start(start), m_end(end)
+        : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid),
+          m_evtMouse(evtMouse), m_start(start), m_end(end)
         { }
+    wxTextUrlEvent(const wxTextUrlEvent& event)
+        : wxCommandEvent(event),
+          m_evtMouse(event.m_evtMouse),
+          m_start(event.m_start),
+          m_end(event.m_end) { }
 
     // get the mouse event which happend over the URL
     const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; }
@@ -723,6 +747,8 @@ public:
     // get the end of the URL
     long GetURLEnd() const { return m_end; }
 
+    virtual wxEvent *Clone() const { return new wxTextUrlEvent(*this); }
+
 protected:
     // the corresponding mouse event
     wxMouseEvent m_evtMouse;
@@ -732,7 +758,7 @@ protected:
          m_end;
 
 private:
-    DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent)
+    DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxTextUrlEvent)
 
 public:
     // for wxWin RTTI only, don't use
@@ -763,7 +789,7 @@ typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&);
 // C++ stream to the wxTextCtrl given to its ctor during its lifetime.
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxStreamToTextRedirector
+class WXDLLIMPEXP_CORE wxStreamToTextRedirector
 {
 private:
     void Init(wxTextCtrl *text)