X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0c7dcb7fd20b96a9ef8059a45a4bafc146644b44..a204e0b5da552017a4932b77d0b13b7c9d0bc23b:/src/stc/stc.cpp?ds=sidebyside diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 35655c3411..003d4e4800 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -28,31 +28,39 @@ int wxForceScintillaLexers(void) { + extern LexerModule lmAda; + extern LexerModule lmAVE; + extern LexerModule lmConf; extern LexerModule lmCPP; + extern LexerModule lmNncrontab; + extern LexerModule lmEiffel; extern LexerModule lmHTML; - extern LexerModule lmXML; - extern LexerModule lmProps; - extern LexerModule lmErrorList; - extern LexerModule lmMake; - extern LexerModule lmBatch; + extern LexerModule lmLISP; + extern LexerModule lmLua; + extern LexerModule lmBatch; // In LexOthers.cxx + extern LexerModule lmPascal; extern LexerModule lmPerl; extern LexerModule lmPython; + extern LexerModule lmRuby; extern LexerModule lmSQL; extern LexerModule lmVB; - if ( - &lmCPP - && &lmHTML - && &lmXML - && &lmProps - && &lmErrorList - && &lmMake - && &lmBatch - && &lmPerl - && &lmPython - && &lmSQL - && &lmVB - ) + if ( &lmAda + && &lmAVE + && &lmConf + && &lmCPP + && &lmNncrontab + && &lmEiffel + && &lmHTML + && &lmLISP + && &lmLua + && &lmBatch + && &lmPascal + && &lmPerl + && &lmPython + && &lmRuby + && &lmSQL + && &lmVB ) { return 1; } @@ -66,26 +74,36 @@ int wxForceScintillaLexers(void) const wxChar* wxSTCNameStr = "stcwindow"; - DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) -DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) +DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ) +DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) -DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) +DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ) +DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) +DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) +DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) +DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) +#if wxUSE_DRAG_AND_DROP +DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) +DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) +DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) +#endif BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_PAINT (wxStyledTextCtrl::OnPaint) EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) + EVT_SCROLL (wxStyledTextCtrl::OnScroll) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) #ifdef __WXMSW__ @@ -94,7 +112,11 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) #endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) +#ifdef __WXGTK__ EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) +#else + EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) +#endif EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) EVT_CHAR (wxStyledTextCtrl::OnChar) EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) @@ -125,6 +147,9 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, { m_swx = new ScintillaWX(this); m_stopWatch.Start(); + m_lastKeyDownConsumed = FALSE; + m_vScrollBar = NULL; + m_hScrollBar = NULL; } @@ -253,8 +278,9 @@ void wxStyledTextCtrl::SetSavePoint() { wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { wxString text; int len = endPos - startPos; + if (!len) return ""; TextRange tr; - tr.lpstrText = text.GetWriteBuf(len*2+1); + tr.lpstrText = text.GetWriteBuf(len*2); tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; SendMsg(2015, 0, (long)&tr); @@ -298,6 +324,12 @@ int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) { return SendMsg(2022, pt.x, pt.y); } +// Find the position from a point within the window but return +// INVALID_POSITION if not close to text. +int wxStyledTextCtrl::PositionFromPointClose(int x, int y) { + return SendMsg(2023, x, y); +} + // Set caret to start of a line and ensure it is visible. void wxStyledTextCtrl::GotoLine(int line) { SendMsg(2024, line, 0); @@ -319,10 +351,15 @@ void wxStyledTextCtrl::SetAnchor(int posAnchor) { wxString wxStyledTextCtrl::GetCurLine(int* linePos) { wxString text; int len = LineLength(GetCurrentLine()); + if (!len) { + if (linePos) *linePos = 0; + return ""; + } + // Need an extra byte because SCI_GETCURLINE writes a null to the string char* buf = text.GetWriteBuf(len+1); - int pos = SendMsg(2027, len, (long)buf); - text.UngetWriteBuf(); + int pos = SendMsg(2027, len+1, (long)buf); + text.UngetWriteBuf(len); if (linePos) *linePos = pos; return text; @@ -333,9 +370,9 @@ int wxStyledTextCtrl::GetEndStyled() { return SendMsg(2028, 0, 0); } -// Convert all line endings in the document to use the current mode. -void wxStyledTextCtrl::ConvertEOLs() { - SendMsg(2029, 0, 0); +// Convert all line endings in the document to one mode. +void wxStyledTextCtrl::ConvertEOLs(int eolMode) { + SendMsg(2029, eolMode, 0); } // Retrieve the current end of line mode - one of CRLF, CR, or LF. @@ -532,6 +569,11 @@ void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) { SendMsg(2059, style, underline); } +// Set a style to be mixed case, or to force upper or lower case. +void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) { + SendMsg(2060, style, caseForce); +} + // Set the foreground colour of the selection and whether to use this setting. void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { SendMsg(2067, useSetting, wxColourAsLong(fore)); @@ -647,6 +689,27 @@ int wxStyledTextCtrl::GetMaxLineState() { return SendMsg(2094, 0, 0); } +// Is the background of the line containing the caret in a different colour? +bool wxStyledTextCtrl::GetCaretLineVisible() { + return SendMsg(2095, 0, 0) != 0; +} + +// Display the background of the line containing the caret in a different colour. +void wxStyledTextCtrl::SetCaretLineVisible(bool show) { + SendMsg(2096, show, 0); +} + +// Get the colour of the background of the line containing the caret. +wxColour wxStyledTextCtrl::GetCaretLineBack() { + long c = SendMsg(2097, 0, 0); + return wxColourFromLong(c); +} + +// Set the colour of the background of the line containing the caret. +void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) { + SendMsg(2098, wxColourAsLong(back), 0); +} + // Display a auto-completion list. // The lenEntered parameter indicates how many characters before // the caret should be used to provide context. @@ -732,6 +795,21 @@ bool wxStyledTextCtrl::AutoCompGetIgnoreCase() { return SendMsg(2116, 0, 0) != 0; } +// Display a list of strings and send notification when user chooses one. +void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { + SendMsg(2117, listType, (long)itemList.c_str()); +} + +// Set whether or not autocompletion is hidden automatically when nothing matches +void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) { + SendMsg(2118, autoHide, 0); +} + +// Retrieve whether or not autocompletion is hidden automatically when nothing matches +bool wxStyledTextCtrl::AutoCompGetAutoHide() { + return SendMsg(2119, 0, 0) != 0; +} + // Set the number of spaces used for one level of indentation. void wxStyledTextCtrl::SetIndent(int indentSize) { SendMsg(2122, indentSize, 0); @@ -921,10 +999,11 @@ int wxStyledTextCtrl::GetFirstVisibleLine() { wxString wxStyledTextCtrl::GetLine(int line) { wxString text; int len = LineLength(line); - char* buf = text.GetWriteBuf(len+1); + if (!len) return ""; + char* buf = text.GetWriteBuf(len); int pos = SendMsg(2153, line, (long)buf); - text.UngetWriteBuf(); + text.UngetWriteBuf(len); return text; } @@ -935,8 +1014,8 @@ int wxStyledTextCtrl::GetLineCount() { } // Sets the size in pixels of the left margin. -void wxStyledTextCtrl::SetMarginLeft(int width) { - SendMsg(2155, 0, width); +void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) { + SendMsg(2155, 0, pixelWidth); } // Returns the size in pixels of the left margin. @@ -945,8 +1024,8 @@ int wxStyledTextCtrl::GetMarginLeft() { } // Sets the size in pixels of the right margin. -void wxStyledTextCtrl::SetMarginRight(int width) { - SendMsg(2157, 0, width); +void wxStyledTextCtrl::SetMarginRight(int pixelWidth) { + SendMsg(2157, 0, pixelWidth); } // Returns the size in pixels of the right margin. @@ -972,10 +1051,11 @@ wxString wxStyledTextCtrl::GetSelectedText() { GetSelection(&start, &end); int len = end - start; - char* buff = text.GetWriteBuf(len+1); + if (!len) return ""; + char* buff = text.GetWriteBuf(len); SendMsg(2161, 0, (long)buff); - text.UngetWriteBuf(); + text.UngetWriteBuf(len); return text; } @@ -983,14 +1063,15 @@ wxString wxStyledTextCtrl::GetSelectedText() { wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { wxString text; int len = endPos - startPos; - char* buff = text.GetWriteBuf(len+1); + if (!len) return ""; + char* buff = text.GetWriteBuf(len); TextRange tr; tr.lpstrText = buff; tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; SendMsg(2162, 0, (long)&tr); - text.UngetWriteBuf(); + text.UngetWriteBuf(len); return text; } @@ -1077,12 +1158,11 @@ void wxStyledTextCtrl::SetText(const wxString& text) { // Retrieve all the text in the document. wxString wxStyledTextCtrl::GetText() { wxString text; - int len = GetTextLength()+1; - char* buff = text.GetWriteBuf(len+1); + int len = GetTextLength(); + char* buff = text.GetWriteBuf(len+1); // leave room for the null... - SendMsg(2182, len, (long)buff); - buff[len] = 0; - text.UngetWriteBuf(); + SendMsg(2182, len+1, (long)buff); + text.UngetWriteBuf(len); return text; } @@ -1101,6 +1181,78 @@ bool wxStyledTextCtrl::GetOvertype() { return SendMsg(2187, 0, 0) != 0; } +// Set the width of the insert mode caret +void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) { + SendMsg(2188, pixelWidth, 0); +} + +// Returns the width of the insert mode caret +int wxStyledTextCtrl::GetCaretWidth() { + return SendMsg(2189, 0, 0); +} + +// Sets the position that starts the target which is used for updating the +// document without affecting the scroll position. +void wxStyledTextCtrl::SetTargetStart(int pos) { + SendMsg(2190, pos, 0); +} + +// Get the position that starts the target. +int wxStyledTextCtrl::GetTargetStart() { + return SendMsg(2191, 0, 0); +} + +// Sets the position that ends the target which is used for updating the +// document without affecting the scroll position. +void wxStyledTextCtrl::SetTargetEnd(int pos) { + SendMsg(2192, pos, 0); +} + +// Get the position that ends the target. +int wxStyledTextCtrl::GetTargetEnd() { + return SendMsg(2193, 0, 0); +} + +// Replace the target text with the argument text. +// Text is counted so it can contain nulls. +// Returns the length of the replacement text. + + int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { + return SendMsg(2194, text.Len(), (long)text.c_str()); + +} + +// Replace the target text with the argument text after \d processing. +// Text is counted so it can contain nulls. +// 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 +// caused by processing the \d patterns. + + int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { + return SendMsg(2195, text.Len(), (long)text.c_str()); + +} + +// Search for a counted string in the target and set the target to the found +// range. Text is counted so it can contain nulls. +// Returns length of range or -1 for failure in which case target is not moved. + + int wxStyledTextCtrl::SearchInTarget(const wxString& text) { + return SendMsg(2197, text.Len(), (long)text.c_str()); + +} + +// Set the search flags used by SearchInTarget +void wxStyledTextCtrl::SetSearchFlags(int flags) { + SendMsg(2198, flags, 0); +} + +// Get the search flags used by SearchInTarget +int wxStyledTextCtrl::GetSearchFlags() { + return SendMsg(2199, 0, 0); +} + // Show a call tip containing a definition near position pos. void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { SendMsg(2200, pos, (long)definition.c_str()); @@ -1203,6 +1355,47 @@ void wxStyledTextCtrl::SetFoldFlags(int flags) { SendMsg(2233, flags, 0); } +// Ensure a particular line is visible by expanding any header line hiding it. +// Use the currently set visibility policy to determine which range to display. +void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) { + SendMsg(2234, line, 0); +} + +// Sets whether a tab pressed when caret is within indentation indents +void wxStyledTextCtrl::SetTabIndents(bool tabIndents) { + SendMsg(2260, tabIndents, 0); +} + +// Does a tab pressed when caret is within indentation indent? +bool wxStyledTextCtrl::GetTabIndents() { + return SendMsg(2261, 0, 0) != 0; +} + +// Sets whether a backspace pressed when caret is within indentation unindents +void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) { + SendMsg(2262, bsUnIndents, 0); +} + +// Does a backspace pressed when caret is within indentation unindent? +bool wxStyledTextCtrl::GetBackSpaceUnIndents() { + return SendMsg(2263, 0, 0) != 0; +} + +// Sets the time the mouse must sit still to generate a mouse dwell event +void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) { + SendMsg(2264, periodMilliseconds, 0); +} + +// Retrieve the time the mouse must sit still to generate a mouse dwell event +int wxStyledTextCtrl::GetMouseDwellTime() { + return SendMsg(2265, 0, 0); +} + +// Move the caret inside current view if it's not there already +void wxStyledTextCtrl::MoveCaretInsideView() { + SendMsg(2401, 0, 0); +} + // How many characters are on a line, not including end of line characters. int wxStyledTextCtrl::LineLength(int line) { return SendMsg(2350, line, 0); @@ -1240,7 +1433,7 @@ void* wxStyledTextCtrl::GetDocPointer() { // Change the document object used. void wxStyledTextCtrl::SetDocPointer(void* docPointer) { - SendMsg(2358, (long)docPointer); + SendMsg(2358, 0, (long)docPointer); } // Set which document modification events are sent to the container. @@ -1287,11 +1480,13 @@ void wxStyledTextCtrl::SearchAnchor() { } // Find some text starting at the search anchor. +// Does not ensure the selection is visible. int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { return SendMsg(2367, flags, (long)text.c_str()); } // Find some text starting at the search anchor and moving backwards. +// Does not ensure the selection is visible. int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { return SendMsg(2368, flags, (long)text.c_str()); } @@ -1349,6 +1544,81 @@ int wxStyledTextCtrl::GetModEventMask() { return SendMsg(2378, 0, 0); } +// Change internal focus flag +void wxStyledTextCtrl::SetSTCFocus(bool focus) { + SendMsg(2380, focus, 0); +} + +// Get internal focus flag +bool wxStyledTextCtrl::GetSTCFocus() { + return SendMsg(2381, 0, 0) != 0; +} + +// Change error status - 0 = OK +void wxStyledTextCtrl::SetStatus(int statusCode) { + SendMsg(2382, statusCode, 0); +} + +// Get error status +int wxStyledTextCtrl::GetStatus() { + return SendMsg(2383, 0, 0); +} + +// Set whether the mouse is captured when its button is pressed +void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) { + SendMsg(2384, captures, 0); +} + +// Get whether mouse gets captured +bool wxStyledTextCtrl::GetMouseDownCaptures() { + return SendMsg(2385, 0, 0) != 0; +} + +// Sets the cursor to one of the SC_CURSOR* values +void wxStyledTextCtrl::SetCursor(int cursorType) { + SendMsg(2386, cursorType, 0); +} + +// Get cursor type +int wxStyledTextCtrl::GetCursor() { + return SendMsg(2387, 0, 0); +} + +// Move to the previous change in capitalistion +void wxStyledTextCtrl::WordPartLeft() { + SendMsg(2390, 0, 0); +} + +// Move to the previous change in capitalistion extending selection to new caret position. +void wxStyledTextCtrl::WordPartLeftExtend() { + SendMsg(2391, 0, 0); +} + +// Move to the change next in capitalistion +void wxStyledTextCtrl::WordPartRight() { + SendMsg(2392, 0, 0); +} + +// Move to the next change in capitalistion extending selection to new caret position. +void wxStyledTextCtrl::WordPartRightExtend() { + SendMsg(2393, 0, 0); +} + +// Set the way the display area is determined when a particular line is to be moved to. +void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) { + SendMsg(2394, visiblePolicy, visibleSlop); +} + +// Delete back from the current position to the start of the line +void wxStyledTextCtrl::DelLineLeft() { + SendMsg(2395, 0, 0); +} + +// Delete forwards from the current position to the end of the line +void wxStyledTextCtrl::DelLineRight() { + SendMsg(2396, 0, 0); +} + // Start notifying the container of all key presses and commands. void wxStyledTextCtrl::StartRecord() { SendMsg(3001, 0, 0); @@ -1384,6 +1654,11 @@ void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { SendMsg(4005, keywordSet, (long)keyWords.c_str()); } +// Set the lexing language of the document based on string name. +void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) { + SendMsg(4006, 0, (long)language.c_str()); +} + // END of generated section //---------------------------------------------------------------------- @@ -1533,6 +1808,16 @@ void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); } +void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { + wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); + if (sb) { + if (sb->IsVertical()) + m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); + else + m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); + } +} + void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { wxSize sz = GetClientSize(); m_swx->DoSize(sz.x, sz.y); @@ -1562,47 +1847,77 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { } +void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { + wxPoint pt = evt.GetPosition(); + ScreenToClient(&pt.x, &pt.y); + m_swx->DoContextMenu(Point(pt.x, pt.y)); +} + + void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { m_swx->DoMouseWheel(evt.GetWheelRotation(), evt.GetWheelDelta(), - evt.GetLinesPerAction()); + evt.GetLinesPerAction(), + evt.ControlDown()); } void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { long key = evt.KeyCode(); - if ((key > WXK_ESCAPE) && - (key != WXK_DELETE) && (key < 255) && - !evt.ControlDown() && !evt.AltDown()) { +// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n", +// key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown()); + + // AltGr keys??? + // \|@#¬[]{}?£$~ ã,õ,Ã,Õ, ñ, Ñ + + // On (some?) non-US keyboards the AltGr key is required to enter some + // common characters. It comes to us as both Alt and Ctrl down so we need + // to let the char through in that case, otherwise if only ctrl or only + // alt let's skip it. + bool ctrl = evt.ControlDown(); + bool alt = evt.AltDown(); + bool skip = ((ctrl || alt) && ! (ctrl && alt)); + + if (key <= 0xff && key >= 32 && !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); + return; } - else { - evt.Skip(); - } + 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) + bool shift = evt.ShiftDown(), + ctrl = evt.ControlDown(), + alt = evt.AltDown(); + + int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed); + +// printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n", +// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); + + if (!processed && !m_lastKeyDownConsumed) evt.Skip(); } + void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { m_swx->DoLoseFocus(); } + void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { m_swx->DoGainFocus(); } + void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) { m_swx->DoSysColourChange(); } + void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) { // do nothing to help avoid flashing } @@ -1625,80 +1940,118 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { void wxStyledTextCtrl::NotifyChange() { wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); + evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; - int eventType = 0; + wxStyledTextEvent evt(0, GetId()); + + evt.SetEventObject(this); + evt.SetPosition(scn.position); + evt.SetKey(scn.ch); + evt.SetModifiers(scn.modifiers); + switch (scn.nmhdr.code) { case SCN_STYLENEEDED: - eventType = wxEVT_STC_STYLENEEDED; + evt.SetEventType(wxEVT_STC_STYLENEEDED); break; + case SCN_CHARADDED: - eventType = wxEVT_STC_CHARADDED; - break; - case SCN_UPDATEUI: - eventType = wxEVT_STC_UPDATEUI; + evt.SetEventType(wxEVT_STC_CHARADDED); break; + case SCN_SAVEPOINTREACHED: - eventType = wxEVT_STC_SAVEPOINTREACHED; + evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); break; + case SCN_SAVEPOINTLEFT: - eventType = wxEVT_STC_SAVEPOINTLEFT; + evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); break; + case SCN_MODIFYATTEMPTRO: - eventType = wxEVT_STC_ROMODIFYATTEMPT; + evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); break; + + case SCN_KEY: + evt.SetEventType(wxEVT_STC_KEY); + break; + case SCN_DOUBLECLICK: - eventType = wxEVT_STC_DOUBLECLICK; + evt.SetEventType(wxEVT_STC_DOUBLECLICK); break; - case SCN_MODIFIED: - eventType = wxEVT_STC_MODIFIED; + + case SCN_UPDATEUI: + evt.SetEventType(wxEVT_STC_UPDATEUI); break; - case SCN_KEY: - eventType = wxEVT_STC_KEY; + + case SCN_MODIFIED: + evt.SetEventType(wxEVT_STC_MODIFIED); + evt.SetModificationType(scn.modificationType); + if (scn.text) + evt.SetText(wxString(scn.text, scn.length)); + evt.SetLength(scn.length); + evt.SetLinesAdded(scn.linesAdded); + evt.SetLine(scn.line); + evt.SetFoldLevelNow(scn.foldLevelNow); + evt.SetFoldLevelPrev(scn.foldLevelPrev); break; + case SCN_MACRORECORD: - eventType = wxEVT_STC_MACRORECORD; + evt.SetEventType(wxEVT_STC_MACRORECORD); + evt.SetMessage(scn.message); + evt.SetWParam(scn.wParam); + evt.SetLParam(scn.lParam); break; + case SCN_MARGINCLICK: - eventType = wxEVT_STC_MARGINCLICK; + evt.SetEventType(wxEVT_STC_MARGINCLICK); + evt.SetMargin(scn.margin); break; + case SCN_NEEDSHOWN: - eventType = wxEVT_STC_NEEDSHOWN; + evt.SetEventType(wxEVT_STC_NEEDSHOWN); + evt.SetLength(scn.length); break; + case SCN_POSCHANGED: - eventType = wxEVT_STC_POSCHANGED; + evt.SetEventType(wxEVT_STC_POSCHANGED); + break; + + case SCN_PAINTED: + evt.SetEventType(wxEVT_STC_PAINTED); + break; + + case SCN_USERLISTSELECTION: + evt.SetEventType(wxEVT_STC_USERLISTSELECTION); + evt.SetListType(scn.listType); + evt.SetText(scn.text); + break; + + case SCN_URIDROPPED: + evt.SetEventType(wxEVT_STC_URIDROPPED); + evt.SetText(scn.text); break; - } - if (eventType) { - wxStyledTextEvent evt(eventType, GetId()); - evt.SetPosition(scn.position); - evt.SetKey(scn.ch); - evt.SetModifiers(scn.modifiers); - if (eventType == wxEVT_STC_MODIFIED) { - evt.SetModificationType(scn.modificationType); - if (scn.text) - evt.SetText(wxString(scn.text, scn.length)); - evt.SetLength(scn.length); - evt.SetLinesAdded(scn.linesAdded); - evt.SetLine(scn.line); - evt.SetFoldLevelNow(scn.foldLevelNow); - evt.SetFoldLevelPrev(scn.foldLevelPrev); - } - if (eventType == wxEVT_STC_MARGINCLICK) - evt.SetMargin(scn.margin); - if (eventType == wxEVT_STC_MACRORECORD) { - evt.SetMessage(scn.message); - evt.SetWParam(scn.wParam); - evt.SetLParam(scn.lParam); - } - GetEventHandler()->ProcessEvent(evt); + case SCN_DWELLSTART: + evt.SetEventType(wxEVT_STC_DWELLSTART); + evt.SetX(scn.x); + evt.SetY(scn.y); + break; + + case SCN_DWELLEND: + evt.SetEventType(wxEVT_STC_DWELLEND); + evt.SetX(scn.x); + evt.SetY(scn.y); + break; + + default: + return; } -} + GetEventHandler()->ProcessEvent(evt); +} //---------------------------------------------------------------------- @@ -1721,39 +2074,59 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_message = 0; m_wParam = 0; m_lParam = 0; - - + m_listType = 0; + m_x = 0; + m_y = 0; +#if wxUSE_DRAG_AND_DROP + m_dragAllowMove = FALSE; + m_dragResult = wxDragNone; +#endif } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } -void wxStyledTextEvent::CopyObject(wxObject& obj) const { - wxCommandEvent::CopyObject(obj); - wxStyledTextEvent* o = (wxStyledTextEvent*)&obj; - o->m_position = m_position; - o->m_key = m_key; - o->m_modifiers = m_modifiers; - o->m_modificationType = m_modificationType; - o->m_text = m_text; - o->m_length = m_length; - o->m_linesAdded = m_linesAdded; - o->m_line = m_line; - o->m_foldLevelNow = m_foldLevelNow; - o->m_foldLevelPrev = m_foldLevelPrev; +wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): + wxCommandEvent(event) +{ + m_position = event.m_position; + m_key = event.m_key; + m_modifiers = event.m_modifiers; + m_modificationType = event.m_modificationType; + m_text = event.m_text; + m_length = event.m_length; + m_linesAdded = event.m_linesAdded; + m_line = event.m_line; + m_foldLevelNow = event.m_foldLevelNow; + m_foldLevelPrev = event.m_foldLevelPrev; + + m_margin = event.m_margin; + + m_message = event.m_message; + m_wParam = event.m_wParam; + m_lParam = event.m_lParam; + + m_listType = event.m_listType; + m_x = event.m_x; + m_y = event.m_y; + +#if wxUSE_DRAG_AND_DROP + m_dragText = event.m_dragText; + m_dragAllowMove =event.m_dragAllowMove; + m_dragResult = event.m_dragResult; +#endif +} + +//---------------------------------------------------------------------- +//---------------------------------------------------------------------- + + - o->m_margin = m_margin; - o->m_message = m_message; - o->m_wParam = m_wParam; - o->m_lParam = m_lParam; -} -//---------------------------------------------------------------------- -//----------------------------------------------------------------------