home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / GRAPHICS / WINDOWPR.ZIP / TUTOR1.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-29  |  4.7 KB  |  212 lines

  1. /*
  2.  * We'll need this for type checking on the windows functions
  3. */
  4. #include "pro.h"
  5.  
  6.  
  7. /*
  8.  * You've got to have this.  It will setup the Window Pro global
  9.  * variables.
  10. */
  11. #include "xglobals.h"
  12.  
  13.  
  14. /*
  15.  * We'll need this for type checking on the virtual screen
  16.  * functions
  17. */
  18. #include "vs.h"
  19.  
  20.  
  21. /*
  22.  * This is really handy, it defines the IBM-PC colors
  23. */
  24. #include "colors.h"
  25.  
  26.  
  27. int main()
  28. {
  29.  
  30.     /*
  31.      * We'll use this to store the window and tile handle
  32.      * returned when we create a window.
  33.     */
  34.     unsigned int window_handle;
  35.     
  36.     /*
  37.      * Initialize Window Pro.  If you don't do this -- forget
  38.      * it, everything blows up.
  39.     */
  40.     method = DMA;
  41.     wn_init();
  42.  
  43.     /*
  44.      * Let's turn off the scroll bars default -- We don't want
  45.      * to worry about those right now.
  46.     */
  47.  
  48.     scroll_bars_on = FALSE;
  49.  
  50.     /*
  51.      * Create a window and get a handle back.
  52.          *
  53.      * The window's virtual screen will be 25 rows by 80
  54.      * columns,
  55.     */
  56.  
  57.     window_handle = wn_createw(25, 80,
  58.  
  59.     /*
  60.      * The upper left corner of the window will be located at the
  61.      * physical screen coordinates of (2,3); second column and
  62.      * third row.
  63.     */
  64.  
  65.     2, 3,
  66.  
  67.     /*
  68.      * The upper left corner of the window will map to the
  69.      * virtual screen coordinate (1,1); first column and
  70.      * first row.
  71.     */
  72.  
  73.     1, 1,
  74.  
  75.     /*
  76.      * The inner dimensions of the window will be 5,10;
  77.      * 5 rows by 5 columns.
  78.     */
  79.  
  80.     5, 10,
  81.  
  82.     /*
  83.      * The window will not be suspended, i.e. all output
  84.      * to the virtual screen will be immediately displayed
  85.       * on the physical screen.
  86.     */
  87.  
  88.     FALSE,
  89.  
  90.     /*
  91.      * We won't use any shadowing effects.
  92.     */
  93.  
  94.     HEAD_ON,
  95.  
  96.     /*
  97.      * Nor will we assign a name to the tile or window.
  98.     */
  99.  
  100.     NULL, NULL);
  101.  
  102.  
  103.     /*
  104.      * More simply put:     
  105.      * wn_createw(25,80,2,3,1,1,5,10,FALSE,HEAD_ON,NULL,NULL);
  106.     */
  107.  
  108.  
  109.     /*
  110.      * Here comes the confusing part:
  111.      * All windows, even those that aren't divided into tiles
  112.      * have tiles.  You really should think of windows as a
  113.      * way of grouping tiles together.  In the above case
  114.      * When we created the window, we also created a tile, and
  115.      * a virtual screen.  The first tile created in a new
  116.      * window always has a handle of 0 and every virtual
  117.      * screen is associated with a tile. We always
  118.      * reference a virtual screen by a pair of handles:
  119.      * A window handle (pointing to a group of tiles), and
  120.      * a tile handle.  In the window we just created the window
  121.      * has a handle of 'window_handle', the tile has a handle
  122.      * of 0, and we reference the virtual screen using
  123.      * {window_handle, 0}.
  124.     */
  125.  
  126.     /*
  127.      * Now let's put something in the virtual screen
  128.      *
  129.     */
  130.  
  131.     /*
  132.      * first we reference the virtual screen
  133.     */
  134.  
  135.     vs_puts(window_handle, 0,
  136.  
  137.     /*
  138.      * Then we say where we want the string put (column, row).
  139.     */
  140.  
  141.     1, 1,
  142.  
  143.     /*
  144.      * Now we indicate the maximum length of the string to output
  145.     */
  146.  
  147.     10,
  148.  
  149.     /* Now the foreground and background color of the string.
  150.      * Note, if the string is shorter than the maximum length
  151.      * The function pads spaces to the end.
  152.     */
  153.  
  154.     WHITE, BLUE,
  155.  
  156.     /*
  157.      * And finally, the string to output.
  158.     */
  159.  
  160.     "Window Pro");
  161.  
  162.     /*
  163.      * More simply put:
  164.      * vs_puts(window_handle,0,1,1,10,BLUE,WHITE,"Window Pro");
  165.     */
  166.  
  167.     /*
  168.      * However, before anything happens on the screen we need to
  169.      * open it.
  170.     */
  171.  
  172.     wn_openw(window_handle);
  173.      getch();
  174.  
  175.     /*
  176.      * If you want to restore the background screen before you exit
  177.      * just do a wn_restorescr().
  178.     */
  179.  
  180.     /* restore the characters to the original screen */
  181.         wn_restorescr();
  182.  
  183.     /* restore the cursor position */
  184.     v_gotoxy(oldx,oldy);
  185.  
  186.     /* restore the cursor shape */
  187.     v_curshape(oldb, olde);
  188.  
  189.     /*
  190.      * That's it:
  191.  
  192. ***********************************************************
  193. * {                                                       *
  194. * wn_init();                                              *
  195. *                                                         *
  196. * window_handle =                                       *
  197. * wn_createw(25,80,2,3,1,1,5,10,FALSE,HEAD_ON,NULL,NULL); *
  198. *                                                         *
  199. * vs_puts(window_handle,0,1,1,10,BLUE,WHITE,              *
  200. * "Window Pro");                                          *
  201. *                                                         *
  202. * wn_openw(window_handle);                                *
  203. * getch();                                                *
  204. * wn_restorescr();                                        *
  205. * v_gotoxy(oldx, oldy)                                    *
  206. * v_curshape(oldb, olde)                                  *
  207. * }                                                       *
  208. ***********************************************************
  209.  
  210.     */
  211. }
  212.