sp-canvas.h revision 50552708bc144fdd1d09e2057b3890d998c92136
341N/A#ifndef SEEN_SP_CANVAS_H
341N/A#define SEEN_SP_CANVAS_H
341N/A
341N/A/**
341N/A * @file
341N/A * SPCanvas, SPCanvasBuf.
341N/A */
341N/A/*
341N/A * Authors:
341N/A * Federico Mena <federico@nuclecu.unam.mx>
341N/A * Raph Levien <raph@gimp.org>
341N/A * Lauris Kaplinski <lauris@kaplinski.com>
341N/A * Jon A. Cruz <jon@joncruz.org>
341N/A *
341N/A * Copyright (C) 1998 The Free Software Foundation
341N/A * Copyright (C) 2002 Lauris Kaplinski
341N/A *
341N/A * Released under GNU GPL, read the file 'COPYING' for more information
341N/A */
341N/A
341N/A#ifdef HAVE_CONFIG_H
341N/A# include "config.h"
341N/A#endif
341N/A
341N/A#ifdef HAVE_INTTYPES_H
341N/A# include <inttypes.h>
341N/A#else
341N/A# ifdef HAVE_STDINT_H
341N/A# include <stdint.h>
341N/A# endif
341N/A#endif
341N/A
341N/A#include <glib.h>
341N/A#include <gdk/gdk.h>
341N/A#include <gtk/gtk.h>
341N/A#include <glibmm/ustring.h>
341N/A#include <2geom/affine.h>
341N/A#include <2geom/rect.h>
341N/A
341N/AG_BEGIN_DECLS
341N/A
341N/A#define SP_TYPE_CANVAS (sp_canvas_get_type())
341N/A#define SP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_CANVAS, SPCanvas))
341N/A#define SP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CANVAS))
341N/A
341N/Astruct SPCanvas;
341N/Astruct SPCanvasItem;
341N/Astruct SPCanvasGroup;
341N/A
341N/Aenum {
341N/A SP_CANVAS_UPDATE_REQUESTED = 1 << 0,
341N/A SP_CANVAS_UPDATE_AFFINE = 1 << 1
341N/A};
341N/A
341N/A/**
341N/A * Structure used when rendering canvas items.
341N/A */
341N/Astruct SPCanvasBuf {
341N/A cairo_t *ct;
341N/A Geom::IntRect rect;
341N/A Geom::IntRect visible_rect;
341N/A
341N/A unsigned char *buf;
341N/A int buf_rowstride;
341N/A bool is_empty;
341N/A};
341N/A
341N/AG_END_DECLS
341N/A
341N/A// SPCanvas -------------------------------------------------
341N/A
341N/Aclass SPCanvasImpl;
341N/A
341N/AGType sp_canvas_get_type() G_GNUC_CONST;
341N/A
341N/A/**
341N/A * Port of GnomeCanvas for inkscape needs.
341N/A */
341N/Astruct SPCanvas {
341N/A friend class SPCanvasImpl;
341N/A
341N/A /**
341N/A * Returns new canvas as widget.
341N/A */
341N/A static GtkWidget *createAA();
341N/A
341N/A /**
341N/A * Returns the root group of the specified canvas.
341N/A */
341N/A SPCanvasGroup *getRoot();
341N/A
341N/A /**
341N/A * Scrolls canvas to specific position (cx and cy are measured in screen pixels).
341N/A */
341N/A void scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling = false);
341N/A
341N/A
341N/A /**
341N/A * Updates canvas if necessary.
341N/A */
341N/A void updateNow();
341N/A
341N/A /**
341N/A * Forces redraw of rectangular canvas area.
341N/A */
341N/A void requestRedraw(int x1, int y1, int x2, int y2);
341N/A
341N/A /**
341N/A * Force a full redraw after a specified number of interrupted redraws.
341N/A */
341N/A void forceFullRedrawAfterInterruptions(unsigned int count);
341N/A
341N/A /**
341N/A * End forced full redraw requests.
341N/A */
341N/A void endForcedFullRedraws();
341N/A
341N/A
341N/A // Data members: ----------------------------------------------------------
341N/A
341N/A GtkWidget widget;
341N/A
341N/A guint idle_id;
341N/A
341N/A SPCanvasItem *root;
341N/A
341N/A bool is_dragging;
341N/A double dx0;
341N/A double dy0;
341N/A int x0;
341N/A int y0;
341N/A
341N/A /* Area that needs redrawing, stored as a microtile array */
341N/A int tLeft, tTop, tRight, tBottom;
341N/A int tileH, tileV;
341N/A uint8_t *tiles;
341N/A
341N/A /** Last known modifier state, for deferred repick when a button is down. */
341N/A int state;
341N/A
341N/A /** The item containing the mouse pointer, or NULL if none. */
341N/A SPCanvasItem *current_item;
341N/A
341N/A /** Item that is about to become current (used to track deletions and such). */
341N/A SPCanvasItem *new_current_item;
341N/A
341N/A /** Item that holds a pointer grab, or NULL if none. */
341N/A SPCanvasItem *grabbed_item;
341N/A
341N/A /** Event mask specified when grabbing an item. */
341N/A guint grabbed_event_mask;
341N/A
341N/A /** If non-NULL, the currently focused item. */
341N/A SPCanvasItem *focused_item;
341N/A
341N/A /** Event on which selection of current item is based. */
341N/A GdkEvent pick_event;
341N/A
341N/A int close_enough;
341N/A
341N/A unsigned int need_update : 1;
341N/A unsigned int need_redraw : 1;
341N/A unsigned int need_repick : 1;
341N/A
341N/A int forced_redraw_count;
341N/A int forced_redraw_limit;
341N/A
341N/A /** For use by internal pick_current_item() function. */
341N/A unsigned int left_grabbed_item : 1;
341N/A
341N/A /** For use by internal pick_current_item() function. */
341N/A unsigned int in_repick : 1;
341N/A
341N/A // In most tools Inkscape only generates enter and leave events
341N/A // on the current item, but no other enter events if a mouse button
341N/A // is depressed -- see function pick_current_item(). Some tools
341N/A // may wish the canvas to generate to all enter events, (e.g., the
341N/A // connector tool). If so, they may temporarily set this flag to
341N/A // 'true'.
341N/A bool gen_all_enter_events;
341N/A
341N/A /** For scripting, sometimes we want to delay drawing. */
341N/A bool drawing_disabled;
341N/A
341N/A int rendermode;
341N/A int colorrendermode;
341N/A
341N/A#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
341N/A bool enable_cms_display_adj;
341N/A Glib::ustring cms_key;
341N/A#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2)
341N/A
341N/A bool is_scrolling;
341N/A
341N/A Geom::Rect getViewbox() const;
341N/A Geom::IntRect getViewboxIntegers() const;
341N/A};
341N/A
341N/Abool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world);
341N/A
341N/Avoid sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
341N/Avoid sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy);
341N/A
341N/AGeom::Point sp_canvas_window_to_world(SPCanvas const *canvas, Geom::Point const win);
341N/AGeom::Point sp_canvas_world_to_window(SPCanvas const *canvas, Geom::Point const world);
341N/A
341N/A#endif // SEEN_SP_CANVAS_H
341N/A
341N/A/*
341N/A Local Variables:
341N/A mode:c++
341N/A c-file-style:"stroustrup"
341N/A c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
341N/A indent-tabs-mode:nil
341N/A fill-column:99
341N/A End:
341N/A*/
341N/A// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
341N/A