⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.c

📁 本文件是tc2.0中的扩展工具
💻 C
📖 第 1 页 / 共 2 页
字号:
	exitBad ()

		/* Make a border with a bottom centered title.	    */
    border.type     = BBRD_SSSS | BBRD_BCT;
    border.attr     = MYBORDATR;
    border.ch	    = NUL;
    border.pbtitle  = "Horizontal Menu";
    border.btattr   = MYTITATR;

		/* Display the menu on the screen.		    */
    if (mndsplay (pmenu, &where, &border) == NIL)
	exitBad ()

		/* Make menu aware of the mouse.		    */
    if (NULL == mnmstyle(pmenu, mouse_style, MO_LEFT))
	exitBad ()

		/* Read a response from the menu.		    */
    if (mnread (pmenu, 0, 1, prrow, prcol, &ch, &scan, MN_DESTROY))
	exitBad ()
}




/**
*
* Name		LOTUS -- Display and allow user selection from a
*			 "Lotus"-style menu.
*
* Synopsis	lotus (dev, row, col, prrow, prcol);
*
*		int dev 	  Device on which to display the
*				  menu.  Either SC_COLOR or SC_MONO.
*		int row, col	  Row and column where the upper-
*				  left corner of the menu's data
*				  area should appear.
*		int mouse_style   The mouse style to use.
*		int *prrow,	  Pointers to variables in which to
*		    *prcol	  return the row and column selected
*				  from the menu.
*
* Description	This function constructs a "Lotus" menu, and
*		waits for user input.  It then returns the row
*		and column of the selection to its caller.
*
* Returns	*prrow, *prcol	  Row and column (relative to menu) of
*				  user selection.
*
**/


void lotus (dev, row, col, mouse_style, prrow, prcol)
int  dev;
int  row,    col;
int  mouse_style;
int *prrow, *prcol;
{
    BMENU  *pmenu;
    BORDER  border;
    WHERE   where;
    int     ch, scan;

		/* Figure out where to display the menu.	    */
    where.dev	     = dev;
    where.page	     = 0;
    where.corner.row = row;
    where.corner.col = col;

		/* Create the menu data structure.		    */
    if ((pmenu = mncreate (2, 70,
			   MYTEXTATR, MYHILATR,
			   MYPROATR, MYLNGATTR)) == NIL)
	exitBad ()

		/* Set up items on the menu, and add keys to the key*/
		/* binding list (upper and lower case of the first  */
		/* letters of the items.			    */
    if (mnlitkey (pmenu, 0, 0, 0, "Worksheet", 1, 0,
	"Global, Insert, Delete, Column-Width, Erase, Titles, Window, Status",
	"Ww",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 11, 0, "Range", 1, 0,
	"Format, Label-Prefix, Erase, Name, Justify, Protect, Unprotect, Input",
	"Rr",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 18, 0, "Copy", 1, 0,
	"Copy a cell or range of cells",
	"Cc",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 24, 0, "Move", 1, 0,
	"Move a cell or range of cells",
	"Mm",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 30, 0, "File", 1, 0,
	"Retrieve, Save, Combine, Xtract, Erase, List, Import, Directory",
	"Ff",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 36, 0, "Print", 1, 0,
	"Output a range to the printer or a print file",
	"Pp",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 43, 0, "Graph", 1, 0,
	"Create a graph",
	"Gg",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 50, 0, "Data", 1, 0,
	"Fill, Table, Sort, Query, Distribution",
	"Dd",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

    if (mnlitkey (pmenu, 0, 56, 0, "Quit", 1, 0,
	"End 3-2-1 Session (Have you saved your play ?)",
	"Qq",   MN_NOMOVE | MN_TRANSMIT) == NIL)
	exitBad ()

		/* Disable ESC key.				    */
    if (mnkey (pmenu, 0, 0, KB_C_N_ESC, KB_S_N_ESC,
	       MN_ABORT, MN_DELETE) == NIL)
	exitBad ()

		/* Make a border with a top centered title.	    */
    border.type     = BBRD_SDDD | BBRD_TCT;
    border.attr     = MYBORDATR;
    border.ch	    = NUL;
    border.pttitle  = "Lotus Menu  (with top-centered title)";
    border.ttattr   = MYTITATR;

		/* Display the menu on the screen.		    */
    if (mndsplay (pmenu, &where, &border) == NIL)
	exitBad ()

		/* Make menu aware of the mouse.		    */
    if (NULL == mnmstyle(pmenu, mouse_style, MO_LEFT))
	exitBad ()

		/* Read a response from the menu.		    */
    if (mnlread (pmenu, 0, 0, prrow, prcol, &ch, &scan, MN_DESTROY))
	exitBad ()
}




/**
*
* Name		GRID -- Display and allow user selection from a
*			grid menu.
*
* Synopsis	grid (dev, row, col, prrow, prcol);
*
*		int dev 	  Device on which to display the
*				  menu.  Either SC_COLOR or SC_MONO.
*		int row, col	  Row and column where the upper-
*				  left corner of the menu's data
*				  area should appear.
*		int mouse_style   The mouse style to use.
*		int *prrow,	  Pointers to variables in which to
*		    *prcol	  return the row and column selected
*				  from the menu.
*
* Description	This function constructs a grid menu, and
*		waits for user input.  It then returns the
*		row and column of the selection to its caller.
*
* Returns	*prrow, *prcol	  Row and column (relative to menu) of
*				  user selection.
*
**/


void grid (dev, row, col, mouse_style, prrow, prcol)
int  dev;
int  row,    col;
int  mouse_style;
int *prrow, *prcol;
{
    BMENU  *pmenu;
    BORDER  border;
    WHERE   where;
    int     ch, scan, x, y;
    char    s[3];

		/* Figure out where to display the menu.	    */
    where.dev	     = dev;
    where.page	     = 0;
    where.corner.row = row;
    where.corner.col = col;

		/* Create the menu data structure.		    */
    if ((pmenu = mncreate (6, 40,
			   MYTEXTATR, MYHILATR,
			   MYPROATR, MYLNGATTR)) == NIL)
	exitBad ()

		/* Set up items on the menu.  We will make a grid   */
		/* of numbers from 0 to 47, in rows across the	    */
		/* menu.					    */
    for (y = 0;  y < 6;  y++)
	for (x = 0;  x < 8;  x++)
		/* Put a the ASCII characters for a number (y*8+x)  */
		/* at location (y, x*5) in the menu.		    */
	    if (mnitem (pmenu, y, (x * 5), 0,
			itoa (((y * 8) + x), s, 10)) == NIL)
		 exitBad ()

		/* Disable ESC key.				    */
    if (mnkey (pmenu, 0, 0, KB_C_N_ESC, KB_S_N_ESC,
	       MN_ABORT, MN_DELETE) == NIL)
	exitBad ()

		/* Make a border with a bottom left title.	    */
    border.type     = BBRD_SSSS | BBRD_BLT;
    border.attr     = MYBORDATR;
    border.ch	    = NUL;
    border.pbtitle  = "Grid Menu  (bottom left title)";
    border.btattr   = MYTITATR;

		/* Display the menu on the screen.		    */
    if (mndsplay (pmenu, &where, &border) == NIL)
	exitBad ()

		/* Make menu aware of the mouse.		    */
    if (NULL == mnmstyle(pmenu, mouse_style, MO_LEFT))
	exitBad ()

		/* Read a response from the menu.		    */
    if (mnread (pmenu, 0, 0, prrow, prcol, &ch, &scan, MN_DESTROY))
	exitBad ()
}


/**
*
* Name		VIRTUAL -- Display and allow user selection from
*			   a virtual menu.
*
* Synopsis	virtual (dev, row, col, prrow, prcol);
*
*		int dev 	  Device on which to display the
*				  menu.  Either SC_COLOR or SC_MONO.
*		int row, col	  Row and column where the upper-
*				  left corner of the menu's data
*				  area should appear.
*		int mouse_style   The mouse style to use.
*		int *prrow,	  Pointers to variables in which to
*		    *prcol	  return the row and column selected
*				  from the menu.
*
* Description	This function constructs a virtual menu, and waits
*		for user input.  It then returns the row and column of
*		the selection to its caller.
*
* Returns	*prrow, *prcol	  Row and column (relative to menu) of
*				  user selection.
*
**/


void virtual (dev, row, col, mouse_style, prrow, prcol)
int  dev;
int  row,    col;
int  mouse_style;
int *prrow, *prcol;
{
    BMENU  *pmenu;
    BORDER  border;
    WHERE   where;
    int     ch, scan;

		/* Figure out where to display the menu.	    */
    where.dev	     = dev;
    where.page	     = 0;
    where.corner.row = row;
    where.corner.col = col;

		/* Create the menu data structure.		    */
    if ((pmenu = mncreate (7, 39,
			   MYTEXTATR, MYHILATR,
			   MYPROATR, MYLNGATTR)) == NIL)
	exitBad ()

		/* Set up items on the menu, and add keys to the key*/
		/* binding list (upper and lower case of the first  */
		/* letters of the items).			    */

		/* First, items on the menu at a Chinese restaraunt.*/
    if (mnitmkey (pmenu, 0, 0, 0, "Mandarin Chicken", "Mm",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 1, 0, 0, "Broccoli Beef", "Bb",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 2, 0, 0, "Sweet & Sour Pork", "Ss",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 3, 0, 0, "Won Ton Soup", "Ww",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 4, 0, 0, "Pork Fried Rice", "Pp",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 5, 0, 0, "Potstickers", "Pp",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 6, 0, 0, "Fortune Cookies", "Ff",
		  MN_NOMOVE) == NIL)
	exitBad ()

		/* Now, items on the menu at an Italian restaraunt. */
    if (mnitmkey (pmenu, 0, 19, 0, "Lasagna", "Ll",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 1, 19, 0, "Tortellini Pesto", "Tt",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 2, 19, 0, "Ravioli w/Meat Sauce", "Rr",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 3, 19, 0, "Fettucini Al Fredo", "Ff",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 4, 19, 0, "Veal Parmesan", "Vv",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 5, 19, 0, "Linguini", "Ll",
		  MN_NOMOVE) == NIL)
	exitBad ()
    if (mnitmkey (pmenu, 6, 19, 0, "Calamari", "Cc",
		  MN_NOMOVE) == NIL)
	exitBad ()

		/* Disable ESC key.				    */
    if (mnkey (pmenu, 0, 0, KB_C_N_ESC, KB_S_N_ESC,
	       MN_ABORT, MN_DELETE) == NIL)
	exitBad ()

		/* Make a border with a bottom centered title.	    */
    border.type     = BBRD_SSSS | BBRD_BCT;
    border.attr     = MYBORDATR;
    border.ch	    = NUL;
    border.pbtitle  = "Virtual";
    border.btattr   = MYTITATR;

		/* Display the menu in a 4 X 30 viewport.	    */
    if (mnvdisp (pmenu, &where, 4, 30, 0, 0, &border) == NIL)
	exitBad ()

		/* Make menu aware of the mouse.		    */
    if (NULL == mnmstyle(pmenu, mouse_style, MO_LEFT))
	exitBad ()

		/* Read a response from the menu.		    */
    if (mnread (pmenu, 0, 0, prrow, prcol, &ch, &scan, MN_DESTROY))
	exitBad ()
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -