vg4->canvas->subcanvas()
Prepare for drawing a new sub-canvas upon a parent-canvas.
SYNTAX
struct VG_Position
vg4->canvas->subcanvas(struct VG_Canvas *cvas, const struct VG_ImagecopyAttrPixel *iattr_pixel)
FUNCTION PARAMETERS
cvas | Parent-canvas |
iattr_pixel | Pixel-modifying part of image-copy attributes, or NULL |
RETURN VALUE
Returns position for sub-canvas (centered to parent-canvas)
DESCRIPTION
Prepare for drawing a new sub-canvas upon a parent-canvas.
If a sub-canvas shall be drawn upon a parent-canvas,
e.g. for typing a filename when clicked on a "create a new file",
this function prepares the background, which is the parent-canvas,
and calculates the position of the sub-canvas.
EXAMPLE
/* execute a sub-canvas cvas upon parent-canvas cvas_parent, * set selection in selname * return VG_TRUE = OK or VG_FALSE = exit request */ VG_BOOL exec_subcanvas(struct VG_Canvas *cvas_parent, struct VG_Canvas *cvas, const char **selname) { struct VG_Position possub; struct VG_Image *wclone; struct VG_ImagecopyAttrPixel iattr_pixel; *selname = NULL; /* reduce brightness */ VG_IMAGECOPY_ATTRPIXEL_DEFAULT(&iattr_pixel); iattr_pixel.brightness = 60; /* get current background */ wclone = vg4->window->clone(NULL, NULL); /* get position for sub-canvas and draw as background parent-canvas with reduced brightness */ possub = vg4->canvas->subcanvas(cvas_parent, &iattr_pixel); /* execute sub-canvas */ if (!vg4->canvas->exec(cvas, &possub, selname)) { return VG_FALSE; } /* restore background */ vg4->window->clear(); vg4->window->copy(wclone, NULL, NULL); vg4->image->destroy(wclone); return VG_TRUE; }