UParamPopup.h
00001 #ifndef _UPARAMPOPUP_H
00002 #define _UPARAMPOPUP_H
00003
00004 #include <gdkmm.h>
00005 #include <gtkmm.h>
00006 #include "UEventBox.h"
00007 #include "USensor.h"
00008
00013
00014 struct PPViewParameters
00015 {
00016 int view_type;
00017 int precision;
00018 std::string format;
00019 Gdk::Color color;
00020 Gdk::Color bg_color;
00021 std::string font;
00022 struct Message
00023 {
00024 Glib::ustring text;
00025 Gdk::Color color;
00026 Gdk::Color bg_color;
00027 Glib::RefPtr<Gdk::Pixbuf> image_ptr;
00028 Glib::ustring font;
00029 };
00030 typedef std::map<int,Message> MessagesMap;
00031 MessagesMap messages_map;
00032 };
00033
00037 class CellRendererSensorValue : public Gtk::CellRenderer
00038 {
00039 public:
00040 CellRendererSensorValue();
00041 virtual ~CellRendererSensorValue();
00042
00046 Glib::PropertyProxy<float> property_value();
00047
00051 Glib::PropertyProxy_ReadOnly<float> property_value() const;
00052
00056 Glib::PropertyProxy<PPViewParameters> property_view_parameters();
00057
00061 Glib::PropertyProxy_ReadOnly<PPViewParameters> property_view_parameters() const;
00062
00063 protected:
00064 Glib::Property<float> property_value_;
00065 Glib::Property<PPViewParameters> property_view_parameters_;
00066
00067 virtual void get_size_vfunc (Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
00068 int* x_offset, int* y_offset, int* width, int* height) const;
00069
00070 virtual void render_vfunc (const Glib::RefPtr<Gdk::Drawable>& window, Gtk::Widget& widget,
00071 const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area,
00072 const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags);
00073 };
00074
00075 inline Glib::PropertyProxy<float>
00076 CellRendererSensorValue::property_value()
00077 {
00078 return property_value_.get_proxy();
00079 }
00080
00081 inline Glib::PropertyProxy_ReadOnly<float>
00082 CellRendererSensorValue::property_value() const
00083 {
00084 return Glib::PropertyProxy_ReadOnly<float>(this,"value");
00085 }
00086
00087 inline Glib::PropertyProxy<PPViewParameters>
00088 CellRendererSensorValue::property_view_parameters()
00089 {
00090 return property_view_parameters_.get_proxy();
00091 }
00092
00093 inline Glib::PropertyProxy_ReadOnly<PPViewParameters>
00094 CellRendererSensorValue::property_view_parameters() const
00095 {
00096 return Glib::PropertyProxy_ReadOnly<PPViewParameters>(this,"view-parameters");
00097 }
00098
00105 class UParamPopup : public UEventBox
00106 {
00107 private:
00108 void ctor();
00109 Glib::Property<Glib::ustring> property_attribut_;
00110 Glib::Property<Glib::ustring> property_value_;
00111 Glib::Property<int> property_window_width_;
00112 Glib::Property<int> property_window_height_;
00113
00114 Gtk::Window * popup_window;
00115 void sensor_value_changed(long value, Gtk::TreeRow row);
00116 PPViewParameters get_view_parameters_from_node(UniXML_iterator& it);
00117
00118 protected:
00119 class ModelColumns : public Gtk::TreeModel::ColumnRecord
00120 {
00121 public:
00122 ModelColumns() {
00123 add(text_message);
00124 add(value);
00125 add(view_parameters);
00126 add(connection);
00127 }
00128
00129 Gtk::TreeModelColumn<Glib::ustring> text_message;
00130 Gtk::TreeModelColumn<long> value;
00131 Gtk::TreeModelColumn<PPViewParameters> view_parameters;
00132 Gtk::TreeModelColumn<USignals::Connection> connection;
00133 } columns;
00134
00135 virtual bool on_button_press_event (GdkEventButton* event);
00136 virtual bool on_focus_out(Gtk::Widget* widget);
00137 virtual Gtk::Window* create_popup();
00138
00139 public:
00140 UParamPopup();
00141 explicit UParamPopup(GtkmmBaseType::BaseObjectType* gobject);
00142
00143 ~UParamPopup();
00144
00148 Glib::PropertyProxy<Glib::ustring> property_attribut();
00149
00153 Glib::PropertyProxy_ReadOnly <Glib::ustring> property_attribut() const;
00154
00158 Glib::PropertyProxy<Glib::ustring> property_value();
00159
00163 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_value() const;
00164
00168 Glib::PropertyProxy<int> property_window_width();
00169
00173 Glib::PropertyProxy_ReadOnly<int> property_window_width() const;
00174
00178 Glib::PropertyProxy<int> property_window_height();
00179
00183 Glib::PropertyProxy_ReadOnly<int> property_window_height() const;
00184 };
00185
00186 inline Glib::PropertyProxy<Glib::ustring>
00187 UParamPopup::property_attribut()
00188 {
00189 return property_attribut_.get_proxy();
00190 }
00191
00192 inline Glib::PropertyProxy_ReadOnly<Glib::ustring>
00193 UParamPopup::property_attribut() const
00194 {
00195 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this,"attribut");
00196 }
00197
00198 inline Glib::PropertyProxy<Glib::ustring>
00199 UParamPopup::property_value()
00200 {
00201 return property_value_.get_proxy();
00202 }
00203
00204 inline Glib::PropertyProxy_ReadOnly<Glib::ustring>
00205 UParamPopup::property_value() const
00206 {
00207 return Glib::PropertyProxy_ReadOnly<Glib::ustring>(this,"value");
00208 }
00209
00210 inline Glib::PropertyProxy<int>
00211 UParamPopup::property_window_width()
00212 {
00213 return property_window_width_.get_proxy();
00214 }
00215
00216 inline Glib::PropertyProxy_ReadOnly<int>
00217 UParamPopup::property_window_width() const
00218 {
00219 return Glib::PropertyProxy_ReadOnly<int>(this,"window-width");
00220 }
00221
00222 inline Glib::PropertyProxy<int>
00223 UParamPopup::property_window_height()
00224 {
00225 return property_window_height_.get_proxy();
00226 }
00227
00228 inline Glib::PropertyProxy_ReadOnly<int>
00229 UParamPopup::property_window_height() const
00230 {
00231 return Glib::PropertyProxy_ReadOnly<int>(this,"window-height");
00232 }
00233 #endif