IupMatrix

IUP - Portable User Interface

IupMatrix Callbacks

Interaction

ACTION: Action generated when a keyboard event occurs.

int function(Ihandle *self, int c, int lin, int col, int active, char* after); [in C]
elem:action(c, lin, col, active, after: number) -> (ret: number) [in IupLua]

self: Identifier of the matrix where the user typed something.
c: Identifier of the typed key. Please refer to the Keyboard Codes table for a list of possible values.
lin, col: Coordinates of the selected cell.
active: 1 if the cell is in edition mode, and 0 if it is not.
after: The new value of the text in case the key is validated (see return values).

Possible return values are: IUP_DEFAULT validates the key, IUP_IGNORE ignores the key, IUP_CONTINUE forwards the key to IUP’s conventional processing. This function can also return the identifier of the key to be treated by the matrix.

CLICK_CB: Action generated when any mouse button is pressed over a cell. This callback is always called after other callbacks.

int function(Ihandle *self, int lin, int col, char *r); [in C]
elem:click(lin, col: number, r:string) -> (ret: number) [in IupLua3]
elem:click_cb(lin, col: number, r:string) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell where the mouse button was pressed. They can be -1 if the user click outside the matrix but inside the canvas that contains it.
r: Status of the mouse buttons and some keyboard keys at the moment the event is generated. The following macros must be used for verification: isshift(r), iscontrol(r), isbutton1(r), isbutton2(r), isbutton3(r), isdouble(r). They return 1 if the respective key or button is pressed, or 0 otherwise.

To interrupt further internal processing return IUP_IGNORE.

MOUSEMOVE_CB: Action generated to notify the application that the mouse has moved over the matrix. 

int function(Ihandle *self, int lin, int col); [in C]
elem:mousemove(lin, col: number) -> (ret: number) [in IupLua3]
elem:mousemove_cb(lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell that the mouse cursor is currently on.

ENTERITEM_CB: Action generated when a matrix cell is selected, becoming the current cell.

int function(Ihandle *self, int lin, int col); [in C]
elem:enteritem(lin, col: number) -> (ret: number) [in IupLua3]
elem:enteritem_cb(lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the selected cell.

The user must return IUP_DEFAULT. This callback is also called when matrix is getting focus.

LEAVEITEM_CB: Action generated when a cell is no longer the current cell.

int function(Ihandle *self, int lin, int col); [in C]
elem:leaveitem(lin, col: number) -> (ret: number) [in IupLua3]
elem:leaveitem_cb(lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell which is no longer the current cell.

The user must return either IUP_DEFAULT or IUP_IGNORE. This callback is also called when the matrix is losing focus. Returning IUP_IGNORE prevents the current cell from changing, but this will not work when the matrix is losing focus.  If you try to move to beyond matrix borders the cell will lose focus and then get it again, so leaveitem and enteritem will be called.

SCROLL_CB: Action generated when the matrix is scrolled with the scrollbars or with the keyboard. Can be used together with the "ORIGIN" attribute to synchronize the movement of two or more matrices.

int function(Ihandle *self, int lin, int col); [in C]
elem:scroll(lin, col: number) -> (ret: number) [in IupLua3]
elem:scroll_cb(lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell currently in the upper left corner of the matrix.

The user must return IUP_DEFAULT.

Drawing

BGCOLOR_CB - Action generated to retrieve the background color of a cell when it needs to be redrawn.

int function(Ihandle *self, int lin, int col, unsigned int *red, unsigned int *green, unsigned int *blue); [in C]
elem:bgcolorcb(lin, col: number) -> (red, green, blue, ret: number) [in IupLua3]
elem:bgcolor_cb(lin, col: number) -> (red, green, blue, ret: number) [in IupLua5]

self: Identifier of the matrix where the user typed something.
lin, col: Coordinates of the cell.
red, green, blue: the cell background color.

If the function return IUP_IGNORE, the return values are ignored and the attribute defined background color will be used. If returns IUP_DEFAULT the returned values will be used as the background color.

FGCOLOR_CB - Action generated to retrieve the foreground color of a cell when it needs to be redrawn.

int function(Ihandle *self, int lin, int col, unsigned int *red, unsigned int *green, unsigned int *blue); [in C]
elem:fgcolorcb(lin, col: number) -> (red, green, blue, ret: number) [in IupLua3]
elem:fgcolor_cb(lin, col: number) -> (red, green, blue, ret: number) [in IupLua5]

self: Identifier of the matrix where the user typed something.
lin, col: Coordinates of the cell.
red, green, blue: the cell foreground color.

If the function return IUP_IGNORE, the return values are ignored and the attribute defined foreground color will be used. If returns IUP_DEFAULT the returned values will be used as the foreground color.

DRAW_CB: Action generated before a cell is drawn. Allows to draw a custom cell contents. You must use the CD library primitives.

int function(Ihandle *self, int lin, int col, int x1, int x2, int y1, int y2); [in C]
elem:draw(lin, col, x1, x2, y1, y2: number) -> (ret: number) [in IupLua3]
elem:draw_cb(lin, col, x1, x2, y1, y2: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the current cell.
x1, x2, y1, y2: Bounding rectangle of the current cell in pixels.

If this function return IUP_IGNORE the normal text drawing will take place. The clipping is set for the bounding rectangle. The callback is called after the cell background has been filled with the background color. If HIDEFOCUS=NO (the default) the drawing area will not include the focus area, if HIDEFOCUS=YES the complete cell is available.

DROPCHECK_CB: Action generated before the current cell is redrawn to determine if a dropdown feedback should be shown. If this action is not registered, no feedback will be shown.

int function(Ihandle *self, int lin, int col); [in C]
elem:dropcheck(lin, col: number) -> (ret: number) [in IupLua3]
elem:dropcheck_cb(lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell.

This function must return IUP_DEFAULT to show a dropdown field feedback, or IUP_IGNORE to ignore the dropdown feedback.

Editing

DROP_CB: Action generated before the current cell enters edition mode to determine if a text field or a dropdown will be shown. It is called after EDITION_CB. If this action is not registered, a text field will be shown. Its return determines what type of element will be used in the edition mode. If the selected type is a dropdown, the values appearing in the dropdown must be fulfilled in this callback, just like elements are added to any list (the drop parameter is the handle of the dropdown list to be shown). You should also set the list’s current value ("VALUE"), the default is always "1". The previously cell value can be verified from the given drop Ihandle via the "PREVIOUSVALUE" attribute.

int function(Ihandle *self, Ihandle *drop, int lin, int col); [in C]
elem:drop(drop: ihandle, lin, col: number) -> (ret: number) [in IupLua3]
elem:drop_cb(drop: ihandle, lin, col: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
drop: Identifier of the dropdown list which will be shown to the user.
lin, col: Coordinates of the current cell.

This function must return IUP_IGNORE to show a text-edition field, or IUP_DEFAULT to show a dropdown field.

DROPSELECT_CB: Action generated when an element in the dropdown list is selected. If returns IUP_CONTINUE the value is accepted as a new value and the matrix leaves edition mode.

int function(Ihandle *self, int lin, int col, Ihandle *drop, char *t, int i, int v); [in C]
elem:dropselect(lin, col: number, drop: ihandle, t: string, i, v: number) -> (ret: number) [in IupLua3]
elem:dropselect_cb(lin, col: number, drop: ihandle, t: string, i, v: number) -> (ret: number) [in IupLua5] 

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the current cell.
drop: Identifier of the dropdown list shown to the user.
t: Text of the item whose state was changed.
i: Number of the item whose state was changed.
v: Indicates if item was selected or unselected (0 or 1).

EDITION_CB: Action generated when the current cell enters or leaves the edition mode.

int function(Ihandle *self, int lin, int col, int mode);  [in C]
elem:edition(lin, col, mode: number) -> (ret: number) [in IupLua3]
elem:edition_cb(lin, col, mode: number) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the current cell.
mode: 1 if the cell has entered the edition mode, or 0 if the cell has left the edition mode.

The new value is accepted only if the callback returns IUP_DEFAULT. If the callback does not exists the new value is always accepted. If the user pressed Enter and the callback returns IUP_IGNORE the editing continues. If the callback returns IUP_CONTINUE when mode is 0, the edit mode is ended but the value is not updated, so the application can update a different value (usefull to format the new value). If the control loses its focus the edition mode will be ended always even if the callback return IUP_IGNORE.

This callback is also called if the user cancel the editing with Esc and when the user press Del to validate the operation for each cell been cleared (in this case is called only with mode=1).

Callback Mode

VALUE_CB: Action generated to verify the value of a cell in the matrix when it needs to be redrawn. Called both for common cells and for line and column titles.

char* function(Ihandle* self, int lin, int col); [in C]
elem:valuecb(lin, col: number) -> (ret: string) [in IupLua3]
elem:value_cb(lin, col: number) -> (ret: string) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell currently in the upper left corner of the matrix.

Must return the string to be redrawn. The existance of this callback defines the callback operation mode of the matrix.

VALUE_EDIT_CB: Action generated to notify the application that the value of a cell was changed. Since it is a notification, it cannot refuse the value modification (which can be done by the "EDITION_CB" callback). This callback is usually set in callback mode, but also works in normal mode.

int function(Ihandle *self, int lin, int col, char* newval); [in C]
elem:value_edit(lin, col, newval: string) -> (ret: number) [in IupLua3]
elem:value_edit_cb(lin, col, newval: string) -> (ret: number) [in IupLua5]

self: Identifier of the matrix interacting with the user.
lin, col: Coordinates of the cell currently in the upper left corner of the matrix.
newval: String containing the new cell value


The canvas callbacks ACTION, SCROLL_CB, KEYPRESS_CB, GETFOCUS_CB, KILLFOCUS_CB if set will be called before the internal callbacks. The IupGetAttribute always returns the internal callbacks.

The canvas callbacks MOTION_CB, MAP_CB, RESIZE_CB and BUTTON_CB can not be changed. The other callbacks can be freely changed.

The GETFOCUS/KILLFOCUS callbacks are always called before other callbacks.

See IupCanvas.