UniWidgets  1.0.0
GroupObject.h
00001 #ifndef _GROUPOBJECT_H
00002 #define _GROUPOBJECT_H
00003 // -------------------------------------------------------------------------
00004 #include <gtk/gtk.h>
00005 #include <gtkmm.h>
00006 #include <uniwidgets/USignals.h>
00007 #include <plugins.h>
00008 #include <global_macros.h>
00009 #include <objects/SimpleObject.h>
00010 // -------------------------------------------------------------------------
00011 namespace UniWidgets
00012 {
00023 class GroupObject : public SimpleObject
00024 {
00025 public:
00026     GroupObject();
00027     explicit GroupObject(GtkmmBaseType::BaseObjectType* gobject);
00028     virtual ~GroupObject();
00029 
00030     /* FIXME: This method must be used only in the typical widgets */
00031     virtual void add_child(Gtk::Widget* child, const long type);        
00032     virtual void add_childgroup(Gtk::Widget* child, const long value);  
00033     Gtk::Widget* get_childrengroup(const long value);           
00034     long get_countgroup();                          
00035 protected:
00036     /* Methods */
00037     virtual void set_child_property_vfunc(GtkWidget* child,
00038             guint property_id,
00039             const GValue* value,
00040             GParamSpec* pspec);                 
00041     /* Variables */
00042     std::map<long, Gtk::Widget*> childrengroup_;                
00043 private:
00044     void constructor();
00045     DISALLOW_COPY_AND_ASSIGN(GroupObject);
00046 };
00047 
00048 }
00049 
00050 /* Constants for GroupObject_Get_Type() */
00051 static const gchar* value = "value";
00052 static const long value_prop = 6;
00053 
00054 template<class T>
00055 inline GType GroupObject_Get_Type()
00056 {
00057     static GType gtype = 0;
00058     if (gtype)
00059         return gtype;
00060 
00061     T* dummy = new T();
00062     GtkContainerClass* container_klass = GTK_CONTAINER_GET_CLASS( dummy->gobj() );
00063 
00064     GParamSpec* spec;
00065     spec = g_param_spec_long (type, type, type, LONG_MIN, LONG_MAX, -1,
00066             GParamFlags(G_PARAM_READABLE|G_PARAM_WRITABLE));
00067     gtk_container_class_install_child_property( container_klass, type_prop, spec);
00068     
00069     spec = g_param_spec_long (value, value, value, LONG_MIN, LONG_MAX, -1,
00070             GParamFlags(G_PARAM_READABLE|G_PARAM_WRITABLE));
00071     gtk_container_class_install_child_property( container_klass, value_prop, spec);
00072 
00073     gtype = G_OBJECT_TYPE(dummy->gobj());
00074     delete( dummy );
00075     Glib::wrap_register(gtype, &UObj_Wrap_New<T>);
00076 
00077     return gtype;
00078 }
00079 #endif