home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRO2.ZIP / TUTOR1.C < prev    next >
Text File  |  1988-11-27  |  5KB  |  214 lines

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