4 * Copyright (C) 2009 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
29 static const char *mode_images[] =
40 static const char *tooltips[] =
43 "Replace current project",
44 "Replace current project and concatenate tracks",
45 "Append in new tracks",
46 "Concatenate to existing tracks",
47 "Paste at insertion point",
48 "Create new resources only",
55 LoadMode::LoadMode(MWindow *mwindow,
56 BC_WindowBase *window,
63 this->mwindow = mwindow;
64 this->window = window;
67 this->output = output;
68 this->use_nothing = use_nothing;
69 this->use_nested = use_nested;
70 for(int i = 0; i < TOTAL_LOADMODES; i++)
77 for(int i = 0; i < TOTAL_LOADMODES; i++)
78 if(mode[i]) delete mode[i];
81 int LoadMode::calculate_h(BC_WindowBase *gui, Theme *theme)
92 BC_Toggle::calculate_extents(gui,
93 theme->get_image_set(mode_images[0]),
108 int LoadMode::calculate_w(BC_WindowBase *gui,
113 int total = gui->get_text_width(MEDIUMFONT, _("Insertion strategy:")) + 10;
114 for(int i = 0; i < TOTAL_LOADMODES; i++)
116 if((i != LOADMODE_NOTHING || use_none) &&
117 (i != LOADMODE_NESTED || use_nested))
128 BC_Toggle::calculate_extents(gui,
129 theme->get_image_set(mode_images[i]),
147 int LoadMode::get_h()
150 result = MAX(result, title->get_h());
151 result = MAX(result, mode[1]->get_h());
155 void LoadMode::create_objects()
157 int x = this->x, y = this->y;
159 window->add_subwindow(title = new BC_Title(x, y, _("Insertion strategy:")));
160 x += title->get_w() + 10;
162 for(int i = 0; i < TOTAL_LOADMODES; i++)
164 if((i != LOADMODE_NOTHING || use_nothing) &&
165 (i != LOADMODE_NESTED || use_nested))
167 VFrame **images = mwindow->theme->get_image_set(mode_images[i]);
168 if(x + images[0]->get_w() > window->get_w())
171 y += images[0]->get_h() + 5;
173 window->add_subwindow(mode[i] = new LoadModeToggle(x,
179 x += mode[i]->get_w() + 10;
186 int LoadMode::get_x()
191 int LoadMode::get_y()
196 int LoadMode::reposition_window(int x, int y)
200 title->reposition_window(x, y);
201 x += title->get_w() + 10;
203 for(int i = 0; i < TOTAL_LOADMODES; i++)
207 VFrame **images = mwindow->theme->get_image_set(mode_images[i]);
208 if(x + images[0]->get_w() > window->get_w())
211 y += images[0]->get_h() + 5;
213 mode[i]->reposition_window(x, y);
214 x += mode[i]->get_w() + 10;
221 void LoadMode::update()
223 for(int i = 0; i < TOTAL_LOADMODES; i++)
227 mode[i]->set_value(*output == i);
239 LoadModeToggle::LoadModeToggle(int x,
247 window->mwindow->theme->get_image_set(images),
248 *window->output == value)
250 this->window = window;
252 set_tooltip(_(tooltip));
255 int LoadModeToggle::handle_event()
257 *window->output = value;