1 /*
2  *  This file is part of XForms.
3  *
4  *  XForms is free software; you can redistribute it and/or modify it
5  *  under the terms of the GNU Lesser General Public License as
6  *  published by the Free Software Foundation; either version 2.1, or
7  *  (at your option) any later version.
8  *
9  *  XForms is distributed in the hope that it will be useful, but
10  *  WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with XForms; see the file COPYING.  If not, write to
16  *  the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
17  *  MA 02111-1307, USA.
18  */
19 
20 
21 /* This demo program uses the routines in the
22    goodies section, that help you create easy
23    forms in an even easier way.
24 */
25 
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29 
30 #include <stdlib.h>
31 #include <string.h>
32 #include "include/forms.h"
33 
34 
35 /***************************************
36  ***************************************/
37 
38 void
timeout_remove_alert(int id FL_UNUSED_ARG,void * data FL_UNUSED_ARG)39 timeout_remove_alert( int    id    FL_UNUSED_ARG,
40 					  void * data  FL_UNUSED_ARG )
41 {
42     fl_hide_alert();
43 }
44 
45 
46 /***************************************
47  ***************************************/
48 
49 int
main(int argc,char * argv[])50 main( int    argc,
51       char * argv[ ] )
52 {
53     int choice;
54     char str1[ 100 ],
55          str2[ 100 ];
56     const char *s;
57 
58     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
59 
60 #if 0
61     fl_set_resource( FLOKLabel, "Go" );
62 #endif
63 
64     if ( fl_show_question( "Do you want bold font ?", 1 ) )
65         fl_set_goodies_font( FL_BOLD_STYLE, FL_NORMAL_SIZE );
66 
67     fl_show_messages( "This is a test program for the goodies of the"
68                       "forms library" );
69 
70     fl_add_timeout( 5000, timeout_remove_alert, 0 );
71     fl_show_alert( "Alert", "Alert form can be used to inform",
72                    "recoverable errors", 0 );
73 
74     if ( fl_show_question( "Do you want to quit?", 0 ) )
75 	{
76 		fl_finish( );
77         exit( 0 );
78 	}
79 
80     strcpy(str1, ( s = fl_show_input( "Give a string:", "" ) ) ? s: "" );
81     fl_show_message( "You typed:", "", str1 );
82     choice = fl_show_choices( "Pick a choice", 2, "One", "Two", "Three", 2 );
83 
84     switch ( choice )
85     {
86         case 1 :
87             fl_show_message( "You typed: One", "", "" );
88             break;
89 
90         case 2 :
91             fl_show_message( "You typed: Two", "", "" );
92             break;
93 
94         case 3 :
95             fl_show_message( "You typed: Three", "", "" );
96             break;
97 
98         default :
99             fl_show_message( "An error occured!", "", "" );
100             break;
101     }
102 
103     strcpy( str2, ( s = fl_show_input( "Give another string:", str1 ) ) ?
104                     s : "<Cancel>" );
105     fl_show_message( "You typed:", "", str2 );
106     fl_show_messages( "Good Bye" );
107 
108     fl_finish( );
109     return 0;
110 }
111 
112 
113 /*
114  * Local variables:
115  * tab-width: 4
116  * indent-tabs-mode: nil
117  * End:
118  */
119