Whole document tree
GnomeCanvasSynopsis
DescriptionThe GNOME canvas is an engine for displaying structured graphics and simplifying the development of complex graphic-based applications. Canvas ItemsThe GNOME Canvas basic building blocks are the GNOME Canvas Items (GnomeCanvasItem): lines, rectangles, text, ellipses, polylines, images and embedded widgets. You can use any of those directly in your application. The CanvasItem system is designed to be extensible. Applications can define their own GnomeCanvasItem objects for special purpose tasks. For example, the GNOME Gnumeric spreadsheet defines a number of special Canvas Items that are specialized for the task of spreadsheets. Specialized canvas items allow the developer to write custom items that can adapt to their needs for speed, scalability and gives the user the power to extend the canvas. Items on the canvas can be reconfigured by using the Gtk argument system. Users can reconfigure the parameters of the canvas items and the changes on the parameters will be reflected immediately on the screen. Flicker free displayThe GNOME Canvas uses off-screen buffers to render the images before transferring them to the screen. Transfers can take place at the command of the programmer (by explicitly requesting a repaint update) or done automatically by the engine (during the idle look handler). Event dispatchingEach GnomeCanvasItem can receive mouse events, keyboard events, mouse-enter and mouse leave events. In addition a canvas item can grab the mouse (for example to implement reliable dragging of objects). Canvas typesThe Canvas can be run in two different modes: X11 mode and Art mode. The mode is chosen at the creation time of the widget by either calling gnome_canvas_new() or gnome_canvas_new_aa(), the former creates an X11 canvas, while the latter creates an Art-based canvas. The X11 mode uses the X server to draw the items and it takes advantage of the X server acceleration features for drawing on the screen. The only drawback is that the output quality and the imaging model are restricted to the X11 quality and imaging model. The Art mode of the canvas has an advanced imaging model based on LibArt and it allows any GnomeCanvasItem (with the exception of the embedded widget item) to be rotated, scaled and translated (this is done by means of applying an affine transformation on the object). Detailsstruct GnomeCanvas
Most of the fields in this structure are for private use only. However, canvas item implementations may make use of some of them. GNOME_CANVAS_EPSILON
This macro defines a ‘small’ floating-point value for the internal computations that the canvas performs. It can be used by item implementations as a test to see whether a number is “almost zero”. GNOME_CANVAS_COLOR()
This macro is used to build a 32-bit integer with an RGB color specification. The specified values must be integers in the range [0, 255]. GNOME_CANVAS_COLOR_A()
This macro is used to build a 32-bit integer with an RGBA color specification. This is the same as an RGB color specification, but with an added alpha or opacity value. The specified values must be integers in the range [0, 255]. struct GnomeCanvasBuf
This structure is passed to the render method of canvas items when they need to paint themselves on an antialiased canvas. The buf field points to a 24-bit RGB buffer for rendering. The buf_rowstride field specifies the number of bytes in each row in the buffer, which should be used to calculate byte offsets inside it. The buffer's pixel offsets in canvas pixel coordinates are given by the rect rectangle. The is_bg and is_buf fields are flags that items can use to implement rendering optimizations, and they are used in conjunction with the bg_color field. The is_buf flag specifies whether the contents of the buffer are an accurate representation of the state of the canvas. If this flag is true, then the RGB data in the buf is valid, that is, it contains meaningful data. The is_bg flag specifies whether the buffer has all its pixels set to the same color. This allows canvas items to optimize for this case by doing alpha compositing for a smaller set of values than if the buffer had pixels of different colors. At least one of these flags is on at any one time. The meaning of their combinations is as follows: Table 1. Values for is_bg and is_buf
Whenever an item paints to an RGB buffer in which the is_bg field was true, the item is then responsible for turning off this flag if it knows that the result will not be pixels all of the same color. If a large item, like a solid rectangle, knows that it will be filling the buffer with a solid color, then it take any one of the following actions:
Most item implementations may only need to perform the actions for the first case described above. The other two are simply optimizations they can perform. gnome_canvas_new ()
Creates a new empty canvas in non-antialiased mode. If you wish to use the &GnomeCanvasImage item inside this canvas, then you must push the gdk_imlib visual and colormap before calling this function, and they can be popped afterwards. gnome_canvas_new_aa ()
Creates a new empty canvas in antialiased mode. You should push the GdkRGB visual and colormap before calling this functions, and they can be popped afterwards. gnome_canvas_root ()
Queries the root group of a canvas. gnome_canvas_set_scroll_region ()
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. gnome_canvas_get_scroll_region ()
Queries the scrolling region of a canvas. gnome_canvas_set_pixels_per_unit ()
Sets the zooming factor of a canvas by specifying the number of pixels that correspond to one canvas unit. gnome_canvas_scroll_to ()
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. gnome_canvas_get_scroll_offsets ()
Queries the scrolling offsets of a canvas. The values are returned in canvas pixel units. gnome_canvas_update_now ()
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. gnome_canvas_get_item_at ()
Looks for the item that is under the specified position, which must be specified in world coordinates. gnome_canvas_request_redraw_uta ()
Informs a canvas that the specified area, given as a microtile array, needs to be repainted. To be used only by item implementations. gnome_canvas_request_redraw ()
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. gnome_canvas_w2c_affine ()
Gets the affine transform that converts from world coordinates to canvas pixel coordinates. gnome_canvas_w2c ()
Converts world coordinates into canvas pixel coordinates. gnome_canvas_w2c_d ()
Converts world coordinates into canvas pixel coordinates. This version gnome_canvas_c2w ()
Converts canvas pixel coordinates to world coordinates. gnome_canvas_window_to_world ()
Converts window-relative coordinates into world coordinates. You can use this when you need to convert mouse coordinates into world coordinates, for example. gnome_canvas_world_to_window ()
Converts world coordinates into window-relative coordinates. gnome_canvas_get_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. gnome_canvas_set_stipple_origin ()
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. gnome_canvas_set_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. gnome_canvas_get_dither ()
Returns the type of dithering used to render an antialiased canvas. See AlsoGnomeCanvasItem, GnomeCanvasGroup, GnomeCanvasRE, GnomeCanvasRectEllipse, GnomeCanvasImage, GnomeCanvasLine, GnomeCanvasPolygon, GnomeCanvasText, GnomeCanvasWidget |