sp-canvas.h revision efeb53ea75db6db7cacd663d1897c213ff87d110
2N/A#ifndef __SP_CANVAS_H__
2N/A#define __SP_CANVAS_H__
2N/A
2N/A/** \file
2N/A * SPCanvas, SPCanvasBuf, and SPCanvasItem.
2N/A *
2N/A * Authors:
2N/A * Federico Mena <federico@nuclecu.unam.mx>
2N/A * Raph Levien <raph@gimp.org>
2N/A * Lauris Kaplinski <lauris@kaplinski.com>
2N/A *
2N/A * Copyright (C) 1998 The Free Software Foundation
2N/A * Copyright (C) 2002 Lauris Kaplinski
2N/A *
2N/A * Released under GNU GPL, read the file 'COPYING' for more information
2N/A */
2N/A
2N/A#ifdef HAVE_CONFIG_H
2N/A# include "config.h"
2N/A#endif
2N/A
2N/A#ifdef HAVE_INTTYPES_H
2N/A# include <inttypes.h>
2N/A#else
2N/A# ifdef HAVE_STDINT_H
2N/A# include <stdint.h>
2N/A# endif
2N/A#endif
2N/A
2N/A#include <glib/gtypes.h>
2N/A#include <gdk/gdkevents.h>
2N/A#include <gdk/gdkgc.h>
2N/A#include <gtk/gtkobject.h>
2N/A#include <gtk/gtkwidget.h>
2N/A
2N/A#include <libnr/nr-matrix.h>
2N/A#include <libnr/nr-rect.h>
2N/A#include <libnr/nr-rect-l.h>
2N/A
2N/Astruct SPCanvas;
2N/Astruct SPCanvasGroup;
2N/A
2N/Aenum {
2N/A SP_CANVAS_UPDATE_REQUESTED = 1 << 0,
2N/A SP_CANVAS_UPDATE_AFFINE = 1 << 1
2N/A};
2N/A
2N/A/**
2N/A * The canvas buf contains the actual pixels.
2N/A */
2N/Astruct SPCanvasBuf{
2N/A guchar *buf;
2N/A int buf_rowstride;
2N/A NRRectL rect;
2N/A NRRectL visible_rect;
2N/A /// Background color, given as 0xrrggbb
2N/A guint32 bg_color;
2N/A // If empty, ignore contents of buffer and use a solid area of bg_color
2N/A bool is_empty;
2N/A};
2N/A
2N/A/**
2N/A * An SPCanvasItem refers to a SPCanvas and to its parent item; it has
2N/A * four coordinates, a bounding rectangle, and a transformation matrix.
2N/A */
2N/Astruct SPCanvasItem : public GtkObject {
2N/A SPCanvas *canvas;
2N/A SPCanvasItem *parent;
2N/A
2N/A double x1, y1, x2, y2;
2N/A NR::Rect bounds;
2N/A NR::Matrix xform;
2N/A};
2N/A
2N/A/**
2N/A * The vtable of an SPCanvasItem.
2N/A */
2N/Astruct SPCanvasItemClass : public GtkObjectClass {
2N/A void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
2N/A
2N/A void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
2N/A double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
2N/A
2N/A int (* event) (SPCanvasItem *item, GdkEvent *event);
2N/A};
2N/A
2N/ASPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...);
2N/A
2N/A#define sp_canvas_item_set gtk_object_set
2N/A
2N/Avoid sp_canvas_item_affine_absolute(SPCanvasItem *item, NR::Matrix const &aff);
2N/A
void sp_canvas_item_raise(SPCanvasItem *item, int positions);
void sp_canvas_item_lower(SPCanvasItem *item, int positions);
void sp_canvas_item_show(SPCanvasItem *item);
void sp_canvas_item_hide(SPCanvasItem *item);
int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime);
void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime);
NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
void sp_canvas_item_grab_focus(SPCanvasItem *item);
void sp_canvas_item_request_update(SPCanvasItem *item);
/* get item z-order in parent group */
gint sp_canvas_item_order(SPCanvasItem * item);
// SPCanvas -------------------------------------------------
/**
* Port of GnomeCanvas for inkscape needs.
*/
struct SPCanvas {
GtkWidget widget;
guint idle_id;
SPCanvasItem *root;
double dx0, dy0;
int x0, y0;
/* Area that needs redrawing, stored as a microtile array */
int tLeft,tTop,tRight,tBottom;
int tileH,tileV;
uint8_t *tiles;
/* Last known modifier state, for deferred repick when a button is down */
int state;
/* The item containing the mouse pointer, or NULL if none */
SPCanvasItem *current_item;
/* Item that is about to become current (used to track deletions and such) */
SPCanvasItem *new_current_item;
/* Item that holds a pointer grab, or NULL if none */
SPCanvasItem *grabbed_item;
/* Event mask specified when grabbing an item */
guint grabbed_event_mask;
/* If non-NULL, the currently focused item */
SPCanvasItem *focused_item;
/* Event on which selection of current item is based */
GdkEvent pick_event;
int close_enough;
/* GC for temporary draw pixmap */
GdkGC *pixmap_gc;
unsigned int need_update : 1;
unsigned int need_redraw : 1;
unsigned int need_repick : 1;
NRRectL redraw_aborted;
long redraw_count;
glong slowest_buffer;
/* For use by internal pick_current_item() function */
unsigned int left_grabbed_item : 1;
/* For use by internal pick_current_item() function */
unsigned int in_repick : 1;
// In most tools Inkscape only generates enter and leave events
// on the current item, but no other enter events if a mouse button
// is depressed -- see function pick_current_item(). Some tools
// may wish the canvas to generate to all enter events, (e.g., the
// connector tool). If so, they may temporarily set this flag to
// 'true'.
bool gen_all_enter_events;
int rendermode;
NR::Rect getViewbox() const;
};
GtkWidget *sp_canvas_new_aa();
SPCanvasGroup *sp_canvas_root(SPCanvas *canvas);
void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear);
void sp_canvas_update_now(SPCanvas *canvas);
void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy);
NR::Point sp_canvas_window_to_world(SPCanvas const *canvas, NR::Point const win);
NR::Point sp_canvas_world_to_window(SPCanvas const *canvas, NR::Point const world);
bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, NR::Point const &world);
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :