From fb6efdf2773463ceb0348ac99b9dac6f2c17727d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 Jul 2005 22:20:06 +0000 Subject: [PATCH] Ctrl+mouse wheel changes zoom factor in print preview (patch 1230919) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/prntbase.h | 5 ++++- src/common/prntbase.cpp | 47 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index f7255eb89c..3ff1e4fbb4 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -16,6 +16,7 @@ All (GUI): - Added wxXmlResource::Unload(). - Possibility of modeless wxWizard dialog (with presentation in sample). - Fixed a rare crash due to malformed HTML in wxHTML (Xavier Nodet). +- Ctrl+mouse wheel changes zoom factor in print preview (Zbigniew Zagórski) wxMSW: diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index 43b6c7cf9e..290a10851f 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -313,11 +313,14 @@ public: void OnPaint(wxPaintEvent& event); void OnChar(wxKeyEvent &event); - // Responds to colour changes void OnSysColourChanged(wxSysColourChangedEvent& event); private: +#if wxUSE_MOUSEWHEEL + void OnMouseWheel(wxMouseEvent& event); +#endif // wxUSE_MOUSEWHEEL + wxPrintPreviewBase* m_printPreview; DECLARE_CLASS(wxPreviewCanvas) diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index b3f2e48a3d..a2cf649620 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -567,6 +567,9 @@ BEGIN_EVENT_TABLE(wxPreviewCanvas, wxScrolledWindow) EVT_PAINT(wxPreviewCanvas::OnPaint) EVT_CHAR(wxPreviewCanvas::OnChar) EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged) +#if wxUSE_MOUSEWHEEL + EVT_MOUSEWHEEL(wxPreviewCanvas::OnMouseWheel) +#endif END_EVENT_TABLE() // VZ: the current code doesn't refresh properly without @@ -669,6 +672,50 @@ void wxPreviewCanvas::OnChar(wxKeyEvent &event) } } +#if wxUSE_MOUSEWHEEL + +void wxPreviewCanvas::OnMouseWheel(wxMouseEvent& event) +{ + wxPreviewControlBar * + controlBar = wxStaticCast(GetParent(), wxPreviewFrame)->GetControlBar(); + + if ( controlBar ) + { + if ( event.ControlDown() && event.GetWheelRotation() != 0 ) + { + int currentZoom = controlBar->GetZoomControl(); + + int delta; + if ( currentZoom < 100 ) + delta = 5; + else if ( currentZoom <= 120 ) + delta = 10; + else + delta = 50; + + if ( event.GetWheelRotation() > 0 ) + delta = -delta; + + int newZoom = currentZoom + delta; + if ( newZoom < 10 ) + newZoom = 10; + if ( newZoom > 200 ) + newZoom = 200; + if ( newZoom != currentZoom ) + { + controlBar->SetZoomControl(newZoom); + m_printPreview->SetZoom(newZoom); + Refresh(); + } + return; + } + } + + event.Skip(); +} + +#endif // wxUSE_MOUSEWHEEL + //---------------------------------------------------------------------------- // wxPreviewControlBar //---------------------------------------------------------------------------- -- 2.45.2