UScale.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * This library is free software; you can redistribute it and/or
00003  * modify it under the terms of the LGPL
00004  *****************************************************************************/
00005 
00006 #ifndef USCALE_H
00007 #define USCALE_H
00008 
00009 #include <vector>
00010 #include <map>
00011 
00012 #include <sigc++/sigc++.h>
00013 
00014 #include <gtkmm.h>
00015 
00016 #include <plotmm/doubleintmap.h>
00017 #include <plotmm/scalediv.h>
00018 
00019 namespace Pango {
00020     class Layout;
00021     class FontDescription;
00022 }
00026     class ScaleLabels : public Gtk::EventBox {
00027         public:
00028             ScaleLabels(Gtk::PositionType p);
00029             virtual ~ScaleLabels();
00030 
00032             Pango::FontDescription *font() { return &font_; }
00033             void set_labels(int offs, const std::map<int,double> &labels);
00034 
00035             void set_labels_color(Gdk::Color color);
00036             void set_labels_font(Pango::FontDescription fd);
00037             void set_enabled(bool b);
00039             bool enabled() const { return enabled_; }
00040             Glib::ustring format(double) const;
00041             int text_width(const Glib::ustring &) const;
00042             int text_height(const Glib::ustring &) const;
00044             inline Gtk::PositionType position(){ return position_; };
00045 
00046             inline void set_scaleDiv(const PlotMM::ScaleDiv &Div){ scaleDiv_ = Div;};
00047             inline void set_scaleMap(const PlotMM::DoubleIntMap &Map){ scaleMap_ = Map;};
00048 
00049         protected:
00050             virtual void newsize_();
00051             virtual void requestsize_() {}
00052             virtual bool on_map_event(GdkEvent *event);
00053 
00054             int offset_;
00055             int layw_, layh_;
00056             int range_;
00057             std::map<int,double> labels_;
00058             Glib::RefPtr<Pango::Layout> layout_;
00059             Pango::FontDescription font_;
00060             Gdk::Color label_color;
00061             bool is_show;
00062 
00063             PlotMM::ScaleDiv scaleDiv_;
00064             PlotMM::DoubleIntMap scaleMap_;
00065 
00066         private:
00067             Gtk::PositionType position_;
00068             bool enabled_;
00069     };
00070 
00074     class VScaleLabels : public ScaleLabels {
00075         public:
00076             VScaleLabels(Gtk::PositionType p);
00077             virtual ~VScaleLabels();
00078 
00079         protected:
00080             virtual bool on_expose_event(GdkEventExpose* event);
00081             virtual void update_();
00082             virtual void requestsize_();
00083     };
00084 
00088     class HScaleLabels : public ScaleLabels {
00089         public:
00090             HScaleLabels(Gtk::PositionType p);
00091             virtual ~HScaleLabels();
00092 
00093         protected:
00094             virtual bool on_expose_event(GdkEventExpose* event);
00095             virtual void update_();
00096             virtual void requestsize_();
00097     };
00098 
00099 
00100 
00104     class Scale : public Gtk::EventBox
00105     {
00106         public:
00107             Scale(Gtk::PositionType p, ScaleLabels *labels= 0);
00108             virtual ~Scale();
00109 
00110             void set_position(Gtk::PositionType p);
00112             Gtk::PositionType position() const { return position_; }
00113 
00114             void set_ticklengths(int major, int minor);
00115             void set_scale_color(Gdk::Color color);
00117             int major_ticklength() const { return majorTL_; }
00119             int minor_ticklength() const { return minorTL_; }
00120 
00122             inline ScaleLabels* get_labels(){return labels_;};
00123 
00124             void set_enabled(bool b);
00126             bool enabled() const { return enabled_; }
00127             inline void set_max_major(int max){maxMaj = max;};
00128             inline void set_max_minor(int max){maxMin = max;};
00129 
00131             const PlotMM::DoubleIntMap &scale_map() const { return scaleMap_; }
00132 
00133             void set_range(double l, double r);
00134             void set_range(double l, double r, bool lg);
00135 
00136             void set_autoscale(bool b);
00138             bool autoscale() const { return autoscale_; }
00139             void begin_autoscale();
00140             void autoscale(double min, double max);
00141             void end_autoscale();
00142 
00146             sigc::signal1<void,bool> signal_enabled;
00147 
00148         protected:
00149             virtual void on_realize();
00150             virtual bool on_expose_event(GdkEventExpose* event);
00151             virtual bool on_map_event(GdkEvent *event);
00152 
00154             virtual void on_tick_change() {}
00155             virtual void redraw() = 0;
00156 
00157             Glib::RefPtr<Gdk::Window> window_;
00158             ScaleLabels *labels_;
00159             Gdk::Color scale_color;
00160             int maxMaj;
00161             int maxMin;
00162             bool is_show;
00163 
00164             PlotMM::ScaleDiv scaleDiv_;
00165             PlotMM::DoubleIntMap scaleMap_;
00166 
00167         private:
00168             Gtk::PositionType position_;
00169             bool autoscale_;
00170             bool enabled_;
00171             int majorTL_, minorTL_;
00172             double asMin_, asMax_;
00173     };
00174 
00178     class VScale : public Scale
00179     {
00180         public:
00181             VScale(Gtk::PositionType p, ScaleLabels *l= 0);
00182             virtual ~VScale();
00183 
00184         protected:
00185             virtual void redraw();
00186             virtual void on_tick_change();
00187     };
00188 
00192     class HScale : public Scale
00193     {
00194         public:
00195             HScale(Gtk::PositionType p, ScaleLabels *l= 0);
00196             virtual ~HScale();
00197 
00198         protected:
00199             virtual void redraw();
00200             virtual void on_tick_change();
00201     };
00202 
00206     class Web : public Gtk::EventBox
00207     {
00208         public:
00209             Web();
00210             virtual ~Web();
00211 
00212             void set_web_color(Gdk::Color color);
00213 
00214             void set_enabled(bool b);
00216             bool enabled() const { return enabled_; }
00217             inline void set_max_h_major(int max){maxMajH = max;};
00218             inline void set_max_h_minor(int max){maxMinH = max;};
00219             inline void set_max_v_major(int max){maxMajV = max;};
00220             inline void set_max_v_minor(int max){maxMinV = max;};
00221 
00223             const PlotMM::DoubleIntMap &h_map() const { return HMap_; }
00224             const PlotMM::DoubleIntMap &v_map() const { return VMap_; }
00225 
00226             void set_h_range(double l, double r);
00227             void set_h_range(double l, double r, bool lg);
00228             void set_v_range(double l, double r);
00229             void set_v_range(double l, double r, bool lg);
00230 
00234             sigc::signal1<void,bool> signal_enabled;
00235 
00236         protected:
00237             virtual void on_realize();
00238             virtual bool on_expose_event(GdkEventExpose* event);
00239             virtual bool on_map_event(GdkEvent *event);
00240 
00241             virtual void redraw();
00242 
00243             Gdk::Color web_color;
00244             int maxMajH;
00245             int maxMinH;
00246             int maxMajV;
00247             int maxMinV;
00248             bool is_show;
00249 
00250             Glib::RefPtr<Gdk::Window> window_;
00251 
00252             PlotMM::ScaleDiv HDiv_;
00253             PlotMM::DoubleIntMap HMap_;
00254             PlotMM::ScaleDiv VDiv_;
00255             PlotMM::DoubleIntMap VMap_;
00256 
00257         private:
00258             bool enabled_;
00259     };
00260 
00261 #endif

Документация по UniWidgets. Последние изменения: Fri Oct 10 09:57:50 2014. Создано системой  doxygen 1.5.9