home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / txcl552 / demo / win_demo.c < prev   
Encoding:
C/C++ Source or Header  |  1991-06-22  |  15.7 KB  |  434 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:   win_demo.c     552.3   22 Jun 1991 14:03:50  $
  9.  |
  10.  | $Log:   win_demo.c    $
  11.  *-D--------------------------------------------------------------------*
  12.  | Win_Demo.C : Demonstration of the TCXL window system. The demo is run
  13.  | twice, once with delays, once without and shows some of the many
  14.  | things that can be done with TCXL windows. WinDemo() is invoked from
  15.  | the main menu of Mid_Demo.C.
  16.  *-N-----------------------[ Notes and Caveats ]------------------------*
  17.  | 1) Use the MakeDemo.Bat file to compile this file.
  18.  *======================================================================*/
  19. #include "demo\TCXLdemo.h"
  20.  
  21. /*----------------------------[ Local data ]----------------------------*/
  22.  
  23. LCL   WndT  CDC   w[10];               /* window handle array           */
  24.  
  25. LCL   IntT  CDC   Siz1[] =             /* window sizes                  */
  26. {  19, 19, 24, 24, 24, 19
  27. };
  28. LCL   IntT  CDC   Siz2[] =
  29. {  60, 75, 75, 60, 45, 45
  30. };
  31. LCL   IntT  CDC   Siz3[] =
  32. {   0, 8,  6,  1, 8,  2                /* fix screen overrun        jpl */
  33. };
  34. LCL   IntT  CDC   Siz4[] =
  35. {   0,  4, 19, 13, 35, 39
  36. };
  37. LCL   ChrP  CDC   Wdm =                /* delay/no-delay pause message  */
  38.    "Now that you've had a chance to see the various features "
  39.    "of the TCXL Window System, we'd like to give you a chance "
  40.    "to see the SAME demonstation again . . . this "
  41.    "time, without the built-in delays.  Press any key to "
  42.    "start this one running.  Watch out!";
  43.  
  44. /*---------------------[ Local function prototypes ]--------------------*/
  45.  
  46. LCL   VOID  CTYP  ActivDemo(NOARG);
  47. LCL   VOID  CTYP  AttrDemo(NOARG);
  48. LCL   VOID  CTYP  BordDemo(NOARG);
  49. LCL   VOID  CTYP  ChgWindAttr(AtrT battr, AtrT wattr);
  50. LCL   VOID  CTYP  CloseWinDemo(NOARG);
  51. LCL   VOID  CTYP  CopyDemo(NOARG);
  52. LCL   VOID  CTYP  DemoWait(NOARG);
  53. LCL   VOID  CTYP  DisplayTitle(BytT tpos);
  54. LCL   VOID  CTYP  DragWindow(IntT nsrow, IntT nscol);
  55. LCL   VOID  CTYP  HideDemo(NOARG);
  56. LCL   VOID  CTYP  HorzLine(BytT wrow, BytT wcol, IntT count, AtrT attr);
  57. LCL   VOID  CTYP  MoveDemo(NOARG);
  58. LCL   VOID  CTYP  MoveWindow(IntT nsrow, IntT nscol);
  59. LCL   VOID  CTYP  ResizeDemo(NOARG);
  60. LCL   VOID  CTYP  ScrollDemo(NOARG);
  61. LCL   VOID  CTYP  SizeWindow(IntT nerow, IntT necol);
  62. LCL   VOID  CTYP  TLineDemo(NOARG);
  63. LCL   VOID  CTYP  TitleDemo(NOARG);
  64. LCL   VOID  CTYP  VertLine(BytT wrow, BytT wcol, IntT count, AtrT attr);
  65.  
  66. /*=======================[ The TCXL window demo ]=======================*
  67.  | Called from the [W]indow item of the Mid_Demo.C main menu.
  68.  *----------------------------------------------------------------------*/
  69.  
  70. VOID  CTYP  WinDemo(NOARG)
  71. {
  72.    VcelFP   s;
  73.  
  74.    s = FarVsave(LGREY|_BLUE);          /* save screen                   */
  75.    MouPush(MOU_FULL);                  /* full mouse support            */
  76.                                        /* slowly, first, then FAST      */
  77.    for(DemoFast = 0; DemoFast < 2; DemoFast++)
  78.    {  ScrollDemo();                    /* scrolling                     */
  79.       AttrDemo();                      /* attributes                    */
  80.       BordDemo();                      /* borders                       */
  81.       TitleDemo();                     /* titles                        */
  82.       ResizeDemo();                    /* resizing                      */
  83.       TLineDemo();                     /* text lines                    */
  84.       MoveDemo();                      /* moving/dragging               */
  85.       HideDemo();                      /* hiding/unhiding               */
  86.       ActivDemo();                     /* activation                    */
  87.       CopyDemo();                      /* copying                       */
  88.       CloseWinDemo();                  /* close it down                 */
  89.       if(!DemoFast)                    /* warn user not to blink ;-)    */
  90.       {  WpopUp(CNT_CNT, 0, 0, 9, 35, 0, WHITE|_CYAN, YELLOW|_RED);
  91.          Wputsw(Wdm);
  92.          KeyWait();
  93.       }
  94.       else                             /* ask user if he/she missed it  */
  95.       {  WpopUp(CNT_CNT, 0, 0, 2, 25, 0, WHITE|_CYAN, YELLOW|_RED);
  96.          WputCen("Fast enough for you?");
  97.          KeyTime(54);
  98.       }
  99.       Wclose();                        /* close the pop-up              */
  100.    }
  101.    DemoFast = 0;
  102.    MouPop();                           /* restore mouse, screen         */
  103.    FarVrestore(s);
  104.    KeyClear();                         /* clear lurking keys            */
  105.    MoveBarDn();                        /* next main-menu item           */
  106. }  /* WinDemo() */
  107.  
  108. /*-----------------------[ Window scrolling demo ]----------------------*/
  109.  
  110. LCL   VOID  CTYP  ScrollDemo(NOARG)
  111. {
  112.    REG IntT    i, j;
  113.  
  114.    if(ERR_ARG == (w[0] = Wopen(1, 1, 11, 41, 2, LMAGENTA|_RED, LCYAN|_RED)))
  115.       ErrorExit(1);                    /* windowing error!              */
  116.  
  117.    HlpSet(H_SCROLL);                   /* set help category             */
  118.  
  119.    Wputf("\n  TCXL's window TTY output functions"
  120.          "\n  such as Wputs() and Wputf() allow"
  121.          "\n  scrolling and ANSI-like Escape code"
  122.          "\n  sequences from inside of windows.");
  123.    PressAKey(6);                       /* pause for a keypress          */
  124.  
  125.    Wgotoxy(8, 0);                      /* set cursor position           */
  126.    for(i = 0; i < 10; i++)
  127.    {  for(j = DGREY; j <= WHITE; j++)
  128.       {  Wputf("\033F%cTCXL  ", j);    /* display "TCXL" over and over  */
  129.          if(!DemoFast)                 /* changing attributes each time */
  130.             _Delay(1);
  131.       }
  132.    }
  133. }  /* ScrollDemo() */
  134.  
  135. /*-----------------------[ Window attribute demo ]----------------------*/
  136.  
  137. LCL   VOID  CTYP  AttrDemo(NOARG)
  138. {
  139.    if(ERR_ARG == (w[1] = Wopen(9, 35, 22, 65, 0, YELLOW|_BLUE, LCYAN|_BLUE)))
  140.       ErrorExit(1);                    /* windowing error!              */
  141.  
  142.    HlpSet(H_CHGATTR);                  /* set help category             */
  143.  
  144.    Wputs("\n  The WchgAtr() function"
  145.         "\n  allows you to change the"
  146.         "\n  attribute of the active"
  147.         "\n  window.");
  148.    PressAKey(6);                       /* pause for a keypress          */
  149.  
  150.    ChgWindAttr(LMAGENTA|_BLUE, WHITE|_GREEN);   /* change attributes    */
  151.    ChgWindAttr(GREEN|_LGREY, LMAGENTA|_RED);
  152.    ChgWindAttr(YELLOW|_BROWN, LCYAN|_BLUE);
  153.    ChgWindAttr(YELLOW|_MAGENTA, YELLOW|_MAGENTA);
  154.    ChgWindAttr(LCYAN|_MAGENTA, WHITE|_MAGENTA);
  155. }  /* AttrDemo() */
  156.  
  157. /*---------------------[ Change window attributes ]---------------------*/
  158.  
  159. LCL   VOID  CTYP  ChgWindAttr(AtrT battr, AtrT wattr)
  160. {
  161.    WchgAtr(battr, wattr);              /* set attributes                */
  162.  
  163.    DemoWait();
  164. }  /* ChgWindAttr() */
  165.  
  166. /*------------------------[ Window border demo ]------------------------*/
  167.  
  168. LCL   VOID  CTYP  BordDemo(NOARG)
  169. {
  170.    REG IntT i;
  171.  
  172.    HlpSet(H_CHGBORD);                  /* set help category             */
  173.    WsetTxt(LGREEN|_MAGENTA);           /* text attribute                */
  174.  
  175.    Wputs("\n\n  The Wborder() function is"
  176.            "\n  used to change the style"
  177.            "\n  of the window's border.");
  178.    PressAKey(10);                      /* pause for a keypress          */
  179.  
  180.    for(i = 5; i >= 0; i--)
  181.    {  Wborder(MsByt(i));               /* keep changing border types    */
  182.       DemoWait();
  183.    }
  184. }  /* BordDemo() */
  185.  
  186. /*-------------------------[ Window title demo ]------------------------*/
  187.  
  188. LCL   VOID  CTYP  TitleDemo(NOARG)
  189. {
  190.    if(ERR_ARG == (w[2] = Wopen(5, 20, 19, 45, 3, LCYAN|_GREEN, WHITE|_GREEN)))
  191.       ErrorExit(1);                    /* windowing error!              */
  192.  
  193.    HlpSet(H_WINTITLE);                 /* set help category             */
  194.  
  195.    Wputs("\n  The Wtitle() function"
  196.          "\n  allows you to give a"
  197.          "\n  window a title.");
  198.    PressAKey(5);                       /* pause for a keypress          */
  199.  
  200.    DisplayTitle(TTL_LFT);              /* show off titles               */
  201.    DisplayTitle(TTL_RGT);
  202.    DisplayTitle(TTL_CNT);
  203. }  /* TitleDemo() */
  204.  
  205. /*-----------------------[ Display window title ]-----------------------*/
  206.  
  207. LCL   VOID  CTYP  DisplayTitle(BytT tpos)
  208. {
  209.    Wtitle("[ My Title ]", tpos, LCYAN|_GREEN);
  210.  
  211.    DemoWait();
  212. }  /* DisplayTitle() */
  213.  
  214. /*------------------------[ Window resize demo ]------------------------*/
  215.  
  216. LCL   VOID  CTYP  ResizeDemo(NOARG)
  217. {
  218.    IntT i;
  219.  
  220.    HlpSet(H_RESIZE);                   /* set help category             */
  221.    WsetTxt(BLUE|_GREEN);               /* text attribute                */
  222.  
  223.    Wputs("\n\n\n  The Wsize() function"
  224.              "\n  allows you to resize"
  225.              "\n  the active window.");
  226.    PressAKey(10);                      /* wait for a keypress           */
  227.  
  228.    for(i = 0; i < 6; i++)              /* resize the window             */
  229.       SizeWindow(Siz1[i], Siz2[i]);
  230. }  /* ResizeDemo() */
  231.  
  232. /*--------------------------[ Resize a window ]-------------------------*/
  233.  
  234. LCL   VOID  CTYP  SizeWindow(IntT r, IntT c)
  235. {
  236.    Wsize(r, c);
  237.    DemoWait();
  238. }  /* SizeWindow() */
  239.  
  240. /*-----------------------[ Window text-line demo ]----------------------*/
  241.  
  242. LCL   VOID  CTYP  TLineDemo(NOARG)
  243. {
  244.    if(ERR_ARG == (w[3] = Wopen(10, 3, 23, 41, 3, YELLOW|_BLUE, LMAGENTA|_BLUE)))
  245.       ErrorExit(1);                    /* windowing error!              */
  246.  
  247.    HlpSet(H_TEXTLINE);                 /* set help category             */
  248.  
  249.    Wputs("\n The WdrwHor() & WdrwVer() functions"
  250.          "\n are used for drawing \"smart\" text"
  251.          "\n lines which will even make their "
  252.          "\n own corners and intersections!   ");
  253.    PressAKey(6);                       /* pause for a keypress          */
  254.  
  255.    HorzLine( 6,  6, 24, LCYAN|_BLUE);  /* draw a fancy box with joins   */
  256.    VertLine( 6,  6,  4, LCYAN|_BLUE);
  257.    HorzLine(10,  6, 24, LCYAN|_BLUE);
  258.    VertLine( 6, 30,  5, LRED|_BLUE);
  259.    VertLine( 6, 18,  5, LRED|_BLUE);
  260.    HorzLine( 7,  6, 25, LRED|_BLUE);
  261.    HorzLine( 9,  6, 25, LGREEN|_BLUE);
  262.    VertLine( 6, 11,  5, LGREEN|_BLUE);
  263.    VertLine( 6, 23,  5, LGREEN|_BLUE);
  264.    HorzLine( 8,  6, 25, LMAGENTA|_BLUE);
  265. }  /* TLineDemo() */
  266.  
  267. /*----------------------[ Draw a horizontal line ]----------------------*/
  268.  
  269. LCL   VOID  CTYP  HorzLine(BytT r, BytT c, IntT n, AtrT a)
  270. {
  271.    WdrwHor(r, c, MsByt(n), 3, a);
  272.    DemoWait();
  273. }  /* HorzLine() */
  274.  
  275. /*-----------------------[ Draw a vertical line ]-----------------------*/
  276.  
  277. LCL   VOID  CTYP  VertLine(BytT r, BytT c, IntT n, AtrT a)
  278. {
  279.    WdrwVer(r, c, MsByt(n), 3, a);
  280.    DemoWait();
  281. }  /* VertLine() */
  282.  
  283. /*-------------------------[ Window move demo ]-------------------------*/
  284.  
  285. LCL   VOID  CTYP  MoveDemo(NOARG)
  286. {
  287.    IntT i;
  288.  
  289.    if(ERR_ARG == (w[4] = Wopen(4, 2, 20, 35, 2, YELLOW|_CYAN, YELLOW|_CYAN)))
  290.       ErrorExit(1);                    /* windowing error!              */
  291.  
  292.    HlpSet(H_WINMOVE);                  /* set help category             */
  293.  
  294.    Wputs("\n   To move the active window,"
  295.          "\n   the Wmove() function is"
  296.          "\n   used.");
  297.    PressAKey(5);                       /* pause for a keypress          */
  298.  
  299.    for(i = 0; i < 6; i++)              /* move it around                */
  300.       MoveWindow(Siz3[i], Siz4[i]);
  301.  
  302.    Wputs("\n\n   Or if you prefer flashier,"
  303.            "\n   window movement, try"
  304.            "\n   Wslide() instead.");
  305.    PressAKey(9);                       /* pause for a keypress          */
  306.  
  307.    for(i = 0; i < 6; i++)              /* drag it around                */
  308.       DragWindow(Siz3[i], Siz4[i]);
  309. }  /* MoveDemo() */
  310.  
  311. /*---------------------------[ Move a window ]--------------------------*/
  312.  
  313. LCL   VOID  CTYP  MoveWindow(IntT r, IntT c)
  314. {
  315.    if (r+16 >= VidDep)                 /* make Window address       jpl */
  316.       r = VidDep - 17;                 /*   adjust for smaller screens  */
  317.  
  318.    if(Wmove(r, c))
  319.       ErrorExit(1);                    /* windowing error!              */
  320.  
  321.    DemoWait();
  322. }  /* MoveWindow() */
  323.  
  324. /*---------------------------[ Drag a window ]--------------------------*/
  325.  
  326. LCL   VOID  CTYP  DragWindow(IntT r, IntT c)
  327. {
  328.    if(Wslide(r, c))
  329.       ErrorExit(1);                    /* windowing error!              */
  330.  
  331.    DemoWait();
  332. }  /* DragWindow() */
  333.  
  334. /*-----------------------[ Window hide/show demo ]----------------------*/
  335.  
  336. LCL   VOID  CTYP  HideDemo(NOARG)
  337. {
  338.    REG IntT i;
  339.  
  340.    HlpSet(H_WINHIDE);                  /* set help category             */
  341.    WsetTxt(YELLOW|_CYAN);              /* text attribute                */
  342.  
  343.    Wputs("\n\n   The Whide() and Wunhide()"
  344.            "\n   functions are used to hide"
  345.            "\n   and unhide windows.");
  346.    PressAKey(13);                      /* pause for a keypress          */
  347.  
  348.    for(i = 0; i < 5; i++)
  349.    {  if(Whide())                      /* hide all, front to back       */
  350.          ErrorExit(1);                 /* windowing error!              */
  351.  
  352.       DemoWait();
  353.    }
  354.    for(i = 0; i < 5; i++)
  355.    {  if(Wunhide(0))                   /* unhide all, back to front     */
  356.          ErrorExit(1);                 /* windowing error!              */
  357.  
  358.       DemoWait();
  359.    }
  360. }  /* HideDemo() */
  361.  
  362. /*-----------------------[ Window activate demo ]-----------------------*/
  363.  
  364. LCL   VOID  CTYP  ActivDemo(NOARG)
  365. {
  366.    REG IntT    i;
  367.  
  368.    if(ERR_ARG == (w[5] = Wopen(9, 44, 22, 78, 1, LCYAN|_CYAN, WHITE|_CYAN)))
  369.       ErrorExit(1);                    /* windowing error!              */
  370.  
  371.    HlpSet(H_ACTIVATE);                 /* set help category             */
  372.  
  373.    Wputs("\n  TCXL's Wactiv() is used to"
  374.         "\n  activate a window, making"
  375.         "\n  it available for windowing"
  376.         "\n  operations.");
  377.    PressAKey(6);                       /* pause for a keypress          */
  378.  
  379.    for(i = 0; i < 6; i++)
  380.    {  Wactiv(w[i]);                    /* activate windows 0 thru 5    */
  381.       DemoWait();                      /* in order, back to front      */
  382.    }
  383. }  /* ActivDemo() */
  384.  
  385. /*-------------------------[ Window copy demo ]-------------------------*/
  386.  
  387. LCL   VOID  CTYP  CopyDemo(NOARG)
  388. {
  389.    HlpSet(H_WINCOPY);                  /* set help category             */
  390.    WsetTxt(LCYAN|_CYAN);               /* text attribute                */
  391.  
  392.    Wputs("\n\n  The Wcopy() function is used"
  393.            "\n  to copy the active window.");
  394.    PressAKey(9);                       /* pause for a keypress          */
  395.  
  396.    if(!Wcopy(1, 1))
  397.       ErrorExit(1);                    /* windowing error!              */
  398.  
  399.    DemoWait();
  400.    if(!Wcopy(3, 40))
  401.       ErrorExit(1);                    /* windowing error!              */
  402.  
  403.    DemoWait();
  404. }  /* CopyDemo() */
  405.  
  406. /*---------------------[ Close out the window demo ]--------------------*/
  407.  
  408. LCL   VOID  CTYP  CloseWinDemo(NOARG)
  409. {
  410.    REG IntT    i;
  411.  
  412.    for(i = 0; i < 8; i++)
  413.    {  Wclose();                        /* close all windows             */
  414.       DemoWait();
  415.    }
  416. }  /* CloseWinDemo() */
  417.  
  418. /*-------------------[ Control delay in window demo ]-------------------*/
  419.  
  420. LCL   VOID  CTYP  DemoWait(NOARG)
  421. {
  422.    if(DemoFast)
  423. #if   defined(__TERMINAL__)            /* if running to TTY         jpl */
  424.       _TTYupdate();                    /* make sure up to date      jpl */
  425. #else                                  /*                           jpl */
  426.       return;                          /* no delay                      */
  427. #endif                                 /*                           jpl */
  428.    else
  429.       _Delay(5);                       /* delay for 5 clock-ticks       */
  430. }
  431.  
  432. /*- end of Win_Demo.C --------------------------------------------------*/
  433.  
  434.