GimpCanvas

GimpCanvas

Synopsis

                    GimpCanvas;
enum                GimpCanvasStyle;
#define             GIMP_CANVAS_NUM_STIPPLES
GtkWidget*          gimp_canvas_new                     (GimpDisplayConfig *config);
void                gimp_canvas_draw_cursor             (GimpCanvas *canvas,
                                                         gint x,
                                                         gint y);
void                gimp_canvas_draw_point              (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y);
void                gimp_canvas_draw_points             (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkPoint *points,
                                                         gint num_points);
void                gimp_canvas_draw_line               (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x1,
                                                         gint y1,
                                                         gint x2,
                                                         gint y2);
void                gimp_canvas_draw_lines              (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkPoint *points,
                                                         gint num_points);
void                gimp_canvas_draw_rectangle          (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);
void                gimp_canvas_draw_arc                (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height,
                                                         gint angle1,
                                                         gint angle2);
void                gimp_canvas_draw_polygon            (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         GdkPoint *points,
                                                         gint num_points);
void                gimp_canvas_draw_segments           (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkSegment *segments,
                                                         gint num_segments);
void                gimp_canvas_draw_text               (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y,
                                                         const gchar *format,
                                                         ...);
void                gimp_canvas_draw_rgb                (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height,
                                                         guchar *rgb_buf,
                                                         gint rowstride,
                                                         gint xdith,
                                                         gint ydith);
void                gimp_canvas_draw_drop_zone          (GimpCanvas *canvas,
                                                         cairo_t *cr);
void                gimp_canvas_set_clip_rect           (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkRectangle *rect);
void                gimp_canvas_set_clip_region         (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkRegion *region);
void                gimp_canvas_set_custom_gc           (GimpCanvas *canvas,
                                                         GdkGC *gc);
void                gimp_canvas_set_stipple_index       (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         guint index);
void                gimp_canvas_set_bg_color            (GimpCanvas *canvas,
                                                         GimpRGB *color);
void                gimp_canvas_scroll                  (GimpCanvas *canvas,
                                                         gint offset_x,
                                                         gint offset_y);

Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GimpCanvas

Implemented Interfaces

GimpCanvas implements AtkImplementorIface and GtkBuildable.

Properties

  "config"                   GimpDisplayConfig*    : Read / Write / Construct Only

Description

Details

GimpCanvas

typedef struct _GimpCanvas GimpCanvas;


enum GimpCanvasStyle

typedef enum
{
  GIMP_CANVAS_STYLE_BLACK,
  GIMP_CANVAS_STYLE_WHITE,
  GIMP_CANVAS_STYLE_RENDER,
  GIMP_CANVAS_STYLE_XOR,
  GIMP_CANVAS_STYLE_XOR_DASHED,
  GIMP_CANVAS_STYLE_XOR_DOTTED,
  GIMP_CANVAS_STYLE_SELECTION_IN,
  GIMP_CANVAS_STYLE_SELECTION_OUT,
  GIMP_CANVAS_STYLE_LAYER_BOUNDARY,
  GIMP_CANVAS_STYLE_GUIDE_NORMAL,
  GIMP_CANVAS_STYLE_GUIDE_ACTIVE,
  GIMP_CANVAS_STYLE_SAMPLE_POINT_NORMAL,
  GIMP_CANVAS_STYLE_SAMPLE_POINT_ACTIVE,
  GIMP_CANVAS_STYLE_LAYER_MASK_ACTIVE,
  GIMP_CANVAS_STYLE_CUSTOM,
  GIMP_CANVAS_NUM_STYLES
} GimpCanvasStyle;


GIMP_CANVAS_NUM_STIPPLES

#define GIMP_CANVAS_NUM_STIPPLES  8


gimp_canvas_new ()

GtkWidget*          gimp_canvas_new                     (GimpDisplayConfig *config);

Creates a new GimpCanvas widget.

The GimpCanvas widget is a GtkDrawingArea abstraction. It manages a set of graphic contexts for drawing on a GIMP display. If you draw using a GimpCanvasStyle, GimpCanvas makes sure that the associated GdkGC is created. All drawing on the canvas needs to happen by means of the GimpCanvas drawing functions. Besides from not needing a GdkGC pointer, the GimpCanvas drawing functions look and work like their GdkDrawable counterparts. GimpCanvas gracefully handles attempts to draw on the unrealized widget.

config :

Returns :

a new GimpCanvas widget

gimp_canvas_draw_cursor ()

void                gimp_canvas_draw_cursor             (GimpCanvas *canvas,
                                                         gint x,
                                                         gint y);

Draws a plus-shaped black and white cursor, centered at the point x, y.

canvas :

the GimpCanvas widget to draw on.

x :

x coordinate

y :

y coordinate

gimp_canvas_draw_point ()

void                gimp_canvas_draw_point              (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y);

Draw a single pixel at the specified location in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

x :

x coordinate

y :

y coordinate

gimp_canvas_draw_points ()

void                gimp_canvas_draw_points             (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkPoint *points,
                                                         gint num_points);

Draws a set of one-pixel points at the locations given in the points argument, in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

points :

an array of GdkPoint x-y pairs.

num_points :

the number of points in the array

gimp_canvas_draw_line ()

void                gimp_canvas_draw_line               (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x1,
                                                         gint y1,
                                                         gint x2,
                                                         gint y2);

Draw a line connecting the specified points, using the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

x1 :

X coordinate of the first point

y1 :

Y coordinate of the first point

x2 :

X coordinate of the second point

y2 :

Y coordinate of the second point

gimp_canvas_draw_lines ()

void                gimp_canvas_draw_lines              (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkPoint *points,
                                                         gint num_points);

Draws a set of lines connecting the specified points, in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

points :

a GdkPoint array.

num_points :

the number of points in the array.

gimp_canvas_draw_rectangle ()

void                gimp_canvas_draw_rectangle          (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height);

Draws a rectangle in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

filled :

TRUE if the rectangle is to be filled.

x :

X coordinate of the upper left corner.

y :

Y coordinate of the upper left corner.

width :

width of the rectangle.

height :

height of the rectangle.

gimp_canvas_draw_arc ()

void                gimp_canvas_draw_arc                (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height,
                                                         gint angle1,
                                                         gint angle2);

Draws an arc or pie slice, in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

filled :

TRUE if the arc is to be filled, producing a 'pie slice'.

x :

X coordinate of the left edge of the bounding rectangle.

y :

Y coordinate of the top edge of the bounding rectangle.

width :

width of the bounding rectangle.

height :

height of the bounding rectangle.

angle1 :

the start angle of the arc.

angle2 :

the end angle of the arc.

gimp_canvas_draw_polygon ()

void                gimp_canvas_draw_polygon            (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gboolean filled,
                                                         GdkPoint *points,
                                                         gint num_points);

Draws a polygon connecting the specified points, in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

filled :

if TRUE, fill the polygon.

points :

a GdkPoint array.

num_points :

the number of points in the array.

gimp_canvas_draw_segments ()

void                gimp_canvas_draw_segments           (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkSegment *segments,
                                                         gint num_segments);

Draws a set of line segments in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

segments :

a GdkSegment array.

num_segments :

the number of segments in the array.

gimp_canvas_draw_text ()

void                gimp_canvas_draw_text               (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y,
                                                         const gchar *format,
                                                         ...);

Draws a layout, in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

x :

X coordinate of the left of the layout.

y :

Y coordinate of the top of the layout.

format :

a standard printf() format string.

... :

the parameters to insert into the format string.

gimp_canvas_draw_rgb ()

void                gimp_canvas_draw_rgb                (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         gint x,
                                                         gint y,
                                                         gint width,
                                                         gint height,
                                                         guchar *rgb_buf,
                                                         gint rowstride,
                                                         gint xdith,
                                                         gint ydith);

Draws an RGB image on the canvas in the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

x :

X coordinate of the upper left corner.

y :

Y coordinate of the upper left corner.

width :

width of the rectangle to be drawn.

height :

height of the rectangle to be drawn.

rgb_buf :

pixel data for the image to be drawn.

rowstride :

the rowstride in rgb_buf.

xdith :

x offset for dither alignment.

ydith :

y offset for dither alignment.

gimp_canvas_draw_drop_zone ()

void                gimp_canvas_draw_drop_zone          (GimpCanvas *canvas,
                                                         cairo_t *cr);

canvas :

cr :


gimp_canvas_set_clip_rect ()

void                gimp_canvas_set_clip_rect           (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkRectangle *rect);

Sets a rectangular clipping area for the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

rect :

a GdkRectangle to set the bounds of the clipping area.

gimp_canvas_set_clip_region ()

void                gimp_canvas_set_clip_region         (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         GdkRegion *region);

Sets a clipping region for the specified style.

canvas :

a GimpCanvas widget

style :

one of the enumerated GimpCanvasStyle's.

region :

a GdkRegion to set the bounds of the clipping area.

gimp_canvas_set_custom_gc ()

void                gimp_canvas_set_custom_gc           (GimpCanvas *canvas,
                                                         GdkGC *gc);

The GimpCanvas widget has an extra style for a custom GdkGC. This function allows you to set the gc for the GIMP_CANVAS_STYLE_CUSTOM. Drawing with the custom style only works if you set a GdkGC earlier. Since the custom GdkGC can under certain circumstances be destroyed by GimpCanvas, you should always set the custom gc before calling a GimpCanvas drawing function with GIMP_CANVAS_STYLE_CUSTOM.

canvas :

a GimpCanvas widget

gc :

a GdkGC;

gimp_canvas_set_stipple_index ()

void                gimp_canvas_set_stipple_index       (GimpCanvas *canvas,
                                                         GimpCanvasStyle style,
                                                         guint index);

Some styles of the GimpCanvas do a stipple fill. GimpCanvas has a set of GIMP_CANVAS_NUM_STIPPLES stipple bitmaps. This function allows you to change the bitmap being used. This can be used to implement a marching ants effect. An older implementation used to use this feature and so it is included since it might be useful in the future. All stipple bitmaps but the default one are created on the fly.

canvas :

a GimpCanvas widget

style :

the GimpCanvasStyle to alter

index :

the new stipple index

gimp_canvas_set_bg_color ()

void                gimp_canvas_set_bg_color            (GimpCanvas *canvas,
                                                         GimpRGB *color);

Sets the background color of the canvas's window. This is the color the canvas is set to if it is cleared.

canvas :

a GimpCanvas widget

color :

a color in GimpRGB format

gimp_canvas_scroll ()

void                gimp_canvas_scroll                  (GimpCanvas *canvas,
                                                         gint offset_x,
                                                         gint offset_y);

Scrolls the canvas using gdk_window_scroll() and makes sure the result is displayed immediately by calling gdk_window_process_updates().

canvas :

the GimpCanvas widget to scroll.

offset_x :

the x scroll amount.

offset_y :

the y scroll amount.

Property Details

The "config" property

  "config"                   GimpDisplayConfig*    : Read / Write / Construct Only