home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / EV_201 / DEMO1 / DEMO1.CPP next >
C/C++ Source or Header  |  1993-07-03  |  8KB  |  201 lines

  1. /*
  2.    Module        :  DEMO1.CPP
  3.    Version       :  2.00
  4.    Revision date :  July 3rd, 1993
  5.    Author(s)     :  Rémy Gendron
  6.  
  7.    Description   :  Short demo program.
  8. */
  9.  
  10.  
  11. // Headers ------------------------------------------------------------------
  12.  
  13. #include <conio.h>                                      // System's libraries
  14. #include <ctype.h>
  15. #include <dos.h>
  16. #include <stdlib.h>
  17. #pragma hdrstop
  18.  
  19. #include "evmsgs.hpp"                                        // Other modules
  20. #include "stdfcts.h"
  21. #include "tdesktop.hpp"
  22. #include "tinput.hpp"
  23. #include "tmenubar.hpp"
  24. #include "tstatusline.hpp"
  25. #include "twindow.hpp"
  26.  
  27. #include "demo1.hcm"                                         // Help contexts
  28.  
  29.  
  30. // Prototypes ---------------------------------------------------------------
  31.  
  32. void about () ;                               // Displays infos on EasyVision
  33. void demowindow () ;                                   // Plays with a window
  34.  
  35.  
  36. // --------------------------------------------------------------------------
  37.  
  38. int main
  39. (
  40.    int  argc,                             // Number of command line arguments
  41.    char *argv[]                    // Array of ptrs to command line arguments
  42. )
  43.  
  44. {
  45.    input_info ii ;
  46.  
  47.  
  48.    desktop.settitle ("EasyVision 2.0  demo program",3,15) ;  // Opens desktop
  49.    desktop.settextmode (C4350,TRUE) ;
  50.    desktop.open () ;
  51.    delay (2000) ;
  52.                                                        // Defines the menubar
  53.    menubar.addmenu ("≡",'S',"System menu",HC_MENU_SYSTEM) ;
  54.    menubar.additem ("Refresh desktop  Alt-R",'R',II_A_R,
  55.                     "Redraws the screen",HC_MENU_SYSTEM_REFRESH) ;
  56.    menubar.additem () ;
  57.    menubar.additem ("About...         Alt-A",'A',II_A_A,
  58.                     "Shows version and copyright informations",
  59.                     HC_MENU_SYSTEM_ABOUT) ;
  60.  
  61.    menubar.addmenu ("Demo",'D',"EasyVision's demonstrations",
  62.                     HC_MENU_DEMO) ;
  63.    menubar.additem ("Open window   Alt-O",'O',II_A_O,
  64.                     "Demonstration of an EasyVision window",
  65.                     HC_MENU_DEMO_OPEN) ;
  66.    menubar.additem () ;
  67.    menubar.additem ("Exit demo     Alt-X",'E',II_A_X,
  68.                     "Exits EasyVision's demo",HC_MENU_DEMO_EXIT) ;
  69.  
  70.    menubar.addmenu ("Examples",'E',"Just an example menu",HC_MENU_EXAMPLES) ;
  71.    menubar.additem ("Dummy off item...  ",'D',II_A_U,
  72.                     "Menu items can be 'offline'",HC_MENU_EXAMPLES_OFFLINE) ;
  73.    menubar.itemsetavail ('E','D',FALSE) ;
  74.    menubar.additem ("Do nothing item... ",'N',II_A_N,
  75.                     "This item is just an example",HC_MENU_EXAMPLES_DUMMY) ;
  76.  
  77.  
  78.    ii.key_code = II_NUL ;
  79.  
  80.    while (ii.key_code != II_A_X)                       // Gets user's command
  81.    {
  82.       statusline.display ("Hit ~Alt-X~ to return to DOS...") ;
  83.       input.get (&ii,0,HC_GENERAL,FALSE) ;
  84.       ii = menubar.through (ii) ;
  85.  
  86.       if (ii.key_code == II_A_R) desktop.refresh () ;
  87.       if (ii.key_code == II_A_A) about () ;
  88.       if (ii.key_code == II_A_O) demowindow () ;
  89.    }
  90.  
  91.    desktop.close () ;                                       // Closes desktop
  92.  
  93.  
  94.    return 0 ;                                   // Program normal termination
  95. }                                                                 // End main
  96.  
  97.  
  98. // --------------------------------------------------------------------------
  99.  
  100. void about ()                                 // Displays infos on EasyVision
  101.  
  102. {
  103.    twindow  huge *winptr ;                          // Ptr to a twindow class
  104.    input_info    ii ;                                         // User's input
  105.  
  106.  
  107.    winptr = new twindow ;                                 // Creates a window
  108.    assert (winptr != NULL,"about",ev_err[1],1) ;
  109.  
  110.    winptr->winsetpos (17,21,TRUE) ;                        // Displays window
  111.    winptr->winsetsize (15,40) ;
  112.    winptr->winsettitle ("About") ;
  113.    winptr->winsetcolors (WHITE,BLACK) ;
  114.    winptr->winsethlpctx (HC_WINDOW_ABOUT) ;
  115.    winptr->winopen () ;
  116.  
  117.    winptr->winwrite ("EasyVision 2.0",2,1,2) ;      // Writes some text in it
  118.    winptr->winwrite ("The easy to use and powerful",4,1,2) ;
  119.    winptr->winwrite ("text mode interface!",5,1,2) ;
  120.    winptr->winwrite ("Copyright (c) 1993 by",7,1,2) ;
  121.    winptr->winwrite ("TNG SOFT",9,1,2) ;
  122.    winptr->winwrite ("The Next Generation Software",10,1,2) ;
  123.                                                           // Creates a button
  124.    winptr->buttoncreate (12,16,"   Ok",13,"Press ~ENTER~ to continue") ;
  125.  
  126.    ii.key_code = II_NUL ;
  127.    winptr->wininput (ii) ;                              // Makes window alive
  128.  
  129.    winptr->winclose () ;                                     // Closes window
  130.    delete (winptr) ;
  131.  
  132.  
  133.    return ;                                // About screen has been displayed
  134. }                                                                // End about
  135.  
  136.  
  137. // --------------------------------------------------------------------------
  138.  
  139. void demowindow ()                                     // Plays with a window
  140.  
  141. {
  142.    twindow  huge *winptr ;                          // Ptr to a twindow class
  143.    input_info    ii ;                                         // User's input
  144.  
  145.  
  146.    randomize () ;                            // Inits random number generator
  147.  
  148.    winptr = new twindow ;                                 // Creates a window
  149.    assert (winptr != NULL,"demowindow",ev_err[1],1) ;
  150.  
  151.    winptr->winsetpos (19,21,TRUE) ;                        // Displays window
  152.    winptr->winsetsize (13,40) ;
  153.    winptr->winsettitle ("Demo Window") ;
  154.    winptr->winsethlpctx (HC_WINDOW_DEMO) ;
  155.    winptr->winopen () ;
  156.  
  157.    winptr->winwrite ("Alpha",2,2) ;             // Writes field's identifiers
  158.    winptr->winwrite ("Numeric",2,20) ;
  159.    winptr->winwrite ("AlphaNumeric",4,2) ;
  160.    winptr->winwrite ("No restrictions",4,20) ;
  161.  
  162.                                                  // Creates some input fields
  163.    winptr->fieldcreate (3,2,30,15,1," ",FALSE,TRUE,"Hello there",
  164.                         "This field only accepts letters") ;
  165.    winptr->fieldcreate (3,20,30,15,2,"",FALSE,TRUE,"1993",
  166.                         "This field only accepts digits") ;
  167.    winptr->fieldcreate (5,2,30,15,3," ",FALSE,FALSE,"Enterprise NCC 1701 D",
  168.                         "This field accepts letters and digits") ;
  169.    winptr->fieldcreate (5,20,30,15,0,"",FALSE,FALSE,"EasyVision 2.0 by TNG SOFT !",
  170.                         "This field accepts anything") ;
  171.  
  172.                                                       // Creates some buttons
  173.    winptr->buttoncreate (7,2,"  Move",'M',"Randomly moves window") ;
  174.    winptr->buttoncreate (7,29,"  Esc",II_ESC,"Closes window") ;
  175.    winptr->buttoncreate (10,2,"   Up",'U',"Moves window up") ;
  176.    winptr->buttoncreate (10,11,"  Down",'D',"Moves window down") ;
  177.    winptr->buttoncreate (10,20,"  Left",'L',"Moves window Left") ;
  178.    winptr->buttoncreate (10,29," Right",'R',"Moves window Right") ;
  179.  
  180.    ii.key_code = II_NUL ;
  181.    while (ii.key_code != II_ESC)                        // Makes window alive
  182.    {
  183.       ii = winptr->wininput (ii) ;
  184.       if (ii.key_code <= 255) ii.key_code = toupper (ii.key_code) ;
  185.  
  186.       if (ii.key_code == 'U') winptr->winscroll ('U') ;
  187.       if (ii.key_code == 'D') winptr->winscroll ('D') ;
  188.       if (ii.key_code == 'L') winptr->winscroll ('L') ;
  189.       if (ii.key_code == 'R') winptr->winscroll ('R') ;
  190.       if (ii.key_code == 'M') winptr->winmove (2+random(36),1+random(41)) ;
  191.    }
  192.  
  193.    winptr->winclose () ;                                     // Closes window
  194.    delete (winptr) ;
  195.  
  196.  
  197.    return ;                                 // Demo window has been displayed
  198. }                                                           // End demowindow
  199.  
  200. // End Source File ----------------------------------------------------------
  201.