![]() |
![]() |
![]() |
GNOME Canvas Library Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
#include <libgnomecanvas/libgnomecanvas.h> struct GnomeCanvas; #define GNOME_CANVAS_EPSILON #define GNOME_CANVAS_COLOR (r, g, b) #define GNOME_CANVAS_COLOR_A (r, g, b, a) GnomeCanvasBuf; GtkWidget * gnome_canvas_new (void
); GtkWidget * gnome_canvas_new_aa (void
); GnomeCanvasGroup * gnome_canvas_root (GnomeCanvas *canvas
); void gnome_canvas_set_scroll_region (GnomeCanvas *canvas
,double x1
,double y1
,double x2
,double y2
); void gnome_canvas_get_scroll_region (GnomeCanvas *canvas
,double *x1
,double *y1
,double *x2
,double *y2
); void gnome_canvas_set_center_scroll_region (GnomeCanvas *canvas
,gboolean center_scroll_region
); gboolean gnome_canvas_get_center_scroll_region (GnomeCanvas *canvas
); void gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas
,double n
); void gnome_canvas_scroll_to (GnomeCanvas *canvas
,int cx
,int cy
); void gnome_canvas_get_scroll_offsets (GnomeCanvas *canvas
,int *cx
,int *cy
); void gnome_canvas_update_now (GnomeCanvas *canvas
); GnomeCanvasItem * gnome_canvas_get_item_at (GnomeCanvas *canvas
,double x
,double y
); void gnome_canvas_request_redraw_uta (GnomeCanvas *canvas
,ArtUta *uta
); void gnome_canvas_request_redraw (GnomeCanvas *canvas
,int x1
,int y1
,int x2
,int y2
); void gnome_canvas_w2c_affine (GnomeCanvas *canvas
,double affine[6]
); void gnome_canvas_w2c (GnomeCanvas *canvas
,double wx
,double wy
,int *cx
,int *cy
); void gnome_canvas_w2c_d (GnomeCanvas *canvas
,double wx
,double wy
,double *cx
,double *cy
); void gnome_canvas_c2w (GnomeCanvas *canvas
,int cx
,int cy
,double *wx
,double *wy
); void gnome_canvas_window_to_world (GnomeCanvas *canvas
,double winx
,double winy
,double *worldx
,double *worldy
); void gnome_canvas_world_to_window (GnomeCanvas *canvas
,double worldx
,double worldy
,double *winx
,double *winy
); int gnome_canvas_get_color (GnomeCanvas *canvas
,const char *spec
,GdkColor *color
); gulong gnome_canvas_get_color_pixel (GnomeCanvas *canvas
,guint rgba
); void gnome_canvas_set_stipple_origin (GnomeCanvas *canvas
,GdkGC *gc
); void gnome_canvas_set_dither (GnomeCanvas *canvas
,GdkRgbDither dither
); GdkRgbDither gnome_canvas_get_dither (GnomeCanvas *canvas
);
GObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkContainer +----GtkLayout +----GnomeCanvas
"aa" gboolean : Read / Write / Construct Only "focused-item" GnomeCanvasItem* : Read / Write
typedef struct { /* 24-bit RGB buffer for rendering */ guchar *buf; /* Rectangle describing the rendering area */ ArtIRect rect; /* Rowstride for the buffer */ int buf_rowstride; /* Background color, given as 0xrrggbb */ guint32 bg_color; /* Invariant: at least one of the following flags is true. */ /* Set when the render rectangle area is the solid color bg_color */ unsigned int is_bg : 1; /* Set when the render rectangle area is represented by the buf */ unsigned int is_buf : 1; } GnomeCanvasBuf;
GtkWidget * gnome_canvas_new (void
);
Creates a new empty canvas in non-antialiased mode.
Returns : |
A newly-created canvas. |
GtkWidget * gnome_canvas_new_aa (void
);
Creates a new empty canvas in antialiased mode.
Returns : |
A newly-created antialiased canvas. |
GnomeCanvasGroup * gnome_canvas_root (GnomeCanvas *canvas
);
Queries the root group of a canvas.
|
A canvas. |
Returns : |
The root group of the specified canvas. |
void gnome_canvas_set_scroll_region (GnomeCanvas *canvas
,double x1
,double y1
,double x2
,double y2
);
Sets the scrolling region of a canvas to the specified rectangle. The canvas will then be able to scroll only within this region. The view of the canvas is adjusted as appropriate to display as much of the new region as possible.
|
A canvas. |
|
Leftmost limit of the scrolling region. |
|
Upper limit of the scrolling region. |
|
Rightmost limit of the scrolling region. |
|
Lower limit of the scrolling region. |
void gnome_canvas_get_scroll_region (GnomeCanvas *canvas
,double *x1
,double *y1
,double *x2
,double *y2
);
Queries the scrolling region of a canvas.
|
A canvas. |
|
Leftmost limit of the scrolling region (return value). |
|
Upper limit of the scrolling region (return value). |
|
Rightmost limit of the scrolling region (return value). |
|
Lower limit of the scrolling region (return value). |
void gnome_canvas_set_center_scroll_region (GnomeCanvas *canvas
,gboolean center_scroll_region
);
When the scrolling region of the canvas is smaller than the canvas window, e.g. the allocation of the canvas, it can be either centered on the window or simply made to be on the upper-left corner on the window. This function lets you configure this property.
|
A canvas. |
|
Whether to center the scrolling region in the canvas window when it is smaller than the canvas' allocation. |
gboolean gnome_canvas_get_center_scroll_region
(GnomeCanvas *canvas
);
Returns whether the canvas is set to center the scrolling region in the window if the former is smaller than the canvas' allocation.
|
A canvas. |
Returns : |
Whether the scroll region is being centered in the canvas window. |
void gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas
,double n
);
Sets the zooming factor of a canvas by specifying the number of pixels that correspond to one canvas unit.
The anchor point for zooming, i.e. the point that stays fixed and all others
zoom inwards or outwards from it, depends on whether the canvas is set to
center the scrolling region or not. You can control this using the
gnome_canvas_set_center_scroll_region()
function. If the canvas is set to
center the scroll region, then the center of the canvas window is used as the
anchor point for zooming. Otherwise, the upper-left corner of the canvas
window is used as the anchor point.
|
A canvas. |
|
The number of pixels that correspond to one canvas unit. |
void gnome_canvas_scroll_to (GnomeCanvas *canvas
,int cx
,int cy
);
Makes a canvas scroll to the specified offsets, given in canvas pixel units. The canvas will adjust the view so that it is not outside the scrolling region. This function is typically not used, as it is better to hook scrollbars to the canvas layout's scrolling adjusments.
|
A canvas. |
|
Horizontal scrolling offset in canvas pixel units. |
|
Vertical scrolling offset in canvas pixel units. |
void gnome_canvas_get_scroll_offsets (GnomeCanvas *canvas
,int *cx
,int *cy
);
Queries the scrolling offsets of a canvas. The values are returned in canvas pixel units.
|
A canvas. |
|
Horizontal scrolling offset (return value). |
|
Vertical scrolling offset (return value). |
void gnome_canvas_update_now (GnomeCanvas *canvas
);
Forces an immediate update and redraw of a canvas. If the canvas does not have any pending update or redraw requests, then no action is taken. This is typically only used by applications that need explicit control of when the display is updated, like games. It is not needed by normal applications.
|
A canvas. |
GnomeCanvasItem * gnome_canvas_get_item_at (GnomeCanvas *canvas
,double x
,double y
);
Looks for the item that is under the specified position, which must be specified in world coordinates.
|
A canvas. |
|
X position in world coordinates. |
|
Y position in world coordinates. |
Returns : |
The sought item, or NULL if no item is at the specified coordinates. |
void gnome_canvas_request_redraw_uta (GnomeCanvas *canvas
,ArtUta *uta
);
Informs a canvas that the specified area, given as a microtile array, needs to be repainted. To be used only by item implementations.
|
A canvas. |
|
Microtile array that specifies the area to be redrawn. It will be freed by this function, so the argument you pass will be invalid after you call this function. |
void gnome_canvas_request_redraw (GnomeCanvas *canvas
,int x1
,int y1
,int x2
,int y2
);
Convenience function that informs a canvas that the specified rectangle needs
to be repainted. This function converts the rectangle to a microtile array
and feeds it to gnome_canvas_request_redraw_uta()
. The rectangle includes
x1
and y1
, but not x2
and y2
. To be used only by item implementations.
|
A canvas. |
|
Leftmost coordinate of the rectangle to be redrawn. |
|
Upper coordinate of the rectangle to be redrawn. |
|
Rightmost coordinate of the rectangle to be redrawn, plus 1. |
|
Lower coordinate of the rectangle to be redrawn, plus 1. |
void gnome_canvas_w2c_affine (GnomeCanvas *canvas
,double affine[6]
);
Gets the affine transform that converts from world coordinates to canvas pixel coordinates.
|
A canvas. |
|
An affine transformation matrix (return value). |
void gnome_canvas_w2c (GnomeCanvas *canvas
,double wx
,double wy
,int *cx
,int *cy
);
Converts world coordinates into canvas pixel coordinates.
|
A canvas. |
|
World X coordinate. |
|
World Y coordinate. |
|
X pixel coordinate (return value). |
|
Y pixel coordinate (return value). |
void gnome_canvas_w2c_d (GnomeCanvas *canvas
,double wx
,double wy
,double *cx
,double *cy
);
Converts world coordinates into canvas pixel coordinates. This version returns coordinates in floating point coordinates, for greater precision.
|
A canvas. |
|
World X coordinate. |
|
World Y coordinate. |
|
X pixel coordinate (return value). |
|
Y pixel coordinate (return value). |
void gnome_canvas_c2w (GnomeCanvas *canvas
,int cx
,int cy
,double *wx
,double *wy
);
Converts canvas pixel coordinates to world coordinates.
|
A canvas. |
|
Canvas pixel X coordinate. |
|
Canvas pixel Y coordinate. |
|
X world coordinate (return value). |
|
Y world coordinate (return value). |
void gnome_canvas_window_to_world (GnomeCanvas *canvas
,double winx
,double winy
,double *worldx
,double *worldy
);
Converts window-relative coordinates into world coordinates. You can use this when you need to convert mouse coordinates into world coordinates, for example.
|
A canvas. |
|
Window-relative X coordinate. |
|
Window-relative Y coordinate. |
|
X world coordinate (return value). |
|
Y world coordinate (return value). |
void gnome_canvas_world_to_window (GnomeCanvas *canvas
,double worldx
,double worldy
,double *winx
,double *winy
);
Converts world coordinates into window-relative coordinates.
|
A canvas. |
|
World X coordinate. |
|
World Y coordinate. |
|
X window-relative coordinate. |
|
Y window-relative coordinate. |
int gnome_canvas_get_color (GnomeCanvas *canvas
,const char *spec
,GdkColor *color
);
Allocates a color based on the specified X color specification. As a convenience to item implementations, it returns TRUE if the color was allocated, or FALSE if the specification was NULL. A NULL color specification is considered as "transparent" by the canvas.
|
A canvas. |
|
X color specification, or NULL for "transparent". |
|
Returns the allocated color. |
Returns : |
TRUE if spec is non-NULL and the color is allocated. If spec
is NULL, then returns FALSE. |
gulong gnome_canvas_get_color_pixel (GnomeCanvas *canvas
,guint rgba
);
Allocates a color from the RGBA value passed into this function. The alpha opacity value is discarded, since normal X colors do not support it.
|
A canvas. |
|
RGBA color specification. |
Returns : |
Allocated pixel value corresponding to the specified color. |
void gnome_canvas_set_stipple_origin (GnomeCanvas *canvas
,GdkGC *gc
);
Sets the stipple origin of the specified GC as is appropriate for the canvas, so that it will be aligned with other stipple patterns used by canvas items. This is typically only needed by item implementations.
|
A canvas. |
|
GC on which to set the stipple origin. |
void gnome_canvas_set_dither (GnomeCanvas *canvas
,GdkRgbDither dither
);
Controls dithered rendering for antialiased canvases. The value of dither should be GDK_RGB_DITHER_NONE, GDK_RGB_DITHER_NORMAL, or GDK_RGB_DITHER_MAX. The default canvas setting is GDK_RGB_DITHER_NORMAL.
|
A canvas. |
|
Type of dithering used to render an antialiased canvas. |
GdkRgbDither gnome_canvas_get_dither (GnomeCanvas *canvas
);
Returns the type of dithering used to render an antialiased canvas.
|
A canvas. |
Returns : |
The dither setting. |
"aa"
property "aa" gboolean : Read / Write / Construct Only
The antialiasing mode of the canvas.
Default value: FALSE
"draw-background"
signalvoid user_function (GnomeCanvas *canvas,
GdkDrawable *arg1,
gint arg2,
gint arg3,
gint arg4,
gint arg5,
gpointer user_data) : Run Last
"render-background"
signalvoid user_function (GnomeCanvas *canvas,
gpointer arg1,
gpointer user_data) : Run Last