Contents Up Previous Next

Grid

Overview

A subwindow used for displaying grids (matrices/tables). A grid can contain text or bitmaps.

Note: this functionality is implemented in Windows only, for the time being.

The following callbacks are valid for the grid class.

OnPaint
Called with a window identifier when the window receives a repaint event from the window manager.
OnSize
The function is called with the window identifier, width and height.
OnCellLeftClick
The function is called with the window identifier, row, column, x, y, control down flag, shift down flag.
OnCellRightClick
The function is called with the window identifier, row, column, x, y, control down flag, shift down flag.
OnCellChange
The function is called with the window identifier, row, column.
OnChangeLabels
The function is called with the window identifier.
OnChangeSelectionLabel
The function is called with the window identifier.

See also window-add-callback.

grid-adjust-scrollbars
grid-append-cols
grid-append-rows
grid-clear-grid
grid-create
grid-create-grid
grid-delete-cols
grid-delete-rows
grid-get-cell-alignment
grid-get-cell-background-colour
grid-get-cell-bitmap
grid-get-cell-text-colour
grid-get-cell-value
grid-get-column-width
grid-get-cursor-column
grid-get-cursor-row
grid-get-rows
grid-get-cols
grid-get-editable
grid-get-label-alignment
grid-get-label-background-colour
grid-get-label-size
grid-get-label-text-colour
grid-get-label-value
grid-get-row-height
grid-get-scroll-pos-x
grid-get-scroll-pos-y
grid-get-text-item
grid-insert-cols
grid-insert-rows
grid-on-activate
grid-on-paint
grid-on-size
grid-set-cell-alignment
grid-set-cell-background-colour
grid-set-cell-bitmap
grid-set-cell-text-colour
grid-set-cell-text-font
grid-set-cell-value
grid-set-column-width
grid-set-divider-pen
grid-set-editable
grid-set-grid-cursor
grid-set-label-alignment
grid-set-label-background-colour
grid-set-label-size
grid-set-label-text-colour
grid-set-label-text-font
grid-set-label-value
grid-set-row-height
grid-update-dimensions


grid-adjust-scrollbars

void ( grid-adjust-scrollbars long grid-id)

Adjusts the scrollbars to suit the size of the grid: this may cause one or both to be hidden. You may wish to call this from code which alters the number of rows or columns (or height/width of rows or columns), or from an OnSize callback.


grid-append-cols

long ( grid-append-cols long grid-id long n optional long update-labels=1) Inserts n columns at the end of the table, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-append-rows

long ( grid-append-rows long grid-id long n optional long update-labels=1) Inserts n rows at the end of the table, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-clear-grid

void ( grid-clear-grid long grid-id)

Clears the grid (untested).


grid-create

long ( grid-create long parent-id optional long x optional long y
optional long width optional long height optional string style=0 optional string name="grid")

Creates a grid window. You must also call grid-create-grid after you call this function.

parent-id must be a valid frame ID.

name gives the canvas a name that can be retrieved with window-get-name.


grid-create-grid

long ( grid-create-grid long grid-id long rows long cols
optional long default-width optional long default-height)

Initializes the size of the grid. Returns 1 if successful, 0 otherwise.


grid-delete-cols

long ( grid-delete-cols long grid-id long position long n optional long update-labels=1) Deletes n columns starting at position, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-delete-rows

long ( grid-delete-rows long grid-id long position long n optional long update-labels=1) Deletes n rows starting at position, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-get-cell-alignment

string ( grid-get-cell-alignment long grid-id long row long col) Gets the cell text alignment at row, col. The return value is one of wxLEFT, wxRIGHT, wxCENTRE.


grid-get-cell-background-colour

long ( grid-set-cell-background-colour long grid-id optional long row=-1 optional long col=-1) Gets the cell background colour.

The return value is a colour value of the kind created using colour-create.

If row and col are zero or greater, the returned colour is that of an individual cell. If these values are -1 or absent, the colour is the global, default cell background colour.


grid-get-cell-bitmap

long ( grid-get-cell-bitmap long grid-id long row long col) Returns the bitmap associated with the cell at row, col. If none has been set, 0 will be returned. See also grid-set-cell-bitmap.


grid-get-cell-text-colour

long ( grid-set-cell-text-colour long grid-id optional long row=-1 optional long col=-1) Gets the cell text colour.

The return value is a colour value of the kind created using colour-create.

If row and col are zero or greater, the returned colour is that of an individual cell. If these values are -1 or absent, the colour is the global, default cell text colour.


grid-get-cell-value

string ( grid-get-cell-value long grid-id long row long col) Gets the cell value at row, col.


grid-get-column-width

long ( grid-get-column-width long grid-id long col) Gets the given column width in pixels.


grid-get-cursor-column

long ( grid-get-cursor-column long grid-id) Returns the column of the currently selected cell.


grid-get-cursor-row

long ( grid-get-cursor-row long grid-id) Returns the row of the currently selected cell.


grid-get-rows

long ( grid-get-rows long grid-id)

Returns the number of rows in the grid.


grid-get-cols

long ( grid-get-cols long grid-id)

Returns the number of columns in the grid.


grid-get-editable

long ( grid-get-editable long grid-id)

Returns 1 if the grid is editable (the text field is showing), 0 otherwise.


grid-get-label-alignment

string ( grid-get-label-alignment long grid-id string orientation) Gets the column label or row label alignment.

If orientation is wxVERTICAL, the row label alignment is returned. If orientation is wxHORIZONTAL, the column label alignment is returned.

The return value is one of wxLEFT, wxRIGHT, wxCENTRE.


grid-get-label-background-colour

long ( grid-get-label-background-colour long grid-id) Gets the label background colour.

The return value is a colour value of the kind created using colour-create.


grid-get-label-size

long ( grid-get-label-size long grid-id string orientation) Gets the column label height or row label width in pixels. If orientation is wxVERTICAL, the row label width is returned. If orientation is wxHORIZONTAL, the column label height is returned.


grid-get-label-text-colour

long ( grid-get-label-text-colour long grid-id) Gets the label text colour.

The return value is a colour value of the kind created using colour-create.


grid-get-label-value

string ( grid-get-label-value long grid-id string orientation long position) position is the label row or column position (starting from zero).

Gets a column label or row label value.

If orientation is wxVERTICAL, the row label alignment is set. If orientation is wxHORIZONTAL, the column label alignment is set.


grid-get-row-height

long ( grid-get-row-height long grid-id long row) Gets the given row height in pixels.


grid-get-scroll-pos-x

long ( grid-get-scroll-pos-x long grid-id)

Returns the current scroll position in the horizontal dimension (in scroll positions, not pixels).


grid-get-scroll-pos-y

long ( grid-get-scroll-pos-y long grid-id)

Returns the current scroll position in the vertical dimension (in scroll positions, not pixels).


grid-get-text-item

long ( grid-get-text-item long grid-id)

Returns the identifier of the text item which is used for editing cells. Use this to set the label of the text item, for example, in an OnChangeSelectionLabel callback, which is called when the user selects a different cell.


grid-insert-cols

long ( grid-insert-cols long grid-id long position long n optional long update-labels=1) Inserts n columns in front of position, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-insert-rows

long ( grid-insert-rows long grid-id long position long n optional long update-labels=1) Inserts n rows in front of position, updating the grid labels if update-labels is 1.

Returns 1 if successful, 0 otherwise.


grid-on-activate

void ( grid-on-activate long grid-id long active)

Call this function from a frame OnActivate callback. This function causes focus to be given to the text field (if in editable mode).


grid-on-paint

void ( grid-on-paint long grid-id)

Call this function if you override the on-paint event handler.


grid-on-size

void ( grid-on-size long grid-id long w long h)

Call this function if you override the on-size event handler.


grid-set-cell-alignment

void ( grid-set-cell-alignment long grid-id string alignment long row long col) Sets the cell text alignment at row, col to the given value. alignment should be one of wxLEFT, wxRIGHT, wxCENTRE.


grid-set-cell-background-colour

void ( grid-set-cell-background-colour long grid-id long colour optional long row=-1 optional long col=-1) Sets the cell background colour.

colour should be a colour value created with colour-create.

If row and col are zero or greater, the colour will be associated with an individual cell. If these values are -1 or absent, the colour will refer to all cells.


grid-set-cell-bitmap

void ( grid-set-cell-bitmap long grid-id long bitmap-id long row long col) Associates a bitmap with the cell at row, col. If this is called, the bitmap will be displayed instead of text. Since colourmaps are not used in drawing the bitmap, use low-colour bitmaps if possible (16 colours or less).


grid-set-cell-text-colour

void ( grid-set-cell-text-colour long grid-id long colour optional long row=-1 optional long col=-1) Sets the cell text colour.

colour should be a colour value created with colour-create.

If row and col are zero or greater, the colour will be associated with an individual cell. If these values are -1 or absent, the colour will refer to all cells.


grid-set-cell-text-font

void ( grid-set-cell-text-font long grid-id long font-id optional long row=-1 optional long col=-1) Sets the cell text font.

font should be a valid font identifier.

If row and col are zero or greater, the font will be associated with an individual cell. If these values are -1 or absent, the font will refer to all cells.


grid-set-cell-value

void ( grid-set-cell-value long grid-id string value long row long col) Sets the cell at row, col to the given value.


grid-set-column-width

void ( grid-set-column-width long grid-id long col long width) Sets the given column width in pixels.


grid-set-divider-pen

void ( grid-set-divider-pen long grid-id long pen-id)

Sets the pen for drawing the cell divisions (light grey by default). If pen-id is 0, the divisions are switched off.


grid-set-editable

void ( grid-set-editable long grid-id long editable)

If editable is 1, displays the text field for entering cell values. If editable is 0, hides the text field.


grid-set-grid-cursor

void ( grid-set-grid-cursor long grid-id longrow longcolumn) Sets the selection to the given cell.


grid-set-label-alignment

void ( grid-set-label-alignment long grid-id string orientation string alignment) Sets the column label or row label alignment.

If orientation is wxVERTICAL, the row label alignment is set. If orientation is wxHORIZONTAL, the column label alignment is set.

alignment should be one of wxLEFT, wxRIGHT, wxCENTRE.


grid-set-label-background-colour

void ( grid-set-label-background-colour long grid-id long colour) Sets the label background colour.

colour should be a colour value created with colour-create.


grid-set-label-size

void ( grid-set-label-size long grid-id string orientation long size) Sets the column label height or row label width in pixels. If orientation is wxVERTICAL, the row label width is set. If orientation is wxHORIZONTAL, the column label height is set.

A value of zero switches off the label in the specified dimension.


grid-set-label-text-colour

void ( grid-set-label-text-colour long grid-id long colour) Sets the label text colour.

colour should be a colour value created with colour-create.


grid-set-label-text-font

void ( grid-set-label-text-font long grid-id long font-id) Sets the label text font.


grid-set-label-value

void ( grid-set-label-value long grid-id string orientation string value long position)

Sets a column label or row label value.

If orientation is wxVERTICAL, the row label alignment is set. If orientation is wxHORIZONTAL, the column label alignment is set.

position is the label row or column position (starting from zero).


grid-set-row-height

void ( grid-set-row-height long grid-id long row long height) Sets the given row height in pixels.


grid-update-dimensions

void ( grid-update-dimensions long grid-id)

Recalculates dimensions so drawing is accurate. You may wish to call this if you alter a grid dimension, such as column width.