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 * Show the built-in symbols
23 *
24 * This file is part of xforms package
25 * T.C. Zhao and M. Overmars (1997)
26 */
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include "include/forms.h"
33 #include <stdlib.h>
34
35 const char * symbols[ ] =
36 {
37 "@>", "@<-", "@9->", "@DnLine", "@8>", "@circle", "@->|",
38 "@>>", "@square", "@4->|", "@8->|", "@<->", "@UpArrow", "@9+",
39 "@->", "@<", "@DnArrow", "@+", "@-->", "@line", "@3->",
40 "@UpLine", "@>|", "@2-->", "@4>|", "@8>|", "@=", "@menu",
41 "@8=", "@|>", "@2|>", "@-32|>", "@+32|>", "@-2circle", NULL
42 };
43
44 #define N ( sizeof symbols / sizeof * symbols - 1 )
45
46
47 /***************************************
48 ***************************************/
49
50 static void
done_cb(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)51 done_cb( FL_OBJECT * ob FL_UNUSED_ARG,
52 long data FL_UNUSED_ARG )
53 {
54 exit( 0 );
55 }
56
57
58 /***************************************
59 ***************************************/
60
61 FL_FORM *
make_symbols(void)62 make_symbols( void )
63 {
64 const char **p;
65 char buf[ 32 ];
66 int x0 = 10,
67 y0 = 10,
68 dx = 35,
69 dy = 35,
70 ty = 17,
71 n = 7;
72 int xsep = 15,
73 ysep = 5;
74 int x,
75 y,
76 i,
77 w,
78 h;
79 FL_OBJECT *obj;
80 FL_FORM *form;
81
82 form = fl_bgn_form( FL_FLAT_BOX,
83 w = 2 * x0 + n * dx + ( n - 1 ) * xsep,
84 h = 2 * y0 + ( 1 + N / n - ! ( N % n ) )
85 * ( dy + ty + ysep ) );
86
87 obj = fl_add_button( FL_HIDDEN_BUTTON, 0, 0, w, h, "" );
88
89 fl_set_object_callback( obj, done_cb, 0 );
90
91 for ( x = x0, y = y0, i = 1, p = symbols; *p; p++, i++ )
92 {
93 int txt_x, txt_y, txt_w, txt_h;
94
95 obj = fl_add_box( FL_UP_BOX, x, y, dx, dy, *p );
96 fl_set_object_lcolor( obj, FL_BOTTOM_BCOL );
97
98 strcat( strcpy( buf, "@" ) , *p );
99 obj = fl_add_box( FL_FLAT_BOX, x, y + dy, dx, ty, buf );
100
101 fl_get_object_geometry( obj, &txt_x, &txt_y, &txt_w, &txt_h );
102 w = fl_get_string_width( fl_get_object_lstyle( obj ),
103 fl_get_object_lsize( obj ),
104 *p, strlen( *p ) )
105 + 2 * fl_get_object_bw( obj );
106 fl_set_object_geometry( obj, txt_x + ( txt_w - w ) / 2, txt_y,
107 w, txt_h );
108
109 if ( i % n == 0 )
110 {
111 static int j = 1;
112
113 x = x0;
114 y = y0 + j * ( dy + ty + ysep + 1);
115 j++;
116 }
117 else
118 x += dx + xsep;
119 }
120
121 fl_end_form( );
122
123 return form;
124 }
125
126
127 /***************************************
128 ***************************************/
129
130 int
main(int argc,char * argv[])131 main( int argc,
132 char * argv[ ] )
133 {
134 FL_FORM *form;
135
136 fl_initialize( &argc, argv , 0, 0, 0 );
137 form = make_symbols( );
138 fl_show_form( form, FL_PLACE_FREE, FL_FULLBORDER, "test" );
139
140 while ( fl_do_forms( ) )
141 /* empty */;
142
143 return 0;
144 }
145
146
147 /*
148 * Local variables:
149 * tab-width: 4
150 * indent-tabs-mode: nil
151 * End:
152 */
153