Added MouseWheel support to wxSTC

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-05-06 01:20:41 +00:00
parent d13d99aa85
commit 37d6243357
14 changed files with 84 additions and 6 deletions

View File

@@ -1256,6 +1256,7 @@ private:
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt);
void OnLoseFocus(wxFocusEvent& evt);

View File

@@ -95,6 +95,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
wMain = win;
wDraw = win;
stc = win;
wheelRotation = 0;
Initialise();
}
@@ -363,6 +364,22 @@ void ScintillaWX::DoVScroll(int type, int pos) {
ScrollTo(topLineNew);
}
void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) {
int topLineNew = topLine;
int lines;
wheelRotation += rotation;
lines = wheelRotation / delta;
wheelRotation -= lines * delta;
if (lines != 0) {
lines *= linesPerAction;
topLineNew -= lines;
ScrollTo(topLineNew);
}
}
void ScintillaWX::DoSize(int width, int height) {
PRectangle rcClient(0,0,width,height);
SetScrollBarsTo(rcClient);

View File

@@ -119,6 +119,7 @@ public:
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction);
void DoAddChar(char ch);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt);
void DoTick() { Tick(); }
@@ -146,6 +147,7 @@ private:
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
int wheelRotation;
};
//----------------------------------------------------------------------

View File

@@ -19,14 +19,14 @@ from fileinput import FileInput
IFACE = './scintilla/include/Scintilla.iface'
H_TEMPLATE = './stc.h.in'
CPP_TEMPLATE = './stc.cpp.in'
H_DEST = '../../include/wx/stc/stc.h' # './stc_test.h' #
CPP_DEST = './stc.cpp' #'./stc_test.cpp'
H_DEST = '../../include/wx/stc/stc.h'
CPP_DEST = './stc.cpp'
# Value prefixes to convert
valPrefixes = [('SCI_', ''),
('SC_', ''),
('SCN_', None), # just toss these...
('SCN_', None), # just toss these out...
('SCEN_', None),
('SCE_', ''),
('SCLEX_', 'LEX_'),

View File

@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
@@ -1556,6 +1557,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(),
evt.GetLinesPerAction());
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode();
if ((key > WXK_ESCAPE) &&

View File

@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
@@ -350,6 +351,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(),
evt.GetLinesPerAction());
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode();
if ((key > WXK_ESCAPE) &&

View File

@@ -154,6 +154,7 @@ private:
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt);
void OnLoseFocus(wxFocusEvent& evt);

View File

@@ -1256,6 +1256,7 @@ private:
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt);
void OnLoseFocus(wxFocusEvent& evt);

View File

@@ -95,6 +95,7 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
wMain = win;
wDraw = win;
stc = win;
wheelRotation = 0;
Initialise();
}
@@ -363,6 +364,22 @@ void ScintillaWX::DoVScroll(int type, int pos) {
ScrollTo(topLineNew);
}
void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction) {
int topLineNew = topLine;
int lines;
wheelRotation += rotation;
lines = wheelRotation / delta;
wheelRotation -= lines * delta;
if (lines != 0) {
lines *= linesPerAction;
topLineNew -= lines;
ScrollTo(topLineNew);
}
}
void ScintillaWX::DoSize(int width, int height) {
PRectangle rcClient(0,0,width,height);
SetScrollBarsTo(rcClient);

View File

@@ -119,6 +119,7 @@ public:
void DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
void DoButtonUp(Point pt, unsigned int curTime, bool ctrl);
void DoButtonMove(Point pt);
void DoMouseWheel(int rotation, int delta, int linesPerAction);
void DoAddChar(char ch);
int DoKeyDown(int key, bool shift, bool ctrl, bool alt);
void DoTick() { Tick(); }
@@ -146,6 +147,7 @@ private:
wxSTCDropTarget* dropTarget;
wxDragResult dragResult;
int wheelRotation;
};
//----------------------------------------------------------------------

View File

@@ -19,14 +19,14 @@ from fileinput import FileInput
IFACE = './scintilla/include/Scintilla.iface'
H_TEMPLATE = './stc.h.in'
CPP_TEMPLATE = './stc.cpp.in'
H_DEST = '../../include/wx/stc/stc.h' # './stc_test.h' #
CPP_DEST = './stc.cpp' #'./stc_test.cpp'
H_DEST = '../../include/wx/stc/stc.h'
CPP_DEST = './stc.cpp'
# Value prefixes to convert
valPrefixes = [('SCI_', ''),
('SC_', ''),
('SCN_', None), # just toss these...
('SCN_', None), # just toss these out...
('SCEN_', None),
('SCE_', ''),
('SCLEX_', 'LEX_'),

View File

@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
@@ -1556,6 +1557,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(),
evt.GetLinesPerAction());
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode();
if ((key > WXK_ESCAPE) &&

View File

@@ -91,6 +91,7 @@ BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
EVT_CHAR (wxStyledTextCtrl::OnChar)
EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
@@ -350,6 +351,14 @@ void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
m_swx->DoContextMenu(Point(pt.x, pt.y));
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
m_swx->DoMouseWheel(evt.GetWheelRotation(),
evt.GetWheelDelta(),
evt.GetLinesPerAction());
}
void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
long key = evt.KeyCode();
if ((key > WXK_ESCAPE) &&

View File

@@ -154,6 +154,7 @@ private:
void OnMouseMove(wxMouseEvent& evt);
void OnMouseLeftUp(wxMouseEvent& evt);
void OnMouseRightUp(wxMouseEvent& evt);
void OnMouseWheel(wxMouseEvent& evt);
void OnChar(wxKeyEvent& evt);
void OnKeyDown(wxKeyEvent& evt);
void OnLoseFocus(wxFocusEvent& evt);