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 * This demo show the different boxtypes. Note that some
23 * boxtypes are not appropriate for some objects
24 *
25 * This file is part of xforms package.
26 * M. Overmars and T.C. Zhao (1997)
27 */
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include "include/forms.h"
34
35
36 static int border = FL_TRANSIENT;
37
38 typedef struct {
39 int val;
40 char * name;
41 } VN_struct;
42
43 #define VN( a ) { a, #a }
44
45 static VN_struct btypes[ ]=
46 {
47 { FL_NO_BOX, "No box" },
48 { FL_UP_BOX, "Up box" },
49 { FL_DOWN_BOX, "Down box" },
50 { FL_BORDER_BOX, "Border box" },
51 { FL_SHADOW_BOX, "Shadow box" },
52 { FL_FLAT_BOX, "Flat box" },
53 { FL_FRAME_BOX, "Frame box" },
54 { FL_EMBOSSED_BOX, "Embossed box" },
55 { FL_ROUNDED_BOX, "Rounded box" },
56 { FL_RFLAT_BOX, "Rflat box" },
57 { FL_RSHADOW_BOX, "Rshadow box" },
58 { FL_OVAL_BOX, "Oval box" },
59 { FL_ROUNDED3D_UPBOX, "Rounded 3D up box" },
60 { FL_ROUNDED3D_DOWNBOX, "Rounded 3D down box" },
61 { FL_OVAL3D_UPBOX, "Oval 3D up box" },
62 { FL_OVAL3D_DOWNBOX, "Oval 3D down box" },
63 /* sentinel */
64 { -1, NULL }
65 };
66
67
68 #include "srs.xbm"
69
70
71 /*************** Callback **********************/
72
73 FL_FORM *form;
74 FL_OBJECT *tobj[ 18 ],
75 *exitob,
76 *btypeob;
77
78
79 /***************************************
80 ***************************************/
81
82 static void
boxtype_cb(FL_OBJECT * ob,long arg FL_UNUSED_ARG)83 boxtype_cb( FL_OBJECT * ob,
84 long arg FL_UNUSED_ARG )
85 {
86 int req_bt = fl_get_select_item( ob )->val;
87 static int lastbt = -1;
88
89 if ( lastbt != req_bt )
90 {
91 size_t i;
92
93 fl_freeze_form( form );
94 for ( i = 0; i < sizeof tobj / sizeof *tobj; i++ )
95 fl_set_object_boxtype( tobj[ i ], btypes[ req_bt ].val );
96 fl_unfreeze_form ( form );
97 lastbt = req_bt;
98 }
99 }
100
101
102 /***************************************
103 ***************************************/
104
105 static void
create_form(void)106 create_form( void )
107 {
108 FL_OBJECT *obj;
109
110 form = fl_bgn_form( FL_NO_BOX, 720, 520 );
111
112 obj = fl_add_box( FL_UP_BOX, 0, 0, 720, 520, "" );
113 fl_set_object_color( obj, FL_BLUE, FL_COL1 );
114
115 obj = fl_add_box( FL_DOWN_BOX, 10, 90, 700, 420, "" );
116 fl_set_object_color( obj, FL_COL1, FL_COL1 );
117
118 obj = fl_add_box( FL_DOWN_BOX, 10, 10, 700, 70, "" );
119 fl_set_object_color( obj, FL_SLATEBLUE, FL_COL1 );
120
121 tobj[ 0 ] = fl_add_box( FL_UP_BOX, 30, 110, 110, 110, "Box" );
122
123 tobj[ 1 ] = fl_add_text( FL_NORMAL_TEXT, 30, 240, 110, 30, "Text" );
124
125 tobj[ 2 ] = fl_add_bitmap( FL_NORMAL_BITMAP, 40, 280, 90, 80, "Bitmap" );
126 fl_set_object_lcolor( tobj[ 2 ], FL_BLUE );
127
128 tobj[ 3 ] = fl_add_chart(FL_BAR_CHART, 160, 110, 160, 110, "Chart");
129
130 tobj[ 4 ] = fl_add_clock( FL_ANALOG_CLOCK, 40, 390, 90, 90, "Clock" );
131 fl_set_object_dblbuffer( tobj[ 4 ], 1 );
132
133 tobj[ 5 ] = fl_add_button( FL_NORMAL_BUTTON, 340, 110, 120, 30, "Button" );
134
135 tobj[ 6 ] = fl_add_lightbutton( FL_PUSH_BUTTON, 340, 150, 120, 30,
136 "Lightbutton" );
137
138 tobj[ 7 ] = fl_add_roundbutton( FL_PUSH_BUTTON, 340, 190, 120, 30,
139 "Roundbutton" );
140
141 tobj[ 8 ] = fl_add_slider( FL_VERT_SLIDER, 160, 250, 40, 230, "Slider" );
142
143 tobj[ 9 ] = fl_add_valslider( FL_VERT_SLIDER, 220, 250, 40, 230,
144 "Valslider" );
145
146 tobj[ 10 ] = fl_add_dial( FL_LINE_DIAL, 280, 250, 100, 100, "Dial" );
147
148 tobj[ 11 ] = fl_add_positioner( FL_NORMAL_POSITIONER, 280, 380, 150, 100,
149 "Positioner" );
150
151 tobj[ 12 ] = fl_add_counter( FL_NORMAL_COUNTER, 480, 110, 210, 30,
152 "Counter" );
153
154 tobj[ 13 ] = fl_add_input( FL_NORMAL_INPUT, 520, 170, 170, 30, "Input" );
155
156 tobj[ 14 ] = fl_add_menu( FL_PUSH_MENU, 400, 240, 100, 30, "Menu" );
157
158 tobj[ 15 ] = fl_add_select( FL_NORMAL_SELECT, 580, 250, 110, 30, "Select" );
159
160 tobj[ 16 ] = fl_add_timer( FL_VALUE_TIMER, 580, 210, 110, 30, "Timer" );
161 fl_set_object_dblbuffer( tobj[ 16 ], 1 );
162
163 tobj[ 17 ] = fl_add_browser( FL_NORMAL_BROWSER, 450, 300, 240, 180,
164 "Browser" );
165
166 exitob = fl_add_button( FL_NORMAL_BUTTON, 590, 30, 100, 30, "Exit" );
167
168 btypeob = fl_add_select( FL_NORMAL_SELECT, 110, 30, 130, 30, "Boxtype" );
169 fl_set_object_callback( btypeob, boxtype_cb, 0 );
170 fl_popup_set_title( fl_get_select_popup( btypeob ), "Boxtype" );
171
172 fl_end_form ( );
173 }
174
175
176 /*************** Main Routine ***********************/
177
178 static char * browserlines[ ] = {
179 "@C1@c@l@bObjects Demo",
180 "This demo shows you many of",
181 "the objects that currently",
182 "exist in the Forms Library.",
183 "",
184 "You can change the boxtype",
185 "of the different objects",
186 "using the buttons at the",
187 "top of the form. Note that",
188 "some combinations might not",
189 "look too good. Also realize",
190 "that for all object classes",
191 "many different types are",
192 "available with different",
193 "behaviour.",
194 NULL
195 };
196
197
198 /***************************************
199 ***************************************/
200
201 int
main(int argc,char * argv[])202 main( int argc,
203 char * argv[ ] )
204 {
205 FL_COLOR c = FL_BLACK;
206 char **p;
207 VN_struct *vn;
208
209 fl_initialize( &argc, argv, "FormDemo", 0, 0 );
210
211 create_form( );
212
213 fl_set_bitmap_data( tobj[ 2 ],
214 sorceress_width, sorceress_height, sorceress_bits );
215
216 fl_add_chart_value( tobj[ 3 ], 15, "Item 1", c++ );
217 fl_add_chart_value( tobj[ 3 ], 5, "Item 2", c++ );
218 fl_add_chart_value( tobj[ 3 ], -10, "Item 3", c++ );
219 fl_add_chart_value( tobj[ 3 ], 25, "Item 4", c++ );
220
221 fl_set_menu( tobj[ 14 ], "Item 1|Item 2|Item 3|Item 4|item 5" );
222
223 fl_add_select_items( tobj[ 15 ], "Item 1" );
224 fl_add_select_items( tobj[ 15 ], "Item 2" );
225 fl_add_select_items( tobj[ 15 ], "Item 3" );
226 fl_add_select_items( tobj[ 15 ], "Item 4" );
227 fl_add_select_items( tobj[ 15 ], "Item 5" );
228
229 fl_set_timer( tobj[ 16 ], 1000.0 );
230
231 for ( p = browserlines; *p; p++ )
232 fl_add_browser_line( tobj[ 17 ], *p );
233
234 for ( vn = btypes; vn->val >= 0; vn++ )
235 fl_add_select_items( btypeob, vn->name );
236
237 fl_set_select_item( btypeob, fl_get_select_item_by_value( btypeob, 1 ) );
238 boxtype_cb( btypeob, 0 );
239
240 fl_show_form ( form, FL_PLACE_MOUSE, border, "Box types" );
241
242 while ( fl_do_forms ( ) != exitob )
243 /* empty */;
244
245 fl_finish( );
246 return 0;
247 }
248
249
250 /*
251 * Local variables:
252 * tab-width: 4
253 * indent-tabs-mode: nil
254 * End:
255 */
256