diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 19d551c7e5..fd255c2f16 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -3173,6 +3173,10 @@ public: // Get the weight of characters of a style. int StyleGetWeight(int style) const; + // Set the character set of the font in a style. + // Converts the Scintilla character set values to a wxFontEncoding. + void StyleSetCharacterSet(int style, int characterSet); + // Set a style to be a hotspot or not. void StyleSetHotSpot(int style, bool hotspot); @@ -3544,6 +3548,9 @@ public: // Draw the selection in normal style or with selection highlighted. void HideSelection(bool hide); + // Retrieve the point in the window where a position is displayed. + wxPoint PointFromPosition(int pos); + // Retrieve the line containing a position. int LineFromPosition(int pos) const; @@ -5042,10 +5049,6 @@ public: wxFontEncoding encoding=wxFONTENCODING_DEFAULT); - // Set the character set of the font in a style. Converts the Scintilla - // character set values to a wxFontEncoding. - void StyleSetCharacterSet(int style, int characterSet); - // Set the font encoding to be used by a style. void StyleSetFontEncoding(int style, wxFontEncoding encoding); @@ -5058,10 +5061,6 @@ public: void SetMargins(int left, int right); - // Retrieve the point in the window where a position is displayed. - wxPoint PointFromPosition(int pos); - - // Scroll enough to make the given line visible void ScrollToLine(int line); diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 38375b84c8..1a6a15182c 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -2767,6 +2767,20 @@ wxStyledTextCtrl is a 1 to 1 mapping of "raw" scintilla interface, whose documentation can be found in the Scintilla website (http://www.scintilla.org/). + + @section stc_index Index of the member groups + + Links for quick access to the various categories of wxStyledTextCtrl functions: + - @ref_member_group{ctor, Constructors and related methods} + - @ref_member_group{scintilla_functions, Scintilla methods} + - @ref_member_group{additional_methods, Additional wxStyledTextCtrl methods} + - @ref_member_group{raw_variants , Raw variants} + - @ref_member_group{text_entry, Text entry methods} + - @ref_member_group{text_area, Text area methods} + + + @section event_list Events + @beginEventEmissionTable{wxStyledTextEvent} @event{EVT_STC_AUTOCOMP_CANCELLED(id, fn)} Process a @c wxEVT_STC_AUTOCOMP_CANCELLED event. @@ -2854,6 +2868,11 @@ class wxStyledTextCtrl : public wxControl, public wxTextEntry { public: + // Ctor, etc + // ---------------------------------------------- + ///@member_group_name{ctor, Constructors and related methods} + //@{ + /** Ctor. */ @@ -2865,8 +2884,7 @@ public: Default ctor. */ wxStyledTextCtrl(); - - + /** Destructor. */ @@ -2880,6 +2898,13 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxSTCNameStr); + //@} + + + // Scintilla methods (generated by gen_iface.py) + // ---------------------------------------------- + ///@member_group_name{scintilla_functions, Scintilla methods} + //@{ // **** Generated methods {{{ @@ -3415,6 +3440,12 @@ public: */ int StyleGetWeight(int style) const; + /** + Set the character set of the font in a style. + Converts the Scintilla character set values to a wxFontEncoding. + */ + void StyleSetCharacterSet(int style, int characterSet); + /** Set a style to be a hotspot or not. */ @@ -4018,6 +4049,11 @@ public: */ void HideSelection(bool hide); + /** + Retrieve the point in the window where a position is displayed. + */ + wxPoint PointFromPosition(int pos); + /** Retrieve the line containing a position. */ @@ -6389,10 +6425,18 @@ public: //}}} + //@} - // **** Manually declared methods + // Manually declared methods + // ---------------------------------------------- + /** + @member_group_name{additional_methods, Additional wxStyledTextCtrl methods} + In addition to the standard Scintilla functions, wxStyledTextCtrl + includes the following functions to simplify some tasks. + */ + //@{ /** Returns the line number of the line with the caret. @@ -6414,21 +6458,17 @@ public: */ void StyleSetSpec(int styleNum, const wxString& spec); - /** Get the font of a style. */ wxFont StyleGetFont(int style); - /** Set style size, face, bold, italic, and underline attributes from a wxFont's attributes. */ void StyleSetFont(int styleNum, wxFont& font); - - /** Set all font style attributes at once. */ @@ -6438,61 +6478,41 @@ public: bool underline, wxFontEncoding encoding=wxFONTENCODING_DEFAULT); - - /** - Set the character set of the font in a style. Converts the Scintilla - character set values to a wxFontEncoding. - */ - void StyleSetCharacterSet(int style, int characterSet); - /** Set the font encoding to be used by a style. */ void StyleSetFontEncoding(int style, wxFontEncoding encoding); - /** Perform one of the operations defined by the wxSTC_CMD_* constants. */ void CmdKeyExecute(int cmd); - /** Set the left and right margin in the edit area, measured in pixels. */ void SetMargins(int left, int right); - - /** - Retrieve the point in the window where a position is displayed. - */ - wxPoint PointFromPosition(int pos); - - /** Scroll enough to make the given line visible */ void ScrollToLine(int line); - /** Scroll enough to make the given column visible */ void ScrollToColumn(int column); - /** - Send a message to Scintilla + Scintilla API call. */ wxIntPtr SendMsg(int msg, wxUIntPtr wp=0, wxIntPtr lp=0) const; - /** Set the vertical scrollbar to use instead of the ont that's built-in. */ void SetVScrollBar(wxScrollBar* bar); - /** Set the horizontal scrollbar to use instead of the ont that's built-in. */ @@ -6538,11 +6558,36 @@ public: */ bool DoDropText(long x, long y, const wxString& data); + /** + Specify whether anti-aliased fonts should be used. + + This will have no effect on some platforms, but on some (wxMac for + example) can greatly improve performance. + */ + void SetUseAntiAliasing(bool useAA); + + /** + Returns the current UseAntiAliasing setting. + */ + bool GetUseAntiAliasing(); + /** Clear annotations from the given line. */ void AnnotationClearLine(int line); + //@} + + + // Raw versions + // ---------------------------------------------- + /** + @member_group_name{raw_variants , Raw variants } + + These methods allow data to be sent to or received from the control + using character buffers instead of using a wxString. + */ + //@{ /** Add text to the document at current position. @@ -6572,6 +6617,8 @@ public: /** Retrieve the target text. + + @since 3.1.1 */ wxCharBuffer GetTargetTextRaw(); @@ -6595,53 +6642,373 @@ public: */ void AppendTextRaw(const char* text, int length=-1); - - static wxVersionInfo GetLibraryVersionInfo(); - + //@} // wxTextEntryBase pure virtual methods // ---------------------------------------------- + ///@member_group_name{text_entry, Text entry methods} + //@{ + /** + Writes the text into the text control at the current insertion position. + + @param text + Text to write to the text control. + + @remarks + Newlines in the text string are the only control characters + allowed, and they will cause appropriate line breaks. + See operator<<() and AppendText() for more convenient ways of + writing to the window. + After the write operation, the insertion point will be at the end + of the inserted text, so subsequent write operations will be appended. + To append text after the user may have interacted with the control, + call wxTextCtrl::SetInsertionPointEnd() before writing. + */ virtual void WriteText(const wxString& text); + + /** + Removes the text starting at the first given position up to + (but not including) the character at the last position. + + This function puts the current insertion point position at @a to as a + side effect. + + @param from + The first position. + @param to + The last position. + */ virtual void Remove(long from, long to); + + /** + Replaces the text starting at the first position up to + (but not including) the character at the last position with the given text. + + This function puts the current insertion point position at @a to as a + side effect. + + @param from + The first position. + @param to + The last position. + @param value + The value to replace the existing text with. + */ virtual void Replace(long from, long to, const wxString& text); + /** + Sets the insertion point at the given position. + + @param pos + Position to set, in the range from 0 to GetLastPosition() inclusive. + */ virtual void SetInsertionPoint(long pos); + + /** + Returns the insertion point, or cursor, position. + + This is defined as the zero based index of the character position to + the right of the insertion point. For example, if the insertion point + is at the end of the single-line text control, it is equal to + GetLastPosition(). + + Notice that insertion position is, in general, different from the index + of the character the cursor position at in the string returned by + GetValue(). While this is always the case for the single line controls, + multi-line controls can use two characters @c "\\r\\n" as line + separator (this is notably the case under MSW) meaning that indices in + the control and its string value are offset by 1 for every line. + + Hence to correctly get the character at the current cursor position, + taking into account that there can be none if the cursor is at the end + of the string, you could do the following: + + @code + wxString GetCurrentChar(wxTextCtrl *tc) + { + long pos = tc->GetInsertionPoint(); + if ( pos == tc->GetLastPosition() ) + return wxString(); + + return tc->GetRange(pos, pos + 1); + } + @endcode + */ virtual long GetInsertionPoint() const; + + /** + Returns the zero based index of the last position in the text control, + which is equal to the number of characters in the control. + */ virtual long GetLastPosition() const; + /** + Selects the text starting at the first position up to (but not + including) the character at the last position. + + If both parameters are equal to -1 all text in the control is selected. + + Notice that the insertion point will be moved to @a from by this + function. + + @param from + The first position. + @param to + The last position. + + @see SelectAll() + */ virtual void SetSelection(long from, long to); + + /** + Deselects selected text in the control. + + @since 2.9.5 + */ virtual void SelectNone(); + + /** + Gets the current selection span. + + If the returned values are equal, there was no selection. Please note + that the indices returned may be used with the other wxTextCtrl methods + but don't necessarily represent the correct indices into the string + returned by GetValue() for multiline controls under Windows (at least,) + you should use GetStringSelection() to get the selected text. + + @param from + The returned first position. + @param to + The returned last position. + + @beginWxPerlOnly + In wxPerl this method takes no parameters and returns a + 2-element list (from, to). + @endWxPerlOnly + */ virtual void GetSelection(long *from, long *to) const; + /** + Returns @true if the controls contents may be edited by user (note that + it always can be changed by the program). + + In other words, this functions returns @true if the control hasn't been + put in read-only mode by a previous call to SetEditable(). + */ virtual bool IsEditable() const; + + /** + Makes the text item editable or read-only, overriding the + @b wxTE_READONLY flag. + + @param editable + If @true, the control is editable. If @false, the control is + read-only. + + @see IsEditable() + */ virtual void SetEditable(bool editable); + //@} + + // wxTextAreaBase pure virtual methods // --------------------------------------------- + ///@member_group_name{text_area, Text area methods} + //@{ + /** + Gets the length of the specified line, not including any trailing + newline character(s). + + @param lineNo + Line number (starting from zero). + + @return + The length of the line, or -1 if @a lineNo was invalid. + */ virtual int GetLineLength(long n) const; + + /** + Returns the contents of a given line in the text control, not including + any trailing newline character(s). + + @param lineNo + The line number, starting from zero. + + @return + The contents of the line. + */ virtual wxString GetLineText(long n) const; + + /** + Returns the number of lines in the text control buffer. + + The returned number is the number of logical lines, i.e. just the count + of the number of newline characters in the control + 1, for wxGTK and + wxOSX/Cocoa ports while it is the number of physical lines, i.e. the + count of lines actually shown in the control, in wxMSW. + Because of this discrepancy, it is not recommended to use this function. + + @remarks + Note that even empty text controls have one line (where the + insertion point is), so GetNumberOfLines() never returns 0. + */ virtual int GetNumberOfLines() const; + /** + Returns @true if the text has been modified by user. + + Note that calling SetValue() doesn't make the control modified. + + @see MarkDirty() + */ virtual bool IsModified() const; + + /** + Mark text as modified (dirty). + + @see IsModified() + */ virtual void MarkDirty(); + + /** + Resets the internal modified flag as if the current changes had been + saved. + */ virtual void DiscardEdits(); + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool SetStyle(long start, long end, const wxTextAttr& style); + + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool GetStyle(long position, wxTextAttr& style); + + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool SetDefaultStyle(const wxTextAttr& style); - + + /** + Converts the given zero based column and line number to a position. + + @param x + The column number. + @param y + The line number. + + @return + The position value, or -1 if x or y was invalid. + */ virtual long XYToPosition(long x, long y) const; + + /** + Converts given position to a zero-based column, line number pair. + + @param pos + Position. + @param x + Receives zero based column number. + @param y + Receives zero based line number. + + @return + @true on success, @false on failure (most likely due to a too large + position parameter). + + @beginWxPerlOnly + In wxPerl this function takes only the @a pos argument and + returns a 2-element list (x, y). + @endWxPerlOnly + + @see XYToPosition() + */ virtual bool PositionToXY(long pos, long *x, long *y) const; - + + /** + Makes the line containing the given position visible. + + @param pos + The position that should be visible. + */ virtual void ShowPosition(long pos); + /** + Finds the position of the character at the specified point. + + If the return code is not @c wxTE_HT_UNKNOWN the row and column of the + character closest to this position are returned, otherwise the output + parameters are not modified. + + Please note that this function is currently only implemented in wxUniv, + wxMSW and wxGTK2 ports and always returns @c wxTE_HT_UNKNOWN in the + other ports. + + @beginWxPerlOnly + In wxPerl this function takes only the @a pt argument and + returns a 3-element list (result, col, row). + @endWxPerlOnly + + @param pt + The position of the point to check, in window device coordinates. + @param pos + Receives the position of the character at the given position. May + be @NULL. + + @see PositionToXY(), XYToPosition() + */ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; + + /** + Finds the row and column of the character at the specified point. + + If the return code is not @c wxTE_HT_UNKNOWN the row and column of the + character closest to this position are returned, otherwise the output + parameters are not modified. + + Please note that this function is currently only implemented in wxUniv, + wxMSW and wxGTK2 ports and always returns @c wxTE_HT_UNKNOWN in the + other ports. + + @beginWxPerlOnly + In wxPerl this function takes only the @a pt argument and + returns a 3-element list (result, col, row). + @endWxPerlOnly + + @param pt + The position of the point to check, in window device coordinates. + @param col + Receives the column of the character at the given position. May be + @NULL. + @param row + Receives the row of the character at the given position. May be + @NULL. + + @see PositionToXY(), XYToPosition() + */ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const; + //@} + + + // VersionInfo + // --------------------------------------------- + + /** + Returns the version of the Scintilla library used by this control. + */ + static wxVersionInfo GetLibraryVersionInfo(); + }; //---------------------------------------------------------------------- @@ -7673,3 +8040,5 @@ const wxEventType wxEVT_STC_AUTOCOMP_CHAR_DELETED; const wxEventType wxEVT_STC_HOTSPOT_RELEASE_CLICK; const wxEventType wxEVT_STC_CLIPBOARD_COPY; const wxEventType wxEVT_STC_CLIPBOARD_PASTE; +const wxEventType wxEVT_STC_AUTOCOMP_COMPLETED; +const wxEventType wxEVT_STC_MARGIN_RIGHT_CLICK; diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 270d6f6d5a..9e7a6b9c49 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -331,7 +331,104 @@ methodOverrideMap = { return stc2wx(buf);''', ('Get the font facename of a style',)), 'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0), - 'StyleSetCharacterSet' : (None, 0, 0, 0), + + 'StyleSetCharacterSet' : (0, 0, + '''void %s(int style, int characterSet) { + wxFontEncoding encoding; + + // Translate the Scintilla characterSet to a wxFontEncoding + switch (characterSet) { + default: + case wxSTC_CHARSET_ANSI: + case wxSTC_CHARSET_DEFAULT: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_BALTIC: + encoding = wxFONTENCODING_ISO8859_13; + break; + + case wxSTC_CHARSET_CHINESEBIG5: + encoding = wxFONTENCODING_CP950; + break; + + case wxSTC_CHARSET_EASTEUROPE: + encoding = wxFONTENCODING_ISO8859_2; + break; + + case wxSTC_CHARSET_GB2312: + encoding = wxFONTENCODING_CP936; + break; + + case wxSTC_CHARSET_GREEK: + encoding = wxFONTENCODING_ISO8859_7; + break; + + case wxSTC_CHARSET_HANGUL: + encoding = wxFONTENCODING_CP949; + break; + + case wxSTC_CHARSET_MAC: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_OEM: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_RUSSIAN: + encoding = wxFONTENCODING_KOI8; + break; + + case wxSTC_CHARSET_SHIFTJIS: + encoding = wxFONTENCODING_CP932; + break; + + case wxSTC_CHARSET_SYMBOL: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_TURKISH: + encoding = wxFONTENCODING_ISO8859_9; + break; + + case wxSTC_CHARSET_JOHAB: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_HEBREW: + encoding = wxFONTENCODING_ISO8859_8; + break; + + case wxSTC_CHARSET_ARABIC: + encoding = wxFONTENCODING_ISO8859_6; + break; + + case wxSTC_CHARSET_VIETNAMESE: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_THAI: + encoding = wxFONTENCODING_ISO8859_11; + break; + + case wxSTC_CHARSET_CYRILLIC: + encoding = wxFONTENCODING_ISO8859_5; + break; + + case wxSTC_CHARSET_8859_15: + encoding = wxFONTENCODING_ISO8859_15; + break; + } + + // We just have Scintilla track the wxFontEncoding for us. It gets used + // in Font::Create in PlatWX.cpp. We add one to the value so that the + // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when + // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back + // to wxFONENCODING_DEFAULT in Font::Create. + SendMsg(%s, style, encoding+1);''', + ('Set the character set of the font in a style.', + 'Converts the Scintilla character set values to a wxFontEncoding.'),), 'AssignCmdKey' : ('CmdKeyAssign', @@ -578,7 +675,15 @@ methodOverrideMap = { ('Retrieve a range of text.',)), - 'PointXFromPosition' : (None, 0, 0, 0), + 'PointXFromPosition' : + ('PointFromPosition', + 'wxPoint %s(int pos);', + '''wxPoint %s(int pos) { + int x = SendMsg(%s, 0, pos); + int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); + return wxPoint(x, y);''', + ('Retrieve the point in the window where a position is displayed.',)), + 'PointYFromPosition' : (None, 0, 0, 0), 'ScrollCaret' : ('EnsureCaretVisible', 0, 0, 0), diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 16b84a7b77..fad8f97326 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -957,6 +957,104 @@ int wxStyledTextCtrl::StyleGetWeight(int style) const return SendMsg(SCI_STYLEGETWEIGHT, style, 0); } +// Set the character set of the font in a style. +// Converts the Scintilla character set values to a wxFontEncoding. +void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) { + wxFontEncoding encoding; + + // Translate the Scintilla characterSet to a wxFontEncoding + switch (characterSet) { + default: + case wxSTC_CHARSET_ANSI: + case wxSTC_CHARSET_DEFAULT: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_BALTIC: + encoding = wxFONTENCODING_ISO8859_13; + break; + + case wxSTC_CHARSET_CHINESEBIG5: + encoding = wxFONTENCODING_CP950; + break; + + case wxSTC_CHARSET_EASTEUROPE: + encoding = wxFONTENCODING_ISO8859_2; + break; + + case wxSTC_CHARSET_GB2312: + encoding = wxFONTENCODING_CP936; + break; + + case wxSTC_CHARSET_GREEK: + encoding = wxFONTENCODING_ISO8859_7; + break; + + case wxSTC_CHARSET_HANGUL: + encoding = wxFONTENCODING_CP949; + break; + + case wxSTC_CHARSET_MAC: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_OEM: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_RUSSIAN: + encoding = wxFONTENCODING_KOI8; + break; + + case wxSTC_CHARSET_SHIFTJIS: + encoding = wxFONTENCODING_CP932; + break; + + case wxSTC_CHARSET_SYMBOL: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_TURKISH: + encoding = wxFONTENCODING_ISO8859_9; + break; + + case wxSTC_CHARSET_JOHAB: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_HEBREW: + encoding = wxFONTENCODING_ISO8859_8; + break; + + case wxSTC_CHARSET_ARABIC: + encoding = wxFONTENCODING_ISO8859_6; + break; + + case wxSTC_CHARSET_VIETNAMESE: + encoding = wxFONTENCODING_DEFAULT; + break; + + case wxSTC_CHARSET_THAI: + encoding = wxFONTENCODING_ISO8859_11; + break; + + case wxSTC_CHARSET_CYRILLIC: + encoding = wxFONTENCODING_ISO8859_5; + break; + + case wxSTC_CHARSET_8859_15: + encoding = wxFONTENCODING_ISO8859_15; + break; + } + + // We just have Scintilla track the wxFontEncoding for us. It gets used + // in Font::Create in PlatWX.cpp. We add one to the value so that the + // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when + // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back + // to wxFONENCODING_DEFAULT in Font::Create. + SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); +} + // Set a style to be a hotspot or not. void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) { @@ -1751,6 +1849,13 @@ void wxStyledTextCtrl::HideSelection(bool hide) SendMsg(SCI_HIDESELECTION, hide, 0); } +// Retrieve the point in the window where a position is displayed. +wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { + int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); + int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); + return wxPoint(x, y); +} + // Retrieve the line containing a position. int wxStyledTextCtrl::LineFromPosition(int pos) const { @@ -4813,106 +4918,6 @@ void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, } -// Set the character set of the font in a style. Converts the Scintilla -// character set values to a wxFontEncoding. -void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) -{ - wxFontEncoding encoding; - - // Translate the Scintilla characterSet to a wxFontEncoding - switch (characterSet) { - default: - case wxSTC_CHARSET_ANSI: - case wxSTC_CHARSET_DEFAULT: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_BALTIC: - encoding = wxFONTENCODING_ISO8859_13; - break; - - case wxSTC_CHARSET_CHINESEBIG5: - encoding = wxFONTENCODING_CP950; - break; - - case wxSTC_CHARSET_EASTEUROPE: - encoding = wxFONTENCODING_ISO8859_2; - break; - - case wxSTC_CHARSET_GB2312: - encoding = wxFONTENCODING_CP936; - break; - - case wxSTC_CHARSET_GREEK: - encoding = wxFONTENCODING_ISO8859_7; - break; - - case wxSTC_CHARSET_HANGUL: - encoding = wxFONTENCODING_CP949; - break; - - case wxSTC_CHARSET_MAC: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_OEM: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_RUSSIAN: - encoding = wxFONTENCODING_KOI8; - break; - - case wxSTC_CHARSET_SHIFTJIS: - encoding = wxFONTENCODING_CP932; - break; - - case wxSTC_CHARSET_SYMBOL: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_TURKISH: - encoding = wxFONTENCODING_ISO8859_9; - break; - - case wxSTC_CHARSET_JOHAB: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_HEBREW: - encoding = wxFONTENCODING_ISO8859_8; - break; - - case wxSTC_CHARSET_ARABIC: - encoding = wxFONTENCODING_ISO8859_6; - break; - - case wxSTC_CHARSET_VIETNAMESE: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_THAI: - encoding = wxFONTENCODING_ISO8859_11; - break; - - case wxSTC_CHARSET_CYRILLIC: - encoding = wxFONTENCODING_ISO8859_5; - break; - - case wxSTC_CHARSET_8859_15: - encoding = wxFONTENCODING_ISO8859_15;; - break; - } - - // We just have Scintilla track the wxFontEncoding for us. It gets used - // in Font::Create in PlatWX.cpp. We add one to the value so that the - // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when - // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back - // to wxFONENCODING_DEFAULT in Font::Create. - SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); -} - - // Set the font encoding to be used by a style. void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) { @@ -4933,13 +4938,6 @@ void wxStyledTextCtrl::SetMargins(int left, int right) { } -// Retrieve the point in the window where a position is displayed. -wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { - int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); - int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); - return wxPoint(x, y); -} - // Scroll enough to make the given line visible void wxStyledTextCtrl::ScrollToLine(int line) { m_swx->DoScrollToLine(line); diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index d1413d1f2a..9b56e3ae67 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -385,106 +385,6 @@ void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, } -// Set the character set of the font in a style. Converts the Scintilla -// character set values to a wxFontEncoding. -void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) -{ - wxFontEncoding encoding; - - // Translate the Scintilla characterSet to a wxFontEncoding - switch (characterSet) { - default: - case wxSTC_CHARSET_ANSI: - case wxSTC_CHARSET_DEFAULT: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_BALTIC: - encoding = wxFONTENCODING_ISO8859_13; - break; - - case wxSTC_CHARSET_CHINESEBIG5: - encoding = wxFONTENCODING_CP950; - break; - - case wxSTC_CHARSET_EASTEUROPE: - encoding = wxFONTENCODING_ISO8859_2; - break; - - case wxSTC_CHARSET_GB2312: - encoding = wxFONTENCODING_CP936; - break; - - case wxSTC_CHARSET_GREEK: - encoding = wxFONTENCODING_ISO8859_7; - break; - - case wxSTC_CHARSET_HANGUL: - encoding = wxFONTENCODING_CP949; - break; - - case wxSTC_CHARSET_MAC: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_OEM: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_RUSSIAN: - encoding = wxFONTENCODING_KOI8; - break; - - case wxSTC_CHARSET_SHIFTJIS: - encoding = wxFONTENCODING_CP932; - break; - - case wxSTC_CHARSET_SYMBOL: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_TURKISH: - encoding = wxFONTENCODING_ISO8859_9; - break; - - case wxSTC_CHARSET_JOHAB: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_HEBREW: - encoding = wxFONTENCODING_ISO8859_8; - break; - - case wxSTC_CHARSET_ARABIC: - encoding = wxFONTENCODING_ISO8859_6; - break; - - case wxSTC_CHARSET_VIETNAMESE: - encoding = wxFONTENCODING_DEFAULT; - break; - - case wxSTC_CHARSET_THAI: - encoding = wxFONTENCODING_ISO8859_11; - break; - - case wxSTC_CHARSET_CYRILLIC: - encoding = wxFONTENCODING_ISO8859_5; - break; - - case wxSTC_CHARSET_8859_15: - encoding = wxFONTENCODING_ISO8859_15;; - break; - } - - // We just have Scintilla track the wxFontEncoding for us. It gets used - // in Font::Create in PlatWX.cpp. We add one to the value so that the - // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when - // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back - // to wxFONENCODING_DEFAULT in Font::Create. - SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); -} - - // Set the font encoding to be used by a style. void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) { @@ -505,13 +405,6 @@ void wxStyledTextCtrl::SetMargins(int left, int right) { } -// Retrieve the point in the window where a position is displayed. -wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { - int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); - int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); - return wxPoint(x, y); -} - // Scroll enough to make the given line visible void wxStyledTextCtrl::ScrollToLine(int line) { m_swx->DoScrollToLine(line); diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 016a621709..fba5e12247 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -164,10 +164,6 @@ public: wxFontEncoding encoding=wxFONTENCODING_DEFAULT); - // Set the character set of the font in a style. Converts the Scintilla - // character set values to a wxFontEncoding. - void StyleSetCharacterSet(int style, int characterSet); - // Set the font encoding to be used by a style. void StyleSetFontEncoding(int style, wxFontEncoding encoding); @@ -180,10 +176,6 @@ public: void SetMargins(int left, int right); - // Retrieve the point in the window where a position is displayed. - wxPoint PointFromPosition(int pos); - - // Scroll enough to make the given line visible void ScrollToLine(int line); diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index cb0ee295ed..74dd428964 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -45,6 +45,20 @@ wxStyledTextCtrl is a 1 to 1 mapping of "raw" scintilla interface, whose documentation can be found in the Scintilla website (http://www.scintilla.org/). + + @section stc_index Index of the member groups + + Links for quick access to the various categories of wxStyledTextCtrl functions: + - @ref_member_group{ctor, Constructors and related methods} + - @ref_member_group{scintilla_functions, Scintilla methods} + - @ref_member_group{additional_methods, Additional wxStyledTextCtrl methods} + - @ref_member_group{raw_variants , Raw variants} + - @ref_member_group{text_entry, Text entry methods} + - @ref_member_group{text_area, Text area methods} + + + @section event_list Events + @beginEventEmissionTable{wxStyledTextEvent} @event{EVT_STC_AUTOCOMP_CANCELLED(id, fn)} Process a @c wxEVT_STC_AUTOCOMP_CANCELLED event. @@ -132,6 +146,11 @@ class wxStyledTextCtrl : public wxControl, public wxTextEntry { public: + // Ctor, etc + // ---------------------------------------------- + ///@member_group_name{ctor, Constructors and related methods} + //@{ + /** Ctor. */ @@ -143,8 +162,7 @@ public: Default ctor. */ wxStyledTextCtrl(); - - + /** Destructor. */ @@ -158,6 +176,13 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxSTCNameStr); + //@} + + + // Scintilla methods (generated by gen_iface.py) + // ---------------------------------------------- + ///@member_group_name{scintilla_functions, Scintilla methods} + //@{ // **** Generated methods {{{ @@ -165,10 +190,18 @@ public: //}}} + //@} - // **** Manually declared methods + // Manually declared methods + // ---------------------------------------------- + /** + @member_group_name{additional_methods, Additional wxStyledTextCtrl methods} + In addition to the standard Scintilla functions, wxStyledTextCtrl + includes the following functions to simplify some tasks. + */ + //@{ /** Returns the line number of the line with the caret. @@ -190,21 +223,17 @@ public: */ void StyleSetSpec(int styleNum, const wxString& spec); - /** Get the font of a style. */ wxFont StyleGetFont(int style); - /** Set style size, face, bold, italic, and underline attributes from a wxFont's attributes. */ void StyleSetFont(int styleNum, wxFont& font); - - /** Set all font style attributes at once. */ @@ -214,61 +243,41 @@ public: bool underline, wxFontEncoding encoding=wxFONTENCODING_DEFAULT); - - /** - Set the character set of the font in a style. Converts the Scintilla - character set values to a wxFontEncoding. - */ - void StyleSetCharacterSet(int style, int characterSet); - /** Set the font encoding to be used by a style. */ void StyleSetFontEncoding(int style, wxFontEncoding encoding); - /** Perform one of the operations defined by the wxSTC_CMD_* constants. */ void CmdKeyExecute(int cmd); - /** Set the left and right margin in the edit area, measured in pixels. */ void SetMargins(int left, int right); - - /** - Retrieve the point in the window where a position is displayed. - */ - wxPoint PointFromPosition(int pos); - - /** Scroll enough to make the given line visible */ void ScrollToLine(int line); - /** Scroll enough to make the given column visible */ void ScrollToColumn(int column); - /** - Send a message to Scintilla + Scintilla API call. */ wxIntPtr SendMsg(int msg, wxUIntPtr wp=0, wxIntPtr lp=0) const; - /** Set the vertical scrollbar to use instead of the ont that's built-in. */ void SetVScrollBar(wxScrollBar* bar); - /** Set the horizontal scrollbar to use instead of the ont that's built-in. */ @@ -314,11 +323,36 @@ public: */ bool DoDropText(long x, long y, const wxString& data); + /** + Specify whether anti-aliased fonts should be used. + + This will have no effect on some platforms, but on some (wxMac for + example) can greatly improve performance. + */ + void SetUseAntiAliasing(bool useAA); + + /** + Returns the current UseAntiAliasing setting. + */ + bool GetUseAntiAliasing(); + /** Clear annotations from the given line. */ void AnnotationClearLine(int line); + //@} + + + // Raw versions + // ---------------------------------------------- + /** + @member_group_name{raw_variants , Raw variants } + + These methods allow data to be sent to or received from the control + using character buffers instead of using a wxString. + */ + //@{ /** Add text to the document at current position. @@ -348,6 +382,8 @@ public: /** Retrieve the target text. + + @since 3.1.1 */ wxCharBuffer GetTargetTextRaw(); @@ -371,53 +407,373 @@ public: */ void AppendTextRaw(const char* text, int length=-1); - - static wxVersionInfo GetLibraryVersionInfo(); - + //@} // wxTextEntryBase pure virtual methods // ---------------------------------------------- + ///@member_group_name{text_entry, Text entry methods} + //@{ + /** + Writes the text into the text control at the current insertion position. + + @param text + Text to write to the text control. + + @remarks + Newlines in the text string are the only control characters + allowed, and they will cause appropriate line breaks. + See operator<<() and AppendText() for more convenient ways of + writing to the window. + After the write operation, the insertion point will be at the end + of the inserted text, so subsequent write operations will be appended. + To append text after the user may have interacted with the control, + call wxTextCtrl::SetInsertionPointEnd() before writing. + */ virtual void WriteText(const wxString& text); + + /** + Removes the text starting at the first given position up to + (but not including) the character at the last position. + + This function puts the current insertion point position at @a to as a + side effect. + + @param from + The first position. + @param to + The last position. + */ virtual void Remove(long from, long to); + + /** + Replaces the text starting at the first position up to + (but not including) the character at the last position with the given text. + + This function puts the current insertion point position at @a to as a + side effect. + + @param from + The first position. + @param to + The last position. + @param value + The value to replace the existing text with. + */ virtual void Replace(long from, long to, const wxString& text); + /** + Sets the insertion point at the given position. + + @param pos + Position to set, in the range from 0 to GetLastPosition() inclusive. + */ virtual void SetInsertionPoint(long pos); + + /** + Returns the insertion point, or cursor, position. + + This is defined as the zero based index of the character position to + the right of the insertion point. For example, if the insertion point + is at the end of the single-line text control, it is equal to + GetLastPosition(). + + Notice that insertion position is, in general, different from the index + of the character the cursor position at in the string returned by + GetValue(). While this is always the case for the single line controls, + multi-line controls can use two characters @c "\\r\\n" as line + separator (this is notably the case under MSW) meaning that indices in + the control and its string value are offset by 1 for every line. + + Hence to correctly get the character at the current cursor position, + taking into account that there can be none if the cursor is at the end + of the string, you could do the following: + + @code + wxString GetCurrentChar(wxTextCtrl *tc) + { + long pos = tc->GetInsertionPoint(); + if ( pos == tc->GetLastPosition() ) + return wxString(); + + return tc->GetRange(pos, pos + 1); + } + @endcode + */ virtual long GetInsertionPoint() const; + + /** + Returns the zero based index of the last position in the text control, + which is equal to the number of characters in the control. + */ virtual long GetLastPosition() const; + /** + Selects the text starting at the first position up to (but not + including) the character at the last position. + + If both parameters are equal to -1 all text in the control is selected. + + Notice that the insertion point will be moved to @a from by this + function. + + @param from + The first position. + @param to + The last position. + + @see SelectAll() + */ virtual void SetSelection(long from, long to); + + /** + Deselects selected text in the control. + + @since 2.9.5 + */ virtual void SelectNone(); + + /** + Gets the current selection span. + + If the returned values are equal, there was no selection. Please note + that the indices returned may be used with the other wxTextCtrl methods + but don't necessarily represent the correct indices into the string + returned by GetValue() for multiline controls under Windows (at least,) + you should use GetStringSelection() to get the selected text. + + @param from + The returned first position. + @param to + The returned last position. + + @beginWxPerlOnly + In wxPerl this method takes no parameters and returns a + 2-element list (from, to). + @endWxPerlOnly + */ virtual void GetSelection(long *from, long *to) const; + /** + Returns @true if the controls contents may be edited by user (note that + it always can be changed by the program). + + In other words, this functions returns @true if the control hasn't been + put in read-only mode by a previous call to SetEditable(). + */ virtual bool IsEditable() const; + + /** + Makes the text item editable or read-only, overriding the + @b wxTE_READONLY flag. + + @param editable + If @true, the control is editable. If @false, the control is + read-only. + + @see IsEditable() + */ virtual void SetEditable(bool editable); + //@} + + // wxTextAreaBase pure virtual methods // --------------------------------------------- + ///@member_group_name{text_area, Text area methods} + //@{ + /** + Gets the length of the specified line, not including any trailing + newline character(s). + + @param lineNo + Line number (starting from zero). + + @return + The length of the line, or -1 if @a lineNo was invalid. + */ virtual int GetLineLength(long n) const; + + /** + Returns the contents of a given line in the text control, not including + any trailing newline character(s). + + @param lineNo + The line number, starting from zero. + + @return + The contents of the line. + */ virtual wxString GetLineText(long n) const; + + /** + Returns the number of lines in the text control buffer. + + The returned number is the number of logical lines, i.e. just the count + of the number of newline characters in the control + 1, for wxGTK and + wxOSX/Cocoa ports while it is the number of physical lines, i.e. the + count of lines actually shown in the control, in wxMSW. + Because of this discrepancy, it is not recommended to use this function. + + @remarks + Note that even empty text controls have one line (where the + insertion point is), so GetNumberOfLines() never returns 0. + */ virtual int GetNumberOfLines() const; + /** + Returns @true if the text has been modified by user. + + Note that calling SetValue() doesn't make the control modified. + + @see MarkDirty() + */ virtual bool IsModified() const; + + /** + Mark text as modified (dirty). + + @see IsModified() + */ virtual void MarkDirty(); + + /** + Resets the internal modified flag as if the current changes had been + saved. + */ virtual void DiscardEdits(); + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool SetStyle(long start, long end, const wxTextAttr& style); + + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool GetStyle(long position, wxTextAttr& style); + + /** + This method is inherited from wxTextAreaBase but is not implemented + in wxStyledTextCtrl. + */ virtual bool SetDefaultStyle(const wxTextAttr& style); - + + /** + Converts the given zero based column and line number to a position. + + @param x + The column number. + @param y + The line number. + + @return + The position value, or -1 if x or y was invalid. + */ virtual long XYToPosition(long x, long y) const; + + /** + Converts given position to a zero-based column, line number pair. + + @param pos + Position. + @param x + Receives zero based column number. + @param y + Receives zero based line number. + + @return + @true on success, @false on failure (most likely due to a too large + position parameter). + + @beginWxPerlOnly + In wxPerl this function takes only the @a pos argument and + returns a 2-element list (x, y). + @endWxPerlOnly + + @see XYToPosition() + */ virtual bool PositionToXY(long pos, long *x, long *y) const; - + + /** + Makes the line containing the given position visible. + + @param pos + The position that should be visible. + */ virtual void ShowPosition(long pos); + /** + Finds the position of the character at the specified point. + + If the return code is not @c wxTE_HT_UNKNOWN the row and column of the + character closest to this position are returned, otherwise the output + parameters are not modified. + + Please note that this function is currently only implemented in wxUniv, + wxMSW and wxGTK2 ports and always returns @c wxTE_HT_UNKNOWN in the + other ports. + + @beginWxPerlOnly + In wxPerl this function takes only the @a pt argument and + returns a 3-element list (result, col, row). + @endWxPerlOnly + + @param pt + The position of the point to check, in window device coordinates. + @param pos + Receives the position of the character at the given position. May + be @NULL. + + @see PositionToXY(), XYToPosition() + */ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; + + /** + Finds the row and column of the character at the specified point. + + If the return code is not @c wxTE_HT_UNKNOWN the row and column of the + character closest to this position are returned, otherwise the output + parameters are not modified. + + Please note that this function is currently only implemented in wxUniv, + wxMSW and wxGTK2 ports and always returns @c wxTE_HT_UNKNOWN in the + other ports. + + @beginWxPerlOnly + In wxPerl this function takes only the @a pt argument and + returns a 3-element list (result, col, row). + @endWxPerlOnly + + @param pt + The position of the point to check, in window device coordinates. + @param col + Receives the column of the character at the given position. May be + @NULL. + @param row + Receives the row of the character at the given position. May be + @NULL. + + @see PositionToXY(), XYToPosition() + */ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord *col, wxTextCoord *row) const; + //@} + + + // VersionInfo + // --------------------------------------------- + + /** + Returns the version of the Scintilla library used by this control. + */ + static wxVersionInfo GetLibraryVersionInfo(); + }; //---------------------------------------------------------------------- @@ -1449,3 +1805,5 @@ const wxEventType wxEVT_STC_AUTOCOMP_CHAR_DELETED; const wxEventType wxEVT_STC_HOTSPOT_RELEASE_CLICK; const wxEventType wxEVT_STC_CLIPBOARD_COPY; const wxEventType wxEVT_STC_CLIPBOARD_PASTE; +const wxEventType wxEVT_STC_AUTOCOMP_COMPLETED; +const wxEventType wxEVT_STC_MARGIN_RIGHT_CLICK;