libgnomecanvasmm
canvas.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _LIBGNOMECANVASMM_CANVAS_H
4 #define _LIBGNOMECANVASMM_CANVAS_H
5 
6 
7 #include <glibmm.h>
8 
9 // -*- C++ -*-
10 /* $Id: canvas.hg,v 1.20 2005/06/08 16:21:02 murrayc Exp $ */
11 
12 /* canvas.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 <libgnomecanvas/gnome-canvas.h>
36 #include <gtkmm/layout.h>
37 #include <gdkmm/color.h>
38 
39 
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 typedef struct _GnomeCanvas GnomeCanvas;
42 typedef struct _GnomeCanvasClass GnomeCanvasClass;
43 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
44 
45 
46 namespace Gnome
47 {
48 
49 namespace Canvas
50 { class Canvas_Class; } // namespace Canvas
51 
52 } // namespace Gnome
53 namespace Gnome
54 {
55 
56 namespace Canvas
57 {
58 
59 class Item;
60 class Group;
61 
68 class Canvas : public Gtk::Layout
69 {
70  public:
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72  typedef Canvas CppObjectType;
73  typedef Canvas_Class CppClassType;
74  typedef GnomeCanvas BaseObjectType;
75  typedef GnomeCanvasClass BaseClassType;
76 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
77 
78  virtual ~Canvas();
79 
80 #ifndef DOXYGEN_SHOULD_SKIP_THIS
81 
82 protected:
83  friend class Canvas_Class;
84  static CppClassType canvas_class_;
85 
86  // noncopyable
87  Canvas(const Canvas&);
88  Canvas& operator=(const Canvas&);
89 
90 protected:
91  explicit Canvas(const Glib::ConstructParams& construct_params);
92  explicit Canvas(GnomeCanvas* castitem);
93 
94 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
95 
96 public:
97 #ifndef DOXYGEN_SHOULD_SKIP_THIS
98  static GType get_type() G_GNUC_CONST;
99  static GType get_base_type() G_GNUC_CONST;
100 #endif
101 
103  GnomeCanvas* gobj() { return reinterpret_cast<GnomeCanvas*>(gobject_); }
104 
106  const GnomeCanvas* gobj() const { return reinterpret_cast<GnomeCanvas*>(gobject_); }
107 
108 
109 public:
110  //C++ methods used to invoke GTK+ virtual functions:
111 #ifdef GLIBMM_VFUNCS_ENABLED
112 #endif //GLIBMM_VFUNCS_ENABLED
113 
114 protected:
115  //GTK+ Virtual Functions (override these to change behaviour):
116 #ifdef GLIBMM_VFUNCS_ENABLED
117 #endif //GLIBMM_VFUNCS_ENABLED
118 
119  //Default Signal Handlers::
120 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
121  virtual void on_draw_background(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height);
122  virtual void on_render_background(GnomeCanvasBuf* buf);
123 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
124 
125 
126 private:
127 
128 public:
129  Canvas();
130 
131  //Allow CanvasAA to access the canvas_class_ member.
132 
133 
134  //: Get the root canvas item
135 
139  Group* root() const;
140 
141  //: Limits of scroll region
142 
151  void set_scroll_region(double x1, double y1, double x2, double y2);
152 
153  //: Get limits of scroll region
154 
161  void get_scroll_region(double& x1, double& y1, double& x2, double& y2) const;
162 
163 
171  void set_center_scroll_region(bool center);
172 
173 
178  bool get_center_scroll_region() const;
179 
180  //: Set the pixels/world coordinates ratio
181  //- With no arguments sets to default of 1.0.
182 
195  void set_pixels_per_unit(double n = 1.0);
196 
197  //: Shift window.
198  //- Makes a canvas scroll to the specified offsets, given in canvas pixel
199  //- units.
200  //- The canvas will adjust the view so that it is not outside the scrolling
201  //- region. This function is typically not used, as it is better to hook
202  //- scrollbars to the canvas layout's scrolling adjusments.
203 
211  void scroll_to(int x, int y);
212 
213  //: Scroll offsets in canvas pixel coordinates.
214 
220  void get_scroll_offsets(int& cx, int& cy) const;
221 
222  //: Repaint immediately, don't wait for idle loop
223  //- normally the canvas queues repainting and does it in an
224  //- idle loop
225 
231  void update_now();
232 
233  //: Find an item at a location.
234  //- Looks for the item that is under the specified position, which must be
235  //- specified in world coordinates. Arguments are in world coordinates.
236  //- Returns 0 if no item is at that
237  //- location.
238 
246  Item* get_item_at(double x, double y) const;
247 
248 
249  //: Repaint small area (internal)
250  //- Used only by item implementations. Request an eventual redraw
251  //- of the region, which includes x1,y1 but not x2,y2
252 
262  void request_redraw(int x1, int y1, int x2, int y2);
263  //TODO: Investigate ArtUta.
264 
271  void request_redraw(ArtUta* uta);
272 
274 
275 
276  //: Convert from World to canvas coordinates (units for the entire canvas)
277  //: to Canvas coordinates (pixels starting at 0,0 in the top left
278  //: of the visible area). The relationship depends on the current
279  //: scroll position and the pixels_per_unit ratio (zoom factor)
280 
287  void w2c(double wx, double wy, int& cx, int& cy) const;
288 
296  void w2c(double wx, double wy, double& cx, double& cy) const;
297 
298  //: From Canvas to World
299 
306  void c2w(int cx, int cy, double& wx, double& wy) const;
307 
308  //: Convert from Window coordinates to world coordinates.
309  //- Window coordinates are based of the widget's GdkWindow.
310  //- This is fairly low-level and not generally useful.
311 
320  void window_to_world (double winx,double winy, double& worldx,double& worldy) const;
321 
322  //: Convert from world coordinates to Window coordinates.
323  //- Window coordinates are based of the widget's GdkWindow.
324  //- This is fairly low-level and not generally useful.
325 
332  void world_to_window (double worldx, double worldy, double& winx, double& winy) const;
333 
334  //: Parse color spec string and allocate it into the GdkColor.
335  bool get_color(const Glib::ustring& spec, Gdk::Color& color) const;
336 
337 
338 /* Allocates a color from the RGB value passed into this function. */
339 
345  gulong get_color_pixel(guint rgba) const;
346 
352  void set_stipple_origin(const Glib::RefPtr<Gdk::GC>& gc);
353 
360  void set_dither(Gdk::RgbDither dither);
361 
365  Gdk::RgbDither get_dither() const;
366 
367 
368  //TODO: Look at ArtSVP.
369 
375  void update_svp(ArtSVP** p_svp, ArtSVP* new_svp);
376 
383  void update_svp_clip(ArtSVP** p_svp, ArtSVP* new_svp, ArtSVP* clip_svp);
384 
385  // The following are simply accessed via the struct in C,
386  // but Federico reports that they are meant to be used.
387  //: Get the pixels per unit.
388  double get_pixels_per_unit() const;
389 
390  //: Draw the background for the area given.
391  //- This method is only used for non-antialiased canvases.
392 
398  Glib::SignalProxy5< void,const Glib::RefPtr<Gdk::Drawable>&,int,int,int,int > signal_draw_background();
399 
400  // Render the background for the buffer given.
401  //- The buf data structure contains both a pointer to a packed 24-bit
402  //- RGB array, and the coordinates.
403  //- This method is only used for antialiased canvases.
404 
410  Glib::SignalProxy1< void,GnomeCanvasBuf* > signal_render_background();
411 
412  //: Private Virtual methods for groping the canvas inside bonobo.
413  #ifdef GLIBMM_VFUNCS_ENABLED
414  virtual void request_update_vfunc();
415 #endif //GLIBMM_VFUNCS_ENABLED
416 
417 
418  // Whether the canvas is in antialiased mode or not.
419  #ifdef GLIBMM_PROPERTIES_ENABLED
420 
426  Glib::PropertyProxy_ReadOnly<bool> property_aa() const;
427 #endif //#GLIBMM_PROPERTIES_ENABLED
428 
429 
430 };
431 
432 //: Antialiased Canvas.
433 //- Constructor takes care of push/pop actions of the colormap.
434 class CanvasAA : public Canvas
435 {
436  public:
437  CanvasAA();
438  explicit CanvasAA(GnomeCanvas* castitem);
439  virtual ~CanvasAA();
440 };
441 
442 } /* namespace Canvas */
443 } /* namespace Gnome */
444 
445 
446 namespace Glib
447 {
456  Gnome::Canvas::Canvas* wrap(GnomeCanvas* object, bool take_copy = false);
457 } //namespace Glib
458 
459 
460 #endif /* _LIBGNOMECANVASMM_CANVAS_H */
461 
void set_pixels_per_unit(double n=1.0)
Sets the zooming factor of a canvas by specifying the number of pixels that correspond to one canvas ...
double get_pixels_per_unit() const
Group * root() const
Queries the root group of a canvas.
Definition: bpath.h:149
Definition: affinetrans.h:29
Art::AffineTrans w2c_affine() const
void update_now()
Forces an immediate update and redraw of a canvas.
gulong get_color_pixel(guint rgba) const
Allocates a color from the RGBA value passed into this function.
void get_scroll_region(double &x1, double &y1, double &x2, double &y2) const
Queries the scrolling region of a canvas.
Glib::PropertyProxy_ReadOnly< bool > property_aa() const
The antialiasing mode of the canvas.
Definition: affinetrans.h:36
void world_to_window(double worldx, double worldy, double &winx, double &winy) const
Converts world coordinates into window-relative coordinates.
Definition: canvas.h:434
void get_scroll_offsets(int &cx, int &cy) const
Queries the scrolling offsets of a canvas.
void update_svp(ArtSVP **p_svp, ArtSVP *new_svp)
Sets the svp to the new value, requesting repaint on what's changed.
virtual void on_draw_background(const Glib::RefPtr< Gdk::Drawable > &drawable, int x, int y, int width, int height)
virtual void on_render_background(GnomeCanvasBuf *buf)
Glib::SignalProxy1< void, GnomeCanvasBuf * > signal_render_background()
void set_stipple_origin(const Glib::RefPtr< Gdk::GC > &gc)
Sets the stipple origin of the specified GC as is appropriate for the canvas, so that it will be alig...
Definition: item.h:66
Definition: group.h:59
void w2c(double wx, double wy, int &cx, int &cy) const
Converts world coordinates into canvas pixel coordinates.
virtual void request_update_vfunc()
const GnomeCanvas * gobj() const
Provides access to the underlying C GtkObject.
Definition: canvas.h:106
void set_dither(Gdk::RgbDither dither)
Controls dithered rendering for antialiased canvases.
void window_to_world(double winx, double winy, double &worldx, double &worldy) const
Converts window-relative coordinates into world coordinates.
Item * get_item_at(double x, double y) const
Looks for the item that is under the specified position, which must be specified in world coordinates...
Glib::SignalProxy5< void, const Glib::RefPtr< Gdk::Drawable > &, int, int, int, int > signal_draw_background()
bool get_color(const Glib::ustring &spec, Gdk::Color &color) const
Canvas functions usually operate in either World coordinates (units for the entire canvas)...
Definition: canvas.h:68
void set_scroll_region(double x1, double y1, double x2, double y2)
Sets the scrolling region of a canvas to the specified rectangle.
GnomeCanvas * gobj()
Provides access to the underlying C GtkObject.
Definition: canvas.h:103
void scroll_to(int x, int y)
Makes a canvas scroll to the specified offsets, given in canvas pixel units.
void request_redraw(int x1, int y1, int x2, int y2)
Convenience function that informs a canvas that the specified rectangle needs to be repainted...
bool get_center_scroll_region() const
Returns whether the canvas is set to center the scrolling region in the window if the former is small...
void c2w(int cx, int cy, double &wx, double &wy) const
Converts canvas pixel coordinates to world coordinates.
void update_svp_clip(ArtSVP **p_svp, ArtSVP *new_svp, ArtSVP *clip_svp)
Sets the svp to the new value, clipping if necessary, and requesting repaint on what's changed...
void set_center_scroll_region(bool center)
When the scrolling region of the canvas is smaller than the canvas window, e.g. the allocation of the...
Gdk::RgbDither get_dither() const
Returns the type of dithering used to render an antialiased canvas.