File: subwindow_ex.c

package info (click to toggle)
libcdk5 5.0.20050424-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,504 kB
  • ctags: 2,620
  • sloc: ansic: 29,645; sh: 4,283; makefile: 634; cpp: 42; sed: 40
file content (75 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* $Id: subwindow_ex.c,v 1.8 2004/08/28 00:57:12 tom Exp $ */

#include <cdk.h>

#ifdef HAVE_XCURSES
char *XCursesProgramName="subwindow_ex";
#endif

/*
 * This demo displays the ability to put widgets within a curses subwindow.
 */
int main (int argc, char **argv)
{
   /* Declare vars. */
   CDKSCREEN *cdkscreen;
   CDKSCROLL *dowList;
   CDKLABEL *title;
   WINDOW *mainWindow, *subWindow;
   char *dow[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
   char *mesg[5];
   int pick;

   CDK_PARAMS params;

   CDKparseParams(argc, argv, &params, "s:" CDK_CLI_PARAMS);

   /* Start curses. */
   mainWindow = initscr();
   curs_set(0);

   /* Create a basic window. */
   subWindow = newwin (LINES-5, COLS-10, 2, 5);

   /* Start Cdk. */
   cdkscreen = initCDKScreen (subWindow);

   /* Box our window. */
   box (subWindow, ACS_VLINE, ACS_HLINE);
   wrefresh (subWindow);

   /* Create a basic scrolling list inside the window. */
   dowList = newCDKScroll (cdkscreen,
			   CDKparamValue(&params, 'X', CENTER),
			   CDKparamValue(&params, 'Y', CENTER),
			   CDKparsePosition(CDKparamString2(&params, 's', "RIGHT")),
			   CDKparamValue(&params, 'H', 10),
			   CDKparamValue(&params, 'W', 15),
			   "<C></U>Pick a Day", dow, 7, NONUMBERS,
			   A_REVERSE,
			   CDKparamValue(&params, 'N', TRUE),
			   CDKparamValue(&params, 'S', FALSE));

   /* Put a title within the window. */
   mesg[0] = "<C><#HL(30)>";
   mesg[1] = "<C>This is a Cdk scrolling list";
   mesg[2] = "<C>inside a curses window.";
   mesg[3] = "<C><#HL(30)>";
   title = newCDKLabel (cdkscreen, CENTER, 0, mesg, 4, FALSE, FALSE);

   /* Refresh the screen. */
   refreshCDKScreen (cdkscreen);

   /* Let the user play. */
   pick = activateCDKScroll (dowList, 0);

   /* Clean up. */
   destroyCDKScroll (dowList);
   destroyCDKLabel (title);
   eraseCursesWindow (subWindow);
   endCDK();

   /* Tell them what they picked. */
   printf ("You picked %s\n", dow[pick]);
   exit (EXIT_SUCCESS);
}