home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* PICKLIST.C */
- /* */
- /* This is a demonstration of how to use UltraWin and InTUItion to perform */
- /* some slick pick lists and browsers with full keyboard and mouse */
- /* capability! This file was created with a tab size of 2, and is heavily */
- /* commented. */
- /* */
- /* Boyd Gafford */
- /* EnQue Software */
- /* 03/16/92 */
- /* */
- /****************************************************************************/
- #include <ctype.h>
- #include <stdio.h>
- #include "t.h" /* include the main TUI header file */
- #include "picklist.def" /* include the TUICP define file */
-
- #define SH_TOP_LEFT 0 /* used by shadow window functions */
- #define SH_TOP_RIGHT 1
- #define SH_BOTTOM_RIGHT 2
- #define SH_BOTTOM_LEFT 3
-
- /*----------------------- global program variables -------------------------*/
- TUI Demo_tui;
-
- char *Text_strs[] =
- {" EnQue Offers FREE Programming Tools for C",
- "",
- " EnQue Software has released a new version of its UltraWin text",
- " windowing library. Key features of UltraWin 2.60 are unlimited overlapping",
- " windows, background printing, PC timer control, mouse and graphic support,",
- " and enhanced data entry capabilities. Also included are a hypertext help",
- " engine and an EGA/VGA font editor.",
- "",
- " Also released is InTUItion 1.60, a textual user-interface library that",
- " includes an interface construction program that allows UltraWin users to",
- " interactively create dialog boxes, menus, pick lists, forms and more using",
- " a mouse. Source code can be automatically generated to perform processing",
- " on each item, saving hours of tedious hand coding and debugging.",
- "",
- " The UltraWin and InTUItion tools and small model libraries are available",
- " FREE from most major online services, the EnQue BBS, or by sending $2.00 for",
- " shipping and handling to EnQue Software. Complete source code, large model",
- " libraries and printed manual can be obtained from EnQue for $99.95 for",
- " UltraWin and $199.90 for both UltraWin and InTUItion. Free upgrades and",
- " technical support are available through the EnQue BBS.",
- "",
- " Requires either Microsoft C or Quick C, Turbo C/C++, Borland C/C++,",
- " Watcom C32 or Zortech C/C++. For more information please contact:",
- "",
- " EnQue Software",
- " Route 1, Box 116C",
- " Pleasant Hill, MO 64080",
- " Voice/Fax (816) 987-2515",
- " EnQue BBS (816) 353-0991"
- };
-
- char *Pick_strs[] =
- {
- " Brock, Eddie",
- " Forbush, Irving",
- " Gafford, Boyd ",
- " Huck, Kevin",
- " Jameson, J.J ",
- " Lee, Stan",
- " Leeds Brant, Betty",
- " Leeds, Ned",
- " Lubinsky, Nathan",
- " Osborne, Harry",
- " Parker, Ben",
- " Parker, May",
- " Parker, Peter",
- " Robinson, Robbie",
- " Stacy, Gwen",
- " Thompson, Flash",
- " Watson, Anna",
- " Watson Parker, Mary Jane",
- " Whitman, Deborah"
- };
-
- /*------------------------------ prototypes --------------------------------*/
- void interact_menu( TUI *tuip, int dlg_inx );
- void pick_sel( TUI *tuip, int dlg_inx );
- void output_str( int x, int y, int w, int first_inx, char *str, WINDOW *wnp );
- void browse_strings( char **strs, int num );
- int pick_strings( char **strs, int num );
- void msg_line( char *msg );
- void deselect_and_draw( TUI *tuip, int inx );
- void shadow_window( WINDOW *wnp, int type, int w, int h, int att );
- void unshadow_window( WINDOW *wnp );
-
- /*********/
- /* ~main */
- /* ********************************************************************/
- /****************************************************************************/
- void main(void)
- {
- WINDOW *desk_wnp;
- int i, c;
-
- load_tui(&Demo_tui, "PICKLIST.TUI");
- init_tui(&Demo_tui);
- init_clock(0x3333); /* use 91 ticks/sec. This */
- /* is required for tone and */
- /* for more precise timing! */
- m_hide();
- c = (Demo_tui.back_att & 0xF0) >> 4; /* get background color */
- desk_wnp = Demo_tui.back_wnp; /* get desktop window ptr */
- desk_wnp->scroll = OFF; /* turn off desktop scroll */
- for (i=0; i<182; i++) /* do a little background */
- { /* to show off the shadow */
- wn_color((i % 8) + 8, c, desk_wnp);
- wn_st("InTUItion ", desk_wnp);
- }
- desk_wnp->att = Demo_tui.back_att; /* restore desktop att */
- wn_color(BLACK, BLUE, desk_wnp);
- m_show();
-
- interact_menu(&Demo_tui, MENU_DIALOG); /* do the main menu! */
-
- end_clock(); /* and the cleanup stuff */
- end_tui(&Demo_tui);
- free_tui(&Demo_tui);
- exit(0);
- }
- /*** end of main ***/
-
- /******************/
- /* ~interact_menu */
- /* ***********************************************************/
- /* This function pulls up the main TUI menu, and allows the user to select */
- /* the demonstration for each function. Notice how both the internal */
- /* transfer mechanism (recursion of do_dialog) and the "do it yourself" */
- /* transfer is done. */
- /****************************************************************************/
- void interact_menu( TUI *tuip, int dlg_inx )
- {
- WINDOW *wnp;
- int ret_inx, inx, end_flag = OFF;
- char disp_str[81];
-
- draw_dialog(tuip, dlg_inx); /* show the dialog */
- wnp = get_dlg_wnp(tuip, dlg_inx); /* get the window pointer */
- m_hide();
- shadow_window(wnp, SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- m_show();
- while (!end_flag)
- {
- msg_line("Select from the menu above");
- ret_inx = do_dialog(tuip, dlg_inx, DO_NORMAL);
- switch( ret_inx )
- {
- /*---------------- these are from the internal xfer ------------------*/
- /*-- each button in the transfer dialog was set to exit all levels ---*/
- case SEL_1: tone(256, 20); break;
- case SEL_2: tone(512, 20); break;
- case SEL_3: tone(768, 20); break;
- case SEL_4: tone(1024, 20); break;
- case SEL_5: tone(1280, 20); break;
- case SEL_6: tone(1536, 20); break;
- case SEL_7: tone(1792, 20); break;
- case SEL_8: tone(2048, 20); break;
-
- /*-------------------- and do same thing ourselves -------------------*/
- case NORMAL_PICK_LIST:
- msg_line("Select from the menu at right");
- pick_sel(tuip, PICK_LIST_DLG);
- break;
-
- /*--------------------- browse the set of strings --------------------*/
- case STRING_BROWSER:
- msg_line("Use the cursor keys or sliders to scroll around the text");
- browse_strings(Text_strs, 29);
- break;
-
- /*--------------------- do a scrolling pick list! --------------------*/
- case SCROLLING_PICK_LIST:
- msg_line("Select a name from the list");
- if ( (inx = pick_strings(Pick_strs, 19)) != -1)
- {
- tone(2048, 10);
- sprintf(disp_str, "You chose%s!", Pick_strs[inx]);
- msg_line(disp_str);
- /* Uw_timers[0] = 91;
- while (Uw_timers[0] > 0) {} */
- wait_ticks(18L);
- }
- break;
-
- /*--------------------- the quit button was chosen -------------------*/
- case QUIT:
- end_flag = ON;
- break;
- }
- deselect_and_draw(tuip, ret_inx);
- }
- m_hide();
- unshadow_window(wnp);
- m_show();
- erase_dialog(tuip, dlg_inx);
- }
- /*** end of interact_menu ***/
-
- /*************/
- /* ~pick_sel */
- /* ****************************************************************/
- /* This is the equivalent of doing the transfer pick list ourselves! Note */
- /* that since this is a function, and not an internal recursive transfer, */
- /* we have full control of what we do WHEN we want to do it! That means we */
- /* can use the new shadow_window function do make things look 3-D. */
- /****************************************************************************/
- void pick_sel( TUI *tuip, int dlg_inx )
- {
- WINDOW *wnp;
- int ret_inx, end_flag = OFF, att = DARKGRAY;
-
- draw_dialog(tuip, dlg_inx); /* show the dialog */
- wnp = get_dlg_wnp(tuip, dlg_inx); /* get the window pointer */
- m_hide();
- shadow_window(wnp, SH_BOTTOM_RIGHT, 2, 1, att); /* and shadow it! */
- m_show();
- while (!end_flag)
- {
- ret_inx = do_dialog(tuip, dlg_inx, DO_NORMAL);
- switch( ret_inx )
- {
- /*---------------- ESC pressed or clicked off dialog -----------------*/
- case NO_SELECTION:
- end_flag = ON;
- break;
-
- /*------------------ selections 1-8 just do a tone -------------------*/
- case SEL_1: tone(256, 20), end_flag = ON; break;
- case SEL_2: tone(512, 20), end_flag = ON; break;
- case SEL_3: tone(768, 20), end_flag = ON; break;
- case SEL_4: tone(1024, 20), end_flag = ON; break;
- case SEL_5: tone(1280, 20), end_flag = ON; break;
- case SEL_6: tone(1536, 20), end_flag = ON; break;
- case SEL_7: tone(1792, 20), end_flag = ON; break;
- case SEL_8: tone(2048, 20), end_flag = ON; break;
- }
- deselect_and_draw(tuip, ret_inx);
- }
- m_hide();
- unshadow_window(wnp);
- m_show();
- erase_dialog(tuip, dlg_inx);
- }
- /*** end of pick_sel ***/
-
- /***************/
- /* ~output_str */
- /* **************************************************************/
- /* This function takes a string, and outputs it to the window, space padded */
- /* out to the width passed, if necessary. if the string is too long for */
- /* the width passed, then it is truncated! This is a simple routine that */
- /* is used by pick_strings and browse_strings to output each entry to the */
- /* window passed by pointer. A handy function to have around. */
- /****************************************************************************/
- void output_str( int x, int y, int w, int first_inx, char *str, WINDOW *wnp )
- {
- int len = strlen(str);
-
- mv_cs(x, y, wnp);
- if (first_inx >= len)
- wn_qch(w, ' ', wnp);
- else
- {
- len = strlen(&str[first_inx]);
- if (len < w)
- wn_st(&str[first_inx], wnp), wn_qch(w - len, ' ', wnp);
- else
- wn_st_qty(&str[first_inx], w, wnp);
- }
- }
- /*** end of output_str ***/
-
- /*******************/
- /* ~browse_strings */
- /* **********************************************************/
- /* Take the array of string pointers and the number of strings, and allow */
- /* the user to browse through using either the keypad or slide bars. This */
- /* is a simple "text file viewer", and adapts to the size of the box in the */
- /* dialog. To give a bigger view area, just size the display box with the */
- /* TUICP. You can also move buttons and sliders around without affecting */
- /* this function -- it is all transparent to the code! */
- /****************************************************************************/
- void browse_strings( char **strs, int num )
- {
- TUI *tuip = &Demo_tui;
- WINDOW *wnp;
- long tics;
- int dlg_inx = BROWSER_DLG, ret_inx, end_flag = OFF;
- int i, max_len, max_x, max_y, x_off = 0, y_off = 0, disp_flag = ON,
- x = get_item_x(tuip, BROWSER_BOX) - 1,
- y = get_item_y(tuip, BROWSER_BOX) - 1,
- w = get_item_w(tuip, BROWSER_BOX),
- h = get_item_h(tuip, BROWSER_BOX),
- att = get_box_att(tuip, BROWSER_BOX),
- num_shown = min(num, h);
-
- max_len = 0; /* find longest length */
- for (i=0; i<num; i++) /* for all strings */
- if ((int) strlen(strs[i]) > max_len)
- max_len = (int) strlen(strs[i]);
-
- max_x = max(max_len - w, 0); /* find maximum x offset */
- max_y = max(num - h, 0); /* find maximum y offset */
-
-
- set_slider(tuip, BROWSER_HSLIDER, /* set slider positions */
- (long) x_off, (long) w, (long) (max_x + 1));
- set_slider(tuip, BROWSER_VSLIDER,
- (long) y_off, (long) h, (long) (max_y + 1));
- draw_dialog(tuip, dlg_inx);
- wnp = get_dlg_wnp(tuip, dlg_inx); /* get the window pointer */
- m_hide();
- shadow_window(wnp, SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- m_show();
- while (!end_flag)
- {
-
- if (disp_flag) /* time to display! */
- {
- switch(disp_flag) /* do appropriate slider */
- {
- case 1:
- set_slider(tuip, BROWSER_HSLIDER,
- (long) x_off, (long) w, (long) (max_x + 1));
- draw_item(tuip, BROWSER_HSLIDER);
- break;
- case 2:
- set_slider(tuip, BROWSER_VSLIDER,
- (long) y_off, (long) h, (long) (max_y + 1));
- draw_item(tuip, BROWSER_VSLIDER);
- break;
- }
- push(wnp->att); /* save the window att */
- wnp->att = att; /* use box color itself! */
- m_hide(); /* hide for uwin output */
- for (i=0; i<num_shown; i++) /* loop through the list */
- output_str(x, y + i, w, x_off, /* and display the string */
- strs[i + y_off], wnp);
- m_show(); /* show after uwin output */
- pop(wnp->att); /* restore the window att */
- disp_flag = OFF;
- }
-
- ret_inx = do_dialog(tuip, dlg_inx, DO_RETURN_EVENT | DO_RETURN_CMD );
-
- switch( ret_inx )
- {
- /*---------------- ESC pressed or clicked off dialog -----------------*/
- case NO_SELECTION:
- case BROWSER_CANCEL:
- end_flag = ON;
- break;
-
- /*---------------------- an event not processable --------------------*/
- case EVENT_RETURNED:
- if (!Event.is_mouse)
- switch( Event.key )
- {
- case KEY_UP: /* up one line */
- if (y_off > 0)
- y_off--, disp_flag = 2;
- break;
- case KEY_DN: /* down one line */
- if (y_off < max_y)
- y_off++, disp_flag = 2;
- break;
- case KEY_PGUP: /* up one page */
- y_off -= h, disp_flag = 2;
- if (y_off < 0)
- y_off = 0;
- break;
- case KEY_PGDN: /* down one page */
- y_off += h, disp_flag = 2;
- if (y_off > max_y)
- y_off = max_y;
- break;
- case KEY_HOME: /* to top of list */
- y_off = 0, disp_flag = 2;
- break;
- case KEY_END: /* to bottom of list */
- y_off = max_y, disp_flag = 2;
- break;
- case KEY_LEFT: /* left one character */
- if (x_off > 0)
- x_off--, disp_flag = 1;
- break;
- case KEY_RIGHT: /* right one character */
- if (x_off < max_x)
- x_off++, disp_flag = 1;
- break;
- }
- break;
-
- case BROWSER_HSLIDER:
- tics = Tics; /* just a 4/91 sec delay */
- while (Tics - tics < 4L) {}
- x_off = (int) get_sldr_pos(tuip, BROWSER_HSLIDER);
- disp_flag = 1;
- break;
-
- case BROWSER_VSLIDER:
- tics = Tics; /* just a 4/91 sec delay */
- while (Tics - tics < 4L) {}
- y_off = (int) get_sldr_pos(tuip, BROWSER_VSLIDER);
- disp_flag = 2;
- break;
-
- case BROWSER_OK:
- end_flag = ON;
- break;
-
- }
- deselect_and_draw(tuip, ret_inx);
- }
- m_hide();
- unshadow_window(wnp);
- m_show();
- erase_dialog(tuip, dlg_inx);
- }
- /*** end of browse_strings ***/
-
- /*****************/
- /* ~pick_strings */
- /* ************************************************************/
- /* Take the array of string pointers, and allow the user to select from */
- /* them using the dialog we designed with the TUICP. Please note that the */
- /* function will return 0 to num - 1 if the string was selected, or a -1 if */
- /* no string was selected. You may edit the actual dialog with the TUICP, */
- /* and this routine will adapt to the size of the box for the strings, as */
- /* well as the number of strings shown. It's all automatic! Feel free to */
- /* use this routine in your own programs for situations where the user must */
- /* choose from an extensive list of items. */
- /****************************************************************************/
- int pick_strings( char **strs, int num )
- {
- TUI *tuip = &Demo_tui;
- WINDOW *wnp;
- long tics, last_tics = Tics;
- int dlg_inx = SCROLL_PICK_LIST_DLG, ret_inx, end_flag = OFF;
- int i, last = num - 1, csr = 0, offset = 0, disp_flag = ON,
- x = get_item_x(tuip, PICK_LIST_BOX) - 1,
- y = get_item_y(tuip, PICK_LIST_BOX) - 1,
- w = get_item_w(tuip, PICK_LIST_BOX),
- h = get_item_h(tuip, PICK_LIST_BOX),
- att = get_box_att(tuip, PICK_LIST_BOX),
- num_shown = min(num, h);
-
- set_slider(tuip, PICK_LIST_SLIDER, /* set slider position */
- (long) csr, (long) h, (long) num);
- draw_dialog(tuip, dlg_inx);
- wnp = get_dlg_wnp(tuip, dlg_inx); /* get the window pointer */
- m_hide();
- shadow_window(wnp, SH_BOTTOM_RIGHT, 2, 1, DARKGRAY);
- m_show();
- while (!end_flag)
- {
- if (disp_flag) /* time to display! */
- {
- if (csr < offset) /* validate index vars */
- offset = csr;
- if (offset < 0)
- offset = 0;
- if (offset < (csr - h + 1))
- offset = csr - h + 1;
-
- set_slider(tuip, PICK_LIST_SLIDER, /* set and draw slider */
- (long) csr, (long) h, (long) num);
- draw_item(tuip, PICK_LIST_SLIDER);
-
- push(wnp->att); /* save the window att */
- m_hide(); /* hide for uwin output */
- for (i=0; i<num_shown; i++) /* loop through the list */
- {
- if ( (offset + i) == csr ) /* set appropriate att */
- wn_color(WHITE, BLACK, wnp);
- else
- wn_att(att, wnp);
- output_str(x, y + i, w, 0, strs[i + offset], wnp);
- }
- m_show(); /* show after uwin output */
- pop(wnp->att); /* restore the window att */
- disp_flag = OFF;
- }
-
- ret_inx = do_dialog(tuip, dlg_inx, DO_RETURN_EVENT | DO_RETURN_CMD );
-
- switch( ret_inx )
- {
- /*---------------- ESC pressed or clicked off dialog -----------------*/
- /*-------------------- or Cancel button pressed ----------------------*/
- case NO_SELECTION:
- case PICK_LIST_CANCEL:
- csr = -1, end_flag = ON;
- break;
-
- /*---------------------- an event passed back to us -------------------*/
- case EVENT_RETURNED:
- if (!Event.is_mouse)
- switch( Event.key )
- {
- case KEY_HOME: /* to start of list */
- csr = offset = 0, disp_flag = ON;
- break;
- case KEY_END: /* to the end of the list */
- csr = last, disp_flag = ON;
- break;
- case KEY_PGUP: /* up one page */
- csr -= h;
- if (csr < 0)
- csr = 0;
- disp_flag = ON;
- break;
- case KEY_PGDN: /* down one page */
- csr += h;
- if (csr > last)
- csr = last;
- disp_flag = ON;
- break;
- case KEY_UP: /* up one entry */
- if (csr > 0)
- csr--, disp_flag = ON;
- break;
- case KEY_DN: /* down one entry */
- if (csr < last)
- csr++, disp_flag = ON;
- break;
- case KEY_ENTER:
- end_flag = ON;
- break;
- }
- break;
-
- /*--------------------------- the slider used -------------------------*/
- case PICK_LIST_SLIDER:
- tics = Tics; /* just a 4/91 sec delay */
- while (Tics - tics < 4L) {}
- csr = (int) get_sldr_pos(tuip, PICK_LIST_SLIDER);
- disp_flag = ON;
- break;
-
- /*-------------------- mouse clicked inside the box -------------------*/
- case PICK_LIST_BOX:
- disp_flag = ON;
- csr = offset + (Event.m_y - y - wnp->pane.y_min - 1);
- if (csr > last)
- csr = last;
- if( (Tics - last_tics) < 20L ) /* a double click? */
- end_flag = ON;
- last_tics = Tics;
- break;
-
- /*----------------------- the ok button was presed --------------------*/
- case PICK_LIST_OK:
- end_flag = ON;
- break;
- }
- deselect_and_draw(tuip, ret_inx);
- }
- m_hide();
- unshadow_window(wnp);
- m_show();
- erase_dialog(tuip, dlg_inx);
- return(csr);
- }
- /*** end of pick_strings ***/
-
- /*************/
- /* ~msg_line */
- /* ****************************************************************/
- /* Display the message at the last line on the screen. */
- /****************************************************************************/
- void msg_line( char *msg )
- {
- WINDOW *wnp = Demo_tui.back_wnp;
-
- push(wnp->att);
- wn_color(BLACK, LIGHTGRAY, wnp);
- mv_cs(0, V_rows - 1, wnp);
- wn_claol(wnp);
- wn_plst(CENTERED, V_rows - 1, msg, wnp);
- pop(wnp->att);
- }
- /*** end of msg_line ***/
-
- /**********************/
- /* ~deselect_and_draw */
- /* *******************************************************/
- /* Take the object indexed into the tui array by inx, deselect it, and draw */
- /* it. This "turns off" buttons when they are returned from do_dialog */
- /****************************************************************************/
- void deselect_and_draw( TUI *tuip, int inx )
- {
- if ( is_valid_inx(tuip, inx) )
- switch( get_item_type(tuip, inx) )
- {
- case T_BUTTON: case T_ICON:
- deselect(tuip, inx);
- draw_item(tuip, inx);
- break;
- }
- }
- /*** end of deselect_and_draw ***/
-
- /******************/
- /* ~shadow_window */
- /* ***********************************************************/
- /* This routine takes the window passed by pointer and shadows it. It does */
- /* this by creating sub windows using the usr_ptr member of the window */
- /* structure. */
- /* */
- /* The contents under these sub windows are read off the screen and put */
- /* inside the windows. The attribute is then changed and the window is */
- /* placed on the screen, giving the illusion of a shadow. */
- /* */
- /* You may pass this routine a width, height and attribute (DARKGRAY on */
- /* BLACK with a width of 2 and height of 1 usually looks nice). */
- /* You may also pass a type, which is a number from 0-3 (see #defines) that */
- /* indicates the direction the shadow falls. */
- /* */
- /* The main thing to remember is be SURE that you call the unshadow_window */
- /* function BEFORE you destroy the window, or else you will have heap */
- /* problems. */
- /****************************************************************************/
- void shadow_window( WINDOW *wnp, int type, int w, int h, int att )
- {
- WINDOW *wnp1, *wnp2; /* shadow window pointers */
- int x1 = wnp->pane.x_min; /* get the screen coords */
- int y1 = wnp->pane.y_min;
- int x2 = wnp->pane.x_max;
- int y2 = wnp->pane.y_max;
- int win1_x1, win1_y1, win1_x2, win1_y2;
- int win2_x1, win2_y1, win2_x2, win2_y2;
- int i;
- uchar *dest;
-
- if (wnp->usr_ptr == NULL)
- {
- switch(type)
- {
- case SH_TOP_LEFT:
- win1_x1 = x1 - w, win1_y1 = y1 - h; /* left side of window */
- win1_x2 = x1 - 1, win1_y2 = y2 - h;
- win2_x1 = x1 , win2_y1 = y1 - h; /* top side of window */
- win2_x2 = x2 - w, win2_y2 = y1 - 1;
- break;
- case SH_TOP_RIGHT:
- win1_x1 = x2 + 1, win1_y1 = y1 - h; /* right side of window */
- win1_x2 = x2 + w, win1_y2 = y2 - h;
- win2_x1 = x1 + w, win2_y1 = y1 - h; /* top side of window */
- win2_x2 = x2 , win2_y2 = y1 - 1;
- break;
- case SH_BOTTOM_LEFT:
- win1_x1 = x1 - w, win1_y1 = y1 + h; /* left side of window */
- win1_x2 = x1 - 1, win1_y2 = y2 + h;
- win2_x1 = x1 , win2_y1 = y2 + 1; /* bottom side of window */
- win2_x2 = x2 - w, win2_y2 = y2 + h;
- break;
- default:
- win1_x1 = x2 + 1, win1_y1 = y1 + h; /* right side of window */
- win1_x2 = x2 + w, win1_y2 = y2 + h;
- win2_x1 = x1 + w, win2_y1 = y2 + 1; /* bottom side of window */
- win2_x2 = x2 , win2_y2 = y2 + h;
- break;
- }
- wnp->usr_ptr = calloc(1, sizeof(WINDOW)); /* alloc/create first win */
- wn_create(win1_x1, win1_y1, win1_x2, win1_y2,
- NO_BDR, WN_POPUP,
- (WINDOW *) wnp->usr_ptr);
- wnp1 = (WINDOW *) wnp->usr_ptr;
- wn_read(wnp1);
- dest = wnp1->buff + 1; /* set to DARKGRAY on BLACK */
- for (i=0; i<(wnp1->cols * wnp1->rows); i++)
- *dest = att, dest += 2;
-
- wnp1->usr_ptr = calloc(1, sizeof(WINDOW)); /* alloc/create second win */
- wn_create(win2_x1, win2_y1, win2_x2, win2_y2,
- NO_BDR, WN_POPUP,
- (WINDOW *) wnp1->usr_ptr);
- wnp2 = (WINDOW *) wnp1->usr_ptr;
- wn_read(wnp2);
- dest = wnp2->buff + 1; /* set to DARKGRAY on BLACK */
- for (i=0; i<(wnp2->cols * wnp2->rows); i++)
- *dest = att, dest += 2;
-
- wn_save(wnp1), wn_rfsh(wnp1); /* do the wn_set equivalent */
- wn_save(wnp2), wn_rfsh(wnp2);
- }
- }
- /*** end of shadow_window ***/
-
- /********************/
- /* ~unshadow_window */
- /* *********************************************************/
- /* This is the complement to shadow_window. You MUST call this function */
- /* before you destroy the window that has been shadowed or you will have */
- /* severe problems. If you don't it will have the same effect as not */
- /* calling wn_destroy on a created window. Your computer will lockup! */
- /****************************************************************************/
- void unshadow_window( WINDOW *wnp )
- {
- WINDOW *wnp1, *wnp2; /* shadow window pointers */
-
- if (wnp->usr_ptr) /* does it have a shadow? */
- {
- wnp1 = (WINDOW *) wnp->usr_ptr; /* get the window pointers */
- wnp2 = (WINDOW *) wnp1->usr_ptr;
- wn_destroy(wnp2), wn_destroy(wnp1);
- free(wnp2), free(wnp1); /* and free the structure */
- wnp->usr_ptr = NULL;
- }
- }
- /*** end of unshadow_window ***/
-
- /*** END OF FILE ***/