newCDKMatrix, activateCDKMatrix, injectCDKMatrix, setCDKMatrix,
setCDKMatrixCell, getCDKMatrixCell, setCDKMatrixCB,
setCDKMatrixULChar, setCDKMatrixURChar, setCDKMatrixLLChar,
setCDKMatrixLRChar, setCDKMatrixVerticalChar,
setCDKMatrixHorizontalChar, setCDKMatrixBoxAttribute,
setCDKMatrixBackgroundColor, drawCDKMatrix, eraseCDKMatrix,
cleanCDKMatrix, moveToCDKMatrixCell, jumpToCell,
destroyCDKMatrix, setCDKMatrixPreProcess, setCDKMatrixPostProcess
- Creates a managed curses matrix widget.
cc [ flag ... ] file ... -lcdk [ library ... ]
#include <cdk.h>
CDKMATRIX *newCDKMatrix (CDKSCREEN *cdkscreen, int xpos,
int ypos, int screenRows, int screenCols, int actualRows,
int actualCols, char *title, char **rowTitles, char
**colTitles, int *columnWidths, int *columnTypes, int
rowSpace, int colSpace, chtype filler, int dominantAt-
tribute, boolean boxCell, boolean shadow);
int activateCDKMatrix (CDKMATRIX *matrix, chtype *
actions);
int injectCDKMatrix (CDKMATRIX *matrix, chtype input);
void setCDKMatrix (CDKMATRIX *matrix, char **info, int
rows, int *columnLengths);
void setCDKMatrixCell (CDKMATRIX *matrix, int row, int
col, char *value);
void getCDKMatrixCell (CDKMATRIX *matrix, int row, int
col);
void setCDKMatrixCB (CDKMATRIX *matrix, MATRIXCB callback-
Function);
void setCDKMatrixULChar (CDKMATRIX *,matrix, chtype char-
acter);
void setCDKMatrixURChar (CDKMATRIX *,matrix, chtype char-
acter);
void setCDKMatrixLLChar (CDKMATRIX *,matrix, chtype char-
acter);
void setCDKMatrixLRChar (CDKMATRIX *,matrix, chtype char-
acter);
void setCDKMatrixVerticalChar (CDKMATRIX *,matrix, chtype
character);
void setCDKMatrixHorizontalChar (CDKMATRIX *,matrix,
chtype character);
void setCDKMatrixBoxAttribute (CDKMATRIX *,matrix, chtype
character);
void setCDKMatrixBackgroundColor (CDKMATRIX *,matrix, char
* color);
void moveCDKMatrix (CDKMATRIX *matrix, int box, int box,
boolean relative, boolean refresh);
void positionCDKMatrix (CDKMATRIX *matrix);
void drawCDKMatrix (CDKMATRIX *matrix, boolean box);
void eraseCDKMatrix (CDKMATRIX *matrix);
void cleanCDKMatrix (CDKMATRIX *matrix);
int moveToCDKMatrixCell (CDKMATRIX *matrix, int row, int
col);
int jumpToCell (CDKMATRIX *matrix);
void destroyCDKMatrix (CDKMATRIX *matrix);
void setCDKMatrixPreProcess (CDKMATRIX *matrix, PROCESSFN
callback, void * data);
void setCDKMatrixPostProcess (CDKMATRIX *matrix, PROCESSFN
callback, void * data);
void bindCDKObject (EObjectType widgetType, void *object,
chtype key, BINDFN function, void *data);
The Cdk matrix widget creates a matrix widget. The following
are functions which create or manipulate the Cdk
matrix box widget.
CDKMATRIX *newCDKMatrix (CDKSCREEN *screen, int xpos, int
ypos, int screenRows, int screenCols, int actualRows, int
actualCols, char *title, char **rowTitles, char **colTi-
tles, int *colWidths, int *colTypes, int rowSpace, int
colSpace, chtype filler, int dominantAttribute, boolean
boxMatrix, boolean boxCell, boolean shadow);
This function creates a pointer to a matrix widget. The
screen parameter is the screen you wish this widget to
be placed in. The parameter xpos controls the placement
of the object along the horizontal axis. This parameter
can accept an integer value or one of the pre-defined
values of LEFT, RIGHT, and CENTER. The parameter ypos
controls the placement of the object along the vertical
axis. This parameter can accept an integer value or one
of the pre-defined values of TOP, BOTTOM, and CENTER.
The parameters screenRows and screenCols are the number
of rows and columns to be displayed on the screen
respectively; where actualRows and actualCols are the
number of actual rows and columns the matrix has. The
title parameter is the string which will be displayed
at the top of the widget. The title can be more than
one line; just provide a carriage return character at
the line break. The two parameters rowTitles and colTi-
tles are the titles along the row and columns respectively.
The parameter columnWidths is an array of integers
stating how wide the individual columns are to be.
The parameter columnTypes is an array of int which correspond
to the individual column display types. The
values of the array should be assigned a value of type
EDisplayType. (it is only declared an int out of
convenience) The following table outlines valid values
for this field and what the result is.
Display_Type Result
vCHAR Only accepts alphabetic characters.
vLCHAR Only accepts alphabetic characters.
Maps the character to lower case
when a character has been accepted.
vUCHAR Only accepts alphabetic characters.
Maps the character to upper case
when a character has been accepted.
vHCHAR Only accepts alphabetic characters.
Displays a . when a character
has been accepted.
vUHCHAR Only accepts alphabetic characters.
Displays a . and maps the
character to upper case when a
character has been accepted.
vLHCHAR Only accepts alphabetic characters.
Displays a . and maps the
character to lower case when a
character has been accepted.
vINT Only accepts numeric characters.
vHINT Only accepts numeric characters.
Displays a . when a character
has been accepted.
vMIXED Accepts any character types.
vLMIXED Accepts any character types.
Maps the character to lower case
when an alphabetic character has
been accepted.
vUMIXED Accepts any character types.
Maps the character to upper case
when an alphabetic character has
been accepted.
vHMIXED Accepts any character types.
Displays a . when a character
has been accepted.
vLHMIXED Accepts any character types.
Displays a . and maps the
charac}er to lower case when a
character has been accepted.
vUHMIXED Accepts any character types.
Displays a . and maps the
character to upper case when a
character has been accepted.
vVIEWONLY Uneditable field.
The parameters rowSpace and colSpace dictate how much
white space is to be between rows and columns respectively.
The filler option is the character to use in
empty space within a cell. The parameter dominantAt-
tribute states which between the two, the rows or the
columns, will have the dominant character attributes.
This is stated when a cell has both a row attribute and
a column attribute. If the value of the parameter domi-
nantAttribute is set to ROW then the attribute of the
row will be displayed. If it is set to COL then the
column's attributes will be displayed instead. The box-
Matrix parameter states whether the widget will be
drawn with a box around it or not. The boxCell parameter
states whether or not the individual cells will
have boxes drawn around them. The shadow parameter
accepts a boolean value to turn the shadow on or off
around this widget. If the widget could not be created
then a NULL pointer is returned.
int activateCDKMatrix (CDKMATRIX *matrix, chtype
*actions);
This function activates the matrix widget and lets the
user interact with the widget. The parameter matrix is
a pointer to a non-NULL matrix widget. If the actions
parameter is passed with a non-NULL value, the characters
in the array will be injected into the widget. To
activate the widget interactively pass in a NULL
pointer for actions. If the character entered into this
widget is RETURN then this function will return 1. It
will also set the structure member exitType to vNORMAL.
If the character entered into this widget was ESCAPE
then the widget will return a value of -1 and the
structure member exitType will be set to vESCAPE_HIT.
The matrix cell contents can be retrieved by using the
info array of the matrix widget.
int injectCDKMatrix (CDKMATRIX *matrix, chtype character);
This function injects a single character into the widget.
The parameter matrix is a pointer to a non-NULL
matrix widget. The parameter character is the character
to inject into the widget. If the character injected
into this widget was RETURN then this function will
return 1. It will also set the structure member exit-
Type to vNORMAL. If the character entered into this
widget was ESCAPE then the widget will return a value
of -1 and the structure member exitType will be set to
vESCAPE_HIT. Any other character injected into the widget
will set the structure member exitType to
vEARLY_EXIT and the function will return -1. The matrix
cell contents can be retrieved by using the info array
of the matrix widget.
void setCDKMatrix (CDKMATRIX *matrix, char **info, int
rows, int *columnLengths);
This function lets the programmer modify certain elements
of an already defined matrix widget. The parameter
info is an array of char * which contains the cell
information. The parameter rows has the number of rows
the parameter info contains, while columnLengths has
the lengths of the individual columns in info.
void setCDKMatrixCell (CDKMATRIX *matrix, int row, int
col, char *value);
This sets the contents of the cell located by the row
and col pair. The value of the cell will be set to
value.
char *getCDKMatrixCell (CDKMATRIX *matrix, int row, int
col);
This returns the contents of the cell located by the
row and col pair.
void setCDKMatrixCB (CDKMATRIX *matrix, MATRIXCB callback-
Function);
This function allows the programmer to set a different
widget input handler. The parameter callbackFunction
is of type MATRIXCB. The current default function is
CDKMatrixCallBack.
void setCDKMatrixULChar (CDKMATRIX *matrix, chtype charac-
ter);
This function sets the upper left hand corner of the
widgets box to the given character.
void setCDKMatrixURChar (CDKMATRIX *matrix, chtype charac-
ter);
This function sets the upper right hand corner of the
widgets box to the given character.
void setCDKMatrixLLChar (CDKMATRIX *matrix, chtype charac-
ter);
This function sets the lower left hand corner of the
widgets box to the given character.
void setCDKMatrixLRChar (CDKMATRIX *matrix, chtype charac-
ter);
This function sets the lower right hand corner of the
widgets box to the given character.
void setCDKMatrixVerticalChar (CDKMATRIX *matrix, chtype
character);
This function sets the vertical drawing character for
the box to the given character.
void setCDKMatrixHorizontalChar (CDKMATRIX *matrix, chtype
character);
This function sets the horizontal drawing character for
the box to the given character.
void setCDKMatrixBoxAttribute (CDKMATRIX *matrix, chtype
attribute);
This function sets the attribute of the box.
void setCDKMatrixBackgroundColor (CDKMATRIX *matrix, char
*color);
This sets the background color of the widget. The
parameter color is in the format of the Cdk format
strings. To get more information look at the cdk_dis-
play manual page.
void moveCDKMatrix (CDKMATRIX *matrix, int xpos, int ypos,
boolean relative, boolean refresh);
This function moves the given widget to the given position.
The parameters xpos and ypos is the new position
of the widget. The parameter xpos can accept an integer
value or one of the pre-defined values of TOP, BOTTOM,
and CENTER. The parameter ypos can accept an integer
value or one of the pre-defined values of LEFT, RIGHT,
and CENTER. The parameter relative states whether the
xpos/ypos pair is a relative move or an absolute move.
For example if xpos = 1 and ypos = 2 and relative =
TRUE, then the widget would move one row down and two
columns right. If the value of relative was FALSE then
the widget would move to the position (1,2). Do not use
the values of TOP, BOTTOM, LEFT, RIGHT, or CENTER when
relative = TRUE. (weird things may happen). The final
parameter refresh is a boolean value which states
whether the widget will get refreshed after the move or
not.
void positionCDKMatrix (CDKMATRIX *matrix);
This function allows the user to move the widget around
the screen via the cursor/keypad keys. The following
key bindings can be used to move the widget around the
screen.
Key Bindings
Key Action
Up Arrow Moves the widget up one line.
Down Arrow Moves the widget down one line.
Left Arrow Moves the widget left one column
Right Arrow Moves the widget right one column
Keypad-1 Moves the widget down one line
and left one column.
Keypad-2 Moves the widget down one line.
Keypad-3 Moves the widget down one line
and right one column.
Keypad-4 Moves the widget left one column
Keypad-5 Centers the widget both vertically
and horizontally.
Keypad-6 Moves the widget right one column
Keypad-7 Moves the widget up one line
and left one column.
Keypad-8 Moves the widget up one line.
Keypad-9 Moves the widget up one line
and right one column.
t Moves the widget to the top of the screen.
b Moves the widget to the bottom of the screen.
l Moves the widget to the left of the screen.
r Moves the widget to the right of the screen.
c Centers the widget between the left and
right of the window.
C Centers the widget between the top and
bottom of the window.
Escape Returns the widget to it's original position.
Return Exits the function and leaves the widget
where it was.
Keypad means that if the keyboard you are using has
a keypad, then the Num-Lock light has to be on in
order to use the keys as listed. (The numeric keys
at the top of the keyboard will work as well.)
void drawCDKMatrix (CDKMATRIX *matrix, boolean box);
This function draws the matrix widget on the
screen. The box option draws the widget with or
without a box.
void eraseCDKMatrix (CDKMATRIX *matrix);
This function removes the widget from the screen.
This does NOT destroy the widget.
void cleanCDKMatrix (CDKMATRIX *matrix);
This function clears the information from the
field.
int moveToCDKMatrixCell (CDKMATRIX *matrix, int row,
int col);
This function jumps to the given cells dictated
by the parameters row and col. It returns a value
of TRUE or FALSE depending if the move was successful
or not.
int jumpToCell (CDKMATRIX *matrix);
This function provides an interactive method of
moving to a cell. It pops up a scale widget and
asks which cell the user wants to go to. Then it
performs the jump.
void destroyCDKMatrix (CDKMATRIX *matrix);
This function removes the widget from the screen
and frees up any memory the object may be using.
void setCDKMatrixPreProcess (CDKMATRIX *matrix, PROCESSFN
function, void *data);
This function allows the user to have the widget
call a function after a key is hit and before the
key is applied to the widget. The parameter func-
tion if of type PROCESSFN. The parameter data is
a pointer to void. To learn more about pre-processing
read the cdk_process manual page.
void setCDKMatrixPostProcess (CDKMATRIX *matrix,
PROCESSFN function, void *data);
This function allows the user to have the widget
call a function after the key has been applied to
the widget. The parameter function if of type
PROCESSFN. The parameter data is a pointer to
void. To learn more about post-processing read
the cdk_process manual page.
void bindCDKObject (EObjectType widgetType, void
*object, char key, BINDFN function, void *data);
This function allows the user to create special
key bindings. The widgetType parameter is a
defined type which states what Cdk object type is
being used. To learn more about the type EOb-
jectType read the cdk_binding manual page. The
object parameter is the pointer to the widget
object. The key is the character to bind. The
function is the function type. To learn more
about the key binding callback function types
read the cdk_binding manual page. The last parameter
data is a pointer to any data that needs to
get passed to the callback function.
When the widget is activated there are several default key
bindings which will help the user enter or manipulate the
information quickly. The following table outlines the keys
and their actions for this widget.
Key Action
Left Arrow Moves one cell to the left.
Right Arrow Moves the cell to the right.
Tab Moves the cell to the right.
Up Arrow Moves one cell up.
Down Arrow Moves one cell down.
Next Page Moves one page forward.
Ctrl-F Moves one page forward.
Prev Page Moves one page backward.
Ctrl-B Moves one page backward.
Ctrl-G Calls the function jumpToCell and requests which
cell the user wishes to jump to.
Ctrl-P Pastes whatever is in the paste buffer, into the
current cell.
Ctrl-K Cuts the contents from the current cell and saves a
copy in the paste buffer.
Ctrl-T Copies the contents of the current cell into the
paste buffer.
Ctrl-E Erases the contents of the current cell.
Delete Deletes the character to the left of the cursor.
Backspace Deletes the character to the left of the cursor.
Ctrl-H Deletes the character to the left of the cursor.
Return Exits the widget and returns 1. This also sets
the structure member exitType in the
widget pointer to the value of vNORMAL.
Escape Exits the widget and returns -1. This also sets
the structure member exitType in the widget
pointer to the value of vESCAPE_HIT.
Ctrl-L Refreshes the screen.
cdk(3), cdk_binding(3), cdk_display(3), cdk_screen(3)
The header file <cdk.h> automatically includes the header
files <curses.h>, <stdlib.h>, <string.h>, <ctype.h>,
<unistd.h>, <dirent.h>, <time.h>, <errno.h>, <pwd.h>,
<grp.h>, <sys/stat.h>, and <sys/types.h>. The <curses.h>
header file includes <stdio.h> and <unctrl.h>.
If you have Ncurses installed on your machine add
-DNCURSES to the compile line to include the Ncurses
header files instead.
24 April 1997 cdk_matrix(3)
[ Back ] |