IupDraw (since 3.19)

A group of functions to draw in a IupCanvas or a IupBackgroundBox. They are simple functions designed to help the drawing of custom controls based on these two controls. It is NOT a complete set of drawing functions, for that you should still use another toolkit like CD.

To use the functions in C/C++ you must include the "iupdraw.h" header.

IMPORTANT: all functions can be used only in IupCanvas or IupBackgroundBox and inside the ACTION callback. To force a redraw anytime use the functions IupUpdate or IupRedraw.

Control

All primitives can be called only between calls to DrawBegin and DrawEnd.

void IupDrawBegin(Ihandle* ih); [in C]
iup.DrawBegin(ih: ihandle) [in Lua]
ih:DrawBegin() [in Lua]

Initialize the drawing process.

void IupDrawEnd(Ihandle* ih); [in C]
iup.DrawEnd(ih: ihandle) [in Lua]
ih:DrawEnd() [in Lua]

Terminates the drawing process.

void IupDrawSetClipRect(Ihandle* ih, int x1, int y1, int x2, int y2); [in C]
iup.DrawSetClipRect(ih: ihandle, x1, y1, x2, y2: number) [in Lua]
ih:DrawSetClipRect(x1, y1, x2, y2: number) [in Lua]

Defines a rectangular clipping region.

void IupDrawResetClip(Ihandle* ih); [in C]
iup.DrawResetClip(ih: ihandle) [in Lua]
ih:DrawResetClip() [in Lua]

Reset the clipping area to none.

Primitives

The primitives color is controlled by the attribute DRAWCOLOR. Default: "0 0 0".

Rectangle, Arc and Polygon can be filled or stroked. When stroked the line style can be continuous, dashed or dotted. These are controlled by the attribute DRAWSTYLE. Can have values: FILL, STROKE, STROKE_DASH or STROKE_DOT. Default: STROKE. The FILL value when set before DrawLine has the same effect as STROKE.

void IupDrawParentBackground(Ihandle* ih); [in C]
iup.DrawParentBackground(ih: ihandle) [in Lua]
ih:DrawParentBackground() [in Lua]

Fills the canvas with the native parent background color.

void IupDrawLine(Ihandle* ih, int x1, int y1, int x2, int y2); [in C]
iup.DrawLine(ih: ihandle, x1, y1, x2, y2: number) [in Lua]
ih:DrawLine(x1, y1, x2, y2: number) [in Lua]

Draws a line including start and end points.

void IupDrawRectangle(Ihandle* ih, int x1, int y1, int x2, int y2); [in C]
iup.DrawRectangle(ih: ihandle, x1, y1, x2, y2: number) [in Lua]
ih:DrawRectangle(x1, y1, x2, y2: number) [in Lua]

Draws a rectangle including start and end points.

void IupDrawArc(Ihandle* ih, int x1, int y1, int x2, int y2, double a1, double a2); [in C]
iup.DrawArc(ih: ihandle, x1, y1, x2, y2, a1, a2: number) [in Lua]
ih:DrawArc(x1, y1, x2, y2: number) [in Lua]

Draws an arc inside a rectangle between the two angles in degrees. When filled will draw a pie shape with the vertex at the center of the rectangle.

void IupDrawPolygon(Ihandle* ih, int* points, int count); [in C]
iup.DrawPolygon(ih: ihandle, points: table of number) [in Lua]
ih:DrawPolygon(points: table of number) [in Lua]

Draws a polygon. Coordinates are stored in the array in the sequence: x1, y1, x2, y2, ...

void IupDrawText(Ihandle* ih, const char* str, int len, int x, int y); [in C]
iup.DrawText(ih: ihandle, str: string, x, y: number) [in Lua]
ih:DrawText(str: string, x, y: number) [in Lua]

Draws a text in the given position using the current FONT. The size of the string is used only in C. Can be 0 so strlen is used internally. The coordinates are relative the top-left corner of the text.

void IupDrawImage(Ihandle* ih, const char* name, int make_inactive, int x, int y); [in C]
iup.DrawImage(ih: ihandle, name: string or image: ihandle, make_inactive, x, y: number) [in Lua]
ih:DrawImage(name: string or image: ihandle, make_inactive, x, y: number) [in Lua]

Draws an image given its name. The coordinates are relative the top-left corner of the image. The image name follows the same behavior as the IMAGE attribute used by many controls. Use IupSetHandle or IupSetAttributeHandle to associate an image to a name. See also IupImage. In Lua, the name parameter can be the actual image handle. The make_inactive parameter will draw the same image in inactive state.

void IupDrawSelectRect(Ihandle* ih, int x1, int y1, int x2, int y2); [in C]
iup.DrawSelectRect(ih: ihandle, x1, y1, x2, y2: number) [in Lua]
ih:DrawSelectRect(x1, y1, x2, y2: number) [in Lua]

Draws a selection rectangle.

void IupDrawFocusRect(Ihandle* ih, int x1, int y1, int x2, int y2); [in C]
iup.DrawFocusRect(ih: ihandle, x1, y1, x2, y2: number) [in Lua]
ih:DrawFocusRect(x1, y1, x2, y2: number) [in Lua]

Draws a focus rectangle.

Information

void IupDrawGetSize(Ihandle* ih, int *w, int *h); [in C]
iup.DrawGetSize(ih: ihandle) -> w, h: number [in Lua]
ih:DrawGetSize() -> w, h: number [in Lua]

Returns the drawing area size. In C unwanted values can be NULL.

void IupDrawGetTextSize(Ihandle* ih, const char* str, int *w, int *h); [in C]
iup.DrawGetTextSize(ih: ihandle, str: string) -> w, h: number [in Lua]
ih:DrawGetTextSize(str: string) -> w, h: number [in Lua]

Returns the given text size using the current FONT.  In C unwanted values can be NULL.

void IupDrawGetImageInfo(const char* name, int *w, int *h, int *bpp); [in C]
iup.DrawGetImageInfo(name: string) -> w, h, bpp: number [in Lua]
ih:DrawGetImageInfo(name: string) -> w, h, bpp: number [in Lua]

Returns the given image size and bits per pixel. bpp can be 8, 24 or 32.  In C unwanted values can be NULL.

See Also

IupCanvas, IupBackgroundBox, IupUpdate, IupRedraw