r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / loadmode.C
blob41599014a2268c357d1b9220e786b546b80d1714
1 #include "loadmode.h"
2 #include "mwindow.h"
3 #include "theme.h"
6 #include <libintl.h>
7 #define _(String) gettext(String)
8 #define gettext_noop(String) String
9 #define N_(String) gettext_noop (String)
12 LoadModeItem::LoadModeItem(char *text, int value)
13  : BC_ListBoxItem(text)
15         this->value = value;
19 LoadMode::LoadMode(MWindow *mwindow,
20         BC_WindowBase *window, 
21         int x, 
22         int y, 
23         int *output, 
24         int use_nothing)
26         this->mwindow = mwindow;
27         this->window = window;
28         this->x = x;
29         this->y = y;
30         this->output = output;
31         this->use_nothing = use_nothing;
32         if(use_nothing) load_modes.append(new LoadModeItem(_("Insert nothing"), LOAD_NOTHING));
33         load_modes.append(new LoadModeItem(_("Replace current project"), LOAD_REPLACE));
34         load_modes.append(new LoadModeItem(_("Replace current project and concatenate tracks"), LOAD_REPLACE_CONCATENATE));
35         load_modes.append(new LoadModeItem(_("Append in new tracks"), LOAD_NEW_TRACKS));
36         load_modes.append(new LoadModeItem(_("Concatenate to existing tracks"), LOAD_CONCATENATE));
37         load_modes.append(new LoadModeItem(_("Paste at insertion point"), LOAD_PASTE));
38         load_modes.append(new LoadModeItem(_("Create new resources only"), LOAD_RESOURCESONLY));
41 LoadMode::~LoadMode()
43         delete title;
44         delete textbox;
45         delete listbox;
46         for(int i = 0; i < load_modes.total; i++)
47                 delete load_modes.values[i];
51 char* LoadMode::mode_to_text()
53         for(int i = 0; i < load_modes.total; i++)
54         {
55                 if(load_modes.values[i]->value == *output) 
56                         return load_modes.values[i]->get_text();
57         }
58         return _("Unknown");
61 int LoadMode::create_objects()
63         int x = this->x, y = this->y;
64         char *default_text;
65         default_text = mode_to_text();
67         window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:")));
68         y += 20;
69         window->add_subwindow(textbox = new BC_TextBox(x, 
70                 y, 
71                 mwindow->theme->loadmode_w, 
72                 1, 
73                 default_text));
74         x += textbox->get_w();
75         window->add_subwindow(listbox = new LoadModeListBox(window, this, x, y));
77         return 0;
80 int LoadMode::reposition_window(int x, int y)
82         title->reposition_window(x, y);
83         y += 20;
84         textbox->reposition_window(x, y);
85         x += textbox->get_w();
86         listbox->reposition_window(x, 
87                 y, 
88                 mwindow->theme->loadmode_w);
89         return 0;
93 LoadModeListBox::LoadModeListBox(BC_WindowBase *window, 
94         LoadMode *loadmode, 
95         int x, 
96         int y)
97  : BC_ListBox(x,
98         y,
99         loadmode->mwindow->theme->loadmode_w,
100         150,
101         LISTBOX_TEXT,
102         (ArrayList<BC_ListBoxItem *>*)&loadmode->load_modes,
103         0,
104         0,
105         1,
106         0,
107         1)
109         this->window = window;
110         this->loadmode = loadmode;
113 LoadModeListBox::~LoadModeListBox()
117 int LoadModeListBox::handle_event()
119 //printf("LoadModeListBox::handle_event 1 %d\n", get_selection(0, 0));
120         if(get_selection(0, 0) >= 0)
121         {
122 //printf("LoadModeListBox::handle_event 2 %s\n", get_selection(0, 0)->get_text());
123                 loadmode->textbox->update(get_selection(0, 0)->get_text());
124                 *(loadmode->output) = ((LoadModeItem*)get_selection(0, 0))->value;
125         }
126         return 1;