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