popup menu mods/pref, pactl fix
[goodguy/history.git] / cinelerra-5.1 / guicast / bcresources.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 BCRESOURCES_H
23 #define BCRESOURCES_H
24
25
26
27 // Global objects for the user interface
28
29
30
31
32 #include "bcdisplayinfo.inc"
33 #include "bcfilebox.h"
34 #include "bcfontentry.inc"
35 #include "bcresources.inc"
36 #include "bcsignals.inc"
37 #include "bcsynchronous.inc"
38 #include "bcwindowbase.inc"
39 #include "vframe.inc"
40
41 #include <X11/Xlib.h>
42
43 typedef struct
44 {
45         const char *suffix;
46         int icon_type;
47 } suffix_to_type_t;
48
49 typedef struct
50 {
51         char path[BCTEXTLEN];
52         int id;
53 } filebox_history_t;
54
55 class BC_Resources
56 {
57 public:
58         BC_Resources(); // The window parameter is used to get the display information initially
59         ~BC_Resources();
60
61         friend class BC_WindowBase;
62
63         int initialize_display(BC_WindowBase *window);
64
65 // Get unique ID
66         int get_id();
67 // Get ID for filebox history.  Persistent.
68         int get_filebox_id();
69         int get_bg_color();          // window backgrounds
70         int get_bg_shadow1();        // border for windows
71         int get_bg_shadow2();
72         int get_bg_light1();
73         int get_bg_light2();
74 // Get synchronous thread for OpenGL
75         BC_Synchronous* get_synchronous();
76 // Called by user after synchronous thread is created.
77         void set_synchronous(BC_Synchronous *synchronous);
78 // Set signal handler
79         static void set_signals(BC_Signals *signal_handler);
80         static BC_Signals* get_signals();
81
82
83 // These values should be changed before the first window is created.
84 // colors
85         int bg_color;          // window backgrounds
86         int border_light1;
87         int border_light2;
88         int border_shadow1;
89         int border_shadow2;
90
91         int bg_shadow1;        // border for windows
92         int bg_shadow2;
93         int bg_light1;
94         int bg_light2;
95         int default_text_color;
96         int disabled_text_color;
97
98
99 // beveled box colors
100         int button_light;
101         int button_highlighted;
102         int button_down;
103         int button_up;
104         int button_shadow;
105         int button_uphighlighted;
106
107 // highlighting
108         int highlight_inverse;
109
110 // 3D box colors for menus
111         int menu_light;
112         int menu_highlighted;
113         int menu_down;
114         int menu_up;
115         int menu_shadow;
116 // If these are nonzero, they override the menu backgrounds.
117         VFrame *menu_popup_bg;
118         VFrame **menu_title_bg;
119         VFrame *menu_bar_bg;
120         VFrame **popupmenu_images;
121
122 // Minimum menu width
123         int min_menu_w;
124 // Menu bar text color
125         int menu_title_text;
126 // color of popup title
127         int popup_title_text;
128 // Right and left margin for text not including triangle space.
129         int popupmenu_margin;
130 // post popup on button release event
131         int popupmenu_btnup;
132 // Right margin for triangle not including text margin.
133         int popupmenu_triangle_margin;
134 // color for item text
135         int menu_item_text;
136 // Override the menu item background if nonzero.
137         VFrame **menu_item_bg;
138
139
140 // color for progress text
141         int progress_text;
142
143
144         int menu_highlighted_fontcolor;
145
146 // ms for double click
147         long double_click;
148 // ms for cursor flash
149         int blink_rate;
150 // ms for scroll repeats
151         int scroll_repeat;
152 // ms before tooltip
153         int tooltip_delay;
154         int tooltip_bg_color;
155         int tooltips_enabled;
156
157         int audiovideo_color;
158
159 // default color of text
160         int text_default;
161 // background color of textboxes and list boxes
162         int text_border1;
163         int text_border2;
164         int text_border2_hi;
165         int text_background;
166         int text_background_hi;
167         int text_background_noborder_hi;
168         int text_border3;
169         int text_border3_hi;
170         int text_border4;
171         int text_highlight;
172         int text_inactive_highlight;
173 // Not used
174         int text_background_noborder;
175
176 // Optional background for highlighted text in toggle
177         VFrame *toggle_highlight_bg;
178         int toggle_text_margin;
179
180 // Background images
181         static VFrame *bg_image;
182         static VFrame *menu_bg;
183
184 // Buttons
185         VFrame **ok_images;
186         VFrame **cancel_images;
187         VFrame **filebox_text_images;
188         VFrame **filebox_icons_images;
189         VFrame **filebox_updir_images;
190         VFrame **filebox_newfolder_images;
191         VFrame **filebox_rename_images;
192         VFrame **filebox_descend_images;
193         VFrame **filebox_delete_images;
194         VFrame **filebox_reload_images;
195
196 // Generic button images
197         VFrame **generic_button_images;
198 // Generic button text margin
199         int generic_button_margin;
200         VFrame **usethis_button_images;
201
202 // Toggles
203         VFrame **checkbox_images;
204         VFrame **radial_images;
205         VFrame **label_images;
206 // menu check
207         VFrame *check;
208
209         VFrame **tumble_data;
210         int tumble_duration;
211
212 // Horizontal bar
213         VFrame *bar_data;
214
215 // Listbox
216         VFrame *listbox_bg;
217         VFrame **listbox_button;
218         VFrame **listbox_expand;
219         VFrame **listbox_column;
220         VFrame *listbox_up;
221         VFrame *listbox_dn;
222         int listbox_title_overlap;
223 // Margin for titles in addition to listbox border
224         int listbox_title_margin;
225         int listbox_title_color;
226         int listbox_title_hotspot;
227         int listbox_border1;
228         int listbox_border2_hi;
229         int listbox_border2;
230         int listbox_border3_hi;
231         int listbox_border3;
232         int listbox_border4;
233 // Selected row color
234         int listbox_selected;
235 // Highlighted row color
236         int listbox_highlighted;
237 // Inactive row color
238         int listbox_inactive;
239 // Default text color
240         int listbox_text;
241
242
243 // Sliders
244         VFrame **horizontal_slider_data;
245         VFrame **vertical_slider_data;
246         VFrame **hscroll_data;
247
248         VFrame **vscroll_data;
249 // Minimum pixels in handle
250         int scroll_minhandle;
251
252 // Pans
253         VFrame **pan_data;
254         int pan_text_color;
255
256 // Pots
257         VFrame **pot_images;
258         int pot_x1, pot_y1, pot_r;
259 // Amount of deflection of pot when down
260         int pot_offset;
261         int pot_needle_color;
262
263 // Meters
264         VFrame **xmeter_images, **ymeter_images;
265         int meter_font;
266         int meter_font_color;
267         int meter_title_w;
268         int meter_3d;
269
270 // Progress bar
271         VFrame **progress_images;
272
273 // Motion required to start a drag
274         int drag_radius;
275
276 // Filebox
277         static suffix_to_type_t suffix_to_type[TOTAL_SUFFIXES];
278         VFrame **type_to_icon;
279 // Display mode for fileboxes
280         int filebox_mode;
281 // Filter currently used in filebox
282         char filebox_filter[BCTEXTLEN];
283 // History of submitted files
284         filebox_history_t filebox_history[FILEBOX_HISTORY_SIZE];
285 // filebox size
286         int filebox_w;
287         int filebox_h;
288 // Column types for filebox
289         int filebox_columntype[FILEBOX_COLUMNS];
290         int filebox_columnwidth[FILEBOX_COLUMNS];
291         int filebox_sortcolumn;
292         int filebox_sortorder;
293 // Column types for filebox in directory mode
294         int dirbox_columntype[FILEBOX_COLUMNS];
295         int dirbox_columnwidth[FILEBOX_COLUMNS];
296         int dirbox_sortcolumn;
297         int dirbox_sortorder;
298 // Bottom margin between list and window
299         int filebox_margin;
300         int dirbox_margin;
301         int directory_color;
302         int file_color;
303         double font_scale, icon_scale;
304
305 // fonts
306         static const char *small_font;
307         static const char *medium_font;
308         static const char *large_font;
309         static const char *big_font;
310 // Backup of fonts in case the first choices don't exist
311         static const char *small_font2;
312         static const char *medium_font2;
313         static const char *large_font2;
314         static const char *big_font2;
315
316         static const char *small_fontset;
317         static const char *medium_fontset;
318         static const char *large_fontset;
319         static const char *big_fontset;
320
321         static const char *small_font_xft, *small_b_font_xft;
322         static const char *medium_font_xft, *medium_b_font_xft;
323         static const char *large_font_xft, *large_b_font_xft;
324         static const char *big_font_xft, *big_b_font_xft;
325
326 // Backup of fonts in case the first choices don't exist
327         static const char *small_font_xft2;
328         static const char *medium_font_xft2;
329         static const char *large_font_xft2;
330         static const char *big_font_xft2;
331         void init_font_defs(double scale);
332
333         VFrame **medium_7segment;
334
335 //clock
336         int draw_clock_background;
337
338         int use_fontset;
339         int use_xft;
340
341 // Current locale uses utf8
342         static int locale_utf8;
343 // Byte order is little_endian
344         static int little_endian;
345 // Language and region
346         static char language[LEN_LANG];
347         static char region[LEN_LANG];
348         static char encoding[LEN_ENCOD];
349         static const char *wide_encoding;
350         static ArrayList<BC_FontEntry*> *fontlist;
351         static int init_fontconfig(const char *search_path);
352         static BC_FontEntry *find_fontentry(const char *displayname, int style,
353                 int mask, int preferred_style = 0);
354         static void encode_to_utf8(char *buffer, int buflen);
355         static FcPattern* find_similar_font(FT_ULong char_code, FcPattern *oldfont);
356         static size_t encode(const char *from_enc, const char *to_enc,
357                 char *input, int input_length, char *output, int output_length);
358         static int find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface);
359         static void dump_fonts(FILE *fp = stdout);
360
361 // Make VFrame use shm
362         int vframe_shm;
363         int use_vframe_shm() { return use_shm && vframe_shm ? 1 : 0; }
364
365         static int get_machine_cpus();
366         static int machine_cpus;
367 // Available display extensions
368         int use_shm;
369         int shm_reply;
370         static int error;
371 // If the program uses recursive_resizing
372         int recursive_resizing;
373 // Work around X server bugs
374         int use_xvideo;
375 // Seems to help if only 1 window is created at a time.
376         Mutex *create_window_lock;
377
378 private:
379 // Test for availability of shared memory pixmaps
380         void init_shm(BC_WindowBase *window);
381         void init_sizes(BC_WindowBase *window);
382         static int x_error_handler(Display *display, XErrorEvent *event);
383         VFrame **list_pointers[100];
384         int list_lengths[100];
385         int list_total;
386         static const char *fc_properties[];
387
388
389         Mutex *id_lock;
390         static Mutex fontconfig_lock;
391
392 // Pointer to signal handler class to run after ipc
393         static BC_Signals *signal_handler;
394         BC_Synchronous *synchronous;
395
396         int id;
397         int filebox_id;
398 };
399
400
401 #endif