SimpleObject.h

00001 #ifndef _SIMPLEOBJECT_H
00002 #define _SIMPLEOBJECT_H
00003 // -------------------------------------------------------------------------
00004 #include <gtk/gtk.h>
00005 #include <gtkmm.h>
00006 #include <UDefaultFunctions.h>
00007 #include <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 //   virtual void get_child_property_vfunc(GtkWidget* child,
00084 //                                                               guint property_id,
00085 //                                                               GValue* value,
00086 //                                                               GParamSpec* pspec);
00087 
00088   /* Handlers */
00089   virtual bool on_expose_event(GdkEventExpose* event);
00090   virtual void on_connect() throw();
00091   virtual void on_disconnect() throw();
00092   virtual void on_realize();
00093   /* Variables */
00094   std::map<long, std::vector<Gtk::Widget*> > children_;    
00096 private:
00097   /* link_ variable is used for link sensor state
00098    * don't use UVoid::connected_ for this */
00099   bool link_;              
00100 //   long state_object;
00101   bool is_initialized;            
00102   bool is_glade;
00103   /* Methods */
00104   void constructor();
00106   void save_value(const long value,const UniSetTypes::ObjectId sensor, const UniSetTypes::ObjectId node = UniSetTypes::DefaultObjectId);
00107 
00108   DISALLOW_COPY_AND_ASSIGN(SimpleObject);
00109 };
00110 
00111 }
00112 
00113 // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00114 namespace Glib
00115 {
00116 template <>
00117 class Value<UniWidgetsTypes::ThresholdType> : public Value_Enum<UniWidgetsTypes::ThresholdType>
00118 {
00119 public:
00120   static GType value_type() G_GNUC_CONST;
00121 };
00122 
00123 template <>
00124 class Value<UniWidgetsTypes::ArrowDeviceType> : public Value_Enum<UniWidgetsTypes::ArrowDeviceType>
00125 {
00126 public:
00127   static GType value_type() G_GNUC_CONST;
00128 };
00129 } // namespace Glib
00130 // #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00131 
00132 
00133 /* Constants for SimpleObject_Get_Type() */
00134 static const gchar* type = "type";
00135 static const long type_prop = 5;
00136 
00137 template<class T>
00138 inline GType SimpleObject_Get_Type()
00139 {
00140   static GType gtype = 0;
00141   if (gtype)
00142     return gtype;
00143 
00144   T* dummy = new T();
00145   GtkContainerClass* container_klass = GTK_CONTAINER_GET_CLASS( dummy->gobj() );
00146   GParamSpec* spec;
00147   spec = g_param_spec_long (type, type, type, LONG_MIN, LONG_MAX, -1,
00148       GParamFlags(G_PARAM_READABLE|G_PARAM_WRITABLE));
00149   gtk_container_class_install_child_property( container_klass, type_prop, spec);
00150   gtype = G_OBJECT_TYPE(dummy->gobj());
00151   delete( dummy );
00152   Glib::wrap_register(gtype, &UObj_Wrap_New<T>);
00153   return gtype;
00154 }
00155 
00156 #endif

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