X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4a65f2c80d04599738e4f3a527c4953ade08d48b..d66c3960d541cf9e3ba10519a49a9e34b4ddfc81:/contrib/src/stc/stc.cpp diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index d51b8d04a0..2f5ea9eae1 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -136,11 +136,27 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, const wxPoint& pos, const wxSize& size, long style, - const wxString& name) : - wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, - wxDefaultValidator, name) + const wxString& name) { + m_swx = NULL; + Create(parent, id, pos, size, style, name); +} + + +void wxStyledTextCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ +#ifdef __WXMAC__ + style |= wxVSCROLL | wxHSCROLL; +#endif + wxControl::Create(parent, id, pos, size, + style | wxWANTS_CHARS | wxCLIP_CHILDREN, + wxDefaultValidator, name); + #ifdef LINK_LEXERS Scintilla_LinkLexers(); #endif @@ -603,7 +619,7 @@ void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { SendMsg(2070, MAKELONG(key, modifiers), cmd); } -// When key+modifier combination km do nothing. +// When key+modifier combination km is pressed do nothing. void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { SendMsg(2071, MAKELONG(key, modifiers)); } @@ -634,6 +650,7 @@ void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { } // Set the set of characters making up words for when moving or selecting by word. +// First sets deaults like SetCharsDefault. void wxStyledTextCtrl::SetWordChars(const wxString& characters) { SendMsg(2077, 0, (long)(const char*)wx2stc(characters)); } @@ -1033,7 +1050,7 @@ int wxStyledTextCtrl::FindText(int minPos, int maxPos, int startPos, int endPos, wxDC* draw, - wxDC* target, // Why does it use two? Can they be the same? + wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; @@ -1289,7 +1306,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // Returns the length of the replacement text. int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { @@ -1298,7 +1315,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Replace the target text with the argument text after \d processing. -// Text is counted so it can contain nulls. +// Text is counted so it can contain NULs. // Looks for \d where d is between 1 and 9 and replaces these with the strings // matched in the last search operation which were surrounded by \( and \). // Returns the length of the replacement text including any change @@ -1310,7 +1327,7 @@ int wxStyledTextCtrl::GetTargetEnd() { } // Search for a counted string in the target and set the target to the found -// range. Text is counted so it can contain nulls. +// range. Text is counted so it can contain NULs. // Returns length of range or -1 for failure in which case target is not moved. int wxStyledTextCtrl::SearchInTarget(const wxString& text) { @@ -1517,7 +1534,7 @@ int wxStyledTextCtrl::GetScrollWidth() { } // Measure the pixel width of some text in a particular style. -// Nul terminated text argument. +// NUL terminated text argument. // Does not handle tab or control characters. int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { return SendMsg(2276, style, (long)(const char*)wx2stc(text)); @@ -1868,7 +1885,7 @@ int wxStyledTextCtrl::GetXOffset() { return SendMsg(2398, 0, 0); } -// Set the last x chosen value to be the caret x position +// Set the last x chosen value to be the caret x position. void wxStyledTextCtrl::ChooseCaretX() { SendMsg(2399, 0, 0); } @@ -1890,7 +1907,7 @@ void wxStyledTextCtrl::SetPrintWrapMode(int mode) { SendMsg(2406, mode, 0); } -// Is printing line wrapped. +// Is printing line wrapped? int wxStyledTextCtrl::GetPrintWrapMode() { return SendMsg(2407, 0, 0); } @@ -1910,6 +1927,11 @@ void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) { SendMsg(2412, underline, 0); } +// Limit hotspots to single line so hotspots on two lines don't merge. +void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) { + SendMsg(2421, singleLine, 0); +} + // Given a valid document position, return the previous position taking code // page into account. Returns 0 if passed 0. int wxStyledTextCtrl::PositionBefore(int pos) { @@ -1932,6 +1954,43 @@ void wxStyledTextCtrl::CopyText(int length, const wxString& text) { SendMsg(2420, length, (long)(const char*)wx2stc(text)); } +// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +// by lines (SC_SEL_LINES). +void wxStyledTextCtrl::SetSelectionMode(int mode) { + SendMsg(2422, mode, 0); +} + +// Get the mode of the current selection. +int wxStyledTextCtrl::GetSelectionMode() { + return SendMsg(2423, 0, 0); +} + +// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelStartPosition(int line) { + return SendMsg(2424, line, 0); +} + +// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line). +int wxStyledTextCtrl::GetLineSelEndPosition(int line) { + return SendMsg(2425, line, 0); +} + +// Set the set of characters making up whitespace for when moving or selecting by word. +// Should be called after SetWordChars. +void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) { + SendMsg(2443, 0, (long)(const char*)wx2stc(characters)); +} + +// Reset the set of characters for whitespace and word characters to the defaults. +void wxStyledTextCtrl::SetCharsDefault() { + SendMsg(2444, 0, 0); +} + +// Get currently selected item position in the auto-completion list +int wxStyledTextCtrl::AutoCompGetCurrent() { + return SendMsg(2445, 0, 0); +} + // Start notifying the container of all key presses and commands. void wxStyledTextCtrl::StartRecord() { SendMsg(3001, 0, 0); @@ -2131,20 +2190,16 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (file.IsOpened()) { wxString contents; -#if wxUSE_UNICODE - wxMemoryBuffer buffer; -#else - wxString buffer; -#endif off_t len = file.Length(); if (len > 0) { - void *bufptr = buffer.GetWriteBuf(len); - success = (file.Read(bufptr, len) == len); - buffer.UngetWriteBuf(len); -#if #wxUSE_UNICODE +#if wxUSE_UNICODE + wxMemoryBuffer buffer(len); + success = (file.Read(buffer.GetData(), len) == len); contents = wxString(buffer, *wxConvCurrent); #else + wxString buffer; + success = (file.Read(wxStringBuffer(buffer, len), len) == len); contents = buffer; #endif } @@ -2163,6 +2218,7 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) } +#if wxUSE_DRAG_AND_DROP wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { return m_swx->DoDragOver(x, y, def); } @@ -2171,6 +2227,7 @@ wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { return m_swx->DoDropText(x, y, data); } +#endif //---------------------------------------------------------------------- @@ -2199,8 +2256,10 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { } void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { - wxSize sz = GetClientSize(); - m_swx->DoSize(sz.x, sz.y); + if (m_swx) { + wxSize sz = GetClientSize(); + m_swx->DoSize(sz.x, sz.y); + } } void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { @@ -2320,6 +2379,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events