]> git.saurik.com Git - wxWidgets.git/commitdiff
Ctrl+mouse wheel changes zoom factor in print preview (patch 1230919)
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 28 Jul 2005 22:20:06 +0000 (22:20 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 28 Jul 2005 22:20:06 +0000 (22:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/prntbase.h
src/common/prntbase.cpp

index f7255eb89c00db9250c4e9bc2bcb2f170e3f62bb..3ff1e4fbb494615ad4c7e9facc2e442879e8ed11 100644 (file)
@@ -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:
 
index 43b6c7cf9e8a143484483a11895ce63f0ea75a3e..290a10851fbef36bc0804f7e981ea8c80a6eb95d 100644 (file)
@@ -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)
index b3f2e48a3ddcaca8c5e37815eec22717f3f52b3e..a2cf6496206ce20c21f4b4827ad8b1ed0723cccf 100644 (file)
@@ -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
 //----------------------------------------------------------------------------