1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /** 3 * @file 4 * A light-weight widget containing an SPCanvas with for rendering an SVG. 5 */ 6 /* 7 * Authors: 8 * Tavmjong Bah <tavmjong@free.fr> 9 * 10 * Copyright (C) 2018 Authors 11 * 12 * The contents of this file may be used under the GNU General Public License Version 2 or later. 13 * Read the file 'COPYING' for more information. 14 * 15 */ 16 17 #ifndef INKSCAPE_UI_SVG_VIEW_WIDGET_VARIATIONS_H 18 #define INKSCAPE_UI_SVG_VIEW_WIDGET_VARIATIONS_H 19 20 21 #include <gtkmm.h> 22 23 class SPDocument; 24 25 namespace Inkscape { 26 27 class CanvasItemDrawing; 28 class CanvasItemGroup; 29 30 namespace UI { 31 32 namespace Widget { 33 class Canvas; 34 } 35 36 namespace View { 37 38 /** 39 * A light-weight widget containing an Inkscape canvas for rendering an SVG. 40 */ 41 class SVGViewWidget : public Gtk::ScrolledWindow { 42 43 public: 44 SVGViewWidget(SPDocument* document); 45 ~SVGViewWidget() override; 46 void setDocument( SPDocument* document); 47 void setResize( int width, int height); 48 void on_size_allocate(Gtk::Allocation& allocation) override; 49 50 private: 51 52 Inkscape::UI::Widget::Canvas *_canvas; 53 54 // From SVGView --------------------------------- 55 56 public: 57 SPDocument* _document = nullptr; 58 unsigned int _dkey = 0; 59 Inkscape::CanvasItemGroup *_parent = nullptr; 60 Inkscape::CanvasItemDrawing *_drawing = nullptr; 61 Gtk::Allocation _allocation; 62 double _hscale = 1.0; ///< horizontal scale 63 double _vscale = 1.0; ///< vertical scale 64 bool _rescale = false; ///< whether to rescale automatically 65 bool _keepaspect = false; 66 double _width = 0.0; 67 double _height = 0.0; 68 69 /** 70 * Helper function that sets rescale ratio. 71 */ 72 void doRescale(); 73 74 /** 75 * Change cursor (used for links). 76 */ 77 void mouseover(); 78 void mouseout(); 79 80 }; 81 82 } // Namespace View 83 } // Namespace UI 84 } // Namespace Inkscape 85 86 #endif // INKSCAPE_UI_SVG_VIEW_WIDGET 87 88 /* 89 Local Variables: 90 mode:c++ 91 c-file-style:"stroustrup" 92 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 93 indent-tabs-mode:nil 94 fill-column:99 95 End: 96 */ 97 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : 98