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/style.h>
00029 #include <cairomm/cairomm.h>
00030 #include <goocanvasitem.h>
00031
00032
00033 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00034 extern "C" { typedef union _GooCanvasPathCommand GooCanvasPathCommand; }
00035 #endif
00036
00037 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00038 typedef struct _GooCanvasItem GooCanvasItem;
00039 typedef struct _GooCanvasItemClass GooCanvasItemClass;
00040 #endif
00041
00042
00043 namespace Goocanvas
00044 { class Item_Class; }
00045 namespace Goocanvas
00046 {
00047
00048
00062 enum PointerEvents
00063 {
00064 CANVAS_EVENTS_VISIBLE_MASK = 1 << 0,
00065 CANVAS_EVENTS_PAINTED_MASK = 1 << 1,
00066 CANVAS_EVENTS_FILL_MASK = 1 << 2,
00067 CANVAS_EVENTS_STROKE_MASK = 1 << 3,
00068 CANVAS_EVENTS_NONE = 0,
00069 CANVAS_EVENTS_VISIBLE_PAINTED = 0x1,
00070 CANVAS_EVENTS_VISIBLE_FILL = 0x1,
00071 CANVAS_EVENTS_VISIBLE_STROKE = 0x1,
00072 CANVAS_EVENTS_VISIBLE = 0x1,
00073 CANVAS_EVENTS_PAINTED = 0x2,
00074 CANVAS_EVENTS_FILL = 0x4,
00075 CANVAS_EVENTS_STROKE = 0x8,
00076 CANVAS_EVENTS_ALL = 0x4
00077 };
00078
00080 inline PointerEvents operator|(PointerEvents lhs, PointerEvents rhs)
00081 { return static_cast<PointerEvents>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
00082
00084 inline PointerEvents operator&(PointerEvents lhs, PointerEvents rhs)
00085 { return static_cast<PointerEvents>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
00086
00088 inline PointerEvents operator^(PointerEvents lhs, PointerEvents rhs)
00089 { return static_cast<PointerEvents>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
00090
00092 inline PointerEvents operator~(PointerEvents flags)
00093 { return static_cast<PointerEvents>(~static_cast<unsigned>(flags)); }
00094
00096 inline PointerEvents& operator|=(PointerEvents& lhs, PointerEvents rhs)
00097 { return (lhs = static_cast<PointerEvents>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
00098
00100 inline PointerEvents& operator&=(PointerEvents& lhs, PointerEvents rhs)
00101 { return (lhs = static_cast<PointerEvents>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
00102
00104 inline PointerEvents& operator^=(PointerEvents& lhs, PointerEvents rhs)
00105 { return (lhs = static_cast<PointerEvents>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
00106
00107 }
00108
00109
00110 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00111 namespace Glib
00112 {
00113
00114 template <>
00115 class Value<Goocanvas::PointerEvents> : public Glib::Value_Flags<Goocanvas::PointerEvents>
00116 {
00117 public:
00118 static GType value_type() G_GNUC_CONST;
00119 };
00120
00121 }
00122 #endif
00123
00124
00125 namespace Goocanvas
00126 {
00127
00131 enum ItemVisibility
00132 {
00133 CANVAS_ITEM_HIDDEN,
00134 CANVAS_ITEM_INVISIBLE,
00135 CANVAS_ITEM_VISIBLE,
00136 CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
00137 };
00138
00139 }
00140
00141
00142 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00143 namespace Glib
00144 {
00145
00146 template <>
00147 class Value<Goocanvas::ItemVisibility> : public Glib::Value_Enum<Goocanvas::ItemVisibility>
00148 {
00149 public:
00150 static GType value_type() G_GNUC_CONST;
00151 };
00152
00153 }
00154 #endif
00155
00156
00157 namespace Goocanvas
00158 {
00159
00160
00161 class Canvas ;
00162 class ItemModel ;
00163
00164
00165 class Item : public Glib::Interface
00166 {
00167
00168 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00169
00170 public:
00171 typedef Item CppObjectType;
00172 typedef Item_Class CppClassType;
00173 typedef GooCanvasItem BaseObjectType;
00174 typedef GooCanvasItemIface BaseClassType;
00175
00176 private:
00177 friend class Item_Class;
00178 static CppClassType item_class_;
00179
00180
00181 Item(const Item&);
00182 Item& operator=(const Item&);
00183
00184 protected:
00185 Item();
00186
00187 public:
00188
00189
00190
00191 explicit Item(GooCanvasItem* castitem);
00192
00193 protected:
00194 #endif
00195
00196 public:
00197 virtual ~Item();
00198
00199 static void add_interface(GType gtype_implementer);
00200
00201 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00202 static GType get_type() G_GNUC_CONST;
00203 static GType get_base_type() G_GNUC_CONST;
00204 #endif
00205
00207 GooCanvasItem* gobj() { return reinterpret_cast<GooCanvasItem*>(gobject_); }
00208
00210 const GooCanvasItem* gobj() const { return reinterpret_cast<GooCanvasItem*>(gobject_); }
00211
00212 private:
00213
00214
00215 public:
00216
00217
00218 Canvas* get_canvas();
00219
00220 const Canvas* get_canvas() const;
00221
00222 void set_canvas(Canvas* canvas);
00223
00224
00225 bool is_visible() const;
00226
00227
00228 Glib::RefPtr<ItemModel> get_model();
00229
00230 Glib::RefPtr<const ItemModel> get_model() const;
00231
00232 void set_model(const Glib::RefPtr<ItemModel>& model);
00233
00234
00235 Glib::RefPtr<Item> get_parent();
00236
00237 Glib::RefPtr<const Item> get_parent() const;
00238
00239 void set_parent(const Glib::RefPtr<Item>& parent);
00240
00241 void remove();
00242
00243
00244 bool is_container() const;
00245
00246 int get_n_children() const;
00247
00248 Glib::RefPtr<Item> get_child(int child_num);
00249
00250 Glib::RefPtr<const Item> get_child(int child_num) const;
00251
00252 int find_child(const Glib::RefPtr<Item>& child);
00253
00254 void add_child(const Glib::RefPtr<Item>& child, int pos);
00255 void add_child(const Glib::RefPtr<Item>& child);
00256
00257
00258 void move_child(int old_position, int new_position);
00259
00260 void remove_child(int child_num);
00261
00262
00263 void raise(const Glib::RefPtr<Item>& above);
00264
00267 void raise();
00268
00269
00270 void lower(const Glib::RefPtr<Item>& below);
00271
00274 void lower();
00275
00276 Bounds get_bounds() const;
00277
00278
00279 void request_update();
00280
00281 void ensure_upated();
00282
00283 void update(bool entire_tree, const Cairo::RefPtr<Cairo::Context>& context, Bounds& bounds);
00284
00285 void paint(const Cairo::RefPtr<Cairo::Context>& context, const Bounds& bounds, double scale);
00286
00287 bool get_requested_area(const Cairo::RefPtr<Cairo::Context>& context, Bounds& bounds) const;
00288
00289 double get_requested_height(const Cairo::RefPtr<Cairo::Context>& context, double width) const;
00290
00291 void allocate_area(const Cairo::RefPtr<Cairo::Context>& context, const Bounds& requested_area, const Bounds& allocated_area, double x_offset, double y_offset);
00292
00293
00294 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);
00295
00296
00297
00298 bool get_transform(Cairo::Matrix* matrix);
00299
00300 void set_transform(const Cairo::Matrix* matrix);
00301
00302
00303 void set_simple_transform(double x, double y, double scale, double rotation);
00304
00305 void translate(double tx, double ty);
00306
00307 void scale(double sx, double sy);
00308
00309 void rotate(double degrees, double cx, double cy);
00310
00311 void skew_x(double degrees, double cx, double cy);
00312
00313 void skew_y(double degrees, double cx, double cy);
00314
00315
00316 bool get_transform_for_child(const Glib::RefPtr<Item>& child, Cairo::Matrix* transform);
00317
00318
00319 Glib::RefPtr<Style> get_style();
00320
00321 Glib::RefPtr<const Style> get_style() const;
00322
00323 void set_style(const Glib::RefPtr<Style>& style);
00324
00325
00326 void animate(double x, double y, double scale, double degrees, bool absolute, int duration, int step_time, GooCanvasAnimateType type);
00327
00328 void stop_animation();
00329
00330
00331
00332
00333
00334
00335
00336
00342 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventCrossing* > signal_enter_notify_event();
00343
00344
00350 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventCrossing* > signal_leave_notify_event();
00351
00352
00358 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventMotion* > signal_motion_notify_event();
00359
00360
00366 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventButton* > signal_button_press_event();
00367
00368
00374 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventButton* > signal_button_release_event();
00375
00376
00382 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventFocus* > signal_focus_in_event();
00383
00384
00390 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventFocus* > signal_focus_out_event();
00391
00392
00398 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventKey* > signal_key_press_event();
00399
00400
00406 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventKey* > signal_key_release_event();
00407
00408
00414 Glib::SignalProxy2< bool,const Glib::RefPtr<Item>&,GdkEventGrabBroken* > signal_grab_broken_event();
00415
00416
00422 Glib::SignalProxy1< void,GParamSpec* > signal_child_notify();
00423
00424
00425 #ifdef GLIBMM_PROPERTIES_ENABLED
00426
00432 Glib::PropertyProxy<bool> property_can_focus() ;
00433 #endif //#GLIBMM_PROPERTIES_ENABLED
00434
00435 #ifdef GLIBMM_PROPERTIES_ENABLED
00436
00442 Glib::PropertyProxy_ReadOnly<bool> property_can_focus() const;
00443 #endif //#GLIBMM_PROPERTIES_ENABLED
00444
00445 #ifdef GLIBMM_PROPERTIES_ENABLED
00446
00452 Glib::PropertyProxy<ItemVisibility> property_visibility() ;
00453 #endif //#GLIBMM_PROPERTIES_ENABLED
00454
00455 #ifdef GLIBMM_PROPERTIES_ENABLED
00456
00462 Glib::PropertyProxy_ReadOnly<ItemVisibility> property_visibility() const;
00463 #endif //#GLIBMM_PROPERTIES_ENABLED
00464
00465 #ifdef GLIBMM_PROPERTIES_ENABLED
00466
00472 Glib::PropertyProxy<Glib::ustring> property_description() ;
00473 #endif //#GLIBMM_PROPERTIES_ENABLED
00474
00475 #ifdef GLIBMM_PROPERTIES_ENABLED
00476
00482 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_description() const;
00483 #endif //#GLIBMM_PROPERTIES_ENABLED
00484
00485 #ifdef GLIBMM_PROPERTIES_ENABLED
00486
00492 Glib::PropertyProxy<double> property_visibility_threshold() ;
00493 #endif //#GLIBMM_PROPERTIES_ENABLED
00494
00495 #ifdef GLIBMM_PROPERTIES_ENABLED
00496
00502 Glib::PropertyProxy_ReadOnly<double> property_visibility_threshold() const;
00503 #endif //#GLIBMM_PROPERTIES_ENABLED
00504
00505 #ifdef GLIBMM_PROPERTIES_ENABLED
00506
00512 Glib::PropertyProxy<PointerEvents> property_pointer_events() ;
00513 #endif //#GLIBMM_PROPERTIES_ENABLED
00514
00515 #ifdef GLIBMM_PROPERTIES_ENABLED
00516
00522 Glib::PropertyProxy_ReadOnly<PointerEvents> property_pointer_events() const;
00523 #endif //#GLIBMM_PROPERTIES_ENABLED
00524
00525
00526 protected:
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575 ;
00576 #ifdef GLIBMM_VFUNCS_ENABLED
00577 virtual Glib::RefPtr<Item> get_parent_vfunc();
00578 #endif //GLIBMM_VFUNCS_ENABLED
00579
00580 #ifdef GLIBMM_VFUNCS_ENABLED
00581 virtual void set_parent_vfunc(const Glib::RefPtr<Item>& parent);
00582 #endif //GLIBMM_VFUNCS_ENABLED
00583
00584
00585 #ifdef GLIBMM_VFUNCS_ENABLED
00586 virtual void get_bounds_vfunc(GooCanvasBounds* bounds);
00587 #endif //GLIBMM_VFUNCS_ENABLED
00588
00589
00590
00591 #ifdef GLIBMM_VFUNCS_ENABLED
00592 virtual void update_vfunc(bool entire_tree, const Cairo::RefPtr<Cairo::Context>& cr, GooCanvasBounds* bounds);
00593 #endif //GLIBMM_VFUNCS_ENABLED
00594
00595
00596 ;
00597 #ifdef GLIBMM_VFUNCS_ENABLED
00598 virtual void paint_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, const Bounds& bounds, double scale);
00599 #endif //GLIBMM_VFUNCS_ENABLED
00600
00601
00602 #ifdef GLIBMM_VFUNCS_ENABLED
00603 virtual bool get_requested_area_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, GooCanvasBounds* requested_area);
00604 #endif //GLIBMM_VFUNCS_ENABLED
00605
00606 #ifdef GLIBMM_VFUNCS_ENABLED
00607 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);
00608 #endif //GLIBMM_VFUNCS_ENABLED
00609
00610
00611
00612
00613 #ifdef GLIBMM_VFUNCS_ENABLED
00614 virtual bool get_transform_vfunc(cairo_matrix_t* transform);
00615 #endif //GLIBMM_VFUNCS_ENABLED
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631 public:
00632
00633 public:
00634
00635 #ifdef GLIBMM_VFUNCS_ENABLED
00636 #endif //GLIBMM_VFUNCS_ENABLED
00637
00638 protected:
00639
00640 #ifdef GLIBMM_VFUNCS_ENABLED
00641 #endif //GLIBMM_VFUNCS_ENABLED
00642
00643
00644 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00645 virtual bool on_enter_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event);
00646 virtual bool on_leave_notify_event(const Glib::RefPtr<Item>& target, GdkEventCrossing* event);
00647 virtual bool on_motion_notify_event(const Glib::RefPtr<Item>& target, GdkEventMotion* event);
00648 virtual bool on_button_press_event(const Glib::RefPtr<Item>& target, GdkEventButton* event);
00649 virtual bool on_button_release_event(const Glib::RefPtr<Item>& target, GdkEventButton* event);
00650 virtual bool on_focus_in_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event);
00651 virtual bool on_focus_out_event(const Glib::RefPtr<Item>& target, GdkEventFocus* event);
00652 virtual bool on_key_press_event(const Glib::RefPtr<Item>& target, GdkEventKey* event);
00653 virtual bool on_key_release_event(const Glib::RefPtr<Item>& target, GdkEventKey* event);
00654 virtual bool on_grab_broken_event(const Glib::RefPtr<Item>& target, GdkEventGrabBroken* event);
00655 virtual void on_child_notify(GParamSpec* pspec);
00656 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00657
00658
00659 };
00660
00661 }
00662
00663
00664 namespace Glib
00665 {
00674 Glib::RefPtr<Goocanvas::Item> wrap(GooCanvasItem* object, bool take_copy = false);
00675
00676 }
00677
00678
00679 #endif
00680