|
UniWidgets
1.0.0
|
00001 #ifndef _SIMPLEOBJECT_H 00002 #define _SIMPLEOBJECT_H 00003 // ------------------------------------------------------------------------- 00004 #include <gtk/gtk.h> 00005 #include <gtkmm.h> 00006 #include <uniwidgets/UDefaultFunctions.h> 00007 #include <uniwidgets/USignals.h> 00008 #include <plugins.h> 00009 #include <global_macros.h> 00010 #include <types.h> 00011 // ------------------------------------------------------------------------- 00015 namespace UniWidgets 00016 { 00017 class AbstractLogic; 00029 class SimpleObject : public UDefaultFunctions<Gtk::Fixed> 00030 { 00031 public: 00032 SimpleObject(); 00033 explicit SimpleObject(GtkmmBaseType::BaseObjectType* gobject); 00034 virtual ~SimpleObject(); 00035 00036 /* Methods */ 00038 long get_value(const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00040 long get_value_from_sm(const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00042 float get_analog_value(const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00044 void set_value_obj(const long value,const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00046 long get_value_obj(const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00047 std::vector<Gtk::Widget*> get_children(const long type); 00049 void set_link(const bool link); 00051 /* FIXME: This method must be used only in the typical widgets */ 00052 virtual void add_child(Gtk::Widget* child, const long type); 00053 00054 /* Set the event handlers */ 00056 void set_confirm_handler(sigc::slot<void, UMessages::MessageId, time_t>& slot, UMessages::MessageId id); 00057 00059 USignals::Connection set_sensor_handler(const USignals::ValueChangedSlot& slot, 00060 const UniSetTypes::ObjectId sensor, 00061 const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00063 USignals::Connection set_analog_sensor_handler(const USignals::AnalogValueChangedSlot& slot, 00064 const UniSetTypes::ObjectId sensor, 00065 const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00067 USignals::Connection set_any_message_handler(const USignals::FullMessageSlot& slot); 00069 USignals::Connection set_message_handler(const USignals::MessageSlot& slot, UMessages::MessageId id); 00071 void increase_child_order(Gtk::Widget* child); 00072 00073 protected: 00074 /* Methods */ 00076 virtual void set_connector(const ConnectorRef& connector) throw(); 00077 00079 virtual void set_child_property_vfunc(GtkWidget* child, 00080 guint property_id, 00081 const GValue* value, 00082 GParamSpec* pspec); 00083 00084 /* Handlers */ 00085 virtual bool on_expose_event(GdkEventExpose* event); 00086 virtual void on_connect() throw(); 00087 virtual void on_disconnect() throw(); 00088 virtual void on_realize(); 00089 /* Variables */ 00090 std::map<long, std::vector<Gtk::Widget*> > children_; 00092 private: 00093 /* link_ variable is used for link sensor state 00094 * don't use UVoid::connected_ for this */ 00095 bool link_; 00096 // long state_object; 00097 bool is_initialized; 00099 /* Methods */ 00100 void constructor(); 00102 void save_value(const long value,const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId); 00103 00104 DISALLOW_COPY_AND_ASSIGN(SimpleObject); 00105 }; 00106 00107 } 00108 00109 // #ifndef DOXYGEN_SHOULD_SKIP_THIS 00110 namespace Glib 00111 { 00112 template <> 00113 class Value<UniWidgetsTypes::ThresholdType> : public Value_Enum<UniWidgetsTypes::ThresholdType> 00114 { 00115 public: 00116 static GType value_type() G_GNUC_CONST; 00117 }; 00118 00119 template <> 00120 class Value<UniWidgetsTypes::ArrowDeviceType> : public Value_Enum<UniWidgetsTypes::ArrowDeviceType> 00121 { 00122 public: 00123 static GType value_type() G_GNUC_CONST; 00124 }; 00125 } // namespace Glib 00126 // #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 00127 00128 00129 /* Constants for SimpleObject_Get_Type() */ 00130 static const gchar* type = "type"; 00131 static const long type_prop = 5; 00132 00133 template<class T> 00134 inline GType SimpleObject_Get_Type() 00135 { 00136 static GType gtype = 0; 00137 if (gtype) 00138 return gtype; 00139 00140 T* dummy = new T(); 00141 GtkContainerClass* container_klass = GTK_CONTAINER_GET_CLASS( dummy->gobj() ); 00142 00143 GParamSpec* spec; 00144 spec = g_param_spec_long (type, type, type, LONG_MIN, LONG_MAX, -1, 00145 GParamFlags(G_PARAM_READABLE|G_PARAM_WRITABLE)); 00146 gtk_container_class_install_child_property( container_klass, type_prop, spec); 00147 00148 gtype = G_OBJECT_TYPE(dummy->gobj()); 00149 delete( dummy ); 00150 Glib::wrap_register(gtype, &UObj_Wrap_New<T>); 00151 00152 return gtype; 00153 } 00154 00155 #endif
1.7.6.1