diff --git a/src/svg-view.cpp b/src/svg-view.cpp
index 6d408e79c62cc533e7e470a139b91ddddc863203..b35375736131a32b6dda884cad0a182558a29551 100644 (file)
--- a/src/svg-view.cpp
+++ b/src/svg-view.cpp
-#define __SP_SVG_VIEW_C__
-
/** \file
* Functions and callbacks for generic SVG view and widget
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Ralf Stephan <ralf@ark.in-berlin.de>
/** \file
* Functions and callbacks for generic SVG view and widget
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Ralf Stephan <ralf@ark.in-berlin.de>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
*/
#include "display/canvas-arena.h"
*/
#include "display/canvas-arena.h"
-#include "display/display-forward.h"
#include "document.h"
#include "sp-item.h"
#include "svg-view.h"
#include "document.h"
#include "sp-item.h"
#include "svg-view.h"
SPSVGView::~SPSVGView()
{
SPSVGView::~SPSVGView()
{
- if (doc() && _drawing)
+ if (doc() && _drawing)
{
{
- sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey);
+ SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
_drawing = NULL;
}
}
_drawing = NULL;
}
}
* Rescales SPSVGView and keeps aspect ratio.
*/
void
* Rescales SPSVGView and keeps aspect ratio.
*/
void
-SPSVGView::setRescale
+SPSVGView::setRescale
(bool rescale, bool keepaspect, gdouble width, gdouble height)
{
g_return_if_fail (!rescale || (width >= 0.0));
(bool rescale, bool keepaspect, gdouble width, gdouble height)
{
g_return_if_fail (!rescale || (width >= 0.0));
SPSVGView::doRescale (bool event)
{
if (!doc()) return;
SPSVGView::doRescale (bool event)
{
if (!doc()) return;
- if (sp_document_width (doc()) < 1e-9) return;
- if (sp_document_height (doc()) < 1e-9) return;
+ if (doc()->getWidth () < 1e-9) return;
+ if (doc()->getHeight () < 1e-9) return;
if (_rescale) {
if (_rescale) {
- _hscale = _width / sp_document_width (doc());
- _vscale = _height / sp_document_height (doc());
+ _hscale = _width / doc()->getWidth ();
+ _vscale = _height / doc()->getHeight ();
if (_keepaspect) {
if (_hscale > _vscale) {
_hscale = _vscale;
if (_keepaspect) {
if (_hscale > _vscale) {
_hscale = _vscale;
}
if (_drawing) {
}
if (_drawing) {
- sp_canvas_item_affine_absolute (_drawing, NR::Matrix(NR::scale(_hscale, _vscale)));
+ sp_canvas_item_affine_absolute (_drawing, Geom::Scale(_hscale, _vscale));
}
if (event) {
}
if (event) {
- emitResized (sp_document_width (doc()) * _hscale,
- sp_document_height (doc()) * _vscale);
+ emitResized (doc()->getWidth () * _hscale,
+ doc()->getHeight () * _vscale);
}
}
}
}
{
GdkCursor *cursor = gdk_cursor_new(GDK_HAND2);
gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, cursor);
{
GdkCursor *cursor = gdk_cursor_new(GDK_HAND2);
gdk_window_set_cursor(GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)->window, cursor);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
}
void
}
void
*/
/// \todo fixme.
static gint
*/
/// \todo fixme.
static gint
-arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPSVGView *svgview)
+arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPSVGView *svgview)
{
static gdouble x, y;
static gboolean active = FALSE;
SPEvent spev;
{
static gdouble x, y;
static gboolean active = FALSE;
SPEvent spev;
- SPItem *spitem = (ai) ? (SPItem*)NR_ARENA_ITEM_GET_DATA (ai) : NULL;
+ SPItem *spitem = (ai) ? (SPItem*)NR_ARENA_ITEM_GET_DATA (ai) : 0;
switch (event->type) {
case GDK_BUTTON_PRESS:
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -147,10 +146,14 @@ arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPSVGView
break;
case GDK_BUTTON_RELEASE:
if (event->button.button == 1) {
break;
case GDK_BUTTON_RELEASE:
if (event->button.button == 1) {
- if (active && (event->button.x == x) && (event->button.y == y)) {
+ if (active && (event->button.x == x) &&
+ (event->button.y == y)) {
spev.type = SP_EVENT_ACTIVATE;
spev.type = SP_EVENT_ACTIVATE;
- sp_item_event (spitem, &spev);
- }
+ if ( spitem != 0 )
+ {
+ spitem->emitEvent (spev);
+ }
+ }
}
active = FALSE;
break;
}
active = FALSE;
break;
@@ -160,12 +163,18 @@ arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPSVGView
case GDK_ENTER_NOTIFY:
spev.type = SP_EVENT_MOUSEOVER;
spev.data = svgview;
case GDK_ENTER_NOTIFY:
spev.type = SP_EVENT_MOUSEOVER;
spev.data = svgview;
- sp_item_event (spitem, &spev);
+ if ( spitem != 0 )
+ {
+ spitem->emitEvent (spev);
+ }
break;
case GDK_LEAVE_NOTIFY:
spev.type = SP_EVENT_MOUSEOUT;
spev.data = svgview;
break;
case GDK_LEAVE_NOTIFY:
spev.type = SP_EVENT_MOUSEOUT;
spev.data = svgview;
- sp_item_event (spitem, &spev);
+ if ( spitem != 0 )
+ {
+ spitem->emitEvent (spev);
+ }
break;
default:
break;
break;
default:
break;
SPSVGView::setDocument (SPDocument *document)
{
if (doc()) {
SPSVGView::setDocument (SPDocument *document)
{
if (doc()) {
- sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), _dkey);
+ SP_ITEM( doc()->getRoot() )->invoke_hide(_dkey);
}
if (!_drawing) {
}
if (!_drawing) {
}
if (document) {
}
if (document) {
- NRArenaItem *ai = sp_item_invoke_show (
- SP_ITEM (sp_document_root (document)),
+ NRArenaItem *ai = SP_ITEM( document->getRoot() )->invoke_show(
SP_CANVAS_ARENA (_drawing)->arena,
SP_CANVAS_ARENA (_drawing)->arena,
- _dkey,
+ _dkey,
SP_ITEM_SHOW_DISPLAY);
SP_ITEM_SHOW_DISPLAY);
-
+
if (ai) {
nr_arena_item_add_child (SP_CANVAS_ARENA (_drawing)->root, ai, NULL);
if (ai) {
nr_arena_item_add_child (SP_CANVAS_ARENA (_drawing)->root, ai, NULL);
- nr_arena_item_unref (ai);
}
doRescale (!_rescale);
}
doRescale (!_rescale);