NetBSD/dist/cdk/man/cdk_matrix.3

513 lines
21 KiB
Groff

.de It
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH cdk_matrix 3 "24 April 1997"
.SH NAME
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.
.SH SYNOPSIS
.LP
.B cc
.RI "[ " "flag" " \|.\|.\|. ] " "file" " \|.\|.\|."
.B \-lcdk
.RI "[ " "library" " \|.\|.\|. ]"
.LP
#include <cdk.h>
.LP
.BI "CDKMATRIX *newCDKMatrix (CDKSCREEN *" "cdkscreen",
.BI "int " "xpos",
.BI "int " "ypos",
.BI "int " "screenRows",
.BI "int " "screenCols",
.BI "int " "actualRows",
.BI "int " "actualCols",
.BI "char *" "title",
.BI "char **" "rowTitles",
.BI "char **" "colTitles",
.BI "int *" "columnWidths",
.BI "int *" "columnTypes",
.BI "int " "rowSpace",
.BI "int " "colSpace",
.BI "chtype " "filler",
.BI "int " "dominantAttribute",
.BO "boolean " "boxMatrix",
.BI "boolean " "boxCell",
.BI "boolean " "shadow");
.LP
.BI "int activateCDKMatrix (CDKMATRIX *" "matrix",
.BI "chtype * " "actions");
.LP
.BI "int injectCDKMatrix (CDKMATRIX *" "matrix",
.BI "chtype " "input");
.LP
.BI "void setCDKMatrix (CDKMATRIX *" "matrix",
.BI "char **" "info",
.BI "int " "rows",
.BI "int *" "columnLengths");
.LP
.BI "void setCDKMatrixCell (CDKMATRIX *" "matrix",
.BI "int " "row",
.BI "int " "col",
.BI "char *" "value");
.LP
.BI "char * getCDKMatrixCell (CDKMATRIX *" "matrix",
.BI "int " "row",
.BI "int " "col");
.LP
.BI "void setCDKMatrixCB (CDKMATRIX *" "matrix",
.BI "MATRIXCB " "callbackFunction");
.LP
.BI "void setCDKMatrixULChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixURChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixLLChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixLRChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixVerticalChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixHorizontalChar (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixBoxAttribute (CDKMATRIX *", "matrix",
.BI "chtype " "character");
.LP
.BI "void setCDKMatrixBackgroundColor (CDKMATRIX *", "matrix",
.BI "char * " "color");
.LP
.BI "void moveCDKMatrix (CDKMATRIX *" "matrix",
.BI "int " "box",
.BI "int " "box",
.BI "boolean " "relative",
.BI "boolean " "refresh");
.LP
.BI "void positionCDKMatrix (CDKMATRIX *" "matrix");
.LP
.BI "void drawCDKMatrix (CDKMATRIX *" "matrix",
.BI "boolean " "box");
.LP
.BI "void eraseCDKMatrix (CDKMATRIX *" "matrix");
.LP
.BI "void cleanCDKMatrix (CDKMATRIX *" "matrix");
.LP
.BI "int moveToCDKMatrixCell (CDKMATRIX *" "matrix",
.BI "int " "row",
.BI "int " "col");
.LP
.BI "int jumpToCell (CDKMATRIX *" "matrix");
.LP
.BI "void destroyCDKMatrix (CDKMATRIX *" "matrix");
.LP
.BI "void setCDKMatrixPreProcess (CDKMATRIX *" "matrix",
.BI "PROCESSFN " "callback",
.BI "void * " "data");
.LP
.BI "void setCDKMatrixPostProcess (CDKMATRIX *" "matrix",
.BI "PROCESSFN " "callback",
.BI "void * " "data");
.LP
.BI "void bindCDKObject (EObjectType " "widgetType",
.BI "void *" "object",
.BI "chtype " "key",
.BI "BINDFN " "function",
.BI "void *" "data");
.SH DESCRIPTION
The Cdk matrix widget creates a matrix widget. The following are functions which
create or manipulate the Cdk matrix box widget.
.SH AVAILABLE FUNCTIONS
CDKMATRIX *newCDKMatrix (CDKSCREEN *\f2screen\f1, int \f2xpos\f1, int \f2ypos\f1, int \f2screenRows\f1, int \f2screenCols\f1, int \f2actualRows\f1, int \f2actualCols\f1, char *\f2title\f1, char **\f2rowTitles\f1, char **\f2colTitles\f1, int *\f2colWidths\f1, int *\f2colTypes\f1, int \f2rowSpace\f1, int \f2colSpace\f1, chtype \f2filler\f1, int \f2dominantAttribute\f2, boolean \f2boxMatrix\f1, boolean \f2boxCell\f1, boolean \f2shadow\f1);
.RS 3
This function creates a pointer to a matrix widget. The \f2screen\f1 parameter
is the screen you wish this widget to be placed in. The parameter \f2xpos\f1
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 \f4LEFT\f1,
\f4RIGHT\f1, and \f4CENTER\f1. The parameter \f2ypos\f1 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 \f4TOP\f1, \f4BOTTOM\f1, and \f4CENTER\f1.
The parameters \f2screenRows\f1 and \f2screenCols\f1 are the number of rows and
columns to be displayed on the screen respectively; where \f2actualRows\f1 and
\f2actualCols\f1 are the number of actual rows and columns the matrix has.
The \f2title\f1 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 \f2rowTitles\f1 and \f2colTitles\f1
are the titles along the row and columns respectively. The parameter
\f2columnWidths\f1 is an array of integers stating how wide the individual
columns are to be. The parameter \f2columnTypes\f1 is an array of \f4int\f1
which correspond to the individual column display types. The values of the
array should be assigned a value of type \f4EDisplayType\f1. (it is only
declared an \f4int\f1 out of convenience) The following table outlines valid
values for this field and what the result is.
.RS 3
.nf
\f2Display_Type Result\f1
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 \f4.\f1 when a character
has been accepted.
vUHCHAR Only accepts alphabetic characters.
Displays a \f4.\f1 and maps the
character to upper case when a
character has been accepted.
vLHCHAR Only accepts alphabetic characters.
Displays a \f4.\f1 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 \f4.\f1 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 \f4.\f1 when a character
has been accepted.
vLHMIXED Accepts any character types.
Displays a \f4.\f1 and maps the
charac}er to lower case when a
character has been accepted.
vUHMIXED Accepts any character types.
Displays a \f4.\f1 and maps the
character to upper case when a
character has been accepted.
vVIEWONLY Uneditable field.
.fi
.RE
The parameters \f2rowSpace\f1 and \f2colSpace\f1 dictate how much white space
is to be between rows and columns respectively. The \f2filler\f1 option is the
character to use in empty space within a cell. The parameter
\f2dominantAttribute\f1 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
\f2dominantAttribute\f1 is set to \f2ROW\f1 then the attribute of the row
will be displayed. If it is set to \f2COL\f1 then the column's attributes
will be displayed instead. The \f2boxMatrix\f1 parameter states whether
the widget will be drawn with a box around it or not. The \f2boxCell\f1
parameter states whether or not the individual cells will have boxes drawn
around them. The \f2shadow\f1 parameter accepts a boolean value to turn
the shadow on or off around this widget. If the widget could not be created
then a \f4NULL\f1 pointer is returned.
.RE
int activateCDKMatrix (CDKMATRIX *\f2matrix\f1, chtype *\f2actions\f1);
.RS 3
This function activates the matrix widget and lets the user interact with the
widget. The parameter \f2matrix\f1 is a pointer to a non-NULL matrix widget.
If the \f2actions\f1 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 \f4NULL\f1 pointer for \f2actions\f1. If the character
entered into this widget is \f4RETURN\f1 then this function will return 1.
It will also set the structure member \f4exitType\f1 to \f4vNORMAL\f1.
If the character entered into this widget was \f4ESCAPE\f1 then the widget
will return a value of -1 and the structure member \f4exitType\f1 will be
set to \f4vESCAPE_HIT\f1. The matrix cell contents can be retrieved by using
the \f2info\f1 array of the matrix widget.
.RE
int injectCDKMatrix (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function injects a single character into the widget. The parameter
\f2matrix\f1 is a pointer to a non-NULL matrix widget. The parameter
\f2character\f1 is the character to inject into the widget. If the character
injected into this widget was \f4RETURN\f1 then this function will return 1.
It will also set the structure member \f4exitType\f1 to \f4vNORMAL\f1. If
the character entered into this widget was \f4ESCAPE\f1 then the widget
will return a value of -1 and the structure member \f4exitType\f1 will be
set to \f4vESCAPE_HIT\f1. Any other character injected into the widget
will set the structure member \f4exitType\f1 to \f4vEARLY_EXIT\f1 and the
function will return -1. The matrix cell contents can be retrieved by
using the \f2info\f1 array of the matrix widget.
.RE
void setCDKMatrix (CDKMATRIX *\f2matrix\f1, char **\f2info\f1, int \f2rows\f1, int *\f2columnLengths\f1);
.RS 3
This function lets the programmer modify certain elements of an already defined
matrix widget. The parameter \f2info\f1 is an array of \f4char *\f1 which
contains the cell information. The parameter \f2rows\f1 has the number of rows
the parameter \f2info\f1 contains, while \f2columnLengths\f1 has the lengths of
the individual columns in \f2info\f1.
.RE
void setCDKMatrixCell (CDKMATRIX *\f2matrix\f1, int \f2row\f1, int \f2col\f1, char *\f2value\f1);
.RS 3
This sets the contents of the cell located by the \f2row\f1 and \f2col\f1 pair. The
value of the cell will be set to \f2value\f1.
.RE
char *getCDKMatrixCell (CDKMATRIX *\f2matrix\f1, int \f2row\f1, int \f2col\f1);
.RS 3
This returns the contents of the cell located by the \f2row\f1 and \f2col\f1 pair.
.RE
void setCDKMatrixCB (CDKMATRIX *\f2matrix\f1, MATRIXCB \f2callbackFunction\f1);
.RS 3
This function allows the programmer to set a different widget input handler.
The parameter \f2callbackFunction\f1 is of type \f4MATRIXCB\f1. The current
default function is \f4CDKMatrixCallBack\f1.
.RE
void setCDKMatrixULChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the upper left hand corner of the widgets box to
the given character.
.RE
void setCDKMatrixURChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the upper right hand corner of the widgets box to
the given character.
.RE
void setCDKMatrixLLChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the lower left hand corner of the widgets box to
the given character.
.RE
void setCDKMatrixLRChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the lower right hand corner of the widgets box to
the given character.
.RE
void setCDKMatrixVerticalChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the vertical drawing character for the box to
the given character.
.RE
void setCDKMatrixHorizontalChar (CDKMATRIX *\f2matrix\f1, chtype \f2character\f1);
.RS 3
This function sets the horizontal drawing character for the box to
the given character.
.RE
void setCDKMatrixBoxAttribute (CDKMATRIX *\f2matrix\f1, chtype \f2attribute\f1);
.RS 3
This function sets the attribute of the box.
.RE
void setCDKMatrixBackgroundColor (CDKMATRIX *\f2matrix\f1, char *\f2color\f1);
.RS 3
This sets the background color of the widget. The parameter \f2color\f1
is in the format of the Cdk format strings. To get more information look
at the \f4cdk_display\f1 manual page.
.RE
void moveCDKMatrix (CDKMATRIX *\f2matrix\f1, int \f2xpos\f1, int \f2ypos\f1, boolean \f2relative\f1, boolean \f2refresh\f1);
.RS 3
This function moves the given widget to the given position. The parameters
\f2xpos\f1 and \f2ypos\f1 is the new position of the widget. The parameter
\f2xpos\f1 can accept an integer value or one of the pre-defined values of
\f4TOP\f1, \f4BOTTOM\f1, and \f4CENTER\f1. The parameter \f2ypos\f1 can
accept an integer value or one of the pre-defined values of \f4LEFT\f1,
\f4RIGHT\f1, and \f4CENTER\f1. The parameter \f2relative\f1 states whether
the \f2xpos\f1/\f2ypos\f1 pair is a relative move or an absolute move. For
example if \f2xpos\f1 = 1 and \f2ypos\f1 = 2 and \f2relative\f1 = \f2TRUE\f1,
then the widget would move one row down and two columns right. If the value
of \f2relative\f1 was \f2FALSE\f1 then the widget would move to the position
(1,2). Do not use the values of \f4TOP\f1, \f4BOTTOM\f1, \f4LEFT\f1,
\f4RIGHT\f1, or \f4CENTER\f1 when \f2relative\f1 = \f4TRUE\f1. (weird things
may happen). The final parameter \f2refresh\f1 is a boolean value which
states whether the widget will get refreshed after the move or not.
.RE
void positionCDKMatrix (CDKMATRIX *\f2matrix\f1);
.RS 3
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.
.LP
.nf
\f4Key Bindings\f1
.RS 3
\f2Key Action\f1
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 its original position.
Return Exits the function and leaves the widget
where it was.
.fi
.RE
.RS 3
.LP
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.)
.LP
void drawCDKMatrix (CDKMATRIX *\f2matrix\f1, boolean \f2box\f1);
.RS 3
This function draws the matrix widget on the screen. The \f2box\f1 option
draws the widget with or without a box.
.RE
void eraseCDKMatrix (CDKMATRIX *\f2matrix\f1);
.RS 3
This function removes the widget from the screen. This does \f4NOT\f1 destroy
the widget.
.RE
void cleanCDKMatrix (CDKMATRIX *\f2matrix\f1);
.RS 3
This function clears the information from the field.
.RE
int moveToCDKMatrixCell (CDKMATRIX *\f2matrix\f1, int \f2row\f1, int \f2col\f1);
.RS 3
This function jumps to the given cells dictated by the parameters \f2row\f1
and \f2col\f1. It returns a value of \f4TRUE\f1 or \f4FALSE\f1 depending if
the move was successful or not.
.RE
int jumpToCell (CDKMATRIX *\f1matrix\f1);
.RS 3
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.
.RE
void destroyCDKMatrix (CDKMATRIX *\f2matrix\f1);
.RS 3
This function removes the widget from the screen and frees up any memory the
object may be using.
.RE
void setCDKMatrixPreProcess (CDKMATRIX *\f2matrix\f1, PROCESSFN \f2function\f1, void *\f2data\f1);
.RS 3
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 \f2function\f1
if of type \f4PROCESSFN\f1. The parameter \f2data\f1 is a pointer to
\f4void\f1. To learn more about pre-processing read the \f4cdk_process\f1
manual page.
.RE
void setCDKMatrixPostProcess (CDKMATRIX *\f2matrix\f1, PROCESSFN \f2function\f1, void *\f2data\f1);
.RS 3
This function allows the user to have the widget call a function after the
key has been applied to the widget. The parameter \f2function\f1 if of type
\f4PROCESSFN\f1. The parameter \f2data\f1 is a pointer to \f4void\f1. To
learn more about post-processing read the \f4cdk_process\f1 manual page.
.RE
void bindCDKObject (EObjectType \f2widgetType\f1, void *\f2object\f1, char \f2key\f1, BINDFN \f2function\f1, void *\f2data\f1);
.RS 3
This function allows the user to create special key bindings. The
\f2widgetType\f1 parameter is a defined type which states what Cdk object
type is being used. To learn more about the type \f4EObjectType\f1 read the
\f4cdk_binding\f1 manual page. The \f2object\f1 parameter is the pointer to
the widget object. The \f2key\f1 is the character to bind. The \f2function\f1
is the function type. To learn more about the key binding callback function
types read the \f4cdk_binding\f1 manual page. The last parameter \f2data\f1
is a pointer to any data that needs to get passed to the callback function.
.RE
.SH KEY BINDINGS
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.
.LP
.RS 3
.nf
\f2Key Action\f1
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 \f4jumpToCell\f1 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 \f4exitType\f1 in the
widget pointer to the value of \f4vNORMAL\f1.
Escape Exits the widget and returns -1. This also sets
the structure member \f4exitType\f1 in the widget
pointer to the value of \f4vESCAPE_HIT\f1.
Ctrl-L Refreshes the screen.
.RE
.fi
.SH SEE ALSO
.BR cdk (3),
.BR cdk_binding (3),
.BR cdk_display (3),
.BR cdk_screen (3)
.SH NOTES
.PP
The header file \f4<cdk.h>\f1 automatically includes the header files
\f4<curses.h>\f1, \f4<stdlib.h>\f1, \f4<string.h>\f1, \f4<ctype.h>\f1,
\f4<unistd.h>\f1, \f4<dirent.h>\f1, \f4<time.h>\f1, \f4<errno.h>\f1,
\f4<pwd.h>\f1, \f4<grp.h>\f1, \f4<sys/stat.h>\f1, and \f4<sys/types.h>\f1.
The \f4<curses.h>\f1 header file includes \f4<stdio.h>\f1 and \f4<unctrl.h>\f1.
.PP
If you have \f4Ncurses\f1 installed on your machine add -DNCURSES to the
compile line to include the Ncurses header files instead.