home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 402_01 / cforms-2.2 / example / main.frm < prev    next >
Encoding:
Text File  |  1993-07-20  |  3.2 KB  |  130 lines

  1. /*
  2.  * Test application for CForms.
  3.  * @(#) $Id: main.frm,v 1.16 1993/07/21 01:53:45 lasse Exp $
  4.  */
  5.  
  6. CCode {
  7. #include <stdio.h>
  8.     int cur_row = 0;
  9.     int main()
  10.     {
  11.         if (cforms_init() != OK) {
  12.             fprintf(stderr, "Failed to start cforms\n");
  13.             exit(1);
  14.         }
  15.  
  16.         if (pic_call(picture("main"), NULL) != OK) {
  17.             fprintf(stderr, "No main picture\n");
  18.         }
  19.  
  20.         cforms_end();
  21.     return 0;
  22.     }
  23. }
  24.  
  25. Viewport view {
  26.     Pos 0,0;
  27.     Size 80, 23;
  28. }
  29.  
  30. Event Key DOWN  { fld_move(fld_down(NULL));  }
  31. Event Key UP    { fld_move(fld_up(NULL));    }
  32. Event Key TAB   { fld_move(fld_next(NULL)); }
  33. Event Key HELP  { message("You're using CForms"); }
  34. Event Key DEL   { message("You pressed delete key"); }
  35. Event Key BS    { message("You pressed backspace key"); }
  36. Global Event Key F2    { message("This is the global event routine for F2"); }
  37. Global Event Key CR    { fld_move(fld_next(NULL));    }
  38.  
  39. Picture Main Viewport View
  40. {
  41.     Event Draw {
  42.     fld_move(field("exit"));
  43.     }
  44.  
  45.     Event Entry     {
  46.     fld_set(NULL, "X");
  47.     fld_set(field("cur"), fld_name(NULL));
  48.     }
  49.     Event Exit      { fld_set(NULL, ""); }
  50.     Event Key LEFT  { fld_move(fld_left(NULL));  }
  51.     Event Key RIGHT { fld_move(fld_right(NULL)); }
  52.     Event Key ESC   { pic_leave(); }
  53.     Event Key F8    { pic_leave(); }
  54.  
  55.     Event Key CR {
  56.     if (!picture(fld_name(NULL))) {
  57.         message("Choice not available %s", fld_name(NULL));
  58.     }
  59.     else pic_call(picture(fld_name(NULL)), NULL);
  60.     }
  61.  
  62.     Literal Center, 1, "M a i n   M e n u";    
  63.     Literal +0, 2, "-----------------";    
  64.  
  65.     Field List { Pos 10, 7; Type Char(1); Protected;
  66.     LValue "[";  RValue "] Adress book"; }
  67.  
  68.     Field Play { Pos +0, +2; Type Char(1); Protected;
  69.     LValue "[";  RValue "] Play Game"; }
  70.  
  71.     Field Status { Pos +0, +2; Type Char(1); Protected;
  72.     LValue "[";  RValue "] Status Report"; }
  73.     
  74.     Field LoopTest { Pos +0, +2; Type Char(1); Protected;
  75.     LValue "[";  RValue "] Test of loops in events"; }
  76.     
  77.     Field Validate { Pos +0, +2; Type Char(1); Protected;
  78.     LValue "[";  RValue "] Test of validation events"; }
  79.     
  80.  
  81.     Field pic_dirent { Pos 40, 7; Type Char(1); Protected;
  82.     LValue "[";  RValue "] Directory browser"; }
  83.  
  84.     Field Ok { Pos +0, +2; Type Char(1); Protected;
  85.     LValue "[";  RValue "] Test of popup"; }
  86.  
  87.     Field System {
  88.     Pos +0, +2; Type Char(1); Protected;
  89.     LValue "[";  RValue "] System command";
  90.     }
  91.  
  92.     Field Keys {
  93.     Pos +0, +2; Type Char(1); Protected;
  94.     LValue "[";  RValue "] Check event codes";
  95.     Event Key Any {
  96.         if (event_code == KEY_LEFT) { fld_move(fld_left(NULL));  }
  97.         else if (event_code == KEY_RIGHT) { fld_move(fld_right(NULL));  }
  98.         else if (event_code == KEY_UP) { fld_move(fld_up(NULL));  }
  99.         else if (event_code == KEY_DOWN) { fld_move(fld_down(NULL));  }
  100.         else if (event_code == KEY_ESC) { pic_leave(); }
  101.         else message("you pressed %d", event_code);
  102.     }
  103.     }
  104.  
  105.     Field Maximum {
  106.     Pos Max, Max;
  107.     Type Char(5);
  108.     LValue "Max: [";
  109.     RValue "]";
  110.     Invisible;
  111.  
  112.     Value "Hello";
  113.     }
  114.  
  115.     Field cur {
  116.     Pos Max, -1;
  117.     Type Char(10);
  118.     Forbidden;
  119.     LValue "(Current field: ";  RValue ")";
  120.     Value "Init value";
  121.     }
  122.  
  123.     Field Exit    {
  124.     Pos Center, Max; Type Char(1); Protected;  LValue "["; RValue "] Exit";
  125.     Event Key CR {
  126.         pic_leave();
  127.     }
  128.     }
  129. }
  130.