X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/64a3ee5fd2926c3e5341af2e4d62925fddb90c43..f409b413be8ed9d70f2cc239d86b69c106f9e86e:/contrib/src/stc/stc.cpp diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 2594133bfc..aa7bf8dd98 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -75,13 +75,19 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) EVT_CHAR (wxStyledTextCtrl::OnChar) + EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu) + EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox) END_EVENT_TABLE() + +IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) + //---------------------------------------------------------------------- // Constructor and Destructor @@ -111,7 +117,7 @@ wxStyledTextCtrl::~wxStyledTextCtrl() { //---------------------------------------------------------------------- -inline long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { +long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { return m_swx->WndProc(msg, wp, lp); } @@ -123,9 +129,10 @@ inline long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { wxString wxStyledTextCtrl::GetText() { wxString text; int len = GetTextLength(); - char* buff = text.GetWriteBuf(len); + char* buff = text.GetWriteBuf(len+1); SendMsg(WM_GETTEXT, len, (long)buff); + buff[len] = 0; text.UngetWriteBuf(); return text; } @@ -141,8 +148,9 @@ wxString wxStyledTextCtrl::GetLine(int line) { int len = GetLineLength(line); char* buff = text.GetWriteBuf(len+1); - *((WORD*)buff) = len+1; + *((WORD*)buff) = len; SendMsg(EM_GETLINE, line, (long)buff); + buff[len] = 0; text.UngetWriteBuf(); return text; } @@ -426,7 +434,7 @@ wxString wxStyledTextCtrl::GetCurrentLineText(int* linePos) { int len = GetLineLength(GetCurrentLine()); char* buff = text.GetWriteBuf(len+1); - int pos = SendMsg(SCI_GETCURLINE, len+1, (long)buff); + int pos = SendMsg(SCI_GETCURLINE, len, (long)buff); text.UngetWriteBuf(); if (linePos) @@ -452,7 +460,7 @@ int wxStyledTextCtrl::LineFromPoint(wxPoint pt) { wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { Point pt; - SendMsg(EM_POSFROMCHAR, pos, (long)&pt); + SendMsg(EM_POSFROMCHAR, (long)&pt, pos); return wxPoint(pt.x, pt.y); } @@ -533,6 +541,27 @@ int wxStyledTextCtrl::GetSelectionType() { } +int wxStyledTextCtrl::GetLinesOnScreen() { + return SendMsg(SCI_LINESONSCREEN); +} + + +bool wxStyledTextCtrl::IsSelectionRectangle() { + return SendMsg(SCI_SELECTIONISRECTANGLE) != 0; +} + + +void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool use) { + SendMsg(SCI_SETHSCROLLBAR, use); +} + + +bool wxStyledTextCtrl::GetUseHorizontalScrollBar() { + return SendMsg(SCI_GETHSCROLLBAR) != 0; +} + + + //---------------------------------------------------------------------- @@ -640,6 +669,16 @@ void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) { } +void wxStyledTextCtrl::SetLineState(int line, int value) { + SendMsg(SCI_SETLINESTATE, line, value); +} + + +int wxStyledTextCtrl::GetLineState(int line) { + return SendMsg(SCI_GETLINESTATE, line); +} + + //---------------------------------------------------------------------- // Style Definition @@ -688,6 +727,7 @@ void wxStyledTextCtrl::StyleResetDefault() { // face:[facename] sets the font face name to use // size:[num] sets the font size in points // eol turns on eol filling +// underline turns on underlining // void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { @@ -705,6 +745,9 @@ void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { else if (option == "italic") StyleSetItalic(styleNum, true); + else if (option == "underline") + StyleSetUnderline(styleNum, true); + else if (option == "eol") StyleSetEOLFilled(styleNum, true); @@ -741,18 +784,21 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { wxString faceName = font.GetFaceName(); bool bold = font.GetWeight() == wxBOLD; bool italic = font.GetStyle() != wxNORMAL; + bool under = font.GetUnderlined(); - StyleSetFontAttr(styleNum, size, faceName, bold, italic); + StyleSetFontAttr(styleNum, size, faceName, bold, italic, under); } void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, const wxString& faceName, - bool bold, bool italic) { + bool bold, bool italic, + bool underline) { StyleSetSize(styleNum, size); StyleSetFaceName(styleNum, faceName); StyleSetBold(styleNum, bold); StyleSetItalic(styleNum, italic); + StyleSetUnderline(styleNum, underline); } @@ -781,6 +827,11 @@ void wxStyledTextCtrl::StyleSetEOLFilled(int styleNum, bool fillEOL) { } +void wxStyledTextCtrl::StyleSetUnderline(int styleNum, bool underline) { + SendMsg(SCI_STYLESETUNDERLINE, styleNum, underline); +} + + //---------------------------------------------------------------------- // Margins in the edit area @@ -871,7 +922,7 @@ void wxStyledTextCtrl::SetSelectionBackground(const wxColour& colour) { void wxStyledTextCtrl::SetCaretForeground(const wxColour& colour) { - SendMsg(SCI_SETCARETFORE, 0, wxColourAsLong(colour)); + SendMsg(SCI_SETCARETFORE, wxColourAsLong(colour)); } @@ -900,11 +951,41 @@ void wxStyledTextCtrl::SetTabWidth(int numChars) { } +void wxStyledTextCtrl::SetIndent(int numChars) { + SendMsg(SCI_SETINDENT, numChars); +} + + +void wxStyledTextCtrl::SetUseTabs(bool usetabs) { + SendMsg(SCI_SETUSETABS, usetabs); +} + + +void wxStyledTextCtrl::SetLineIndentation(int line, int indentation) { + SendMsg(SCI_SETLINEINDENTATION, line, indentation); +} + + +int wxStyledTextCtrl:: GetLineIndentation(int line) { + return SendMsg(SCI_GETLINEINDENTATION, line); +} + + +int wxStyledTextCtrl::GetLineIndentationPos(int line) { + return SendMsg(SCI_GETLINEINDENTPOSITION, line); +} + + void wxStyledTextCtrl::SetWordChars(const wxString& wordChars) { SendMsg(SCI_SETTABWIDTH, 0, (long)wordChars.c_str()); } +void wxStyledTextCtrl::SetUsePop(bool usepopup) { + SendMsg(SCI_USEPOPUP, usepopup); +} + + //---------------------------------------------------------------------- // Brace highlighting @@ -1009,7 +1090,7 @@ int wxStyledTextCtrl::IndicatorGetStyle(int indicNum) { void wxStyledTextCtrl::IndicatorSetColour(int indicNum, const wxColour& colour) { - SendMsg(SCI_INDICSETSTYLE, indicNum, wxColourAsLong(colour)); + SendMsg(SCI_INDICSETFORE, indicNum, wxColourAsLong(colour)); } @@ -1048,6 +1129,21 @@ void wxStyledTextCtrl::AutoCompStopChars(const wxString& stopChars) { } +void wxStyledTextCtrl::AutoCompSetSeparator(char separator) { + SendMsg(SCI_AUTOCSETSEPARATOR, separator); +} + + +char wxStyledTextCtrl::AutoCompGetSeparator() { + return SendMsg(SCI_AUTOCGETSEPARATOR); +} + + +void wxStyledTextCtrl::AutoCompSelect(const wxString& stringtoselect) { + SendMsg(SCI_AUTOCSELECT, (long)stringtoselect.c_str()); +} + + //---------------------------------------------------------------------- // Call tips @@ -1171,8 +1267,8 @@ int wxStyledTextCtrl::GetFoldLevel(int line) { } -int wxStyledTextCtrl::GetLastChild(int line) { - return SendMsg(SCI_GETLASTCHILD, line); +int wxStyledTextCtrl::GetLastChild(int line, int level) { + return SendMsg(SCI_GETLASTCHILD, line, level); } @@ -1196,8 +1292,8 @@ bool wxStyledTextCtrl::GetLineVisible(int line) { } -void wxStyledTextCtrl::SetFoldExpanded(int line) { - SendMsg(SCI_SETFOLDEXPANDED, line); +void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { + SendMsg(SCI_SETFOLDEXPANDED, line, expanded); } @@ -1216,6 +1312,33 @@ void wxStyledTextCtrl::EnsureVisible(int line) { } +void wxStyledTextCtrl::SetFoldFlags(int flags) { + SendMsg(SCI_SETFOLDFLAGS, flags); +} + + +//---------------------------------------------------------------------- +// Zooming + +void wxStyledTextCtrl::ZoomIn() { + SendMsg(SCI_ZOOMIN); +} + + +void wxStyledTextCtrl::ZoomOut() { + SendMsg(SCI_ZOOMOUT); +} + + +void wxStyledTextCtrl::SetZoom(int zoom) { + SendMsg(SCI_SETZOOM, zoom); +} + + +int wxStyledTextCtrl::GetZoom() { + return SendMsg(SCI_GETZOOM); +} + //---------------------------------------------------------------------- // Long Lines @@ -1274,6 +1397,18 @@ void wxStyledTextCtrl::SetKeywords(int keywordSet, const wxString& keywordLi +//---------------------------------------------------------------------- +// Event mask for Modified Event + +void wxStyledTextCtrl::SetModEventMask(int mask) { + SendMsg(SCI_SETMODEVENTMASK, mask); +} + + +//int wxStyledTextCtrl::GetModEventMask() { +// return SendMsg(SCI_GETMODEVENTMASK); +//} + //---------------------------------------------------------------------- // Event handlers @@ -1320,20 +1455,23 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { } void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { - int processed = 0; long key = evt.KeyCode(); if ((key > WXK_ESCAPE) && (key != WXK_DELETE) && (key < 255) && !evt.ControlDown() && !evt.AltDown()) { m_swx->DoAddChar(key); - processed = true; } else { - key = toupper(key); - processed = m_swx->DoKeyDown(key, evt.ShiftDown(), - evt.ControlDown(), evt.AltDown()); + evt.Skip(); } +} + +void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { + long key = evt.KeyCode(); + key = toupper(key); + int processed = m_swx->DoKeyDown(key, evt.ShiftDown(), + evt.ControlDown(), evt.AltDown()); if (! processed) evt.Skip(); } @@ -1361,9 +1499,15 @@ void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { } +void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { + m_swx->DoOnListBox(); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events + void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); GetEventHandler()->ProcessEvent(evt); @@ -1417,7 +1561,8 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { evt.SetModifiers(scn.modifiers); if (eventType == wxEVT_STC_MODIFIED) { evt.SetModificationType(scn.modificationType); - evt.SetText(scn.text); + if (scn.text) + evt.SetText(wxString(scn.text, scn.length)); evt.SetLength(scn.length); evt.SetLinesAdded(scn.linesAdded); evt.SetLine(scn.line);