Add support for horizontal mouse wheel scrolling in wxSTC.
Handle horizontal mouse wheel scrolling events in a similar (but simpler, as they always scroll and never change the font size) way to the vertical ones in wxStyledTextCtrl. Closes #15266. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74312 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -671,6 +671,7 @@ All (GUI):
|
|||||||
- Fix wxStyledTextCtrl::SetInsertionPointEnd() (troelsk).
|
- Fix wxStyledTextCtrl::SetInsertionPointEnd() (troelsk).
|
||||||
- Add wxFileDialog::GetCurrentlySelectedFilename() (Carl Godkin).
|
- Add wxFileDialog::GetCurrentlySelectedFilename() (Carl Godkin).
|
||||||
- Add wxMouseEvent::GetColumnsPerAction() (toiffel).
|
- Add wxMouseEvent::GetColumnsPerAction() (toiffel).
|
||||||
|
- Add support for horizontal mouse wheel scrolling in wxSTC (toiffel).
|
||||||
- Improve wrapping of cell contents in wxGrid (nmset).
|
- Improve wrapping of cell contents in wxGrid (nmset).
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
@@ -244,7 +244,8 @@ ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
|
|||||||
focusEvent = false;
|
focusEvent = false;
|
||||||
wMain = win;
|
wMain = win;
|
||||||
stc = win;
|
stc = win;
|
||||||
wheelRotation = 0;
|
wheelVRotation = 0;
|
||||||
|
wheelHRotation = 0;
|
||||||
Initialise();
|
Initialise();
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
sysCaretBitmap = 0;
|
sysCaretBitmap = 0;
|
||||||
@@ -830,13 +831,28 @@ void ScintillaWX::DoVScroll(int type, int pos) {
|
|||||||
ScrollTo(topLineNew);
|
ScrollTo(topLineNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScintillaWX::DoMouseWheel(int rotation, int delta,
|
void ScintillaWX::DoMouseWheel(wxMouseWheelAxis axis, int rotation, int delta,
|
||||||
int linesPerAction, int ctrlDown,
|
int linesPerAction, int columnsPerAction,
|
||||||
bool isPageScroll ) {
|
bool ctrlDown, bool isPageScroll) {
|
||||||
int topLineNew = topLine;
|
int topLineNew = topLine;
|
||||||
int lines;
|
int lines;
|
||||||
|
int xPos = xOffset;
|
||||||
|
int pixels;
|
||||||
|
|
||||||
if (ctrlDown) { // Zoom the fonts if Ctrl key down
|
if (axis == wxMOUSE_WHEEL_HORIZONTAL) {
|
||||||
|
wheelHRotation += rotation * (columnsPerAction * vs.spaceWidth);
|
||||||
|
pixels = wheelHRotation / delta;
|
||||||
|
wheelHRotation -= pixels * delta;
|
||||||
|
if (pixels != 0) {
|
||||||
|
xPos += pixels;
|
||||||
|
PRectangle rcText = GetTextRectangle();
|
||||||
|
if (xPos > scrollWidth - rcText.Width()) {
|
||||||
|
xPos = scrollWidth - rcText.Width();
|
||||||
|
}
|
||||||
|
HorizontalScrollTo(xPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ctrlDown) { // Zoom the fonts if Ctrl key down
|
||||||
if (rotation > 0) {
|
if (rotation > 0) {
|
||||||
KeyCommand(SCI_ZOOMIN);
|
KeyCommand(SCI_ZOOMIN);
|
||||||
}
|
}
|
||||||
@@ -847,9 +863,9 @@ void ScintillaWX::DoMouseWheel(int rotation, int delta,
|
|||||||
else { // otherwise just scroll the window
|
else { // otherwise just scroll the window
|
||||||
if ( !delta )
|
if ( !delta )
|
||||||
delta = 120;
|
delta = 120;
|
||||||
wheelRotation += rotation;
|
wheelVRotation += rotation;
|
||||||
lines = wheelRotation / delta;
|
lines = wheelVRotation / delta;
|
||||||
wheelRotation -= lines * delta;
|
wheelVRotation -= lines * delta;
|
||||||
if (lines != 0) {
|
if (lines != 0) {
|
||||||
if (isPageScroll)
|
if (isPageScroll)
|
||||||
lines = lines * LinesOnScreen(); // lines is either +1 or -1
|
lines = lines * LinesOnScreen(); // lines is either +1 or -1
|
||||||
|
@@ -152,7 +152,9 @@ public:
|
|||||||
void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
|
||||||
void DoLeftButtonMove(Point pt);
|
void DoLeftButtonMove(Point pt);
|
||||||
void DoMiddleButtonUp(Point pt);
|
void DoMiddleButtonUp(Point pt);
|
||||||
void DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown, bool isPageScroll);
|
void DoMouseWheel(wxMouseWheelAxis axis, int rotation, int delta,
|
||||||
|
int linesPerAction, int columnsPerAction,
|
||||||
|
bool ctrlDown, bool isPageScroll);
|
||||||
void DoAddChar(int key);
|
void DoAddChar(int key);
|
||||||
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
int DoKeyDown(const wxKeyEvent& event, bool* consumed);
|
||||||
void DoTick() { Tick(); }
|
void DoTick() { Tick(); }
|
||||||
@@ -191,7 +193,8 @@ private:
|
|||||||
wxDragResult dragResult;
|
wxDragResult dragResult;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int wheelRotation;
|
int wheelVRotation;
|
||||||
|
int wheelHRotation;
|
||||||
|
|
||||||
// For use in creating a system caret
|
// For use in creating a system caret
|
||||||
bool HasCaretSizeChanged();
|
bool HasCaretSizeChanged();
|
||||||
|
@@ -4695,9 +4695,11 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
|
|||||||
|
|
||||||
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
|
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
m_swx->DoMouseWheel(evt.GetWheelRotation(),
|
m_swx->DoMouseWheel(evt.GetWheelAxis(),
|
||||||
|
evt.GetWheelRotation(),
|
||||||
evt.GetWheelDelta(),
|
evt.GetWheelDelta(),
|
||||||
evt.GetLinesPerAction(),
|
evt.GetLinesPerAction(),
|
||||||
|
evt.GetColumnsPerAction(),
|
||||||
evt.ControlDown(),
|
evt.ControlDown(),
|
||||||
evt.IsPageScroll());
|
evt.IsPageScroll());
|
||||||
}
|
}
|
||||||
|
@@ -833,9 +833,11 @@ void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
|
|||||||
|
|
||||||
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
|
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
|
||||||
{
|
{
|
||||||
m_swx->DoMouseWheel(evt.GetWheelRotation(),
|
m_swx->DoMouseWheel(evt.GetWheelAxis(),
|
||||||
|
evt.GetWheelRotation(),
|
||||||
evt.GetWheelDelta(),
|
evt.GetWheelDelta(),
|
||||||
evt.GetLinesPerAction(),
|
evt.GetLinesPerAction(),
|
||||||
|
evt.GetColumnsPerAction(),
|
||||||
evt.ControlDown(),
|
evt.ControlDown(),
|
||||||
evt.IsPageScroll());
|
evt.IsPageScroll());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user