4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
30 static const char *mode_text[] =
33 N_("Replace current project"),
34 N_("Replace current project and concatenate tracks"),
35 N_("Append in new tracks"),
36 N_("Concatenate to existing tracks"),
37 N_("Paste at insertion point"),
38 N_("Create new resources only"),
43 LoadModeItem::LoadModeItem(const char *text, int value)
44 : BC_ListBoxItem(text)
50 LoadMode::LoadMode(MWindow *mwindow, BC_WindowBase *window,
51 int x, int y, int *output, int use_nothing)
53 this->mwindow = mwindow;
54 this->window = window;
57 this->output = output;
58 this->use_nothing = use_nothing;
59 int mode = LOADMODE_NOTHING;
61 load_modes.append(new LoadModeItem(_(mode_text[mode]), mode));
62 while( ++mode < TOTAL_LOADMODES )
63 load_modes.append(new LoadModeItem(_(mode_text[mode]), mode));
71 for(int i = 0; i < load_modes.total; i++)
72 delete load_modes.values[i];
75 int LoadMode::calculate_w(BC_WindowBase *gui, Theme *theme)
77 return theme->loadmode_w + 24;
80 int LoadMode::calculate_h(BC_WindowBase *gui, Theme *theme)
82 return BC_Title::calculate_h(gui, _("Insertion strategy:"), MEDIUMFONT) +
83 BC_TextBox::calculate_h(gui, MEDIUMFONT, 1, 1);
86 char* LoadMode::mode_to_text()
88 for(int i = 0; i < load_modes.total; i++)
90 if(load_modes.values[i]->value == *output)
91 return load_modes.values[i]->get_text();
96 int LoadMode::create_objects()
98 int x = this->x, y = this->y;
100 default_text = mode_to_text();
102 window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:")));
104 window->add_subwindow(textbox = new BC_TextBox(x, y,
105 mwindow->theme->loadmode_w, 1, default_text));
106 x += textbox->get_w();
107 window->add_subwindow(listbox = new LoadModeListBox(window, this, x, y));
112 int LoadMode::get_h()
115 result = MAX(result, title->get_h());
116 result = MAX(result, textbox->get_h());
120 int LoadMode::get_x()
125 int LoadMode::get_y()
130 int LoadMode::reposition_window(int x, int y)
134 title->reposition_window(x, y);
136 textbox->reposition_window(x, y);
137 x += textbox->get_w();
138 listbox->reposition_window(x,
140 mwindow->theme->loadmode_w);
145 LoadModeListBox::LoadModeListBox(BC_WindowBase *window,
151 loadmode->mwindow->theme->loadmode_w,
154 (ArrayList<BC_ListBoxItem *>*)&loadmode->load_modes,
161 this->window = window;
162 this->loadmode = loadmode;
165 LoadModeListBox::~LoadModeListBox()
169 int LoadModeListBox::handle_event()
171 if(get_selection(0, 0) >= 0)
173 loadmode->textbox->update(get_selection(0, 0)->get_text());
174 *(loadmode->output) = ((LoadModeItem*)get_selection(0, 0))->value;