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  * Inverted slider
23  *
24  * T.C. Zhao and M. Overmars
25  */
26 
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30 
31 #include "include/forms.h"
32 #include <stdlib.h>
33 
34 typedef struct {
35     FL_FORM   * inv;
36     void      * vdata;
37     char      * cdata;
38     long        ldata;
39     FL_OBJECT * sl[ 3 ];
40     FL_OBJECT * done;
41 } FD_inv;
42 
43 FD_inv *ui;
44 
45 static FD_inv *create_form_inv( void );
46 
47 
48 /***************************************
49  ***************************************/
50 
51 static void
invert_it(FL_OBJECT * ob,long data FL_UNUSED_ARG)52 invert_it( FL_OBJECT * ob,
53            long        data  FL_UNUSED_ARG )
54 {
55    if ( fl_get_button( ob ) )
56    {
57        fl_set_slider_bounds( ui->sl[ 0 ], 1.0, 0.0 );
58        fl_set_slider_bounds( ui->sl[ 1 ], 1.0, 0.0 );
59        fl_set_slider_bounds( ui->sl[ 2 ], 1.0, 0.0 );
60    }
61    else
62    {
63        fl_set_slider_bounds( ui->sl[ 0 ], 0.0, 1.0 );
64        fl_set_slider_bounds( ui->sl[ 1 ], 0.0, 1.0 );
65        fl_set_slider_bounds( ui->sl[ 2 ], 0.0, 1.0 );
66    }
67 }
68 
69 
70 /***************************************
71  ***************************************/
72 
73 int
main(int argc,char * argv[])74 main( int    argc,
75       char * argv[ ] )
76 {
77     fl_initialize( &argc, argv, "FormDemo", 0, 0 );
78     ui = create_form_inv( );
79 
80     fl_show_form( ui->inv, FL_PLACE_CENTER | FL_FREE_SIZE, FL_TRANSIENT,
81                   "inv" );
82 
83     while ( fl_do_forms( ) != ui->done )
84         /* empty */ ;
85 
86     fl_finish( );
87     fl_free( ui );
88     return 0;
89 }
90 
91 
92 /***************************************
93  ***************************************/
94 
95 static FD_inv *
create_form_inv(void)96 create_form_inv( void )
97 {
98     FL_OBJECT *obj;
99     FD_inv *fdui = fl_calloc( 1, sizeof *fdui );
100 
101     fdui->inv = fl_bgn_form(FL_NO_BOX, 245, 280);
102 
103     fl_add_box(FL_UP_BOX,0,0,245,280,"");
104 
105     fdui->sl[ 0 ] = fl_add_valslider( FL_VERT_SLIDER, 20, 30, 35, 230, "" );
106 
107     fdui->sl[ 1 ] = fl_add_valslider( FL_VERT_FILL_SLIDER, 65, 30, 35, 230,
108                                       "" );
109 
110     fdui->sl[ 2 ] = obj = fl_add_valslider( FL_VERT_NICE_SLIDER,
111                                             115, 30, 35, 230,
112                                           "" );
113     fl_set_object_boxtype( obj, FL_FLAT_BOX );
114     fl_set_object_color( obj, FL_COL1, FL_BLUE );
115 
116     fdui->done = fl_add_button( FL_RETURN_BUTTON, 160, 235, 75, 30, "Exit" );
117 
118     obj = fl_add_checkbutton( FL_PUSH_BUTTON, 165, 30, 75, 35, "Invert" );
119     fl_set_object_callback( obj, invert_it, 0 );
120 
121     fl_end_form( );
122 
123     return fdui;
124 }
125 
126 
127 /*
128  * Local variables:
129  * tab-width: 4
130  * indent-tabs-mode: nil
131  * End:
132  */
133