/[svn]/gigedit/trunk/src/gigedit/paramedit.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/paramedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1582 by persson, Sat Dec 8 12:28:53 2007 UTC revision 2446 by persson, Sun Apr 28 15:40:43 2013 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2013 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
20    #include <cstring>
21    
22  #include "paramedit.h"  #include "paramedit.h"
23    
24    #include "global.h"
25    #include "compat.h"
26    
27    std::string gig_encoding("CP1252");
28    
29    Glib::ustring gig_to_utf8(const gig::String& gig_string) {
30        return Glib::convert_with_fallback(gig_string, "UTF-8", gig_encoding, "?");
31    }
32    
33    gig::String gig_from_utf8(const Glib::ustring& utf8_string) {
34        return Glib::convert_with_fallback(utf8_string, gig_encoding, "UTF-8", "?");
35    }
36    
37    
38  namespace {  namespace {
39      const char* const controlChangeTexts[] = {      const char* const controlChangeTexts[] = {
40          "none", "channelaftertouch", "velocity",          _("none"), _("channelaftertouch"), _("velocity"),
41          0,          0,
42          "modwheel", // "Modulation Wheel or Lever",          _("modwheel"), // "Modulation Wheel or Lever",
43          "breath", // "Breath Controller",          _("breath"), // "Breath Controller",
44          0,          0,
45          "foot", // "Foot Controller",          _("foot"), // "Foot Controller",
46          "portamentotime", // "Portamento Time",          _("portamentotime"), // "Portamento Time",
47          0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0,
48          "effect1", // "Effect Control 1",          _("effect1"), // "Effect Control 1",
49          "effect2", // "Effect Control 2",          _("effect2"), // "Effect Control 2",
50          0, 0,          0, 0,
51          "genpurpose1", // "General Purpose Controller 1",          _("genpurpose1"), // "General Purpose Controller 1",
52          "genpurpose2", // "General Purpose Controller 2",          _("genpurpose2"), // "General Purpose Controller 2",
53          "genpurpose3", // "General Purpose Controller 3",          _("genpurpose3"), // "General Purpose Controller 3",
54          "genpurpose4", // "General Purpose Controller 4",          _("genpurpose4"), // "General Purpose Controller 4",
55          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57          0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0,
58          "sustainpedal", // "Damper Pedal on/off (Sustain)",          _("sustainpedal"), // "Damper Pedal on/off (Sustain)",
59          "portamento", // "Portamento On/Off",          _("portamento"), // "Portamento On/Off",
60          "sostenuto", // "Sustenuto On/Off",          _("sostenuto"), // "Sustenuto On/Off",
61          "softpedal", // "Soft Pedal On/Off",          _("softpedal"), // "Soft Pedal On/Off",
62          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
63          "genpurpose5", // "General Purpose Controller 5",          _("genpurpose5"), // "General Purpose Controller 5",
64          "genpurpose6", // "General Purpose Controller 6",          _("genpurpose6"), // "General Purpose Controller 6",
65          "genpurpose7", // "General Purpose Controller 7",          _("genpurpose7"), // "General Purpose Controller 7",
66          "genpurpose8", // "General Purpose Controller 8",          _("genpurpose8"), // "General Purpose Controller 8",
67          0, 0, 0, 0, 0, 0, 0,          0, 0, 0, 0, 0, 0, 0,
68          "effect1depth", // "Effects 1 Depth",          _("effect1depth"), // "Effects 1 Depth",
69          "effect2depth", // "Effects 2 Depth",          _("effect2depth"), // "Effects 2 Depth",
70          "effect3depth", // "Effects 3 Depth",          _("effect3depth"), // "Effects 3 Depth",
71          "effect4depth", // "Effects 4 Depth",          _("effect4depth"), // "Effects 4 Depth",
72          "effect5depth", // "Effects 5 Depth"          _("effect5depth"), // "Effects 5 Depth"
73      };      };
74  }  }
75    
# Line 61  LabelWidget::LabelWidget(const char* lab Line 77  LabelWidget::LabelWidget(const char* lab
77      label(Glib::ustring(labelText) + ":"),      label(Glib::ustring(labelText) + ":"),
78      widget(widget)      widget(widget)
79  {  {
80      label.set_alignment(Gtk::ALIGN_LEFT);      label.set_alignment(Gtk::ALIGN_START);
81  }  }
82    
83  void LabelWidget::set_sensitive(bool sensitive)  void LabelWidget::set_sensitive(bool sensitive)
# Line 72  void LabelWidget::set_sensitive(bool sen Line 88  void LabelWidget::set_sensitive(bool sen
88    
89  NumEntry::NumEntry(const char* labelText, double lower, double upper,  NumEntry::NumEntry(const char* labelText, double lower, double upper,
90                     int decimals) :                     int decimals) :
91        LabelWidget(labelText, box),
92    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
93      adjust(lower, lower, upper, 1, 10),      adjust(lower, lower, upper, 1, 10),
94    #else
95        adjust(Gtk::Adjustment::create(lower, lower, upper, 1, 10)),
96    #endif
97      scale(adjust),      scale(adjust),
98      spinbutton(adjust),      spinbutton(adjust)
     LabelWidget(labelText, box)  
99  {  {
100        scale.set_size_request(70);
101      spinbutton.set_digits(decimals);      spinbutton.set_digits(decimals);
102      spinbutton.set_value(0);      spinbutton.set_value(0);
103      scale.set_draw_value(false);      scale.set_draw_value(false);
# Line 88  NumEntryGain::NumEntryGain(const char* l Line 109  NumEntryGain::NumEntryGain(const char* l
109                             double lower, double upper,                             double lower, double upper,
110                             int decimals, double coeff) :                             int decimals, double coeff) :
111      NumEntry(labelText, lower, upper, decimals),      NumEntry(labelText, lower, upper, decimals),
     coeff(coeff),  
112      value(0),      value(0),
113        coeff(coeff),
114      connected(true)      connected(true)
115  {  {
116      spinbutton.signal_value_changed().connect(      spinbutton.signal_value_changed().connect(
# Line 179  void NumEntryPermille::set_value(uint16_ Line 200  void NumEntryPermille::set_value(uint16_
200  NoteEntry::NoteEntry(const char* labelText) :  NoteEntry::NoteEntry(const char* labelText) :
201      NumEntryTemp<uint8_t>(labelText)      NumEntryTemp<uint8_t>(labelText)
202  {  {
203        spinbutton.set_width_chars(4);
204      spinbutton.signal_input().connect(      spinbutton.signal_input().connect(
205          sigc::mem_fun(*this, &NoteEntry::on_input));          sigc::mem_fun(*this, &NoteEntry::on_input));
206      spinbutton.signal_output().connect(      spinbutton.signal_output().connect(
# Line 186  NoteEntry::NoteEntry(const char* labelTe Line 208  NoteEntry::NoteEntry(const char* labelTe
208  }  }
209    
210  const char* notes[] = {  const char* notes[] = {
211      "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"      _("C"), _("C#"), _("D"), _("D#"), _("E"), _("F"),_("F#"),
212        _("G"), _("G#"), _("A"), _("A#"), _("B")
213  };  };
214    
215    
# Line 221  bool NoteEntry::on_output() Line 244  bool NoteEntry::on_output()
244  }  }
245    
246  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :
247      align(0, 0, 0, 0),      LabelWidget(labelText, align),
248      LabelWidget(labelText, align)      align(0, 0, 0, 0)
249  {  {
250      for (int i = 0 ; i < 99 ; i++) {      for (int i = 0 ; i < 99 ; i++) {
251          if (controlChangeTexts[i]) {          if (controlChangeTexts[i]) {
252    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
253              combobox.append_text(controlChangeTexts[i]);              combobox.append_text(controlChangeTexts[i]);
254    #else
255                combobox.append(controlChangeTexts[i]);
256    #endif
257          }          }
258      }      }
259      combobox.signal_changed().connect(      combobox.signal_changed().connect(
# Line 255  void ChoiceEntryLeverageCtrl::value_chan Line 282  void ChoiceEntryLeverageCtrl::value_chan
282      default:      default:
283          value.type = gig::leverage_ctrl_t::type_controlchange;          value.type = gig::leverage_ctrl_t::type_controlchange;
284          int x = 3;          int x = 3;
285          for (int cc = 0 ; cc < 96 ; cc++) {          for (uint cc = 0 ; cc < 96 ; cc++) {
286              if (controlChangeTexts[cc + 3]) {              if (controlChangeTexts[cc + 3]) {
287                  if (rowno == x) {                  if (rowno == x) {
288                      value.controller_number = cc;                      value.controller_number = cc;
# Line 285  void ChoiceEntryLeverageCtrl::set_value( Line 312  void ChoiceEntryLeverageCtrl::set_value(
312          break;          break;
313      case gig::leverage_ctrl_t::type_controlchange:      case gig::leverage_ctrl_t::type_controlchange:
314          x = -1;          x = -1;
315          for (int cc = 0 ; cc < 96 ; cc++) {          for (uint cc = 0 ; cc < 96 ; cc++) {
316              if (controlChangeTexts[cc + 3]) {              if (controlChangeTexts[cc + 3]) {
317                  x++;                  x++;
318                  if (value.controller_number == cc) {                  if (value.controller_number == cc) {
# Line 317  StringEntry::StringEntry(const char* lab Line 344  StringEntry::StringEntry(const char* lab
344      entry.signal_changed().connect(sig_changed.make_slot());      entry.signal_changed().connect(sig_changed.make_slot());
345  }  }
346    
347    gig::String StringEntry::get_value() const
348    {
349        return gig_from_utf8(entry.get_text());
350    }
351    
352    void StringEntry::set_value(const gig::String& value) {
353        entry.set_text(gig_to_utf8(value));
354    }
355    
356    
357  StringEntryMultiLine::StringEntryMultiLine(const char* labelText) :  StringEntryMultiLine::StringEntryMultiLine(const char* labelText) :
358      LabelWidget(labelText, frame)      LabelWidget(labelText, frame)
359  {  {
# Line 331  gig::String StringEntryMultiLine::get_va Line 368  gig::String StringEntryMultiLine::get_va
368      Glib::ustring value = text_buffer->get_text();      Glib::ustring value = text_buffer->get_text();
369      for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2)      for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2)
370          value.replace(i, 1, "\x0d\x0a");          value.replace(i, 1, "\x0d\x0a");
371      return value;      return gig_from_utf8(value);
372    }
373    
374    void StringEntryMultiLine::set_value(const gig::String& value)
375    {
376        Glib::ustring text = gig_to_utf8(value);
377        for (int i = 0 ; (i = text.find("\x0d\x0a", i, 2)) >= 0 ; i++)
378            text.replace(i, 2, "\x0a");
379        text_buffer->set_text(text);
380    }
381    
382    
383    Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) {  }
384    
385    void Table::add(BoolEntry& boolentry)
386    {
387        attach(boolentry.widget, 0, 2, rowno, rowno + 1,
388               Gtk::FILL, Gtk::SHRINK);
389        rowno++;
390    }
391    
392    void Table::add(BoolEntryPlus6& boolentry)
393    {
394        attach(boolentry.widget, 0, 2, rowno, rowno + 1,
395               Gtk::FILL, Gtk::SHRINK);
396        rowno++;
397  }  }
398    
399  void StringEntryMultiLine::set_value(gig::String value)  void Table::add(LabelWidget& prop)
400  {  {
401      for (int i = 0 ; (i = value.find("\x0d\x0a", i, 2)) >= 0 ; i++)      attach(prop.label, 1, 2, rowno, rowno + 1,
402          value.replace(i, 2, "\x0a");             Gtk::FILL, Gtk::SHRINK);
403      text_buffer->set_text(value);      attach(prop.widget, 2, 3, rowno, rowno + 1,
404               Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
405        rowno++;
406  }  }

Legend:
Removed from v.1582  
changed lines
  Added in v.2446

  ViewVC Help
Powered by ViewVC