IupCanvas

IUP - Portable User Interface

IupCanvas

Creates an interface element that is a canvas - a working area for your application.

Creation

Ihandle* IupCanvas(char *action); [in C]
iupcanvas{} -> (elem: iuplua_tag) [in IupLua3]
iup.canvas{} -> (elem: iuplua_tag) [in IupLua5]
canvas(action) [in LED]

action: Name of the action generated when the canvas needs to be redrawn.

This function returns the identifier of the created canvas, or NULL if an error occurs.

Attributes

BGCOLOR: Background color. In Windows the background is painted only if the ACTION callback is not defined. If the callback is defined the application must draw all the canvas contents. For better results also let the attribute CLIPCHILDREN=YES in the dialog.

CURSOR: Canvas cursor.

SIZE: Size of the canvas. Default: size of one character.

SCROLLBAR: Associates a horizontal and/or vertical scrollbar to the canvas.

DX: Size of the thumb in the horizontal scrollbar.

DY: Size of the thumb in the vertical scrollbar.

POSX: Position of the thumb in the horizontal scrollbar.

POSY: Position of the thumb in the vertical scrollbar.

XMAX: Maximum value of the horizontal scrollbar.

XMIN: Minimum value of the horizontal scrollbar.

YMIN: Minimum value of the vertical scrollbar.

YMAX: Maximum value of the vertical scrollbar.

BORDER: Shows a border around the canvas. It can only be changed before the element is mapped. This attribute does not work on Motif. Default: "YES".

EXPAND: The default value is "YES".

DRAWSIZE: The size of the drawing area in pixels. In Motif this is identical to RASTERSIZE. In Windows it is obtained from the canvas client area since it may contains a border.

Callbacks

ACTION: Action generated when the canvas needs to be redrawn. Also receives as parameters the scrollbar position:

int function(Ihandle *self, float x, float y); [in C]
elem:action(x, y: number) -> (ret: number) [in IupLua]

x: Thumb position in the horizontal scrollbar.
y: Thumb position in the vertical scrollbar.

This action is also generated right after the dialog is viewed by means of functions IupShow, IupShowXY or IupPopup.

BUTTON_CB: Action generated when any mouse button is pressed or released.

ENTERWINDOW_CB: Action generated when the mouse enters the canvas.

LEAVEWINDOW_CB: Action generated when the mouse leaves the canvas.

MOTION_CB: Action generated when the mouse is moved.

KEYPRESS_CB: Action generated when a key is pressed or released.

RESIZE_CB: Action generated when the canvas' size is changed.

SCROLL_CB: Called when the scrollbar is manipulated.

MAP_CB: Called right after the element is mapped.

WOM_CB: Action generated when an audio device receives an event.

WHEEL_CB: Action generated when the mouse wheel is rotated.

Note

Note that some keys might remove the focus from the canvas. To avoid this, return IGNORE in the K_ANY callback.

The mouse cursor position can be programatically controled using the global attribute CURSORPOS.

Examples