From ce1ecc6d48415cf3b348e42b1e53ae2333d9098a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 16 Feb 2001 08:40:24 +0000 Subject: [PATCH] Copied/merged from the 2.2 branch. Changes needed to build with new event system git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/ScintillaWX.cpp | 48 ++++++++---------------- contrib/src/stc/scintilla/src/Editor.cxx | 44 ++++++++++++++-------- contrib/src/stc/stc.cpp | 39 +++++++++++++++---- src/stc/ScintillaWX.cpp | 48 ++++++++---------------- src/stc/scintilla/src/Editor.cxx | 44 ++++++++++++++-------- src/stc/stc.cpp | 39 +++++++++++++++---- 6 files changed, 152 insertions(+), 110 deletions(-) diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index f7349c8d27..9f19ebbca9 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -325,57 +325,41 @@ void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { void ScintillaWX::DoHScroll(int type, int pos) { int xPos = xOffset; - switch (type) { - case wxEVT_SCROLLWIN_LINEUP: + if (type == wxEVT_SCROLLWIN_LINEUP) xPos -= H_SCROLL_STEP; - break; - case wxEVT_SCROLLWIN_LINEDOWN: + else if (type == wxEVT_SCROLLWIN_LINEDOWN) xPos += H_SCROLL_STEP; - break; - case wxEVT_SCROLLWIN_PAGEUP: + else if (type == wxEVT_SCROLLWIN_PAGEUP) xPos -= H_SCROLL_PAGE; - break; - case wxEVT_SCROLLWIN_PAGEDOWN: + else if (type == wxEVT_SCROLLWIN_PAGEDOWN) xPos += H_SCROLL_PAGE; - break; - case wxEVT_SCROLLWIN_TOP: + else if (type == wxEVT_SCROLLWIN_TOP) xPos = 0; - break; - case wxEVT_SCROLLWIN_BOTTOM: + else if (type == wxEVT_SCROLLWIN_BOTTOM) xPos = H_SCROLL_MAX; - break; - case wxEVT_SCROLLWIN_THUMBTRACK: + else if (type == wxEVT_SCROLLWIN_THUMBTRACK) xPos = pos; - break; - } + HorizontalScrollTo(xPos); } void ScintillaWX::DoVScroll(int type, int pos) { int topLineNew = topLine; - switch (type) { - case wxEVT_SCROLLWIN_LINEUP: + if (type == wxEVT_SCROLLWIN_LINEUP) topLineNew -= 1; - break; - case wxEVT_SCROLLWIN_LINEDOWN: + else if (type == wxEVT_SCROLLWIN_LINEDOWN) topLineNew += 1; - break; - case wxEVT_SCROLLWIN_PAGEUP: + else if (type == wxEVT_SCROLLWIN_PAGEUP) topLineNew -= LinesToScroll(); - break; - case wxEVT_SCROLLWIN_PAGEDOWN: + else if (type == wxEVT_SCROLLWIN_PAGEDOWN) topLineNew += LinesToScroll(); - break; - case wxEVT_SCROLLWIN_TOP: + else if (type == wxEVT_SCROLLWIN_TOP) topLineNew = 0; - break; - case wxEVT_SCROLLWIN_BOTTOM: + else if (type == wxEVT_SCROLLWIN_BOTTOM) topLineNew = MaxScrollPos(); - break; - case wxEVT_SCROLLWIN_THUMBTRACK: + else if (type == wxEVT_SCROLLWIN_THUMBTRACK) topLineNew = pos; - break; - } + ScrollTo(topLineNew); } diff --git a/contrib/src/stc/scintilla/src/Editor.cxx b/contrib/src/stc/scintilla/src/Editor.cxx index 6d2676ffbc..87b579bbc1 100644 --- a/contrib/src/stc/scintilla/src/Editor.cxx +++ b/contrib/src/stc/scintilla/src/Editor.cxx @@ -14,7 +14,7 @@ #if PLAT_WX || PLAT_GTK #include "WinDefs.h" -#endif +#endif #include "ContractionState.h" #include "SVector.h" @@ -106,7 +106,7 @@ Editor::Editor() { #ifdef MACRO_SUPPORT recordingMacro = 0; -#endif +#endif foldFlags = 0; } @@ -303,8 +303,22 @@ int Editor::PositionFromLineX(int line, int x) { } void Editor::RedrawRect(PRectangle rc) { - //Platform::DebugPrintf("Redraw %d %d - %d %d\n", rc.left, rc.top, rc.right, rc.bottom); - wDraw.InvalidateRectangle(rc); + //Platform::DebugPrintf("Redraw %d %d - %d %d\n", rc.left, rc.top, rc.right, rc.bottom); + + // Clip the redraw rectangle into the client area + PRectangle rcClient = GetClientRectangle(); + if (rc.top < rcClient.top) + rc.top = rcClient.top; + if (rc.bottom > rcClient.bottom) + rc.bottom = rcClient.bottom; + if (rc.left < rcClient.left) + rc.left = rcClient.left; + if (rc.right > rcClient.right) + rc.right = rcClient.right; + + if ((rc.bottom > rc.top) && (rc.right > rc.left)) { + wDraw.InvalidateRectangle(rc); + } } void Editor::Redraw() { @@ -659,10 +673,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.ms[margin].symbol) { /* alternate scheme: if (vs.ms[margin].mask & SC_MASK_FOLDERS) - surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); + surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); else // Required because of special way brush is created for selection margin - surface->FillRectangle(rcSelMargin, pixmapSelPattern); + surface->FillRectangle(rcSelMargin, pixmapSelPattern); */ if (vs.ms[margin].mask & SC_MASK_FOLDERS) // Required because of special way brush is created for selection margin @@ -1653,7 +1667,7 @@ void Editor::NotifyChar(char ch) { txt[1] = '\0'; NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); } -#endif +#endif } void Editor::NotifySavePoint(bool isSavePoint) { @@ -1939,7 +1953,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long scn.lParam = lParam; NotifyParent(scn); } -#endif +#endif // Force scroll and keep position relative to top of window void Editor::PageMove(int direction, bool extend) { @@ -3019,7 +3033,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { #ifdef MACRO_SUPPORT if (recordingMacro) NotifyMacroRecord(iMessage, wParam, lParam); -#endif +#endif switch (iMessage) { @@ -3411,9 +3425,9 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { return SEL_EMPTY; else return SEL_TEXT; -#else +#else return 0; -#endif +#endif case EM_HIDESELECTION: hideSelection = wParam; @@ -3447,7 +3461,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { vs.rightMarginWidth = vs.aveCharWidth / 2; } InvalidateStyleRedraw(); -#endif +#endif break; case SCI_SETMARGINLEFT: @@ -4238,10 +4252,10 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { case SCI_SETOVERTYPE: inOverstrike = wParam; break; - + case SCI_GETOVERTYPE: return inOverstrike ? TRUE : FALSE; - + #ifdef MACRO_SUPPORT case SCI_STARTRECORD: recordingMacro = 1; @@ -4250,7 +4264,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { case SCI_STOPRECORD: recordingMacro = 0; return 0; -#endif +#endif default: return DefWndProc(iMessage, wParam, lParam); diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 3573c3f648..a362eaf491 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -1539,16 +1539,38 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { m_swx->DoContextMenu(Point(pt.x, pt.y)); } + void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { long key = evt.KeyCode(); - if ((key > WXK_ESCAPE) && - (key != WXK_DELETE) && (key < 255) && - !evt.ControlDown() && !evt.AltDown()) { - - m_swx->DoAddChar(key); - } - else { - evt.Skip(); + switch (key) { + // Special handling for charcters that must be typed with AltGr down on + // foreign keyboards. (Comes to us as Ctrl+Alt, and so would get + // filtered out by the default case below.) + // + // There should be a better way to do this... + // + case '\\': + case '|': + case '@': + case '#': + case '¬': + case '[': + case ']': + case '{': + case '}': + case '?': + m_swx->DoAddChar(key); + break; + + default: + if ((key > WXK_ESCAPE) && (key != WXK_DELETE) && (key < 255) && + !evt.ControlDown() && !evt.AltDown()) { + + m_swx->DoAddChar(key); + } + else { + evt.Skip(); + } } } @@ -1561,6 +1583,7 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { evt.Skip(); } + void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { m_swx->DoLoseFocus(); } diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index f7349c8d27..9f19ebbca9 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -325,57 +325,41 @@ void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { void ScintillaWX::DoHScroll(int type, int pos) { int xPos = xOffset; - switch (type) { - case wxEVT_SCROLLWIN_LINEUP: + if (type == wxEVT_SCROLLWIN_LINEUP) xPos -= H_SCROLL_STEP; - break; - case wxEVT_SCROLLWIN_LINEDOWN: + else if (type == wxEVT_SCROLLWIN_LINEDOWN) xPos += H_SCROLL_STEP; - break; - case wxEVT_SCROLLWIN_PAGEUP: + else if (type == wxEVT_SCROLLWIN_PAGEUP) xPos -= H_SCROLL_PAGE; - break; - case wxEVT_SCROLLWIN_PAGEDOWN: + else if (type == wxEVT_SCROLLWIN_PAGEDOWN) xPos += H_SCROLL_PAGE; - break; - case wxEVT_SCROLLWIN_TOP: + else if (type == wxEVT_SCROLLWIN_TOP) xPos = 0; - break; - case wxEVT_SCROLLWIN_BOTTOM: + else if (type == wxEVT_SCROLLWIN_BOTTOM) xPos = H_SCROLL_MAX; - break; - case wxEVT_SCROLLWIN_THUMBTRACK: + else if (type == wxEVT_SCROLLWIN_THUMBTRACK) xPos = pos; - break; - } + HorizontalScrollTo(xPos); } void ScintillaWX::DoVScroll(int type, int pos) { int topLineNew = topLine; - switch (type) { - case wxEVT_SCROLLWIN_LINEUP: + if (type == wxEVT_SCROLLWIN_LINEUP) topLineNew -= 1; - break; - case wxEVT_SCROLLWIN_LINEDOWN: + else if (type == wxEVT_SCROLLWIN_LINEDOWN) topLineNew += 1; - break; - case wxEVT_SCROLLWIN_PAGEUP: + else if (type == wxEVT_SCROLLWIN_PAGEUP) topLineNew -= LinesToScroll(); - break; - case wxEVT_SCROLLWIN_PAGEDOWN: + else if (type == wxEVT_SCROLLWIN_PAGEDOWN) topLineNew += LinesToScroll(); - break; - case wxEVT_SCROLLWIN_TOP: + else if (type == wxEVT_SCROLLWIN_TOP) topLineNew = 0; - break; - case wxEVT_SCROLLWIN_BOTTOM: + else if (type == wxEVT_SCROLLWIN_BOTTOM) topLineNew = MaxScrollPos(); - break; - case wxEVT_SCROLLWIN_THUMBTRACK: + else if (type == wxEVT_SCROLLWIN_THUMBTRACK) topLineNew = pos; - break; - } + ScrollTo(topLineNew); } diff --git a/src/stc/scintilla/src/Editor.cxx b/src/stc/scintilla/src/Editor.cxx index 6d2676ffbc..87b579bbc1 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -14,7 +14,7 @@ #if PLAT_WX || PLAT_GTK #include "WinDefs.h" -#endif +#endif #include "ContractionState.h" #include "SVector.h" @@ -106,7 +106,7 @@ Editor::Editor() { #ifdef MACRO_SUPPORT recordingMacro = 0; -#endif +#endif foldFlags = 0; } @@ -303,8 +303,22 @@ int Editor::PositionFromLineX(int line, int x) { } void Editor::RedrawRect(PRectangle rc) { - //Platform::DebugPrintf("Redraw %d %d - %d %d\n", rc.left, rc.top, rc.right, rc.bottom); - wDraw.InvalidateRectangle(rc); + //Platform::DebugPrintf("Redraw %d %d - %d %d\n", rc.left, rc.top, rc.right, rc.bottom); + + // Clip the redraw rectangle into the client area + PRectangle rcClient = GetClientRectangle(); + if (rc.top < rcClient.top) + rc.top = rcClient.top; + if (rc.bottom > rcClient.bottom) + rc.bottom = rcClient.bottom; + if (rc.left < rcClient.left) + rc.left = rcClient.left; + if (rc.right > rcClient.right) + rc.right = rcClient.right; + + if ((rc.bottom > rc.top) && (rc.right > rc.left)) { + wDraw.InvalidateRectangle(rc); + } } void Editor::Redraw() { @@ -659,10 +673,10 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.ms[margin].symbol) { /* alternate scheme: if (vs.ms[margin].mask & SC_MASK_FOLDERS) - surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); + surface->FillRectangle(rcSelMargin, vs.styles[STYLE_DEFAULT].back.allocated); else // Required because of special way brush is created for selection margin - surface->FillRectangle(rcSelMargin, pixmapSelPattern); + surface->FillRectangle(rcSelMargin, pixmapSelPattern); */ if (vs.ms[margin].mask & SC_MASK_FOLDERS) // Required because of special way brush is created for selection margin @@ -1653,7 +1667,7 @@ void Editor::NotifyChar(char ch) { txt[1] = '\0'; NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); } -#endif +#endif } void Editor::NotifySavePoint(bool isSavePoint) { @@ -1939,7 +1953,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long scn.lParam = lParam; NotifyParent(scn); } -#endif +#endif // Force scroll and keep position relative to top of window void Editor::PageMove(int direction, bool extend) { @@ -3019,7 +3033,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { #ifdef MACRO_SUPPORT if (recordingMacro) NotifyMacroRecord(iMessage, wParam, lParam); -#endif +#endif switch (iMessage) { @@ -3411,9 +3425,9 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { return SEL_EMPTY; else return SEL_TEXT; -#else +#else return 0; -#endif +#endif case EM_HIDESELECTION: hideSelection = wParam; @@ -3447,7 +3461,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { vs.rightMarginWidth = vs.aveCharWidth / 2; } InvalidateStyleRedraw(); -#endif +#endif break; case SCI_SETMARGINLEFT: @@ -4238,10 +4252,10 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { case SCI_SETOVERTYPE: inOverstrike = wParam; break; - + case SCI_GETOVERTYPE: return inOverstrike ? TRUE : FALSE; - + #ifdef MACRO_SUPPORT case SCI_STARTRECORD: recordingMacro = 1; @@ -4250,7 +4264,7 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { case SCI_STOPRECORD: recordingMacro = 0; return 0; -#endif +#endif default: return DefWndProc(iMessage, wParam, lParam); diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 3573c3f648..a362eaf491 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -1539,16 +1539,38 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { m_swx->DoContextMenu(Point(pt.x, pt.y)); } + void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { long key = evt.KeyCode(); - if ((key > WXK_ESCAPE) && - (key != WXK_DELETE) && (key < 255) && - !evt.ControlDown() && !evt.AltDown()) { - - m_swx->DoAddChar(key); - } - else { - evt.Skip(); + switch (key) { + // Special handling for charcters that must be typed with AltGr down on + // foreign keyboards. (Comes to us as Ctrl+Alt, and so would get + // filtered out by the default case below.) + // + // There should be a better way to do this... + // + case '\\': + case '|': + case '@': + case '#': + case '¬': + case '[': + case ']': + case '{': + case '}': + case '?': + m_swx->DoAddChar(key); + break; + + default: + if ((key > WXK_ESCAPE) && (key != WXK_DELETE) && (key < 255) && + !evt.ControlDown() && !evt.AltDown()) { + + m_swx->DoAddChar(key); + } + else { + evt.Skip(); + } } } @@ -1561,6 +1583,7 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { evt.Skip(); } + void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { m_swx->DoLoseFocus(); } -- 2.45.2