IupCells

IUP - Portable User Interface

IupCells

Creates a grid widget (set of cells) that enables several application-specific drawing, such as: chess tables, tiles editors, degrade scales, drawable spreadsheets and so forth.

This element is mostly based on application callbacks functions that determine the number of cells (rows and coluns), their appearence and interation. This mechanism offers full flexibility to applications, but requires programmers attention to avoid infinite loops inside this functions. Using callbacks, cells can be also grouped to form major or hierarchical elements, such as headers,  footers etc. This callback approach was intentionally chosen to allow all cells to be dinamically and directly changed based on application's data structures. Since the size of each cell is given by the application the size of the control also must be given using SIZE or RASTERSIZE attributes.

This is an additional control that depends on the CD library. It is included in the Controls Library.

It inherits from IupCanvas.

Originally implemented by André Clinio.

Creation

Ihandle* IupCells(void); [in C]
iup.cells{} -> (elem: ihandle) [in Lua]
cells() [in LED] 

Returns: the identifier of the created element, or NULL if an error occurs.

Attributes

BOXED: Determines if the bounding cells' regions should be drawn with black lines. It can be "YES" or "NO". Default: "YES". If the span atributtes are used, set this attribute to "NO" to avoid grid drawing over spanned cells.

CLIPPED: Determines if, before cells drawing, each bounding region should be clipped. This attribute should the changed in few specific cases.  It can be "YES" or "NO". Default: "YES".

NON_SCROLLABLE_LINES: Determines the number of non-scrollable lines (vertical headers) that should allways be visible despite the vertical scrollbar position. It can  be any non-negative integer value. Default: "0"

NON_SCROLLABLE_COLS: Determines the number of non-scrollable columns (horizontal headers) that should allways be visible despite the horizontal scrollbar position. It can be any non-negative integer value. Default: "0"

ORIGIN: Sets the first visible line and column positions. This attribute is set by a formatted string "%d:%d" (C syntax), where each "%d" represent the line and column integer indexes respectely.

REPAINT(write-only): When set with any value, provokes the control full repaint.

FULL_VISIBLE (write-only): Tries to show completely a specific cell (considering any vertical or horizontal header or scrollbar position) .This attribute is set by a formatted string "%d:%d" (C syntax), where each "%d"represent the line and column integer indexes respectely.

NO_COLOR:  Adjusts the default color of cells which the drawing callback does nothing. Default: use the BGCOLOR attribute.

LIMITSL:C (read-only): Returns the limits of a given cell. Input format is "lin:col" or "%d:%d" in C. Output format is "xmin:xmax:ymin:ymax" or "%d:%d:%d:%d" in C.

FIRST_COL (read-only): Returns the number of the first visible column.

FIRST_LINE  (read-only): Returns the number of the first visible line.

BUFFERIZE: When set to "YES", disables the control redrawing. It should be used only to avoid the control blinking effect when several attributes are being changed at sequentially. When REPAINT attribute is set, BUFFERIZE is automatically adjusted to "NO". Default: "NO".

IMAGE_CANVAS (read-only): Returns the internal image CD canvas. This attribute should be used only in specific cases and by experienced CD programmers.

CANVAS (read-only): Returns the internal IUP CD canvas. This attribute should be used only in specific cases and by experienced CD programmers.


ACTIVE, FONT, X, Y, POSITION, WID, TIP, SIZE, RASTERSIZE, ZORDER, VISIBLE: also accepted. 

Callbacks

DRAW_CB: called when a specif cell needs to be repainted.

int function(Ihandle* ih, int line, int column, int xmin, int xmax, int ymin, int ymax, cdCanvas* canvas);  [in C]
elem:draw_cb(line, column, xmin, xmax, ymin, ymax: number, canvas: cdCanvas) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
line, column: the grid position inside the control that is being repainted, in grid coordinates.
xmin, xmax, ymin, ymax: the raster bounding box of the repainting cells, where the application can use CD functions to draw anything. If the atributte IUP_CLIPPED is set (the default), all CD graphical primitives is clipped to the bounding region.
canvas: internal canvas CD used to draw the cells.

MOUSECLICK_CB: called when a color is selected. The primary color is selected with the left mouse button, and if existant the secondary is selected with the right mouse button.

int function(Ihandle* ih, int button, int pressed, int line, int column, int x, int y, char* status);  [in C]
elem:mouseclick_cb(button, pressed, line, column, x, y: number, string: status) -> (ret: number) [in Lua]

Same as the BUTTON_CB IupCanvas callback with two additional parameters:

line, column: the grid position in the control where the event has occurred, in grid coordinates.

MOUSEMOTION_CB: called when the mouse moves over the control.

int function(Ihandle *ih, int line, int column, int x, int y, char *r); [in C]
elem:mousemotion_cb(x, y: number, r: string) -> (ret: number) [in Lua]

Same as the MOTION_CB IupCanvas callback with two additional parameters:

line, column: the grid position in the control where the event has occurred, in grid coordinates.

WIDTH_CB: called when the controls needs to know the colunm width

int function(Ihandle* ih, int column);  [in C]
elem:width_cb(column: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
column: the column index

Return: an integer that specifies the desired width (in pixels). Default is 60 pixels.

HEIGHT_CB: called when the controls needs to know a (eventually new) line heigth.

int function(Ihandle* ih, int line);  [in C]
elem:height_cb(line: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
line: the line index

Return: an integer that specifies the desired heigth (in pixels). Default is 30 pixels.

NLINES_CB: called when then controls needs to know its number of lines.

int function(Ihandle* ih);  [in C]
elem:nlines_cb() -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.

Return: an integer that specifies the number of lines. Default is 10 lines.

NCOLS_CB: called when then controls needs to know its number of columns.

int function(Ihandle* ih);  [in C]
elem:ncols_cb() -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.

Return: an integer that specifies the number of columns. Default is 10 columns.

HSPAN_CB: called when the control needs to know if a cell should be horizontally spanned.

int function(Ihandle* ih, int line, int column);  [in C]
elem:hspan_cb(line, column: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
line, column: the line and colun indexes (in grid coordinates)

Return: an integer that specifies the desired span. Default is 1 (no span).

VSPAN_CB: called when the control needs to know if a cell should be vertically spanned.

int function(Ihandle* ih, int line, int column);  [in C]
elem:vspan_cb(line, column: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
line, column: the line and colun indexes (in grid coordinates)

Return: an integer that specifies the desired span. Default is 1 (no span).

SCROLLING_CB: called when the scrollbars are activated.

int function(Ihandle* ih, int line, int column);  [in C]
elem:scrolling_cb(line, column: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
line, column: the first visible line and colunm indexes (in grid coordinates)

Return: If IUP_IGNORE the cell is not redrawn. By default the cell is always redrawn.


MAP_CB, GETFOCUS_CB, KILLFOCUS_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, K_ANY, HELP_CB: All common callbacks are supported.

Examples

Browse Example Files

Checkerboard Pattern

Numbering Cells

See Also

IupCanvas