~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/svg-view-widget.cpp

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define __SP_SVG_VIEW_C__
2
 
 
3
1
/** \file
4
2
 * Functions and callbacks for generic SVG view and widget
5
3
 *
6
4
 * Authors:
7
5
 *   Lauris Kaplinski <lauris@kaplinski.com>
8
6
 *   Ralf Stephan <ralf@ark.in-berlin.de>
 
7
 *   Abhishek Sharma
 
8
 *   Jon A. Cruz <jon@joncruz.org>
9
9
 *
 
10
 * Copyright (C) 2010 authors
10
11
 * Copyright (C) 2001-2002 Lauris Kaplinski
11
12
 * Copyright (C) 2001 Ximian, Inc.
12
13
 *
13
14
 * Released under GNU GPL, read the file 'COPYING' for more information
14
15
 */
15
16
 
16
 
#include <gtk/gtkscrolledwindow.h>
 
17
#include <gtk/gtk.h>
 
18
#include "display/sp-canvas.h"
 
19
#include "display/sp-canvas-group.h"
17
20
#include "display/canvas-arena.h"
18
21
#include "document.h"
19
22
#include "svg-view.h"
60
63
static void
61
64
sp_svg_view_widget_class_init (SPSVGSPViewWidgetClass *klass)
62
65
{
63
 
        GtkObjectClass *object_class;
64
 
        GtkWidgetClass *widget_class;
65
 
        SPViewWidgetClass *vw_class;
66
 
 
67
 
        object_class = GTK_OBJECT_CLASS (klass);
68
 
        widget_class = GTK_WIDGET_CLASS (klass);
69
 
        vw_class = SP_VIEW_WIDGET_CLASS (klass);
70
 
 
71
 
        widget_parent_class = (SPViewWidgetClass*)gtk_type_class (SP_TYPE_VIEW_WIDGET);
 
66
        GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
 
67
        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
68
        SPViewWidgetClass *vw_class = SP_VIEW_WIDGET_CLASS (klass);
 
69
 
 
70
        widget_parent_class = (SPViewWidgetClass *)g_type_class_peek_parent (klass);
72
71
 
73
72
        object_class->destroy = sp_svg_view_widget_destroy;
74
73
 
100
99
        gtk_widget_show (vw->sw);
101
100
 
102
101
        /* Canvas */
103
 
        gtk_widget_push_visual (gdk_rgb_get_visual ());
104
102
        gtk_widget_push_colormap (gdk_rgb_get_cmap ());
105
103
        vw->canvas = sp_canvas_new_aa ();
106
104
        gtk_widget_pop_colormap ();
107
 
        gtk_widget_pop_visual ();
108
105
        style = gtk_style_copy (vw->canvas->style);
109
106
        style->bg[GTK_STATE_NORMAL] = style->white;
110
107
        gtk_widget_set_style (vw->canvas, style);
149
146
                gdouble width, height;
150
147
 
151
148
                svgv = static_cast<SPSVGView*> (v);
152
 
                width = sp_document_width (v->doc()) * svgv->_hscale;
153
 
                height = sp_document_height (v->doc()) * svgv->_vscale;
 
149
                width = (v->doc())->getWidth () * svgv->_hscale;
 
150
                height = (v->doc())->getHeight () * svgv->_vscale;
154
151
 
155
152
                if (width <= vw->maxwidth) {
156
153
                        hpol = GTK_POLICY_NEVER;
211
208
 
212
209
        g_return_val_if_fail (doc != NULL, NULL);
213
210
 
214
 
        widget = (GtkWidget*)gtk_type_new (SP_TYPE_SVG_VIEW_WIDGET);
 
211
        widget = (GtkWidget*)g_object_new (SP_TYPE_SVG_VIEW_WIDGET, NULL);
215
212
 
216
213
        reinterpret_cast<SPSVGView*>(SP_VIEW_WIDGET_VIEW (widget))->setDocument (doc);
217
214
 
221
218
/**
222
219
 * Flags the SPSVGSPViewWidget to have its size renegotiated with Gtk.
223
220
 */
224
 
void
225
 
sp_svg_view_widget_set_resize (SPSVGSPViewWidget *vw, bool resize, gdouble width, gdouble height)
 
221
void SPSVGSPViewWidget::setResize(bool resize, gdouble width, gdouble height)
226
222
{
227
 
        g_return_if_fail (vw != NULL);
228
 
 
229
 
        g_return_if_fail (SP_IS_SVG_VIEW_WIDGET (vw));
230
 
        g_return_if_fail (!resize || (width > 0.0));
231
 
        g_return_if_fail (!resize || (height > 0.0));
232
 
 
233
 
        vw->resize = resize;
234
 
        vw->maxwidth = width;
235
 
        vw->maxheight = height;
236
 
 
237
 
        if (resize) {
238
 
                gtk_widget_queue_resize (GTK_WIDGET (vw));
239
 
        }
 
223
    g_return_if_fail( !resize || (width > 0.0) );
 
224
    g_return_if_fail( !resize || (height > 0.0) );
 
225
 
 
226
    this->resize = resize;
 
227
    this->maxwidth = width;
 
228
    this->maxheight = height;
 
229
 
 
230
    if ( resize ) {
 
231
        gtk_widget_queue_resize( GTK_WIDGET(this) );
 
232
    }
240
233
}
241
234
 
242
235