165e7d7a58e9edead930ae34e2cd42006d682245
[goodguy/history.git] / cinelerra-5.1 / guicast / bctheme.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 BCTHEME_H
23 #define BCTHEME_H
24
25 #include "arraylist.h"
26 #include "bcresources.inc"
27 #include "bcwindowbase.inc"
28 #include "vframe.inc"
29 #include <stdarg.h>
30
31 class BC_ThemeSet;
32
33
34
35
36 class BC_Theme
37 {
38 public:
39         BC_Theme();
40         virtual ~BC_Theme();
41
42 // Set pointer to binary object containing images and contents.
43 // Immediately loads the contents from the object.
44         void set_data(unsigned char *ptr);
45
46 // Compose widgets using standard images.
47 // The arguments are copied into new VFrames for a new image set.
48 // The image set is put in the image table only if the title is nonzero.
49         VFrame** new_button(const char *overlay_path,
50                 const char *up_path,
51                 const char *hi_path,
52                 const char *dn_path,
53                 const char *title);
54         VFrame** new_button4(const char *overlay_path,
55                 const char *up_path,
56                 const char *hi_path,
57                 const char *dn_path,
58                 const char *disabled_path,
59                 const char *title);
60         VFrame** new_button(const char *overlay_path,
61                 VFrame *up,
62                 VFrame *hi,
63                 VFrame *dn,
64                 const char *title);
65         VFrame** new_toggle(const char *overlay_path,
66                 const char *up_path,
67                 const char *hi_path,
68                 const char *checked_path,
69                 const char *dn_path,
70                 const char *checkedhi_path,
71                 const char *title);
72         VFrame** new_toggle(const char *overlay_path,
73                 VFrame *up,
74                 VFrame *hi,
75                 VFrame *checked,
76                 VFrame *dn,
77                 VFrame *checkedhi,
78                 const char *title);
79
80
81 // The two main routines for creating images are new_image_set and new_image.
82 // If the title already exists in the table, the existing entry is returned.
83 // These create image sets which are stored in the set table.
84 // Takes comma delimited char* pointers to filenames.
85         VFrame** new_image_set(const char *title, int total, va_list *args);
86         VFrame** new_image_set(const char *title, int total, ...);
87         VFrame** new_image_set(int total, ...);
88 // Creates an image set from VFrame pointers.
89 // The images are considered not references and deleted with the image set.
90 // If the title already exists, the existing entry is deleted and overridden.
91         VFrame** new_image_set_images(const char *title, int total, ...);
92
93 // Decompresses image and puts on images table before returning it.
94         VFrame* new_image(const char *title, const char *path);
95         VFrame* new_image(const char *path);
96
97
98 // These retrieve images based on case sensitive title
99         VFrame* get_image(const char *title, int use_default = 1);
100         VFrame** get_image_set(const char *title, int use_default = 1);
101         BC_ThemeSet* get_image_set_object(const char *title);
102
103 // Loads compressed data into temporary
104         unsigned char* get_image_data(const char *title);
105
106 // Verify all images have been used after initialization.
107         void check_used();
108
109         void dump();
110         BC_Resources* get_resources();
111
112 private:
113         void overlay(VFrame *dst, VFrame *src, int in_x1 = -1, int in_x2 = -1, int shift = 0);
114         void init_contents();
115
116
117
118 // Decompressed image storage.
119 // Sets of images.
120         ArrayList<BC_ThemeSet*> image_sets;
121
122 // Compressed images are loaded in here.
123         class image_item {
124         public:
125                 char *name;
126                 unsigned char *data;
127                 int used;
128
129                 image_item(char *nm, unsigned char *dp) {
130                         name = nm;  data = dp;  used = 0;
131                 }
132         } *last_image;
133         int images_dirty;
134         ArrayList<image_item *> images;
135
136         static int images_cmpr(const void *ap, const void *bp);
137 };
138
139 class BC_ThemeSet
140 {
141 public:
142 // Set is_reference if the images are going to be created by new_image
143         BC_ThemeSet(int total, int is_reference, const char *title);
144         ~BC_ThemeSet();
145
146         VFrame **data;
147         char *title;
148         int total;
149         int is_reference;
150 };
151
152
153
154 #endif