609791302289ecf980b8842df0991a5e8b76b3b2
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bctoggle.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCTOGGLE_H
23 #define BCTOGGLE_H
24
25 #include "bcbitmap.inc"
26 #include "bcsubwindow.h"
27 #include "bccolors.h"
28 #include "fonts.h"
29 #include "vframe.inc"
30
31
32 class BC_Toggle : public BC_SubWindow
33 {
34 public:
35         BC_Toggle(int x, int y,
36                 VFrame **data,
37                 int value,
38                 const char *caption = "",
39                 int bottom_justify = 0,
40                 int font = MEDIUMFONT,
41                 int color = -1);
42         virtual ~BC_Toggle();
43
44         virtual int handle_event() { return 0; };
45         int get_value();
46         void set_radial(int value);
47         int set_value(int value, int draw = 1);
48         void set_select_drag(int value);
49         int update(int value, int draw = 1);
50         void reposition_window(int x, int y);
51         void enable();
52         void disable();
53         void set_status(int value);
54         static void calculate_extents(BC_WindowBase *gui,
55                 VFrame **images,
56                 int bottom_justify,
57                 int *text_line,
58                 int *w,
59                 int *h,
60                 int *toggle_x,
61                 int *toggle_y,
62                 int *text_x,
63                 int *text_y,
64                 int *text_w,
65                 int *text_h,
66                 const char *caption,
67                 int font);
68
69         int initialize();
70         int set_images(VFrame **data);
71         void set_underline(int number);
72         int cursor_enter_event();
73         int cursor_leave_event();
74 // In select drag mode these 3 need to be overridden and called back to.
75         virtual int button_press_event();
76         virtual int button_release_event();
77         int cursor_motion_event();
78         int repeat_event(int64_t repeat_id);
79         virtual int draw_face(int flash, int flush /* = 1 */);
80
81         enum
82         {
83                 TOGGLE_UP,
84                 TOGGLE_UPHI,
85                 TOGGLE_CHECKED,
86                 TOGGLE_DOWN,
87                 TOGGLE_CHECKEDHI,
88                 TOGGLE_IMAGES
89         };
90
91         int has_caption();
92
93         BC_Pixmap *images[TOGGLE_IMAGES];
94         BC_Pixmap *bg_image;
95         VFrame **data;
96         char caption[BCTEXTLEN];
97         int status;
98         int value;
99         int toggle_x;
100         int toggle_y;
101 // Start of text background
102         int text_x;
103 // Start of text
104         int text_text_x;
105         int text_y;
106 // Width of text background
107         int text_w;
108         int text_h;
109         int text_line;
110         int bottom_justify;
111         int font;
112         int color;
113         int select_drag;
114         int enabled;
115         int underline;
116         int is_radial;
117 };
118
119 class BC_Radial : public BC_Toggle
120 {
121 public:
122         BC_Radial(int x,
123                 int y,
124                 int value,
125                 const char *caption = "",
126                 int font = MEDIUMFONT,
127                 int color = -1);
128 };
129
130 class BC_CheckBox : public BC_Toggle
131 {
132 public:
133         BC_CheckBox(int x,
134                 int y,
135                 int value,
136                 const char *caption = "",
137                 int font = MEDIUMFONT,
138                 int color = -1);
139         BC_CheckBox(int x,
140                 int y,
141                 int *value,
142                 const char *caption = "",
143                 int font = MEDIUMFONT,
144                 int color = -1);
145         virtual int handle_event();
146         static int calculate_h(BC_WindowBase *gui, int font=MEDIUMFONT);
147
148         static void calculate_extents(BC_WindowBase *gui, int *w, int *h,
149                 const char *caption="", int font=MEDIUMFONT);
150         int *value;
151 };
152
153 class BC_Label : public BC_Toggle
154 {
155 public:
156         BC_Label(int x,
157                 int y,
158                 int value,
159                 int font = MEDIUMFONT,
160                 int color = -1);
161 };
162
163 #endif