home *** CD-ROM | disk | FTP | other *** search
- /*
- * Test application for CForms.
- * @(#) $Id: main.frm,v 1.16 1993/07/21 01:53:45 lasse Exp $
- */
-
- CCode {
- #include <stdio.h>
- int cur_row = 0;
- int main()
- {
- if (cforms_init() != OK) {
- fprintf(stderr, "Failed to start cforms\n");
- exit(1);
- }
-
- if (pic_call(picture("main"), NULL) != OK) {
- fprintf(stderr, "No main picture\n");
- }
-
- cforms_end();
- return 0;
- }
- }
-
- Viewport view {
- Pos 0,0;
- Size 80, 23;
- }
-
- Event Key DOWN { fld_move(fld_down(NULL)); }
- Event Key UP { fld_move(fld_up(NULL)); }
- Event Key TAB { fld_move(fld_next(NULL)); }
- Event Key HELP { message("You're using CForms"); }
- Event Key DEL { message("You pressed delete key"); }
- Event Key BS { message("You pressed backspace key"); }
- Global Event Key F2 { message("This is the global event routine for F2"); }
- Global Event Key CR { fld_move(fld_next(NULL)); }
-
- Picture Main Viewport View
- {
- Event Draw {
- fld_move(field("exit"));
- }
-
- Event Entry {
- fld_set(NULL, "X");
- fld_set(field("cur"), fld_name(NULL));
- }
- Event Exit { fld_set(NULL, ""); }
- Event Key LEFT { fld_move(fld_left(NULL)); }
- Event Key RIGHT { fld_move(fld_right(NULL)); }
- Event Key ESC { pic_leave(); }
- Event Key F8 { pic_leave(); }
-
- Event Key CR {
- if (!picture(fld_name(NULL))) {
- message("Choice not available %s", fld_name(NULL));
- }
- else pic_call(picture(fld_name(NULL)), NULL);
- }
-
- Literal Center, 1, "M a i n M e n u";
- Literal +0, 2, "-----------------";
-
- Field List { Pos 10, 7; Type Char(1); Protected;
- LValue "["; RValue "] Adress book"; }
-
- Field Play { Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Play Game"; }
-
- Field Status { Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Status Report"; }
-
- Field LoopTest { Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Test of loops in events"; }
-
- Field Validate { Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Test of validation events"; }
-
-
- Field pic_dirent { Pos 40, 7; Type Char(1); Protected;
- LValue "["; RValue "] Directory browser"; }
-
- Field Ok { Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Test of popup"; }
-
- Field System {
- Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] System command";
- }
-
- Field Keys {
- Pos +0, +2; Type Char(1); Protected;
- LValue "["; RValue "] Check event codes";
- Event Key Any {
- if (event_code == KEY_LEFT) { fld_move(fld_left(NULL)); }
- else if (event_code == KEY_RIGHT) { fld_move(fld_right(NULL)); }
- else if (event_code == KEY_UP) { fld_move(fld_up(NULL)); }
- else if (event_code == KEY_DOWN) { fld_move(fld_down(NULL)); }
- else if (event_code == KEY_ESC) { pic_leave(); }
- else message("you pressed %d", event_code);
- }
- }
-
- Field Maximum {
- Pos Max, Max;
- Type Char(5);
- LValue "Max: [";
- RValue "]";
- Invisible;
-
- Value "Hello";
- }
-
- Field cur {
- Pos Max, -1;
- Type Char(10);
- Forbidden;
- LValue "(Current field: "; RValue ")";
- Value "Init value";
- }
-
- Field Exit {
- Pos Center, Max; Type Char(1); Protected; LValue "["; RValue "] Exit";
- Event Key CR {
- pic_leave();
- }
- }
- }
-