home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PCWSAMPO.ZIP / DEMOWIN.C next >
C/C++ Source or Header  |  1989-04-07  |  5KB  |  156 lines

  1. /* DemoWin.C:        Programma dimostrativo per le funzioni relative alla
  2.                     gestione delle finestre di PcWindow                 */
  3.  
  4. /* Allegato alla versione 1.31 di PcWindow                */
  5.  
  6.  
  7. #include <pcw.h>
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <conio.h>
  11. #include <stdlib.h>
  12.  
  13.  
  14. /* Definizione attributi video */
  15.  
  16. #define NORMATT attrib(WHITE, NORMAL, BLACK, STEADY)
  17. #define WND1 attrib(WHITE, NORMAL, BLUE, STEADY)
  18. #define SCRITTE attrib(RED, HILIGHT, BLUE, BLINK)
  19.  
  20.  
  21. void main(void)
  22. {
  23.     int i,j,k;
  24.     char s[21], c;
  25.     char t[21], ds[11];
  26.  
  27.  
  28.     strcpy(s,"Prova di scrittura  ");
  29.  
  30.  
  31.     if (Pcw_init(3,3,400) != OK)            /* Inizializza il toolkit  */
  32.         exit(1);
  33.  
  34.     Pcw_clear_screen(NORMATT);
  35.  
  36.     Pcw_beep();
  37.  
  38.     printf("Questo testo e' sul video di sfondo\n");
  39.     printf("gestito dal DOS: %s\n\n", s);
  40.  
  41.  
  42.     Pcw_no_flick();                         /* Vengono disabilitati i
  43.                                                flickers             */
  44.  
  45.     Pcw_copyright(13);                      /* Stampa il copyright  */
  46.  
  47.  
  48.     /* Qui segue la definizione delle tre finestre adoperate    */
  49.  
  50.     Pcw_define(0,20,20,LT_DOUBLE,attrib(GREEN,NORMAL,RED,STEADY),
  51.            WND1,reverse(WND1), 20,20,"Esempio");
  52.     Pcw_define(1,50,5,LT_SINGLE, attrib(BLUE,NORMAL,GREEN,STEADY),
  53.            attrib(BLUE,NORMAL,WHITE,STEADY),attrib(BLUE,NORMAL,WHITE,STEADY),
  54.            50,5,"\0");
  55.  
  56.     Pcw_sprintat(1,2,1," Pc Window:  Personal Computer Window System ",SCRITTE);
  57.     Pcw_sprintat(1,2,2,"             Versione  1.31                  ",SCRITTE);
  58.     Pcw_sprintat(1,2,3,"  Copyright (c) 1988 -  Pasquale Cantiello   ",SCRITTE);
  59.  
  60.     Pcw_define(2,22,3,NO_BORDER,attrib(GREEN,NORMAL,RED,STEADY),
  61.         reverse(WND1),WND1,22,3,"\0");
  62.  
  63.     Pcw_sprintat(2,0,0, "Un tasto qualunque per", reverse(WND1));
  64.     Pcw_sprintat(2,0,1, "terminare alla fine", reverse(WND1));
  65.     Pcw_sprintat(2,0,2, "del ciclo", reverse(WND1));
  66.  
  67.  
  68.     /* Di seguito viene eseguito un ciclo delle principali funzioni:
  69.         2 volte per ognuna delle 3 velocita'      */
  70.  
  71.     for (i = 1; i <= 6; i++) {
  72.     Pcw_write_25(" Dimostrativo in esecuzione", attrib(RED, HILIGHT, BLUE,
  73.             BLINK));
  74.     if (i == 1)
  75.         Pcw_set_speed(VERYFAST);
  76.     else if (i == 3)
  77.         Pcw_set_speed(FAST);
  78.     else if (i == 5)
  79.         Pcw_set_speed(SLOW);
  80.  
  81.         Pcw_open_pos(1,FADEHORIZ,10,3);
  82.         Pcw_open_pos(2, FADERIGHT, 30, 11);
  83.         Pcw_move_rel(UP, 8, FADE);
  84.         Pcw_move_rel(LEFT, 20, FADE);
  85.         Pcw_move_rel(DOWN, 8, FADE);
  86.         Pcw_move_rel(RIGHT, 20, FADE);
  87.         Pcw_open(0,ISTANT);
  88.         Pcw_cls(0,0);
  89.         strcpy(t,s);
  90.         t[20]='\0';
  91.  
  92.         /* Viene scritto questo pattern di caratteri utile per verificare
  93.             gli effetti di movimento e di scrolling         */
  94.  
  95.         for (j = 1; j <= 20; j++) {
  96.         Pcw_sprintat(0,0,j-1,t,attrib(WHITE,NORMAL,BLUE,STEADY));
  97.             c = t[19];
  98.             for (k = 0; k<19; k++)
  99.                 t[19-k] = t[19-k-1];
  100.             t[0] = c;
  101.         }
  102.         Pcw_set_input_flag(VIS);
  103.     Pcw_set_input_mode(BLANK, attrib(WHITE,NORMAL,BLUE,STEADY),
  104.             attrib(BLUE, NORMAL, WHITE, BLINK), ALL);
  105.     Pcw_input(IT_ALFANUM,5,8,10,"Input",ds);
  106.     Pcw_input(IT_ALFANUM,5,12,10,"Secondo",ds);
  107.         Pcw_size(0,RESTRICT,BOTH,5,ISTANT);
  108.         Pcw_size(0,ENLARGE,BOTH,5,ISTANT);
  109.         Pcw_close(ISTANT);
  110.         Pcw_open(0,FADELEFT);
  111.         Pcw_size(0,RESTRICT,LEFT,5,FADE);
  112.         Pcw_size(0,ENLARGE,LEFT,5,FADE);
  113.         Pcw_close(FADELEFT);
  114.         Pcw_open(0,FADERIGHT);
  115.         Pcw_size(0,RESTRICT,RIGHT,5,FADE);
  116.         Pcw_size(0,ENLARGE,RIGHT,5,FADE);
  117.         Pcw_close(FADERIGHT);
  118.         Pcw_open(0,FADEHORIZ);
  119.         Pcw_size(0,RESTRICT,HORIZ,5,FADE);
  120.         Pcw_size(0,ENLARGE,HORIZ,5,FADE);
  121.         Pcw_close(FADEHORIZ);
  122.         Pcw_open(0,FADEUP);
  123.         Pcw_size(0,RESTRICT,UP,5,FADE);
  124.         Pcw_size(0,ENLARGE,UP,5,FADE);
  125.         Pcw_close(FADEUP);
  126.         Pcw_open(0,FADEDOWN);
  127.         Pcw_size(0,RESTRICT,DOWN,5,FADE);
  128.         Pcw_size(0,ENLARGE,DOWN,5,FADE);
  129.         Pcw_close(FADEDOWN);
  130.         Pcw_open(0,FADEVERT);
  131.         Pcw_size(0,RESTRICT,VERT,5,FADE);
  132.         Pcw_size(0,ENLARGE,VERT,5,FADE);
  133.         Pcw_size(0,RESTRICT,BOTH,5,FADE);
  134.         Pcw_scroll(0,UP,5,FADE);
  135.         Pcw_scroll(0,RIGHT,5,FADE);
  136.         Pcw_scroll(0,DOWN,5,FADE);
  137.         Pcw_scroll(0,LEFT,5,FADE);
  138.         Pcw_set_view(0,3,3);
  139.         Pcw_set_view(0,5,5);
  140.         Pcw_size(0,ENLARGE,BOTH,5,FADE);
  141.         Pcw_move_abs(20,3,FADEHORIZ);
  142.         Pcw_move_abs(0,0,FADEVERT);
  143.         Pcw_move_rel(RIGHT,20,FADE);
  144.         Pcw_move_rel(LEFT,20,FADE);
  145.         Pcw_move_rel(DOWN,3,FADE);
  146.         Pcw_move_rel(UP,3,FADE);
  147.         Pcw_close(FADEVERT);
  148.         Pcw_close(FADEHORIZ);
  149.         Pcw_close(FADERIGHT);
  150.         if (kbhit())
  151.             break;
  152.     }
  153.     Pcw_beep();
  154.     Pcw_clear_screen(NORMATT);
  155. }
  156.