summaryrefslogtreecommitdiffstats
path: root/src/svg-view.cpp
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/svg-view.cpp
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/svg-view.cpp')
-rw-r--r--src/svg-view.cpp81
1 files changed, 31 insertions, 50 deletions
diff --git a/src/svg-view.cpp b/src/svg-view.cpp
index b35375736..6eca02d5c 100644
--- a/src/svg-view.cpp
+++ b/src/svg-view.cpp
@@ -1,5 +1,5 @@
-/** \file
- * Functions and callbacks for generic SVG view and widget
+/*
+ * Functions and callbacks for generic SVG view and widget.
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
@@ -13,16 +13,15 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <2geom/transforms.h>
#include "display/canvas-arena.h"
+#include "display/drawing-group.h"
#include "document.h"
#include "sp-item.h"
#include "svg-view.h"
+#include "sp-root.h"
-
-/**
- * Constructs new SPSVGView object and returns pointer to it.
- */
-SPSVGView::SPSVGView (SPCanvasGroup *parent)
+SPSVGView::SPSVGView(SPCanvasGroup *parent)
{
_hscale = 1.0;
_vscale = 1.0;
@@ -40,16 +39,12 @@ SPSVGView::~SPSVGView()
{
if (doc() && _drawing)
{
- SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
+ doc()->getRoot()->invoke_hide(_dkey);
_drawing = NULL;
}
}
-/**
- * Rescales SPSVGView to given proportions.
- */
-void
-SPSVGView::setScale (gdouble hscale, gdouble vscale)
+void SPSVGView::setScale(gdouble hscale, gdouble vscale)
{
if (!_rescale && ((hscale != _hscale) || (vscale != _vscale))) {
_hscale = hscale;
@@ -58,12 +53,7 @@ SPSVGView::setScale (gdouble hscale, gdouble vscale)
}
}
-/**
- * Rescales SPSVGView and keeps aspect ratio.
- */
-void
-SPSVGView::setRescale
-(bool rescale, bool keepaspect, gdouble width, gdouble height)
+void SPSVGView::setRescale(bool rescale, bool keepaspect, gdouble width, gdouble height)
{
g_return_if_fail (!rescale || (width >= 0.0));
g_return_if_fail (!rescale || (height >= 0.0));
@@ -76,15 +66,17 @@ SPSVGView::setRescale
doRescale (true);
}
-/**
- * Helper function that sets rescale ratio and emits resize event.
- */
-void
-SPSVGView::doRescale (bool event)
+void SPSVGView::doRescale(bool event)
{
- if (!doc()) return;
- if (doc()->getWidth () < 1e-9) return;
- if (doc()->getHeight () < 1e-9) return;
+ if (!doc()) {
+ return;
+ }
+ if (doc()->getWidth () < 1e-9) {
+ return;
+ }
+ if (doc()->getHeight () < 1e-9) {
+ return;
+ }
if (_rescale) {
_hscale = _width / doc()->getWidth ();
@@ -108,16 +100,14 @@ SPSVGView::doRescale (bool event)
}
}
-void
-SPSVGView::mouseover()
+void SPSVGView::mouseover()
{
GdkCursor *cursor = gdk_cursor_new(GDK_HAND2);
gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, cursor);
gdk_cursor_unref(cursor);
}
-void
-SPSVGView::mouseout()
+void SPSVGView::mouseout()
{
gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, NULL);
}
@@ -127,14 +117,13 @@ SPSVGView::mouseout()
* Callback connected with arena_event.
*/
/// \todo fixme.
-static gint
-arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVGView *svgview)
+static gint arena_handler(SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPSVGView *svgview)
{
static gdouble x, y;
static gboolean active = FALSE;
SPEvent spev;
- SPItem *spitem = (ai) ? (SPItem*)NR_ARENA_ITEM_GET_DATA (ai) : 0;
+ SPItem *spitem = (ai) ? (SPItem*) ai->data() : 0;
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -183,14 +172,10 @@ arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVG
return TRUE;
}
-/**
- * Callback connected with set_document signal.
- */
-void
-SPSVGView::setDocument (SPDocument *document)
+void SPSVGView::setDocument(SPDocument *document)
{
if (doc()) {
- SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
+ doc()->getRoot()->invoke_hide(_dkey);
}
if (!_drawing) {
@@ -198,27 +183,23 @@ SPSVGView::setDocument (SPDocument *document)
g_signal_connect (G_OBJECT (_drawing), "arena_event", G_CALLBACK (arena_handler), this);
}
+ View::setDocument (document);
+
if (document) {
- NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show(
- SP_CANVAS_ARENA (_drawing)->arena,
+ Inkscape::DrawingItem *ai = document->getRoot()->invoke_show(
+ SP_CANVAS_ARENA (_drawing)->drawing,
_dkey,
SP_ITEM_SHOW_DISPLAY);
if (ai) {
- nr_arena_item_add_child (SP_CANVAS_ARENA (_drawing)->root, ai, NULL);
+ SP_CANVAS_ARENA (_drawing)->drawing.root()->prependChild(ai);
}
doRescale (!_rescale);
}
-
- View::setDocument (document);
}
-/**
- * Callback connected with document_resized signal.
- */
-void
-SPSVGView::onDocumentResized (gdouble width, gdouble height)
+void SPSVGView::onDocumentResized(gdouble width, gdouble height)
{
setScale (width, height);
doRescale (!_rescale);