Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

loadmode.C

Go to the documentation of this file.
00001 #include "clip.h"
00002 #include "loadmode.h"
00003 #include "mwindow.h"
00004 #include "theme.h"
00005 
00006 
00007 #include <libintl.h>
00008 #define _(String) gettext(String)
00009 #define gettext_noop(String) String
00010 #define N_(String) gettext_noop (String)
00011 
00012 
00013 LoadModeItem::LoadModeItem(char *text, int value)
00014  : BC_ListBoxItem(text)
00015 {
00016         this->value = value;
00017 }
00018 
00019 
00020 LoadMode::LoadMode(MWindow *mwindow,
00021         BC_WindowBase *window, 
00022         int x, 
00023         int y, 
00024         int *output, 
00025         int use_nothing)
00026 {
00027         this->mwindow = mwindow;
00028         this->window = window;
00029         this->x = x;
00030         this->y = y;
00031         this->output = output;
00032         this->use_nothing = use_nothing;
00033         if(use_nothing) load_modes.append(new LoadModeItem(_("Insert nothing"), LOAD_NOTHING));
00034         load_modes.append(new LoadModeItem(_("Replace current project"), LOAD_REPLACE));
00035         load_modes.append(new LoadModeItem(_("Replace current project and concatenate tracks"), LOAD_REPLACE_CONCATENATE));
00036         load_modes.append(new LoadModeItem(_("Append in new tracks"), LOAD_NEW_TRACKS));
00037         load_modes.append(new LoadModeItem(_("Concatenate to existing tracks"), LOAD_CONCATENATE));
00038         load_modes.append(new LoadModeItem(_("Paste at insertion point"), LOAD_PASTE));
00039         load_modes.append(new LoadModeItem(_("Create new resources only"), LOAD_RESOURCESONLY));
00040 }
00041 
00042 LoadMode::~LoadMode()
00043 {
00044         delete title;
00045         delete textbox;
00046         delete listbox;
00047         for(int i = 0; i < load_modes.total; i++)
00048                 delete load_modes.values[i];
00049 }
00050 
00051 int LoadMode::calculate_h(BC_WindowBase *gui)
00052 {
00053         return BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1);
00054 }
00055 
00056 char* LoadMode::mode_to_text()
00057 {
00058         for(int i = 0; i < load_modes.total; i++)
00059         {
00060                 if(load_modes.values[i]->value == *output) 
00061                         return load_modes.values[i]->get_text();
00062         }
00063         return _("Unknown");
00064 }
00065 
00066 int LoadMode::create_objects()
00067 {
00068         int x = this->x, y = this->y;
00069         char *default_text;
00070         default_text = mode_to_text();
00071 
00072         window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:")));
00073         y += 20;
00074         window->add_subwindow(textbox = new BC_TextBox(x, 
00075                 y, 
00076                 mwindow->theme->loadmode_w, 
00077                 1, 
00078                 default_text));
00079         x += textbox->get_w();
00080         window->add_subwindow(listbox = new LoadModeListBox(window, this, x, y));
00081 
00082         return 0;
00083 }
00084 
00085 int LoadMode::get_h()
00086 {
00087         int result = 0;
00088         result = MAX(result, title->get_h());
00089         result = MAX(result, textbox->get_h());
00090         return result;
00091 }
00092 
00093 int LoadMode::get_x()
00094 {
00095         return x;
00096 }
00097 
00098 int LoadMode::get_y()
00099 {
00100         return y;
00101 }
00102 
00103 int LoadMode::reposition_window(int x, int y)
00104 {
00105         this->x = x;
00106         this->y = y;
00107         title->reposition_window(x, y);
00108         y += 20;
00109         textbox->reposition_window(x, y);
00110         x += textbox->get_w();
00111         listbox->reposition_window(x, 
00112                 y, 
00113                 mwindow->theme->loadmode_w);
00114         return 0;
00115 }
00116 
00117 
00118 LoadModeListBox::LoadModeListBox(BC_WindowBase *window, 
00119         LoadMode *loadmode, 
00120         int x, 
00121         int y)
00122  : BC_ListBox(x,
00123         y,
00124         loadmode->mwindow->theme->loadmode_w,
00125         150,
00126         LISTBOX_TEXT,
00127         (ArrayList<BC_ListBoxItem *>*)&loadmode->load_modes,
00128         0,
00129         0,
00130         1,
00131         0,
00132         1)
00133 {
00134         this->window = window;
00135         this->loadmode = loadmode;
00136 }
00137 
00138 LoadModeListBox::~LoadModeListBox()
00139 {
00140 }
00141 
00142 int LoadModeListBox::handle_event()
00143 {
00144         if(get_selection(0, 0) >= 0)
00145         {
00146                 loadmode->textbox->update(get_selection(0, 0)->get_text());
00147                 *(loadmode->output) = ((LoadModeItem*)get_selection(0, 0))->value;
00148         }
00149         return 1;
00150 }
00151 
00152 
00153 
00154 
00155 

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4