canvas.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _LIBGNOMECANVASMM_CANVAS_H
00004 #define _LIBGNOMECANVASMM_CANVAS_H
00005 
00006 
00007 #include <glibmm.h>
00008 
00009 // -*- C++ -*-
00010 /* $Id: canvas.hg,v 1.20 2005/06/08 16:21:02 murrayc Exp $ */
00011 
00012 /* canvas.h
00013  * 
00014  * Copyright (C) 1998 EMC Capital Management Inc.
00015  * Developed by Havoc Pennington <hp@pobox.com>
00016  *
00017  * Copyright (C) 1999 The Gtk-- Development Team
00018  *
00019  * This library is free software; you can redistribute it and/or
00020  * modify it under the terms of the GNU Library General Public
00021  * License as published by the Free Software Foundation; either
00022  * version 2 of the License, or (at your option) any later version.
00023  *
00024  * This library is distributed in the hope that it will be useful,
00025  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00026  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027  * Library General Public License for more details.
00028  *
00029  * You should have received a copy of the GNU Library General Public
00030  * License along with this library; if not, write to the Free
00031  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00032  */
00033 
00034 #include <libgnomecanvas/gnome-canvas.h>
00035 #include <libgnomecanvasmm/affinetrans.h>
00036 #include <gtkmm/layout.h>
00037 #include <gdkmm/color.h>
00038 
00039 
00040 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00041 typedef struct _GnomeCanvas GnomeCanvas;
00042 typedef struct _GnomeCanvasClass GnomeCanvasClass;
00043 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00044 
00045 
00046 namespace Gnome
00047 {
00048 
00049 namespace Canvas
00050 { class Canvas_Class; } // namespace Canvas
00051 
00052 } // namespace Gnome
00053 namespace Gnome
00054 {
00055 
00056 namespace Canvas
00057 {
00058 
00059 class Item;
00060 class Group;
00061 
00068 class Canvas : public Gtk::Layout
00069 {
00070   public:
00071 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00072   typedef Canvas CppObjectType;
00073   typedef Canvas_Class CppClassType;
00074   typedef GnomeCanvas BaseObjectType;
00075   typedef GnomeCanvasClass BaseClassType;
00076 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00077 
00078   virtual ~Canvas();
00079 
00080 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00081 
00082 protected:
00083   friend class Canvas_Class;
00084   static CppClassType canvas_class_;
00085 
00086   // noncopyable
00087   Canvas(const Canvas&);
00088   Canvas& operator=(const Canvas&);
00089 
00090 protected:
00091   explicit Canvas(const Glib::ConstructParams& construct_params);
00092   explicit Canvas(GnomeCanvas* castitem);
00093 
00094 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00095 
00096 public:
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   GnomeCanvas*       gobj()       { return reinterpret_cast<GnomeCanvas*>(gobject_); }
00104 
00106   const GnomeCanvas* gobj() const { return reinterpret_cast<GnomeCanvas*>(gobject_); }
00107 
00108 
00109 public:
00110   //C++ methods used to invoke GTK+ virtual functions:
00111 #ifdef GLIBMM_VFUNCS_ENABLED
00112 #endif //GLIBMM_VFUNCS_ENABLED
00113 
00114 protected:
00115   //GTK+ Virtual Functions (override these to change behaviour):
00116 #ifdef GLIBMM_VFUNCS_ENABLED
00117 #endif //GLIBMM_VFUNCS_ENABLED
00118 
00119   //Default Signal Handlers::
00120 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00121   virtual void on_draw_background(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height);
00122   virtual void on_render_background(GnomeCanvasBuf* buf);
00123 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
00124 
00125 
00126 private:
00127 
00128 public:
00129   Canvas();
00130 
00131   //Allow CanvasAA to access the canvas_class_ member.
00132   
00133 
00134   //: Get the root canvas item
00135   
00139   Group* root() const;
00140            
00141   //: Limits of scroll region
00142   
00151   void set_scroll_region(double x1, double y1, double x2, double y2);
00152 
00153   //: Get limits of scroll region
00154   
00161   void get_scroll_region(double& x1, double& y1, double& x2, double& y2) const;
00162 
00163   
00171   void set_center_scroll_region(bool center);
00172 
00173   
00178   bool get_center_scroll_region() const;
00179 
00180   //: Set the pixels/world coordinates ratio
00181   //- With no arguments sets to default of 1.0.
00182   
00195   void set_pixels_per_unit(double n = 1.0);
00196 
00197   //: Shift window.
00198   //- Makes a canvas scroll to the specified offsets, given in canvas pixel
00199   //- units.
00200   //- The canvas will adjust the view so that it is not outside the scrolling
00201   //- region.  This function is typically not used, as it is better to hook
00202   //- scrollbars to the canvas layout's scrolling adjusments.
00203   
00211   void scroll_to(int x, int y);
00212 
00213   //: Scroll offsets in canvas pixel coordinates.
00214   
00220   void get_scroll_offsets(int& cx, int& cy) const;
00221 
00222   //: Repaint immediately, don't wait for idle loop
00223   //- normally the canvas queues repainting and does it in an
00224   //- idle loop
00225   
00231   void update_now();
00232 
00233   //: Find an item at a location.
00234   //- Looks for the item that is under the specified position, which must be
00235   //- specified in world coordinates.  Arguments are in world coordinates.
00236   //- Returns 0 if no item is at that
00237   //- location.
00238   
00246   Item* get_item_at(double x, double y) const;
00247 
00248 
00249   //: Repaint small area (internal)
00250   //- Used only by item implementations. Request an eventual redraw
00251   //- of the region, which includes x1,y1 but not x2,y2
00252   
00262   void request_redraw(int x1, int y1, int x2, int y2);
00263   //TODO: Investigate ArtUta.
00264   
00271   void request_redraw(ArtUta* uta);
00272 
00273   Art::AffineTrans w2c_affine() const;
00274   
00275 
00276   //: Convert from World to canvas coordinates (units for the entire canvas)
00277   //: to Canvas coordinates (pixels starting at 0,0 in the top left
00278   //: of the visible area). The relationship depends on the current
00279   //: scroll position and the pixels_per_unit ratio (zoom factor)
00280   
00287   void w2c(double wx, double wy, int& cx, int& cy) const;
00288   
00296   void w2c(double wx, double wy, double& cx, double& cy) const;
00297 
00298   //: From Canvas to World
00299   
00306   void c2w(int cx, int cy, double& wx, double& wy) const;
00307 
00308   //: Convert from Window coordinates to world coordinates.
00309   //- Window coordinates are based of the widget's GdkWindow.
00310   //- This is fairly low-level and not generally useful.
00311   
00320   void window_to_world (double winx,double winy, double& worldx,double& worldy) const;
00321 
00322   //: Convert from world coordinates to Window coordinates.
00323   //- Window coordinates are based of the widget's GdkWindow.
00324   //- This is fairly low-level and not generally useful.
00325   
00332   void world_to_window (double worldx, double worldy, double& winx, double& winy) const;
00333 
00334   //: Parse color spec string and allocate it into the GdkColor.
00335   bool get_color(const Glib::ustring& spec, Gdk::Color& color) const;
00336   
00337 
00338 /* Allocates a color from the RGB value passed into this function. */
00339   
00345   gulong get_color_pixel(guint rgba) const;
00346   
00352   void set_stipple_origin(const Glib::RefPtr<Gdk::GC>& gc);
00353   
00360   void set_dither(Gdk::RgbDither dither);
00361   
00365   Gdk::RgbDither get_dither() const;
00366 
00367 
00368   //TODO: Look at ArtSVP.
00369   
00375   void update_svp(ArtSVP** p_svp, ArtSVP* new_svp);
00376   
00383   void update_svp_clip(ArtSVP** p_svp, ArtSVP* new_svp, ArtSVP* clip_svp);
00384 
00385   // The following are simply accessed via the struct in C,
00386   //  but Federico reports that they are meant to be used.
00387   //: Get the pixels per unit.
00388    double get_pixels_per_unit() const;
00389  
00390   //: Draw the background for the area given.
00391   //- This method is only used for non-antialiased canvases.
00392   
00398   Glib::SignalProxy5< void,const Glib::RefPtr<Gdk::Drawable>&,int,int,int,int > signal_draw_background();
00399 
00400   // Render the background for the buffer given. 
00401   //- The buf data structure contains both a pointer to a packed 24-bit
00402   //- RGB array, and the coordinates.
00403   //- This method is only used for antialiased canvases.
00404   
00410   Glib::SignalProxy1< void,GnomeCanvasBuf* > signal_render_background();
00411 
00412   //: Private Virtual methods for groping the canvas inside bonobo.
00413   #ifdef GLIBMM_VFUNCS_ENABLED
00414   virtual void request_update_vfunc();
00415 #endif //GLIBMM_VFUNCS_ENABLED
00416 
00417 
00418   // Whether the canvas is in antialiased mode or not.
00419   #ifdef GLIBMM_PROPERTIES_ENABLED
00420 
00426   Glib::PropertyProxy_ReadOnly<bool> property_aa() const;
00427 #endif //#GLIBMM_PROPERTIES_ENABLED
00428 
00429 
00430 };
00431 
00432 //: Antialiased Canvas.
00433 //- Constructor takes care of push/pop actions of the colormap.
00434 class CanvasAA : public Canvas
00435 {
00436   public:
00437     CanvasAA();
00438     virtual ~CanvasAA();
00439 };
00440 
00441 } /* namespace Canvas */
00442 } /* namespace Gnome */
00443 
00444 
00445 namespace Glib
00446 {
00455   Gnome::Canvas::Canvas* wrap(GnomeCanvas* object, bool take_copy = false);
00456 } //namespace Glib
00457 
00458 
00459 #endif /* _LIBGNOMECANVASMM_CANVAS_H */
00460 

Generated on Mon Sep 17 15:58:14 2007 for libgnomecanvasmm by  doxygen 1.5.3