X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f97d84a63b21fffcc830390e5bc3fe0eedb6e15b..14dd645ee16eb022afb19f35d0c8cfdf2d3cdee9:/contrib/src/stc/stc.cpp.in diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index b5df70df2a..e4c51365a9 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -28,31 +28,37 @@ int wxForceScintillaLexers(void) { + extern LexerModule lmAda; + extern LexerModule lmAVE; + extern LexerModule lmConf; extern LexerModule lmCPP; + 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 + && &lmEiffel + && &lmHTML + && &lmLISP + && &lmLua + && &lmBatch + && &lmPascal + && &lmPerl + && &lmPython + && &lmRuby + && &lmSQL + && &lmVB ) { return 1; } @@ -66,14 +72,42 @@ 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_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_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 ) + + + + BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) EVT_PAINT (wxStyledTextCtrl::OnPaint) EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) EVT_SIZE (wxStyledTextCtrl::OnSize) EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) +#ifdef __WXMSW__ + // Let Scintilla see the double click as a second click + EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) +#endif EVT_MOTION (wxStyledTextCtrl::OnMouseMove) EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) - EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) + EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) + EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) EVT_CHAR (wxStyledTextCtrl::OnChar) EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) @@ -103,6 +137,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, { m_swx = new ScintillaWX(this); m_stopWatch.Start(); + m_lastKeyDownConsumed = FALSE; } @@ -328,45 +363,56 @@ void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { } -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.ControlDown()); +} + + void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { long key = evt.KeyCode(); - if ((key > WXK_ESCAPE) && - (key != WXK_DELETE) && (key < 255) && - !evt.ControlDown() && !evt.AltDown()) { - + if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed) { m_swx->DoAddChar(key); } - else { - 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) + int processed = m_swx->DoKeyDown(key, + evt.ShiftDown(), + evt.ControlDown(), + evt.AltDown(), + &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 } @@ -394,73 +440,110 @@ void wxStyledTextCtrl::NotifyChange() { void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { SCNotification& scn = *_scn; - int eventType = 0; + wxStyledTextEvent evt(0, GetId()); + + 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; + + case SCN_DWELLSTART: + evt.SetEventType(wxEVT_STC_DWELLSTART); + evt.SetX(scn.x); + evt.SetY(scn.y); 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_DWELLEND: + evt.SetEventType(wxEVT_STC_DWELLEND); + evt.SetX(scn.x); + evt.SetY(scn.y); + break; + + default: + return; } + + GetEventHandler()->ProcessEvent(evt); } @@ -485,8 +568,9 @@ wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) m_message = 0; m_wParam = 0; m_lParam = 0; - - + m_listType = 0; + m_x = 0; + m_y = 0; } bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } @@ -514,7 +598,9 @@ void wxStyledTextEvent::CopyObject(wxObject& obj) const { o->m_wParam = m_wParam; o->m_lParam = m_lParam; - + o->m_listType = m_listType; + o->m_x = m_x; + o->m_y = m_y; }