IUP/Controls/IupCanvas: Difference between revisions

From Vendetta Lua
Jump to navigationJump to search
Created page with "__NOTOC__ __NOEDITSECTION__ Creates an interface element that is a canvas - a working area for your application. ===Creation=== :iup.canvas{} -> ('''elem''': ihandle) :This..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
__NOEDITSECTION__
__NOEDITSECTION__
{{IUP Controls}}
Creates an interface element that is a canvas - a working area for your application.
Creates an interface element that is a canvas - a working area for your application.


===Creation===
===Creation===


:iup.canvas{} -> ('''elem''': ihandle)
    iup.canvas{} -> ('''elem''': ihandle)


:This function returns the identifier of the created canvas, or nil if an error occurs.
:This function returns the identifier of the created canvas, or nil if an error occurs.
Line 16: Line 17:


:'''[[IUP/Attributes/Common/SCROLLBAR|SCROLLBAR]]''': Associates a horizontal and/or vertical scrollbar to the canvas.
:'''[[IUP/Attributes/Common/SCROLLBAR|SCROLLBAR]]''': Associates a horizontal and/or vertical scrollbar to the canvas.
:'''SCROLLBARSIZE''': number


:'''[[IUP/Attributes/DX|DX]]''': Size of the thumb in the horizontal scrollbar.
:'''[[IUP/Attributes/DX|DX]]''': Size of the thumb in the horizontal scrollbar.
Line 36: Line 39:


:'''[[IUP/Attributes/Common/EXPAND|EXPAND]]''': The default value is "YES".
:'''[[IUP/Attributes/Common/EXPAND|EXPAND]]''': The default value is "YES".
:'''TABSTOP''': Possible values: "YES", "NO"
:'''CANVASLINES'''
:'''MOUSECLICKSOUND'''
:'''LINEX''': number
:'''XSTYLE''': number
:'''COLORPICKERMODE''': Possible values: "ON", "OFF"


===Callbacks===
===Callbacks===
Line 50: Line 65:
:[[IUP/Callbacks/BUTTON_CB|BUTTON_CB]]: Action generated when any mouse button is pressed or released.
:[[IUP/Callbacks/BUTTON_CB|BUTTON_CB]]: Action generated when any mouse button is pressed or released.


:[[IUP/Callbacks/ENTERWINDOW_CB|ENTERWINDOW_CB]]: Action generated when the mouse enters the canvas.
:[[IUP/Callbacks/ENTERWINDOW_CB|ENTERWINDOW_CB]]: Action generated when the mouse enters the canvas.  This event triggers twice.


:[[IUP/Callbacks/LEAVEWINDOW_CB|LEAVEWINDOW_CB]]: Action generated when the mouse leaves the canvas.
:[[IUP/Callbacks/LEAVEWINDOW_CB|LEAVEWINDOW_CB]]: Action generated when the mouse leaves the canvas.  This event triggers twice.


:[[IUP/Callbacks/MOTION_CB|MOTION_CB]]: Action generated when the mouse is moved.
:[[IUP/Callbacks/MOTION_CB|MOTION_CB]]: Action generated when the mouse is moved.


:[[IUP/Callbacks/KEYPRESS_CB|KEYPRESS_CB]]: Action generated when a key is pressed or released.
:[[IUP/Callbacks/KEYPRESS_CB|KEYPRESS_CB]]: Action generated when a key is pressed or released.
<!-- :[[IUP/Callbacks/RESIZE_CB|RESIZE_CB]]: Action generated when the canvas' size is changed. -->


:[[IUP/Callbacks/SCROLL_CB|SCROLL_CB]]: Called when the scrollbar is manipulated.
:[[IUP/Callbacks/SCROLL_CB|SCROLL_CB]]: Called when the scrollbar is manipulated.


:[[IUP/Callbacks/MAP_CB|MAP_CB]]: Called right after the element is mapped.
===Note===


===Note===
:Note that some keys might remove the focus from the canvas. To avoid this, return IGNORE in the [[IUP/Callbacks/K_ANY|K_ANY]] callback.


:Note that some keys might remove the focus from the canvas. To avoid this, return IGNORE in the K_ANY callback.
[[Category:IUP Controls]]

Latest revision as of 06:13, 11 May 2023


Controls

Dialog
Fill
Hbox
Vbox
Zbox
Cbox
Radio
Button
Canvas
Frame
Label
List
Multiline
Text
Toggle
Progress Bar
Matrix
Tree
Navmap

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

Creation

   iup.canvas{} -> (elem: ihandle)
This function returns the identifier of the created canvas, or nil if an error occurs.

Attributes

BGCOLOR: Border color
SIZE: Size of the canvas. Default: size of one character.
SCROLLBAR: Associates a horizontal and/or vertical scrollbar to the canvas.
SCROLLBARSIZE: number
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.
XMIN: Minimum value of the horizontal scrollbar.
XMAX: Maximum 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. Default: "YES".
EXPAND: The default value is "YES".
TABSTOP: Possible values: "YES", "NO"
CANVASLINES
MOUSECLICKSOUND
LINEX: number
XSTYLE: number
COLORPICKERMODE: Possible values: "ON", "OFF"

Callbacks

ACTION: Action generated when the canvas needs to be redrawn. Also receives as parameters the scrollbar position:
elem:action(x, y: number) -> (ret: number)
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. This event triggers twice.
LEAVEWINDOW_CB: Action generated when the mouse leaves the canvas. This event triggers twice.
MOTION_CB: Action generated when the mouse is moved.
KEYPRESS_CB: Action generated when a key is pressed or released.
SCROLL_CB: Called when the scrollbar is manipulated.

Note

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