00001
00002
00003 #ifndef _GOOCANVASMM_ITEM_H
00004 #define _GOOCANVASMM_ITEM_H
00005
00006
00007 #include <glibmm.h>
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <goocanvasmm/bounds.h>
00028 #include <goocanvasmm/enums.h>
00029 #include <goocanvasmm/style.h>
00030 #include <cairomm/cairomm.h>
00031 #include <goocanvasitem.h>
00032
00033
00034 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00035 extern "C" { typedef union _GooCanvasPathCommand GooCanvasPathCommand; }
00036 #endif
00037
00038 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00039 typedef struct _GooCanvasItem GooCanvasItem;
00040 typedef struct _GooCanvasItemClass GooCanvasItemClass;
00041 #endif
00042
00043
00044 namespace Goocanvas
00045 { class Item_Class; }
00046 namespace Goocanvas
00047 {
00048
00049 class Canvas ;
00050 class ItemModel ;
00051
00052
00053 class Item : public Glib::Interface
00054 {
00055
00056 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00057
00058 public:
00059 typedef Item CppObjectType;
00060 typedef Item_Class CppClassType;
00061 typedef GooCanvasItem BaseObjectType;
00062 typedef GooCanvasItemIface BaseClassType;
00063
00064 private:
00065 friend class Item_Class;
00066 static CppClassType item_class_;
00067
00068
00069 Item(const Item&);
00070 Item& operator=(const Item&);
00071
00072 protected:
00073 Item();
00074
00081 explicit Item(const Glib::Interface_Class& interface_class);
00082
00083 public:
00084
00085
00086
00087 explicit Item(GooCanvasItem* castitem);
00088
00089 protected:
00090 #endif
00091
00092 public:
00093 virtual ~Item();
00094
00095 static void add_interface(GType gtype_implementer);
00096
00097 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00098 static GType get_type() G_GNUC_CONST;
00099 static GType get_base_type() G_GNUC_CONST;
00100 #endif
00101
00103 GooCanvasItem* gobj() { return reinterpret_cast<GooCanvasItem*>(gobject_); }
00104
00106 const GooCanvasItem* gobj() const { return reinterpret_cast<GooCanvasItem*>(gobject_); }
00107
00108 private:
00109
00110
00111 public:
00112
00113
00117 Canvas* get_canvas();
00118
00122 const Canvas* get_canvas() const;
00123
00124
00131 void set_canvas(Canvas* canvas);
00132
00133
00143 bool is_visible() const;
00144
00145
00149 Glib::RefPtr<ItemModel> get_model();
00150
00154 Glib::RefPtr<const ItemModel> get_model() const;
00155
00159 void set_model(const Glib::RefPtr<ItemModel>& model);
00160
00161
00165 Glib::RefPtr<Item> get_parent();
00166
00170 Glib::RefPtr<const Item> get_parent() const;
00171
00183 void set_parent(const Glib::RefPtr<Item>& parent);
00184
00190 void remove();
00191
00192
00196 bool is_container() const;
00197
00201 int get_n_children() const;
00202
00208 Glib::RefPtr<Item> get_child(int child_num);
00209
00215 Glib::RefPtr<const Item> get_child(int child_num) const;
00216
00221 int find_child(const Glib::RefPtr<Item>& child);
00222
00228 void add_child(const Glib::RefPtr<Item>& child, int pos);
00229 void add_child(const Glib::RefPtr<Item>& child);
00230
00231
00237 void get_child_property_value(const Glib::RefPtr<Item>& child, const Glib::ustring& property_name, Glib::ValueBase& value) const;
00238
00244 void set_child_property_value(const Glib::RefPtr<Item>& child, const Glib::ustring& property_name, const Glib::ValueBase& value);
00245
00246
00247 template <class PropertyType>
00248 void get_child_property(const Glib::RefPtr<Item>& child, const Glib::ustring& the_property_name, PropertyType& value) const;
00249
00250 template <class PropertyType>
00251 void set_child_property(const Glib::RefPtr<Item>& child, const Glib::ustring& the_property_name, const PropertyType& value);
00252
00253
00258 void move_child(int old_position, int new_position);
00259
00263 void remove_child(int child_num);
00264
00265
00270 void raise(const Glib::RefPtr<Item>& above);
00271
00274 void raise();
00275
00276
00281 void lower(const Glib::RefPtr<Item>& below);
00282
00285 void lower();
00286
00287 Bounds get_bounds() const;
00288
00289
00296 void request_update();
00297
00304 void ensure_updated();
00305
00314 void update(bool entire_tree, const Cairo::RefPtr<Cairo::Context>& context, Bounds& bounds);
00315
00328 void paint(const Cairo::RefPtr<Cairo::Context>& context, const Bounds& bounds, double scale);
00329
00339 bool get_requested_area(const Cairo::RefPtr<Cairo::Context>& context, Bounds& bounds) const;
00340
00353 double get_requested_height(const Cairo::RefPtr<Cairo::Context>& context, double width) const;
00354
00377 void allocate_area(const Cairo::RefPtr<Cairo::Context>& context, const Bounds& requested_area, const Bounds& allocated_area, double x_offset, double y_offset);
00378
00379
00380
00381
00382
00383
00399 Glib::ListHandle< Glib::RefPtr<Item> > get_items_at(double x, double y, const Cairo::RefPtr<Cairo::Context>& context, bool is_pointer_event, bool parent_is_visible, const Glib::ListHandle< Glib::RefPtr<Item> >& found_items);
00400
00416 Glib::ListHandle< Glib::RefPtr<const Item> > get_items_at(double x, double y, const Cairo::RefPtr<Cairo::Context>& context, bool is_pointer_event, bool parent_is_visible, const Glib::ListHandle< Glib::RefPtr<const Item> >& found_items) const;
00417
00418
00419 Glib::ListHandle< Glib::RefPtr<Item> > get_items_at(double x, double y, const Cairo::RefPtr<Cairo::Context>& context, bool is_pointer_event, bool parent_is_visible);
00420 Glib::ListHandle< Glib::RefPtr<const Item> > get_items_at(double x, double y, const Cairo::RefPtr<Cairo::Context>& context, bool is_pointer_event, bool parent_is_visible) const;
00421
00422
00423
00428 bool get_transform(Cairo::Matrix* matrix);
00429
00434 void set_transform(const Cairo::Matrix* matrix);
00435
00436
00443 void set_simple_transform(double x, double y, double scale, double rotation);
00444
00456 bool get_simple_transform(double& x, double& y, double& scale, double& rotation) const;
00457
00462 void translate(double tx, double ty);
00463
00468 void scale(double sx, double sy);
00469
00476 void rotate(double degrees, double cx, double cy);
00477
00484 void skew_x(double degrees, double cx, double cy);
00485
00492 void skew_y(double degrees, double cx, double cy);
00493
00494
00502 bool get_transform_for_child(const Glib::RefPtr<Item>& child, Cairo::Matrix* transform);
00503
00504
00509 Glib::RefPtr<Style> get_style();
00510
00515 Glib::RefPtr<const Style> get_style() const;
00516
00520 void set_style(const Glib::RefPtr<Style>& style);
00521
00522
00539 void animate(double x, double y, double scale, double degrees, bool absolute, int duration, int step_time, GooCanvasAnimateType type);
00540
00544 void stop_animation();
00545
00546
00547 bool get_is_static() const;
00548
00549 void set_is_static(bool is_static = true);
00550
00551
00552
00553
00554
00555
00556
00562 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventCrossing* > signal_enter_notify_event();
00563
00564
00570 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventCrossing* > signal_leave_notify_event();
00571
00572
00578 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventMotion* > signal_motion_notify_event();
00579
00580
00586 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventButton* > signal_button_press_event();
00587
00588
00594 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventButton* > signal_button_release_event();
00595
00596
00602 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventFocus* > signal_focus_in_event();
00603
00604
00610 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventFocus* > signal_focus_out_event();
00611
00612
00618 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventKey* > signal_key_press_event();
00619
00620
00626 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventKey* > signal_key_release_event();
00627
00628
00634 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventGrabBroken* > signal_grab_broken_event();
00635
00636
00642 Glib::SignalProxy1< void,GParamSpec* > signal_child_notify();
00643
00644
00650 Glib::SignalProxy1< void,bool > signal_animation_finished();
00651
00652
00653 #ifdef GLIBMM_PROPERTIES_ENABLED
00654
00660 Glib::PropertyProxy< Glib::RefPtr<Item> > property_parent() ;
00661 #endif //#GLIBMM_PROPERTIES_ENABLED
00662
00663 #ifdef GLIBMM_PROPERTIES_ENABLED
00664
00670 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Item> > property_parent() const;
00671 #endif //#GLIBMM_PROPERTIES_ENABLED
00672
00673 #ifdef GLIBMM_PROPERTIES_ENABLED
00674
00680 Glib::PropertyProxy<ItemVisibility> property_visibility() ;
00681 #endif //#GLIBMM_PROPERTIES_ENABLED
00682
00683 #ifdef GLIBMM_PROPERTIES_ENABLED
00684
00690 Glib::PropertyProxy_ReadOnly<ItemVisibility> property_visibility() const;
00691 #endif //#GLIBMM_PROPERTIES_ENABLED
00692
00693 #ifdef GLIBMM_PROPERTIES_ENABLED
00694
00700 Glib::PropertyProxy<double> property_visibility_threshold() ;
00701 #endif //#GLIBMM_PROPERTIES_ENABLED
00702
00703 #ifdef GLIBMM_PROPERTIES_ENABLED
00704
00710 Glib::PropertyProxy_ReadOnly<double> property_visibility_threshold() const;
00711 #endif //#GLIBMM_PROPERTIES_ENABLED
00712
00713 #ifdef GLIBMM_PROPERTIES_ENABLED
00714
00720 Glib::PropertyProxy<Cairo::Matrix*> property_transform() ;
00721 #endif //#GLIBMM_PROPERTIES_ENABLED
00722
00723 #ifdef GLIBMM_PROPERTIES_ENABLED
00724
00730 Glib::PropertyProxy_ReadOnly<Cairo::Matrix*> property_transform() const;
00731 #endif //#GLIBMM_PROPERTIES_ENABLED
00732
00733 #ifdef GLIBMM_PROPERTIES_ENABLED
00734
00740 Glib::PropertyProxy<PointerEvents> property_pointer_events() ;
00741 #endif //#GLIBMM_PROPERTIES_ENABLED
00742
00743 #ifdef GLIBMM_PROPERTIES_ENABLED
00744
00750 Glib::PropertyProxy_ReadOnly<PointerEvents> property_pointer_events() const;
00751 #endif //#GLIBMM_PROPERTIES_ENABLED
00752
00753 #ifdef GLIBMM_PROPERTIES_ENABLED
00754
00760 Glib::PropertyProxy<Glib::ustring> property_title() ;
00761 #endif //#GLIBMM_PROPERTIES_ENABLED
00762
00763 #ifdef GLIBMM_PROPERTIES_ENABLED
00764
00770 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_title() const;
00771 #endif //#GLIBMM_PROPERTIES_ENABLED
00772
00773 #ifdef GLIBMM_PROPERTIES_ENABLED
00774
00780 Glib::PropertyProxy<Glib::ustring> property_description() ;
00781 #endif //#GLIBMM_PROPERTIES_ENABLED
00782
00783 #ifdef GLIBMM_PROPERTIES_ENABLED
00784
00790 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_description() const;
00791 #endif //#GLIBMM_PROPERTIES_ENABLED
00792
00793 #ifdef GLIBMM_PROPERTIES_ENABLED
00794
00800 Glib::PropertyProxy<bool> property_can_focus() ;
00801 #endif //#GLIBMM_PROPERTIES_ENABLED
00802
00803 #ifdef GLIBMM_PROPERTIES_ENABLED
00804
00810 Glib::PropertyProxy_ReadOnly<bool> property_can_focus() const;
00811 #endif //#GLIBMM_PROPERTIES_ENABLED
00812
00813
00814 protected:
00815
00816
00817
00818 #ifdef GLIBMM_VFUNCS_ENABLED
00819 virtual int get_n_children_vfunc() const;
00820 #endif //GLIBMM_VFUNCS_ENABLED
00821
00822 #ifdef GLIBMM_VFUNCS_ENABLED
00823 virtual Glib::RefPtr<Item> get_child_vfunc(int child_num) const;
00824 #endif //GLIBMM_VFUNCS_ENABLED
00825
00826 #ifdef GLIBMM_VFUNCS_ENABLED
00827 virtual void request_update_vfunc();
00828 #endif //GLIBMM_VFUNCS_ENABLED
00829
00830 #ifdef GLIBMM_VFUNCS_ENABLED
00831 virtual Canvas* get_canvas_vfunc() const;
00832 #endif //GLIBMM_VFUNCS_ENABLED
00833
00834 #ifdef GLIBMM_VFUNCS_ENABLED
00835 virtual void set_canvas_vfunc(Canvas* canvas);
00836 #endif //GLIBMM_VFUNCS_ENABLED
00837
00838
00839
00840
00841 #ifdef GLIBMM_VFUNCS_ENABLED
00842 virtual void add_child_vfunc(const Glib::RefPtr<Item>& child, int position);
00843 #endif //GLIBMM_VFUNCS_ENABLED
00844
00845 #ifdef GLIBMM_VFUNCS_ENABLED
00846 virtual void move_child_vfunc(int old_position, int new_position);
00847 #endif //GLIBMM_VFUNCS_ENABLED
00848
00849 #ifdef GLIBMM_VFUNCS_ENABLED
00850 virtual void remove_child_vfunc(int child_num);
00851 #endif //GLIBMM_VFUNCS_ENABLED
00852
00853 #ifdef GLIBMM_VFUNCS_ENABLED
00854 virtual void get_child_property_vfunc(const Glib::RefPtr<Item>& child, guint property_id, Glib::ValueBase& value, GParamSpec* pspec) const;
00855 #endif //GLIBMM_VFUNCS_ENABLED
00856
00857 #ifdef GLIBMM_VFUNCS_ENABLED
00858 virtual void set_child_property_vfunc(const Glib::RefPtr<Item>& child, guint property_id, const Glib::ValueBase& value, GParamSpec* pspec);
00859 #endif //GLIBMM_VFUNCS_ENABLED
00860
00861 #ifdef GLIBMM_VFUNCS_ENABLED
00862 virtual bool get_transform_for_child_vfunc(const Glib::RefPtr<Item>& child, Cairo::Matrix* transform) const;
00863 #endif //GLIBMM_VFUNCS_ENABLED
00864
00865
00866
00867
00868 #ifdef GLIBMM_VFUNCS_ENABLED
00869 virtual Glib::RefPtr<Item> get_parent_vfunc() const;
00870 #endif //GLIBMM_VFUNCS_ENABLED
00871
00872 #ifdef GLIBMM_VFUNCS_ENABLED
00873 virtual void set_parent_vfunc(const Glib::RefPtr<Item>& parent);
00874 #endif //GLIBMM_VFUNCS_ENABLED
00875
00876
00877 #ifdef GLIBMM_VFUNCS_ENABLED
00878
00879 virtual void get_bounds_vfunc(Bounds& bounds) const;
00880 virtual Glib::ListHandle<Glib::RefPtr<Item> > get_items_at_vfunc(double x, double y, const Cairo::RefPtr<Cairo::Context>& context, bool is_pointer_event, bool is_parent_visible, const Glib::ListHandle<Glib::RefPtr<Item> >& found_items);
00881 #endif
00882
00883
00884 #ifdef GLIBMM_VFUNCS_ENABLED
00885 virtual void update_vfunc(bool entire_tree, const Cairo::RefPtr<Cairo::Context>& cr, Bounds& bounds);
00886 #endif //GLIBMM_VFUNCS_ENABLED
00887
00888
00889 #ifdef GLIBMM_VFUNCS_ENABLED
00890 virtual void paint_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, const Bounds& bounds, double scale);
00891 #endif //GLIBMM_VFUNCS_ENABLED
00892
00893
00894 #ifdef GLIBMM_VFUNCS_ENABLED
00895 virtual bool get_requested_area_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, GooCanvasBounds* requested_area) const;
00896 #endif //GLIBMM_VFUNCS_ENABLED
00897
00898 #ifdef GLIBMM_VFUNCS_ENABLED
00899 virtual void allocate_area_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, const Bounds& requested_area, const Bounds& allocated_area, double x_offset, double y_offset);
00900 #endif //GLIBMM_VFUNCS_ENABLED
00901
00902
00903
00904
00905 #ifdef GLIBMM_VFUNCS_ENABLED
00906 virtual bool get_transform_vfunc(Cairo::Matrix* transform) const;
00907 #endif //GLIBMM_VFUNCS_ENABLED
00908
00909 #ifdef GLIBMM_VFUNCS_ENABLED
00910 virtual void set_transform_vfunc(const Cairo::Matrix* transform);
00911 #endif //GLIBMM_VFUNCS_ENABLED
00912
00913
00914 #ifdef GLIBMM_VFUNCS_ENABLED
00915 virtual Glib::RefPtr<Style> get_style_vfunc() const;
00916 #endif //GLIBMM_VFUNCS_ENABLED
00917
00918 #ifdef GLIBMM_VFUNCS_ENABLED
00919 virtual void set_style_vfunc(const Glib::RefPtr<Style>& style);
00920 #endif //GLIBMM_VFUNCS_ENABLED
00921
00922 #ifdef GLIBMM_VFUNCS_ENABLED
00923 virtual bool is_visible_vfunc() const;
00924 #endif //GLIBMM_VFUNCS_ENABLED
00925
00926 #ifdef GLIBMM_VFUNCS_ENABLED
00927 virtual double get_requested_height_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, double width);
00928 #endif //GLIBMM_VFUNCS_ENABLED
00929
00930 #ifdef GLIBMM_VFUNCS_ENABLED
00931 virtual bool get_is_static_vfunc() const;
00932 #endif //GLIBMM_VFUNCS_ENABLED
00933
00934 #ifdef GLIBMM_VFUNCS_ENABLED
00935 virtual void set_is_static_vfunc(bool is_static);
00936 #endif //GLIBMM_VFUNCS_ENABLED
00937
00938
00939
00940
00941
00942 #ifdef GLIBMM_VFUNCS_ENABLED
00943 virtual Glib::RefPtr<ItemModel> get_model_vfunc() const;
00944 #endif //GLIBMM_VFUNCS_ENABLED
00945
00946 #ifdef GLIBMM_VFUNCS_ENABLED
00947 virtual void set_model_vfunc(const Glib::RefPtr<ItemModel>& model);
00948 #endif //GLIBMM_VFUNCS_ENABLED
00949
00950
00951 public:
00952
00953 public:
00954
00955 #ifdef GLIBMM_VFUNCS_ENABLED
00956 #endif //GLIBMM_VFUNCS_ENABLED
00957
00958 protected:
00959
00960 #ifdef GLIBMM_VFUNCS_ENABLED
00961 #endif //GLIBMM_VFUNCS_ENABLED
00962
00963
00964 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00965 virtual bool on_enter_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event);
00966 virtual bool on_leave_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event);
00967 virtual bool on_motion_notify_event(const Glib::RefPtr<Item>& target, GdkEventMotion* event);
00968 virtual bool on_button_press_event(const Glib::RefPtr<Item>& target, GdkEventButton* event);
00969 virtual bool on_button_release_event(const Glib::RefPtr<Item>& target, GdkEventButton* event);
00970 virtual bool on_focus_in_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event);
00971 virtual bool on_focus_out_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event);
00972 virtual bool on_key_press_event(const Glib::RefPtr<Item>& target, GdkEventKey* event);
00973 virtual bool on_key_release_event(const Glib::RefPtr<Item>& target, GdkEventKey* event);
00974 virtual bool on_grab_broken_event(const Glib::RefPtr<Item>& target, GdkEventGrabBroken* event);
00975 virtual void on_child_notify(GParamSpec* pspec);
00976 virtual void on_animation_finished(bool stopped);
00977 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00978
00979
00980 };
00981
00982 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00983
00984 template <class PropertyType>
00985 void Item::get_child_property(const Glib::RefPtr<Item>& child, const Glib::ustring& the_property_name, PropertyType& value) const
00986 {
00987 Glib::Value<PropertyType> property_value;
00988 property_value.init(Glib::Value<PropertyType>::value_type());
00989
00990 this->get_child_property_value(child, the_property_name, property_value);
00991
00992 value = property_value.get();
00993 }
00994
00995 template <class PropertyType>
00996 void Item::set_child_property(const Glib::RefPtr<Item>& child, const Glib::ustring& the_property_name, const PropertyType& value)
00997 {
00998 Glib::Value<PropertyType> property_value;
00999 property_value.init(Glib::Value<PropertyType>::value_type());
01000 property_value.set(value);
01001
01002 this->set_child_property_value(child, the_property_name, property_value);
01003 }
01004
01005
01006 #endif
01007
01008 }
01009
01010
01011 namespace Glib
01012 {
01021 Glib::RefPtr<Goocanvas::Item> wrap(GooCanvasItem* object, bool take_copy = false);
01022
01023 }
01024
01025
01026 #endif
01027