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 License
15  *  along with XForms.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 
19 /**
20  * \file fd_initforms.c
21  *
22  *  This file is part of XForms package
23  *  Copyright (c) 1996-2002  T.C. Zhao and Mark Overmars
24  *  All rights reserved.
25  *
26  *  create and initialize all control panels
27  */
28 
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 
33 #include "fd_main.h"
34 #include "fd/ui_attrib.h"       /* from  directory fd */
35 #include "fd/ui_theforms.h" /* from  directory fd */
36 
37 FD_control *fd_control;
38 FD_test *fd_test;
39 FD_align *fd_align;
40 FD_resize *fd_resize;
41 FD_helpform *fd_help;
42 FD_attrib *fd_attrib;
43 FD_generic_attrib *fd_generic_attrib;
44 
45 extern int fd_helpfontsize;
46 extern int fd_align_fontsize,
47            fd_type_fontsize;
48 
49 static void init_helpform( void );
50 static void init_controlform( void );
51 static void init_attribform( void );
52 static void init_testform( void );
53 
54 
55 /***************************************
56  ***************************************/
57 
58 void
create_the_forms(void)59 create_the_forms( void )
60 {
61     static int init;
62 
63     if ( init )
64     {
65         fprintf( stderr, "fd forms already initialized\n" );
66         return;
67     }
68 
69     init = 1;
70 
71     fd_control = create_form_control( );
72     init_controlform( );        /* GUI  */
73     control_init( fd_control ); /* menu */
74 
75     fd_attrib = create_form_attrib( );
76     fd_generic_attrib = create_form_generic_attrib( );
77 
78     init_attribform( );
79 
80     fd_test = create_form_test( );
81     init_testform( );
82 
83     fd_align = create_form_align( );
84     init_align( );
85 
86     fd_resize = create_form_resize( );
87 
88     /* Help form */
89 
90     fd_help = create_form_helpform( );
91     init_helpform( );
92 }
93 
94 
95 /***************************************
96  * Conditionally modify the basic color of attribute form
97  ***************************************/
98 
99 void
modify_attrib_basic_color(FL_COLOR col1,FL_COLOR col2)100 modify_attrib_basic_color( FL_COLOR col1,
101                            FL_COLOR col2 )
102 {
103     fl_set_object_color( fd_generic_attrib->text[ 0 ], col1, col2 );
104     fl_set_object_color( fd_generic_attrib->text[ 1 ], col1, col2 );
105     fl_set_object_color( fd_generic_attrib->text[ 2 ], col1, col2 );
106     fl_set_object_color( fd_generic_attrib->text[ 3 ], col1, col2 );
107     fl_set_object_color( fd_generic_attrib->background, col1, col2 );
108 }
109 
110 
111 /***************************************
112  ***************************************/
113 
114 void
clearlog_cb(FL_OBJECT * ob FL_UNUSED_ARG,long data FL_UNUSED_ARG)115 clearlog_cb( FL_OBJECT * ob    FL_UNUSED_ARG,
116              long        data  FL_UNUSED_ARG )
117 {
118     fl_clear_browser( fd_test->browser );
119 }
120 
121 
122 /***************************************
123  ***************************************/
124 
125 static void
init_helpform(void)126 init_helpform( void )
127 {
128     fl_adjust_form_size( fd_help->helpform );
129     fl_set_form_position( fd_help->helpform, -1, 1 );
130 
131     /* load one help */
132 
133     fl_set_button( fd_help->vbutt, 1 );
134     fl_call_object_callback( fd_help->vbutt );
135 }
136 
137 
138 /***************************************
139  ***************************************/
140 
141 static void
init_controlform(void)142 init_controlform( void )
143 {
144     /* sort of auto-resizing depending on the font size */
145 
146     if ( fli_cntl.buttonFontSize > FL_DEFAULT_SIZE )
147     {
148         fd_align_fontsize = FL_SMALL_SIZE;
149         fd_type_fontsize = FL_SMALL_SIZE;
150     }
151 
152     if ( fd_control->objectbrowser->lsize > FL_NORMAL_SIZE )
153     {
154         fl_set_object_lsize( fd_control->objectbrowser, FL_NORMAL_SIZE );
155         fl_set_object_lsize( fd_control->formbrowser, FL_NORMAL_SIZE );
156         fl_set_object_lsize( fd_control->groupbrowser, FL_NORMAL_SIZE );
157     }
158 
159 //    fl_fit_object_label( fd_control->renameform, 1, 0 );
160 //    fl_fit_object_label( fd_control->resizeform, 1, 0 );
161     fl_fit_object_label( fd_control->objectmenu, -3, 0 );
162 }
163 
164 
165 /***************************************
166  ***************************************/
167 
168 static void
init_attribform(void)169 init_attribform( void )
170 {
171     FL_OBJECT *t;
172 
173     if ( fl_get_visual_depth( ) <= 2 )
174         modify_attrib_basic_color( FL_WHITE, FL_WHITE );
175 
176     fl_adjust_form_size( fd_attrib->attrib );
177     fl_fit_object_label( fd_attrib->readyobj, 12, 1 );
178     fd_attrib->attrib->y = 5;
179 
180     fl_set_tabfolder_autofit( fd_attrib->attrib_folder, FL_ENLARGE_ONLY );
181 
182     t = fl_addto_tabfolder( fd_attrib->attrib_folder, " Generic ",
183                             fd_generic_attrib->generic_attrib );
184     fl_set_object_shortcut( t, "#G", 1 );
185 }
186 
187 
188 /***************************************
189  ***************************************/
190 
191 static void
init_testform(void)192 init_testform( void )
193 {
194     fl_fit_object_label( fd_test->stoptesting, 2, 1 );
195     fl_set_object_dblbuffer( fd_test->browser, 1 );
196 }
197 
198 
199 #include "fd/ui_attrib.c"
200 #include "fd/ui_theforms.c"
201 
202 
203 /*
204  * Local variables:
205  * tab-width: 4
206  * indent-tabs-mode: nil
207  * End:
208  */
209