home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / txcl552 / demo / userdemo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-22  |  7.6 KB  |  172 lines

  1. /*=====[ The TesSeRact(TM) CXL User Interface Development System ]======*
  2.  | Copyright (c) 1987-1991, Innovative Data Concepts, Inc.
  3.  | All Rights Reserved.
  4.  |
  5.  | This Library is part of IDC's TesSeRact Development Tools product
  6.  | line. For information about other IDC products, call 1-215-443-9705.
  7.  *-V--------------------------------------------------------------------*
  8.  | $Header:   userdemo.c     552.2   13 Jun 1991  5:00:08  $
  9.  |
  10.  | $Log:   userdemo.c    $
  11.  *-D--------------------------------------------------------------------*
  12.  | UserDemo.C : TCXL User-level Demonstration Program.
  13.  |
  14.  | Syntax:  USERDEMO [-switches]
  15.  |
  16.  |    -c  = CGA snow elimination
  17.  |    -b  = BIOS screen writing
  18.  |    -m  = force monochrome text attributes
  19.  *-N-----------------------[ Notes and Caveats ]------------------------*
  20.  | 1) Also requires MenuDemo.C, EntrDemo.C and DemoMisc.C.
  21.  | 2) Use the MakeDemo.Bat file to compile this program.
  22.  *======================================================================*/
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include "demo\TCXLdemo.h"             /* TCXL demo-specific            */
  26. #include <TCXLsel.h>                   /* TCXL selection/windows/video  */
  27.  
  28. /*----------------------------[ Global data ]---------------------------*/
  29.  
  30. IntT  CDC   LeftRow, LeftCol;          /* main menu coords              */
  31. IntT  CDC   RightRow, RightCol;
  32. IntT  CDC   DemoFast = 0;              /* window delay flag             */
  33. ChrP  CDC   months[] =                 /* months table                  */
  34. {
  35.    "January", "February", "March", "April", "May", "June", "July",
  36.    "August", "September", "October", "November", "December", NULL
  37. };
  38.  
  39. /*-----------[ Main menu item-build and menu-build objects ]------------*
  40.  | Elements for each item IbldT are:
  41.  |    istr, ichr, imsk, irow, icol, itag, ihlp, ikey, iusr,
  42.  |    ibef, isel, iaft, itxt, isub
  43.  | Elements for the menu MbldT are:
  44.  |    mitm, mcnt, mbgr, mbgc, menr, menc, mtyp, mfrt, mfra,
  45.  |    mwat, mtat, msat, mnat, mbat,
  46.  |    mtag, mopn, musr, mwid, mofs, mdtr, mdtc, mdat
  47.  | The structures are defined in <TCXLmnu.h>.
  48.  *----------------------------------------------------------------------*/
  49.  
  50. LCL   IbldT CDC   UserItm[5] =         /*- Main Menu Items -------------*/
  51. {  {  "Menu System",      'M', 0, 0, 0, 1, H_MENUING,   0, 0,
  52.       NULL, MenuDemo,   NULL, NULL, NULL  },
  53.    {  "Entry System",     'E', 0, 1, 0, 2, H_DATAENTRY, 0, 0,
  54.       NULL, EntryDemo,  NULL, NULL, NULL  },
  55.    {  "Selection System", 'S', 0, 2, 0, 3, H_LISTPICK,  0, 0,
  56.       NULL, SelectDemo, NULL, NULL, NULL  },
  57.    {  "Information",      'n', 0, 3, 0, 4, H_NONE,      0, 0,
  58.       NULL, TcxlInfo,   NULL, NULL, NULL  },
  59.    {  "Exit demo",        'x', 0, 4, 0, 5, H_NONE,      0, 0,
  60.       NULL, NULL,       NULL, NULL, NULL  }
  61. };
  62. LCL   MbldT CDC   UserMnu =            /*- Main menu -------------------*/
  63. {  &UserItm[0], 5,  0,  0,  0,  0, MNU_VER, BOX_SNG, LBLUE|_BLUE,
  64.    LBLUE|_BLUE, LCYAN|_BLUE, WHITE|_BLUE, 0, BLUE|_LGREY,
  65.    1, PreMenu1,  0, 19, 1, 0xFF, 0xFF, 0xFF
  66. };
  67.  
  68. LCL   ChrP  CDC   prn_ports[] =        /* printer ports table           */
  69. {
  70.    "PRN", "LPT1", "LPT2", "COM1", "COM2", NULL
  71. };
  72.  
  73. /*---------------------[ Local function prototypes ]--------------------*/
  74.  
  75. LCL   VOID  CTYP  PrePick1(NOARG);
  76. LCL   VOID  CTYP  YouSelected(ChrP str);
  77.  
  78. /*=================[ The TCXL User-Level Demo Program ]=================*/
  79.  
  80. IntT CDC main(IntT argc, ChrP argv[])
  81. {
  82.    Initialize();                       /* initialize TCXL               */
  83.    ParseCmdLine(argc, argv);           /* parse any options             */
  84.    OpenBkgrnd();                       /* build screen                  */
  85.    UserMnu.mbgr = MsByt(LeftRow);      /* set main-menu position        */
  86.    UserMnu.mbgc = MsByt(LeftCol);
  87.    UserMnu.menr = MsByt(RightRow);
  88.    UserMnu.menc = MsByt(RightCol);
  89.    MainMenu(&UserMnu);                 /* display/process main menu     */
  90.    NormalExit();                       /* we're done                    */
  91.    return(0);                          /* *** never executed ***        */
  92. }
  93.  
  94. /*=======================[ Selection-system demo ]======================*
  95.  | Demonstrate the string-selectection, file-selection, in-place
  96.  | text-selection and attribute-selection features of TCXL. Called from
  97.  | the main-menu [S]election item.
  98.  *----------------------------------------------------------------------*/
  99.  
  100. VOID  CTYP  SelectDemo(NOARG)
  101. {
  102.    REG VcelFP  s;
  103.  
  104.    s = FarVsave(LGREY|_BLUE);          /* save the screen               */
  105.    MouPush(MOU_FULL);                  /* full mouse support            */
  106.  
  107.    if(!WpopUp(CNT_CNT, 5, 11, 17, 68,  /* pop up the demo window        */
  108.       3, LMAGENTA|_RED, LRED|_MAGENTA))
  109.       ErrorExit(1);                    /* windowing error!              */
  110.  
  111.    AddShadow();                        /* add a shadow                  */
  112.    Wputf("\033R\001\033C\003Select a month =>\033R\001\033C\003");
  113.    HlpSet(H_STRPICK);                  /* set help category             */
  114.  
  115.    YouSelected(months[SelStr(LeftRow,  /* string select                 */
  116.       32, LeftRow + 5, -1, 0, LGREEN|_RED, LCYAN|_RED, RED|_LGREY,
  117.       months, 0, _VFVCP(PrePick1))]);
  118.    Wputf("\033R\003\033C\003Now, select a file.\033R\003\033C\003");
  119.  
  120.    HlpSet(H_FILEPICK);                 /* set help category             */
  121.  
  122.    SelParOn();
  123.    SelDirOn();
  124.    YouSelected(SelFile(LeftRow,        /* file select                   */
  125.       LeftCol - 18, LeftRow + 10, LeftCol + 39, 0, LCYAN|_RED,
  126.       LGREY|_RED, RED|_LGREY, 1, "*.*", _VFVCP(AddShadow)));
  127.  
  128.                                        /* in-place text-select          */
  129.    Wputf("\033R\005\033C\003Select a printer port:\033R\005\033C\003");
  130.    YouSelected(prn_ports[SelTxt(5, 27, LMAGENTA|_MAGENTA, prn_ports, 0)]);
  131.  
  132.    HlpSet(H_PICKATTR);                 /*set help category              */
  133.    Wputf("\033R\007\033C\003Select a text attribute:\033R\007\033C\003");
  134.                                        /* attribute-selection           */
  135.    YouSelected(VatrTxt(MsAtr(SelAttr(LeftRow - 6, LeftCol - 21, 0, 0,
  136.       TRUE, _VFVCP(AddShadow)))));
  137.    Wclose();                           /* close window                  */
  138.    MouPop();                           /* restore mouse                 */
  139.    FarVrestore(s);                     /* restore screen                */
  140.    MoveBarDn();                        /* select next main-menu item    */
  141. }  /* SelectDemo() */
  142.  
  143.  
  144. /*-------------------[ String-select "open" function ]------------------*
  145.  * Called when the string-select window is opened
  146.  *----------------------------------------------------------------------*/
  147.  
  148. LCL   VOID  CTYP  PrePick1(NOARG)
  149. {
  150.    Wmessage("* *", BRD_BOT, 4, LGREEN|_RED);
  151.    AddShadow();
  152. }
  153.  
  154. /*---------[ Display the selected string or an error message ]----------*
  155.  | Also prompt for a keypress 2 lines below the string/error message.
  156.  *----------------------------------------------------------------------*/
  157.  
  158. LCL   VOID  CTYP  YouSelected(ChrP str)
  159. {
  160.    VposT rc;
  161.  
  162.    if(TcxlErr)                         /* error message                 */
  163.       Wputf("\033EL%s", WerrMsg());
  164.    else                                /* selected string               */
  165.       Wputf("\033ELYou selected:  \033F\005%s\033F\004", str);
  166.    HlpSet(H_LISTPICK);                 /* set help category             */
  167.    WcurGet(rc);                        /* get cursor position           */
  168.    PressAKey(MsByt(VposR(rc) + 2));    /* prompt for a key              */
  169. }
  170.  
  171. /*- end of UserDemo.c --------------------------------------------------*/
  172.