UniWidgets  1.0.0
UButton.h
00001 #ifndef _UBUTTON_H
00002 #define _UBUTTON_H
00003 // -------------------------------------------------------------------------
00004 #include <map>
00005 #include <string>
00006 #include <uniwidgets/UDefaultFunctions.h>
00007 #include <uniwidgets/SensorProp.h>
00008 #include <global_macros.h>
00009 #include <gtkmm.h>
00010 // -------------------------------------------------------------------------
00011 #define INVERT      "invert"
00012 // ------------------------------------------------------------------------------------------
00013 namespace UniWidgets
00014 {
00015 class TypicalImitatorLamp;
00035 class UButton : public UDefaultFunctions<Gtk::ToggleButton>
00036 {
00037 public:
00038     UButton();
00039     explicit UButton(GtkmmBaseType::BaseObjectType* gobject);
00040     ~UButton() {};
00041 
00042     /* Properties get/set methods */
00043     Glib::PropertyProxy<bool> property_invert();
00044     Glib::PropertyProxy_ReadOnly<bool> property_invert() const;
00045     Gdk::Rectangle *btn_lamp_rect;      
00047     virtual void set_connector(const ConnectorRef& connector) throw();
00048 
00049   void process_sensor_changed(float value);  
00051 protected:
00052     /* Properties */
00053     SensorProp dout;            
00055     /* Event handlers */
00056     virtual void on_clicked();
00057     virtual void on_enter();
00058     virtual void on_leave();
00059     virtual void on_pressed();
00060     virtual void on_released();
00061     virtual void on_realize();
00062 
00063     virtual void on_connect() throw();  
00064   bool on_my_event(GdkEvent* event);
00065 
00066 private:
00067   Gtk::Frame frame;
00068     TypicalImitatorLamp *state_lamp;
00069     Gdk::Rectangle *lamp_rect;
00070 
00071     bool refresh;
00072     int count;
00073 
00074     /* Properties */
00075     Glib::Property<bool> property_invert_;
00076 
00077     /* Methods */
00078     void ctor();
00079 
00080     ADD_PROPERTY( toggle_off, bool )
00081     ADD_PROPERTY( node, UniSetTypes::ObjectId )
00082     ADD_PROPERTY( add_lamp, bool )
00083     ADD_PROPERTY( state_lamp_ai, UniSetTypes::ObjectId )
00084     ADD_PROPERTY( lamp_width, long )
00085     ADD_PROPERTY( lamp_height, long )
00086     ADD_PROPERTY( lamp_x, long )
00087     ADD_PROPERTY( lamp_y, long )
00088     ADD_PROPERTY( imagelamp_path, Glib::ustring )
00089     ADD_PROPERTY( imagelamp2_path, Glib::ustring )
00090     ADD_PROPERTY( blinktime1, int )
00091     ADD_PROPERTY( blinktime2, int )
00092 };
00093 // -------------------------------------------------------------------------
00094 inline Glib::PropertyProxy<bool>
00095 UButton::property_invert()
00096 {
00097     return property_invert_.get_proxy();
00098 }
00099 // -------------------------------------------------------------------------
00100 inline Glib::PropertyProxy_ReadOnly<bool>
00101 UButton::property_invert() const
00102 {
00103     return Glib::PropertyProxy_ReadOnly<bool>(this, INVERT);
00104 }
00105 
00106 }
00107 // -------------------------------------------------------------------------
00108 #endif