license header for review
[cinelerra_cv/ct.git] / cinelerra / loadmode.C
blob05952ae29f4df113046e4c4f15da3ada229c2c11
1 #include "clip.h"
2 #include "loadmode.h"
3 #include "mwindow.h"
4 #include "theme.h"
7 #include <libintl.h>
8 #define _(String) gettext(String)
9 #define gettext_noop(String) String
10 #define N_(String) gettext_noop (String)
13 LoadModeItem::LoadModeItem(char *text, int value)
14  : BC_ListBoxItem(text)
16         this->value = value;
20 LoadMode::LoadMode(MWindow *mwindow,
21         BC_WindowBase *window, 
22         int x, 
23         int y, 
24         int *output, 
25         int use_nothing)
27         this->mwindow = mwindow;
28         this->window = window;
29         this->x = x;
30         this->y = y;
31         this->output = output;
32         this->use_nothing = use_nothing;
33         if(use_nothing) load_modes.append(new LoadModeItem(_("Insert nothing"), LOAD_NOTHING));
34         load_modes.append(new LoadModeItem(_("Replace current project"), LOAD_REPLACE));
35         load_modes.append(new LoadModeItem(_("Replace current project and concatenate tracks"), LOAD_REPLACE_CONCATENATE));
36         load_modes.append(new LoadModeItem(_("Append in new tracks"), LOAD_NEW_TRACKS));
37         load_modes.append(new LoadModeItem(_("Concatenate to existing tracks"), LOAD_CONCATENATE));
38         load_modes.append(new LoadModeItem(_("Paste at insertion point"), LOAD_PASTE));
39         load_modes.append(new LoadModeItem(_("Create new resources only"), LOAD_RESOURCESONLY));
42 LoadMode::~LoadMode()
44         delete title;
45         delete textbox;
46         delete listbox;
47         for(int i = 0; i < load_modes.total; i++)
48                 delete load_modes.values[i];
51 int LoadMode::calculate_h(BC_WindowBase *gui)
53         return BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1);
56 char* LoadMode::mode_to_text()
58         for(int i = 0; i < load_modes.total; i++)
59         {
60                 if(load_modes.values[i]->value == *output) 
61                         return load_modes.values[i]->get_text();
62         }
63         return _("Unknown");
66 int LoadMode::create_objects()
68         int x = this->x, y = this->y;
69         char *default_text;
70         default_text = mode_to_text();
72         window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:")));
73         y += 20;
74         window->add_subwindow(textbox = new BC_TextBox(x, 
75                 y, 
76                 mwindow->theme->loadmode_w, 
77                 1, 
78                 default_text));
79         x += textbox->get_w();
80         window->add_subwindow(listbox = new LoadModeListBox(window, this, x, y));
82         return 0;
85 int LoadMode::get_h()
87         int result = 0;
88         result = MAX(result, title->get_h());
89         result = MAX(result, textbox->get_h());
90         return result;
93 int LoadMode::get_x()
95         return x;
98 int LoadMode::get_y()
100         return y;
103 int LoadMode::reposition_window(int x, int y)
105         this->x = x;
106         this->y = y;
107         title->reposition_window(x, y);
108         y += 20;
109         textbox->reposition_window(x, y);
110         x += textbox->get_w();
111         listbox->reposition_window(x, 
112                 y, 
113                 mwindow->theme->loadmode_w);
114         return 0;
118 LoadModeListBox::LoadModeListBox(BC_WindowBase *window, 
119         LoadMode *loadmode, 
120         int x, 
121         int y)
122  : BC_ListBox(x,
123         y,
124         loadmode->mwindow->theme->loadmode_w,
125         150,
126         LISTBOX_TEXT,
127         (ArrayList<BC_ListBoxItem *>*)&loadmode->load_modes,
128         0,
129         0,
130         1,
131         0,
132         1)
134         this->window = window;
135         this->loadmode = loadmode;
138 LoadModeListBox::~LoadModeListBox()
142 int LoadModeListBox::handle_event()
144         if(get_selection(0, 0) >= 0)
145         {
146                 loadmode->textbox->update(get_selection(0, 0)->get_text());
147                 *(loadmode->output) = ((LoadModeItem*)get_selection(0, 0))->value;
148         }
149         return 1;
157 //      Local Variables:
158 //      mode: C++
159 //      c-file-style: "linux"
160 //      End: