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