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

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

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

revision 1460 by persson, Sat Oct 27 12:28:33 2007 UTC revision 2169 by persson, Sun Mar 6 07:51:04 2011 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2011 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 22  Line 22 
22    
23  #include <gig.h>  #include <gig.h>
24    
25  #include <math.h>  #include <cmath>
26    
27  #include <gtkmm/adjustment.h>  #include <gtkmm/adjustment.h>
28  #include <gtkmm/alignment.h>  #include <gtkmm/alignment.h>
29  #include <gtkmm/box.h>  #include <gtkmm/box.h>
30    #include <gtkmm/checkbutton.h>
31  #include <gtkmm/comboboxtext.h>  #include <gtkmm/comboboxtext.h>
32    #include <gtkmm/frame.h>
33  #include <gtkmm/label.h>  #include <gtkmm/label.h>
34  #include <gtkmm/scale.h>  #include <gtkmm/scale.h>
35  #include <gtkmm/spinbutton.h>  #include <gtkmm/spinbutton.h>
36    #include <gtkmm/textview.h>
37    
38    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 12) || GTKMM_MAJOR_VERSION < 2
39    #define OLD_TOOLTIPS
40  #include <gtkmm/tooltips.h>  #include <gtkmm/tooltips.h>
41    #endif
42    
43  class LabelWidget {  class LabelWidget {
44  public:  public:
# Line 44  public: Line 51  public:
51          return sig_changed;          return sig_changed;
52      }      }
53  protected:  protected:
54    #ifdef OLD_TOOLTIPS
55      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
56    #endif
57      sigc::signal<void> sig_changed;      sigc::signal<void> sig_changed;
58  };  };
59    
60  class NumEntry : public LabelWidget {  class NumEntry : public LabelWidget {
61  protected:  protected:
62    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
63      Gtk::Adjustment adjust;      Gtk::Adjustment adjust;
64    #else
65        Glib::RefPtr<Gtk::Adjustment> adjust;
66    #endif
67      Gtk::HScale scale;      Gtk::HScale scale;
68      Gtk::SpinButton spinbutton;      Gtk::SpinButton spinbutton;
69      Gtk::HBox box;      Gtk::HBox box;
# Line 62  public: Line 75  public:
75      NumEntry(const char* labelText, double lower = 0, double upper = 127,      NumEntry(const char* labelText, double lower = 0, double upper = 127,
76               int decimals = 0);               int decimals = 0);
77      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
78    #ifdef OLD_TOOLTIPS
79          tooltips.set_tip(spinbutton, tip_text);          tooltips.set_tip(spinbutton, tip_text);
80    #else
81            spinbutton.set_tooltip_text(tip_text);
82    #endif
83      }      }
84      void set_upper(double upper) {      void set_upper(double upper) {
85    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
86          adjust.set_upper(upper);          adjust.set_upper(upper);
87    #else
88            adjust->set_upper(upper);
89    #endif
90      }      }
91  };  };
92    
# Line 118  void NumEntryTemp<T>::value_changed() Line 139  void NumEntryTemp<T>::value_changed()
139  template<typename T>  template<typename T>
140  void NumEntryTemp<T>::set_value(T value)  void NumEntryTemp<T>::set_value(T value)
141  {  {
142    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
143      if (value > adjust.get_upper()) value = T(adjust.get_upper());      if (value > adjust.get_upper()) value = T(adjust.get_upper());
144    #else
145        if (value > adjust->get_upper()) value = T(adjust->get_upper());
146    #endif
147      if (this->value != value) {      if (this->value != value) {
148          this->value = value;          this->value = value;
149          const double f = pow(10, spinbutton.get_digits());          const double f = pow(10, spinbutton.get_digits());
# Line 164  public: Line 189  public:
189      void set_choices(const char** texts, const T* values);      void set_choices(const char** texts, const T* values);
190    
191      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
192          tooltips.set_tip(combobox, tip_text); //FIXME: don't Gtk::ComboBoxes support tooltips ???  #ifdef OLD_TOOLTIPS
193            tooltips.set_tip(combobox, tip_text);
194    #else
195            combobox.set_tooltip_text(tip_text);
196    #endif
197      }      }
198  };  };
199    
200  template<typename T>  template<typename T>
201  ChoiceEntry<T>::ChoiceEntry(const char* labelText) :  ChoiceEntry<T>::ChoiceEntry(const char* labelText) :
202      align(0, 0, 0, 0),      LabelWidget(labelText, align),
203      LabelWidget(labelText, align)      align(0, 0, 0, 0)
204  {  {
205      combobox.signal_changed().connect(sig_changed.make_slot());      combobox.signal_changed().connect(sig_changed.make_slot());
206      align.add(combobox);      align.add(combobox);
# Line 181  template<typename T> Line 210  template<typename T>
210  void ChoiceEntry<T>::set_choices(const char** texts, const T* values)  void ChoiceEntry<T>::set_choices(const char** texts, const T* values)
211  {  {
212      for (int i = 0 ; texts[i] ; i++) {      for (int i = 0 ; texts[i] ; i++) {
213    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
214          combobox.append_text(texts[i]);          combobox.append_text(texts[i]);
215    #else
216            combobox.append(texts[i]);
217    #endif
218      }      }
219      this->values = values;      this->values = values;
220  }  }
# Line 227  public: Line 260  public:
260      void set_value(bool value) { checkbutton.set_active(value); }      void set_value(bool value) { checkbutton.set_active(value); }
261    
262      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
263    #ifdef OLD_TOOLTIPS
264          tooltips.set_tip(checkbutton, tip_text);          tooltips.set_tip(checkbutton, tip_text);
265    #else
266            checkbutton.set_tooltip_text(tip_text);
267    #endif
268      }      }
269  };  };
270    
# Line 247  public: Line 284  public:
284  class StringEntry : public LabelWidget {  class StringEntry : public LabelWidget {
285  private:  private:
286      Gtk::Entry entry;      Gtk::Entry entry;
     gig::String* ptr;  
     void value_changed();  
287  public:  public:
288      StringEntry(const char* labelText);      StringEntry(const char* labelText);
289      void set_ptr(gig::String* ptr);      gig::String get_value() const { return entry.get_text(); }
290        void set_value(gig::String value) { entry.set_text(value); }
291        void set_width_chars(int n_chars) { entry.set_width_chars(n_chars); }
292    };
293    
294    class StringEntryMultiLine : public LabelWidget {
295    private:
296        Gtk::TextView text_view;
297        Glib::RefPtr<Gtk::TextBuffer> text_buffer;
298        Gtk::Frame frame;
299    public:
300        StringEntryMultiLine(const char* labelText);
301        gig::String get_value() const;
302        void set_value(gig::String value);
303  };  };
304    
305    

Legend:
Removed from v.1460  
changed lines
  Added in v.2169

  ViewVC Help
Powered by ViewVC