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 /*
22 * Tabbed folder demo and tester
23 *
24 * This file is part of xforms package
25 * T.C. Zhao and M. Overmars
26 *
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include "include/forms.h"
34 #include "fd/folder_gui.h"
35 #include <stdlib.h>
36
37
38 static void make_folder( FL_OBJECT * );
39
40
41 /* callback routines */
42
43 /***************************************
44 ***************************************/
45
46 void
hide_show_cb(FL_OBJECT * ob,long data)47 hide_show_cb( FL_OBJECT * ob,
48 long data )
49 {
50 FD_mainform *fdui = ob->form->fdui;
51
52 ( data ? fl_show_object : fl_hide_object )( fdui->folder );
53 }
54
55
56 /***************************************
57 ***************************************/
58
59 void
reshow_cb(FL_OBJECT * ob,long data FL_UNUSED_ARG)60 reshow_cb( FL_OBJECT * ob,
61 long data FL_UNUSED_ARG )
62 {
63 fl_hide_form( ob->form );
64 fl_show_form( ob->form, FL_PLACE_CENTER, FL_FULLBORDER, "TabFolder" );
65
66 }
67
68 /***************************************
69 ***************************************/
70
71 void
set_cb(FL_OBJECT * ob,long data FL_UNUSED_ARG)72 set_cb( FL_OBJECT * ob,
73 long data FL_UNUSED_ARG )
74 {
75 FD_mainform *fdui = ob->form->fdui;
76 int n = fl_get_active_folder_number( fdui->folder );
77
78 fl_set_folder_bynumber( fdui->folder, n % 5 + 1 );
79 }
80
81
82 /***************************************
83 ***************************************/
84
85 void
deactivate_cb(FL_OBJECT * ob,long data FL_UNUSED_ARG)86 deactivate_cb( FL_OBJECT * ob,
87 long data FL_UNUSED_ARG )
88 {
89 FD_mainform *fdui = ob->form->fdui;
90
91 if ( fl_object_is_active( fdui->folder ) )
92 {
93 fl_set_object_label( ob, "Activate" );
94 fl_deactivate_object( fdui->folder );
95 }
96 else
97 {
98 fl_set_object_label( ob, "Deactivate" );
99 fl_activate_object( fdui->folder );
100 }
101 }
102
103
104 /***************************************
105 ***************************************/
106
107 void
done_cb(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)108 done_cb( FL_OBJECT * ob FL_UNUSED_ARG,
109 long data FL_UNUSED_ARG )
110 {
111 fl_finish( );
112 exit( 0 );
113 }
114
115
116 /***************************************
117 ***************************************/
118
119 int
main(int argc,char * argv[])120 main( int argc,
121 char * argv[ ] )
122 {
123 FD_mainform *fd_mainform;
124
125 fl_set_border_width( -2 );
126 fl_initialize( &argc, argv, 0, 0, 0 );
127 fd_mainform = create_form_mainform( );
128
129 make_folder( fd_mainform->folder );
130
131 /* show the first form */
132
133 fl_show_form( fd_mainform->mainform, FL_PLACE_CENTER, FL_FULLBORDER,
134 "TabFolder" );
135
136 while ( fl_do_forms( ) )
137 /* empty */ ;
138
139 return 0;
140 }
141
142
143 /***************************************
144 ***************************************/
145
146 static void
make_folder(FL_OBJECT * folder FL_UNUSED_ARG)147 make_folder( FL_OBJECT * folder FL_UNUSED_ARG )
148 {
149 FD_buttonform *fd_buttonform;
150 FD_staticform *fd_staticform;
151 FD_valuatorform *fd_valuatorform;
152 FD_choiceform *fd_choiceform;
153 FD_inputform *fd_inputform;
154 float y[ 6 ] = { 5.5, 4, 4.5, 3.8, 4, 5 };
155 char *label[ ] = { "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" };
156 size_t i;
157 int xx,
158 yy,
159 ww,
160 hh;
161
162 fd_buttonform = create_form_buttonform( );
163 fd_staticform = create_form_staticform( );
164 fd_valuatorform = create_form_valuatorform( );
165 fd_choiceform = create_form_choiceform( );
166 fd_inputform = create_form_inputform( );
167
168 /* form initialization code */
169
170 for ( i = 0; i < sizeof y / sizeof *y; i++ )
171 fl_add_chart_value( fd_staticform->chart, y[ i ], label[ i ], i + 1 );
172
173 fl_addto_menu( fd_choiceform->pulldown,
174 "MenuEntry1|MenuEntry2|MenuEntry3|MenuEntry4" );
175 fl_addto_menu( fd_choiceform->pushmenu,
176 "MenuEntry1|MenuEntry2|MenuEntry3" );
177 fl_addto_choice( fd_choiceform->choice,
178 "Choice1|Choice2|Choice3|Choice4|Choice5|Choice6" );
179
180 fl_load_browser( fd_choiceform->browser, "01Readme" );
181
182 fl_get_folder_area( folder, &xx, &yy, &ww, &hh );
183 fl_addto_tabfolder( folder, "ButtonObj", fd_buttonform->buttonform );
184 fl_addto_tabfolder( folder, "StaticObj", fd_staticform->staticform );
185 fl_addto_tabfolder( folder, "ValuatorObj", fd_valuatorform->valuatorform );
186 fl_addto_tabfolder( folder, "ChoiceObj", fd_choiceform->choiceform );
187 fl_addto_tabfolder( folder, "InputObj", fd_inputform->inputform );
188 fl_get_folder_area( folder, &xx, &yy, &ww, &hh );
189 }
190
191
192 /*
193 * Local variables:
194 * tab-width: 4
195 * indent-tabs-mode: nil
196 * End:
197 */
198