Creating a New Logical Attribute Array at Run-time

The system logical attributes provide a very flexible means of color control and will suffice for most applications. For some applications, you may wish to have logical attributes that are separate from those of the system. Vermont Views allows you to define one or more additional sets of logical attributes and assign a specific set to be used with each window, form, or menu. When you do not assign a set to a window, form, or menu, the system or Designer logical attributes will be used by output functions.

The window structure contains a member (UCHAR *lattarray) whose purpose is to allow window-specific logical attributes. When this member is NULLP, the system uses the LATT_SYS, the system logical attribute array. If the member contains a pointer, the window output functions will use the contents of this array to determine the physical attribute that corresponds to a specified logical attribute.

Because forms and menus are all displayed within windows, forms and menus also can use this facility.

To create and use a logical attribute array other than the system's, you can copy a column from the system table, modify it during run-time, and associate the new array with each window that is to use it. These steps are described in detail below:

Step 1: Copy a column from the system table and modify it.

Use the logical attribute array initialization function, latt_init(), to copy a column from the system logical attribute table to a logical attribute array.

The latt_init() function call is as follows:

int latt_init(tbl_col, lattrowq, latt_colq, att_tbl, latt_array)
 
int tbl_col;    
/* Column to copy from table
*/
int latt_rowq;
/* Number of rows in the table
*/
int latt_colq;
/* Number of columns in the table
*/
UCHAR *att_tbl[][PATTQ];
/* Attribute table to copy column from
*/
UCHAR *latt_array;
/* Logical attribute array to copy column to
*/

Then, call latt_rpl() to change the definitions for this array. For example, the calls could be as follows:

latt_init(1, LATTQ, PATTQ, _att_tbl, my_latt);

latt_rpl(LHELP, NORMAL, LIGHT | BLUE, BLUE, my_latt);

As many calls to latt_rpl() as desired could be made.

Step 2: Assign your logical attribute array to each window that is to use it.

The function to set the logical attribute array to use for a window is the set window logical attribute function, sw_latt():

void sw_latt(latt_array, wnp)
 
UCHAR latt_array[];
/* Logical attribute array to use for window
*/
WINDOWPTR wnp;
/* Pointer to a window
*/

To assign the logical attribute array my_latt to a form, make the call:

sw_latt(my_latt, fmp->wnp);


Home Contents Previous Next