1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _LIBGNOMECANVASMM_ITEM_H
4 #define _LIBGNOMECANVASMM_ITEM_H
5 
6 
7 #include <glibmm.h>
8 
9 // -*- C++ -*-
10 /* $Id: item.hg,v 1.7 2005/06/09 11:26:34 murrayc Exp $ */
11 
12 /* item.h
13  *
14  * Copyright (C) 1998 EMC Capital Management Inc.
15  * Developed by Havoc Pennington <hp@pobox.com>
16  *
17  * Copyright (C) 1999 The Gtk-- Development Team
18  *
19  * This library is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU Lesser General Public
21  * License as published by the Free Software Foundation; either
22  * version 2.1 of the License, or (at your option) any later version.
23  *
24  * This library is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
27  * Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public
30  * License along with this library; if not, write to the Free
31  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32  */
33 
34 #include <gtkmm/object.h>
35 #include <gdkmm/cursor.h>
36 #include <libgnomecanvas/gnome-canvas.h>
37 
38 #include <libgnomecanvasmm/point.h>
39 #include <libgnomecanvasmm/affinetrans.h>
40 #include <libgnomecanvasmm/properties.h>
41 
42 
43 #ifndef DOXYGEN_SHOULD_SKIP_THIS
44 typedef struct _GnomeCanvasItem GnomeCanvasItem;
45 typedef struct _GnomeCanvasItemClass GnomeCanvasItemClass;
46 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
47 
48 
49 namespace Gnome
50 {
51 
52 namespace Canvas
53 { class Item_Class; } // namespace Canvas
54 
55 } // namespace Gnome
56 namespace Gnome
57 {
58 
59 namespace Canvas
60 {
61 
62 class Canvas;
63 class Group;
64 
65 
66 class Item : public Gtk::Object
67 {
68   public:
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70   typedef Item CppObjectType;
71   typedef Item_Class CppClassType;
72   typedef GnomeCanvasItem BaseObjectType;
73   typedef GnomeCanvasItemClass BaseClassType;
74 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
75 
76   virtual ~Item();
77 
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 
80 private:
81   friend class Item_Class;
82   static CppClassType item_class_;
83 
84   // noncopyable
85   Item(const Item&);
86   Item& operator=(const Item&);
87 
88 protected:
89   explicit Item(const Glib::ConstructParams& construct_params);
90   explicit Item(GnomeCanvasItem* castitem);
91 
92 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
93 
94 public:
95 #ifndef DOXYGEN_SHOULD_SKIP_THIS
96   static GType get_type()      G_GNUC_CONST;
97   static GType get_base_type() G_GNUC_CONST;
98 #endif
99 
100   ///Provides access to the underlying C GtkObject.
gobj()101   GnomeCanvasItem*       gobj()       { return reinterpret_cast<GnomeCanvasItem*>(gobject_); }
102 
103   ///Provides access to the underlying C GtkObject.
gobj()104   const GnomeCanvasItem* gobj() const { return reinterpret_cast<GnomeCanvasItem*>(gobject_); }
105 
106 
107 public:
108   //C++ methods used to invoke GTK+ virtual functions:
109 #ifdef GLIBMM_VFUNCS_ENABLED
110 #endif //GLIBMM_VFUNCS_ENABLED
111 
112 protected:
113   //GTK+ Virtual Functions (override these to change behaviour):
114 #ifdef GLIBMM_VFUNCS_ENABLED
115 #endif //GLIBMM_VFUNCS_ENABLED
116 
117   //Default Signal Handlers::
118 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
119   virtual bool on_event(GdkEvent* p1);
120 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
121 
122 
123 private:
124 
125 
126 public:
127 
128   //:  Move an item by the specified amount
129 
130   /** Moves a canvas item by creating an affine transformation matrix for
131    * translation by using the specified values. This happens in item
132    * local coordinate system, so if you have nontrivial transform, it
133    * most probably does not do, what you want.
134    * @param dx Horizontal offset.
135    * @param dy Vertical offset.
136    */
137   void move(double dx, double dy);
138 
139   //: Raise an item in the z-order of its parent group by the specified
140   //: number of positions.  If the number is zero, then the item will
141   //: be made the topmost of its parent group.
142 
143   /** Raises the item in its parent's stack by the specified number of positions.
144    * If the number of positions is greater than the distance to the top of the
145    * stack, then the item is put at the top.
146    * @param positions Number of steps to raise the item.
147    */
148   void raise(int positions);
149 
150   //: Lower an item in the z-order of its parent group by the specified
151   //: number of positions.  If the number is zero, then the item will be
152   //: made the bottommost of its parent group.  */
153 
154   /** Lowers the item in its parent's stack by the specified number of positions.
155    * If the number of positions is greater than the distance to the bottom of the
156    * stack, then the item is put at the bottom.
157    * @param positions Number of steps to lower the item.
158    */
159   void lower(int positions);
160 
161   //: Raise an item to the top of its parent group's z-order.
162 
163   /** Raises an item to the top of its parent's stack.
164    */
165   void raise_to_top();
166 
167   //: Lower an item to the bottom of its parent group's z-order
168 
169   /** Lowers an item to the bottom of its parent's stack.
170    */
171   void lower_to_bottom();
172 
173   //: Grab the mouse for the specified item.  Only the events in
174   //: event_mask will be reported.  If cursor is non-NULL, it will be
175   //: used during the duration of the grab.  Time is a proper X event
176   //: time parameter.  Returns the same values as XGrabPointer().
177   int grab(unsigned int event_mask, const Gdk::Cursor& cursor, guint32 etime);
178   int grab(unsigned int event_mask, guint32 etime);
179 
180 
181   //: Ungrabs the mouse -- the specified item must be the same that was
182   //: passed to gnome_canvas_item_grab().  Time is a proper X event
183   //: time parameter.
184 
185   /** Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
186    * mouse.
187    * @param etime The timestamp for ungrabbing the mouse.
188    */
189   void ungrab(guint32 etime);
190 
191   //: These functions convert from a coordinate system to another.  "w"
192   //: is world coordinates and "i" is item coordinates.
193 
194   /** Converts a coordinate pair from world coordinates to item-relative
195    * coordinates.
196    * @param x X coordinate to convert (input/output value).
197    * @param y Y coordinate to convert (input/output value).
198    */
199   void w2i(double& x, double& y);
200 
201   /** Converts a coordinate pair from item-relative coordinates to world
202    * coordinates.
203    * @param x X coordinate to convert (input/output value).
204    * @param y Y coordinate to convert (input/output value).
205    */
206   void i2w(double& x, double& y);
207 
208   //: Used to send all of the keystroke events to a specific item as well
209   //: as GDK_FOCUS_CHANGE events.
210 
211   /** Makes the specified item take the keyboard focus, so all keyboard events will
212    * be sent to it.  If the canvas widget itself did not have the focus, it grabs
213    * it as well.
214    */
215   void grab_focus();
216 
217   //: Fetch the bounding box of the item.  The bounding box may not be
218   //: exactly tight, but the canvas items will do the best they can.
219 
220   /** Queries the bounding box of a canvas item.  The bounds are returned in the
221    * coordinate system of the item's parent.
222    * @param x1 Leftmost edge of the bounding box (return value).
223    * @param y1 Upper edge of the bounding box (return value).
224    * @param x2 Rightmost edge of the bounding box (return value).
225    * @param y2 Lower edge of the bounding box (return value).
226    */
227   void get_bounds(double& x1, double& y1, double& x2, double& y2) const;
228 
229   //: Make the item visible
230 
231   /** Shows a canvas item.  If the item was already shown, then no action is taken.
232    */
233   void show();
234 
235   //: Hide the item
236 
237   /** Hides a canvas item.  If the item was already hidden, then no action is
238    * taken.
239    */
240   void hide();
241 
242   //: Apply a relative affine transformation to the item
243   void affine_relative(const Art::AffineTrans &affine);
244 
245 
246   //: Apply an absolute affine transformation to the item
247   void affine_absolute(const Art::AffineTrans &affine);
248 
249 
250   //: Gets the affine transform that converts from item-relative
251   //: coordinates to world coordinates
252   Art::AffineTrans get_i2w_affine() const;
253 
254 
255   //: Gets the affine transform that converts from item-relative
256   //: coordinates to canvas pixel coordinates
257   Art::AffineTrans get_i2c_affine() const;
258 
259 
260   /** Changes the parent of the specified item to be the new group.  The item keeps
261    * its group-relative coordinates as for its old parent, so the item may change
262    * its absolute position within the canvas.
263    * @param new_group A canvas group.
264    */
265   void reparent(Group& new_group);
266 
267   /// Returns the canvas we're on.
268    Canvas* get_canvas() const;
269 
270   #ifdef GLIBMM_VFUNCS_ENABLED
271   virtual void update_vfunc(double* affine, ArtSVP* clip_path, int flags);
272 #endif //GLIBMM_VFUNCS_ENABLED
273 
274   #ifdef GLIBMM_VFUNCS_ENABLED
275   virtual void realize_vfunc();
276 #endif //GLIBMM_VFUNCS_ENABLED
277 
278   #ifdef GLIBMM_VFUNCS_ENABLED
279   virtual void unrealize_vfunc();
280 #endif //GLIBMM_VFUNCS_ENABLED
281 
282   #ifdef GLIBMM_VFUNCS_ENABLED
283   virtual void map_vfunc();
284 #endif //GLIBMM_VFUNCS_ENABLED
285 
286   #ifdef GLIBMM_VFUNCS_ENABLED
287   virtual void unmap_vfunc();
288 #endif //GLIBMM_VFUNCS_ENABLED
289 
290   #ifdef GLIBMM_VFUNCS_ENABLED
291   virtual ArtUta* coverage_vfunc();
292 #endif //GLIBMM_VFUNCS_ENABLED
293 
294   #ifdef GLIBMM_VFUNCS_ENABLED
295   virtual void draw_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height);
296 #endif //GLIBMM_VFUNCS_ENABLED
297 
298   #ifdef GLIBMM_VFUNCS_ENABLED
299   virtual void render_vfunc(GnomeCanvasBuf* buf);
300 #endif //GLIBMM_VFUNCS_ENABLED
301 
302   #ifdef GLIBMM_VFUNCS_ENABLED
303   virtual double point_vfunc(double x, double y, int cx, int cy, GnomeCanvasItem** actual_item);
304 #endif //GLIBMM_VFUNCS_ENABLED
305 
306   #ifdef GLIBMM_VFUNCS_ENABLED
307   virtual void bounds_vfunc(double* x1, double* y1, double* x2, double* y2);
308 #endif //GLIBMM_VFUNCS_ENABLED
309 
310 
311   //: Signal: an event ocurred for an item of this type.  The(x, y)
312   //: coordinates are in the canvas world coordinate system.
313 
314   /**
315    * @par Prototype:
316    * <tt>bool on_my_%event(GdkEvent* p1)</tt>
317    */
318 
319   Glib::SignalProxy1< bool,GdkEvent* > signal_event();
320 
321 
322   Group* get_parent_group();
323   const Group* get_parent_group() const;
324 
325   #ifdef GLIBMM_PROPERTIES_ENABLED
326 /**
327    *
328    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
329    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
330    * the value of the property changes.
331    */
332   Glib::PropertyProxy<Group*> property_parent() ;
333 #endif //#GLIBMM_PROPERTIES_ENABLED
334 
335 #ifdef GLIBMM_PROPERTIES_ENABLED
336 /**
337    *
338    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
339    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
340    * the value of the property changes.
341    */
342   Glib::PropertyProxy_ReadOnly<Group*> property_parent() const;
343 #endif //#GLIBMM_PROPERTIES_ENABLED
344 
345 
346 protected:
347 
348   //- For class children use only
349   void item_construct(Group& group);
350 
351   //- Unsafe version - can't use a _gtk_string here, C++ doesn't like
352   //- classes being passed before ellipses('...') args
353   void item_construct(Group& group, const gchar* first_arg_name,
354                       va_list ap);
355 
356   //- Set arguments - For class children use only
357   void set(const gchar* first_arg_name, ...);
358 
359   //: Request that the update method eventually get called.  This should be used
360   //: only by item implementations.
361 
362   /** To be used only by item implementations.  Requests that the canvas queue an
363    * update for the specified item.
364    */
365   void request_update();
366 
367 
368   /** Resets the bounding box of a canvas item to an empty rectangle.
369    */
370   void reset_bounds();
371 
372   /** Sets the svp to the new value, requesting repaint on what's changed. This
373    * function takes responsibility for freeing new_svp. This routine also adds the
374    * svp's bbox to the item's.
375    * @param p_svp A pointer to the existing svp.
376    * @param new_svp The new svp.
377    */
378   void update_svp(ArtSVP **p_svp, ArtSVP *new_svp);
379 
380   /** Sets the svp to the new value, clipping if necessary, and requesting repaint
381    * on what's changed. This function takes responsibility for freeing new_svp.
382    * @param p_svp A pointer to the existing svp.
383    * @param new_svp The new svp.
384    * @param clip_svp A clip path, if non-null.
385    */
386   void update_svp_clip(ArtSVP **p_svp, ArtSVP *new_svp, ArtSVP *clip_svp);
387 
388   /** Request redraw of the svp if in aa mode, or the entire item in in xlib mode.
389    * @param svp The svp that needs to be redrawn.
390    */
391   void request_redraw_svp(const ArtSVP* svp);
392 
393   /** Sets the bbox to the new value, requesting full repaint.
394    * @param item The canvas item needing update.
395    * @param x1 Left coordinate of the new bounding box.
396    * @param y1 Top coordinate of the new bounding box.
397    * @param x2 Right coordinate of the new bounding box.
398    * @param y2 Bottom coordinate of the new bounding box.
399    */
400   void update_bbox(int x1, int y1, int x2, int y2);
401 
402 
403 };
404 
405 } /* namespace Canvas */
406 } /* namespace Gnome */
407 
408 
409 namespace Glib
410 {
411   /** A Glib::wrap() method for this object.
412    *
413    * @param object The C instance.
414    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
415    * @result A C++ instance that wraps this C instance.
416    *
417    * @relates Gnome::Canvas::Item
418    */
419   Gnome::Canvas::Item* wrap(GnomeCanvasItem* object, bool take_copy = false);
420 } //namespace Glib
421 
422 
423 #endif /* _LIBGNOMECANVASMM_ITEM_H */
424 
425