X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/37d6243357b65ce2a2fa7a35b848ebefb88a3912..bb6de5ffad98697205287a04fe91ca73e7194709:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index b2a778bb31..991ae203ac 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -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,21 +74,30 @@ 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) @@ -88,9 +105,13 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) 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) @@ -121,6 +142,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, { m_swx = new ScintillaWX(this); m_stopWatch.Start(); + m_lastKeyDownConsumed = FALSE; } @@ -346,8 +368,9 @@ 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)); } @@ -355,44 +378,67 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { 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 && !iscntrl(key) && !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 } @@ -415,80 +461,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; - } - 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_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; + + case SCN_DWELLEND: + evt.SetEventType(wxEVT_STC_DWELLEND); + evt.SetX(scn.x); + evt.SetY(scn.y); + break; + + default: + return; } -} + GetEventHandler()->ProcessEvent(evt); +} //---------------------------------------------------------------------- @@ -511,8 +595,13 @@ 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; } @@ -540,10 +629,20 @@ 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; - +#if wxUSE_DRAG_AND_DROP + o->m_dragText = m_dragText; + o->m_dragAllowMove =m_dragAllowMove; + o->m_dragResult = m_dragResult; +#endif } //---------------------------------------------------------------------- //---------------------------------------------------------------------- + + +