+ScopeSettings::ScopeSettings(ScopeGUI *gui, int x, int y)
+ : BC_PopupMenu(x, y, xS(150), _("Settings"))
+{
+ this->gui = gui;
+ refresh_on = 0;
+ release_on = 0;
+}
+
+void ScopeSettings::create_objects()
+{
+ add_item(smooth_on =
+ new ScopeSettingOn(this, _("Smooth"), SCOPE_SMOOTH));
+ smooth_on->set_checked(gui->use_smooth);
+ if( gui->use_refresh >= 0 ) {
+ add_item(refresh_on =
+ new ScopeSettingOn(this, _("Refresh on Stop"), SCOPE_REFRESH));
+ add_item(release_on =
+ new ScopeSettingOn(this, _("Refresh on Release"), SCOPE_RELEASE));
+ refresh_on->set_checked(gui->use_refresh);
+ release_on->set_checked(gui->use_release);
+ }
+ add_item(new BC_MenuItem(_("-VectorWheel Grids-")));
+
+ gui->grat_paths.remove_all_objects();
+ ScopeGratItem *item;
+ add_item(item = new ScopeGratItem(this, _("None"), 0));
+ if( item->idx == gui->grat_idx ) item->set_checked(1);
+ gui->grat_paths.append(0);
+ FileSystem fs;
+ fs.set_filter("[*.png]");
+ char scope_path[BCTEXTLEN];
+ sprintf(scope_path, "%s%s", File::get_plugin_path(), SCOPE_SEARCHPATH);
+ fs.update(scope_path);
+ for( int i=0; i<fs.total_files(); ++i ) {
+ FileItem *file_item = fs.get_entry(i);
+ if( file_item->get_is_dir() ) continue;
+ strcpy(scope_path, file_item->get_name());
+ char *cp = strrchr(scope_path, '.');
+ if( cp ) *cp = 0;
+ add_item(item = new ScopeGratItem(this, scope_path, gui->grat_paths.size()));
+ if( item->idx == gui->grat_idx ) item->set_checked(1);
+ gui->grat_paths.append(cstrdup(file_item->get_path()));
+ }
+}
+
+void ScopeSettings::update_toggles()
+{
+ if( refresh_on )
+ refresh_on->set_checked(gui->use_refresh);
+ if( release_on )
+ release_on->set_checked(gui->use_release);
+}
+
+ScopeGratItem::ScopeGratItem(ScopeSettings *settings, const char *text, int idx)
+ : BC_MenuItem(text)
+{
+ this->settings = settings;
+ this->idx = idx;
+}
+
+int ScopeGratItem::handle_event()
+{
+ for( int i=0,n=settings->total_items(); i<n; ++i ) {
+ ScopeGratItem *item = (ScopeGratItem *)settings->get_item(i);
+ item->set_checked(item->idx == idx);
+ }
+ settings->gui->update_graticule(idx);
+ return 1;
+}
+
+
+ScopeGainReset::ScopeGainReset(ScopeGain *gain, int x, int y)
+ : BC_Button(x, y, gain->gui->theme->get_image_set("reset_button"))
+{
+ this->gain = gain;
+}
+
+int ScopeGainReset::calculate_w(BC_Theme *theme)
+{
+ VFrame *vfrm = *theme->get_image_set("reset_button");
+ return vfrm->get_w();
+}
+
+int ScopeGainReset::handle_event()
+{
+ gain->slider->update(5);
+ return gain->handle_event();
+}
+
+ScopeGainSlider::ScopeGainSlider(ScopeGain *gain, int x, int y, int w)
+ : BC_ISlider(x, y, 0, w, w, 1, 9, *gain->value)
+{
+ this->gain = gain;
+}
+
+int ScopeGainSlider::handle_event()
+{
+ return gain->handle_event();
+}
+
+ScopeGain::ScopeGain(ScopeGUI *gui, int x, int y, int w, int *value)
+{
+ this->gui = gui;
+ this->x = x;
+ this->y = y;
+ this->w = w;
+ this->value = value;
+
+ slider = 0;
+ reset = 0;
+}
+ScopeGain::~ScopeGain()
+{
+ delete reset;
+ delete slider;
+}
+
+int ScopeGain::calculate_h()
+{
+ return BC_ISlider::get_span(0);
+}
+
+void ScopeGain::create_objects()
+{
+ reset_w = ScopeGainReset::calculate_w(gui->theme);
+ gui->add_subwindow(slider = new ScopeGainSlider(this, x, y, w-reset_w-xS(5)));
+ gui->add_subwindow(reset = new ScopeGainReset(this, x+w-reset_w, y));
+}
+
+int ScopeGain::handle_event()
+{
+ *value = slider->get_value();
+ gui->update_scope();
+ gui->toggle_event();
+ return 1;
+}
+
+void ScopeGain::reposition_window(int x, int y)
+{
+ this->x = x; this->y = y;
+ slider->reposition_window(x, y);
+ reset->reposition_window(x+w-reset_w, y);
+}
+
+ScopeWaveSlider::ScopeWaveSlider(ScopeGUI *gui, int x, int y, int w)
+ : ScopeGain(gui, x, y, w, &gui->use_wave_gain)
+{
+}
+
+ScopeVectSlider::ScopeVectSlider(ScopeGUI *gui, int x, int y, int w)
+ : ScopeGain(gui, x, y, w, &gui->use_vect_gain)
+{
+}
+