Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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 #include <glibmm.h>
00007 
00008 // -*- C++ -*-
00009 /* $Id: canvas.hg,v 1.19 2004/04/07 19:13:51 murrayc Exp $ */
00010 
00011 /* canvas.h
00012  * 
00013  * Copyright (C) 1998 EMC Capital Management Inc.
00014  * Developed by Havoc Pennington <hp@pobox.com>
00015  *
00016  * Copyright (C) 1999 The Gtk-- Development Team
00017  *
00018  * This library is free software; you can redistribute it and/or
00019  * modify it under the terms of the GNU Library General Public
00020  * License as published by the Free Software Foundation; either
00021  * version 2 of the License, or (at your option) any later version.
00022  *
00023  * This library is distributed in the hope that it will be useful,
00024  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026  * Library General Public License for more details.
00027  *
00028  * You should have received a copy of the GNU Library General Public
00029  * License along with this library; if not, write to the Free
00030  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00031  */
00032 
00033 #include <libgnomecanvas/gnome-canvas.h>
00034 #include <libgnomecanvasmm/affinetrans.h>
00035 #include <gtkmm/layout.h>
00036 #include <gdkmm/color.h>
00037 
00038 
00039 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00040 typedef struct _GnomeCanvas GnomeCanvas;
00041 typedef struct _GnomeCanvasClass GnomeCanvasClass;
00042 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00043 
00044 
00045 namespace Gnome
00046 {
00047 
00048 namespace Canvas
00049 { class Canvas_Class; } // namespace Canvas
00050 
00051 } // namespace Gnome
00052 namespace Gnome
00053 {
00054 
00055 namespace Canvas
00056 {
00057 
00058 class Item;
00059 class Group;
00060 
00067 class Canvas : public Gtk::Layout
00068 {
00069   public:
00070 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00071   typedef Canvas CppObjectType;
00072   typedef Canvas_Class CppClassType;
00073   typedef GnomeCanvas BaseObjectType;
00074   typedef GnomeCanvasClass BaseClassType;
00075 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00076 
00077   virtual ~Canvas();
00078 
00079 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00080 
00081 protected:
00082   friend class Canvas_Class;
00083   static CppClassType canvas_class_;
00084 
00085   // noncopyable
00086   Canvas(const Canvas&);
00087   Canvas& operator=(const Canvas&);
00088 
00089 protected:
00090   explicit Canvas(const Glib::ConstructParams& construct_params);
00091   explicit Canvas(GnomeCanvas* castitem);
00092 
00093 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00094 
00095 public:
00096 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00097   static GType get_type()      G_GNUC_CONST;
00098   static GType get_base_type() G_GNUC_CONST;
00099 #endif
00100 
00102   GnomeCanvas*       gobj()       { return reinterpret_cast<GnomeCanvas*>(gobject_); }
00103 
00105   const GnomeCanvas* gobj() const { return reinterpret_cast<GnomeCanvas*>(gobject_); }
00106 
00107 
00108 public:
00109   //C++ methods used to invoke GTK+ virtual functions:
00110 
00111 protected:
00112   //GTK+ Virtual Functions (override these to change behaviour):
00113 
00114   //Default Signal Handlers::
00115   virtual void on_draw_background(const Glib::RefPtr<Gdk::Drawable>& drawable, int x, int y, int width, int height);
00116   virtual void on_render_background(GnomeCanvasBuf* buf);
00117 
00118 
00119 private:
00120 ;
00121 public:
00122   Canvas();
00123 
00124   //Allow CanvasAA to access the canvas_class_ member.
00125   
00126 
00127   //: Get the root canvas item
00128   
00132   Group* root() const;
00133            
00134   //: Limits of scroll region
00135   
00144   void set_scroll_region(double x1, double y1, double x2, double y2);
00145 
00146   //: Get limits of scroll region
00147   
00154   void get_scroll_region(double& x1, double& y1, double& x2, double& y2) const;
00155 
00156   
00164   void set_center_scroll_region(bool center);
00165 
00166   
00171   bool get_center_scroll_region() const;
00172 
00173   //: Set the pixels/world coordinates ratio
00174   //- With no arguments sets to default of 1.0.
00175   
00188   void set_pixels_per_unit(double n = 1.0);
00189 
00190   //: Shift window.
00191   //- Makes a canvas scroll to the specified offsets, given in canvas pixel
00192   //- units.
00193   //- The canvas will adjust the view so that it is not outside the scrolling
00194   //- region.  This function is typically not used, as it is better to hook
00195   //- scrollbars to the canvas layout's scrolling adjusments.
00196   
00204   void scroll_to(int x, int y);
00205 
00206   //: Scroll offsets in canvas pixel coordinates.
00207   
00213   void get_scroll_offsets(int& cx, int& cy) const;
00214 
00215   //: Repaint immediately, don't wait for idle loop
00216   //- normally the canvas queues repainting and does it in an
00217   //- idle loop
00218   
00224   void update_now();
00225 
00226   //: Find an item at a location.
00227   //- Looks for the item that is under the specified position, which must be
00228   //- specified in world coordinates.  Arguments are in world coordinates.
00229   //- Returns 0 if no item is at that
00230   //- location.
00231   
00239   Item* get_item_at(double x, double y) const;
00240 
00241 
00242   //: Repaint small area (internal)
00243   //- Used only by item implementations. Request an eventual redraw
00244   //- of the region, which includes x1,y1 but not x2,y2
00245   
00255   void request_redraw(int x1, int y1, int x2, int y2);
00256   //TODO: Investigate ArtUta.
00257   
00264   void request_redraw(ArtUta* uta);
00265 
00266   Art::AffineTrans w2c_affine() const;
00267   
00268 
00269   //: Convert from World to canvas coordinates (units for the entire canvas)
00270   //: to Canvas coordinates (pixels starting at 0,0 in the top left
00271   //: of the visible area). The relationship depends on the current
00272   //: scroll position and the pixels_per_unit ratio (zoom factor)
00273   
00280   void w2c(double wx, double wy, int& cx, int& cy) const;
00281   
00289   void w2c(double wx, double wy, double& cx, double& cy) const;
00290 
00291   //: From Canvas to World
00292   
00299   void c2w(int cx, int cy, double& wx, double& wy) const;
00300 
00301   //: Convert from Window coordinates to world coordinates.
00302   //- Window coordinates are based of the widget's GdkWindow.
00303   //- This is fairly low-level and not generally useful.
00304   
00313   void window_to_world (double winx,double winy, double& worldx,double& worldy) const;
00314 
00315   //: Convert from world coordinates to Window coordinates.
00316   //- Window coordinates are based of the widget's GdkWindow.
00317   //- This is fairly low-level and not generally useful.
00318   
00325   void world_to_window (double worldx, double worldy, double& winx, double& winy) const;
00326 
00327   //: Parse color spec string and allocate it into the GdkColor.
00328   bool get_color(const Glib::ustring& spec, Gdk::Color& color) const;
00329   
00330 
00331 /* Allocates a color from the RGB value passed into this function. */
00332   
00338   gulong get_color_pixel(guint rgba) const;
00339   
00345   void set_stipple_origin(const Glib::RefPtr<Gdk::GC>& gc);
00346   
00353   void set_dither(Gdk::RgbDither dither);
00354   
00358   Gdk::RgbDither get_dither() const;
00359 
00360 
00361   //TODO: Look at ArtSVP.
00362   
00368   void update_svp(ArtSVP** p_svp, ArtSVP* new_svp);
00369   
00376   void update_svp_clip(ArtSVP** p_svp, ArtSVP* new_svp, ArtSVP* clip_svp);
00377 
00378   // The following are simply accessed via the struct in C,
00379   //  but Federico reports that they are meant to be used.
00380   //: Get the pixels per unit.
00381   double get_pixels_per_unit() const;
00382 
00383   //: Draw the background for the area given.
00384   //- This method is only used for non-antialiased canvases.
00385   
00386 
00387   Glib::SignalProxy5< void,const Glib::RefPtr<Gdk::Drawable>&,int,int,int,int > signal_draw_background();
00388 
00389   // Render the background for the buffer given. 
00390   //- The buf data structure contains both a pointer to a packed 24-bit
00391   //- RGB array, and the coordinates.
00392   //- This method is only used for antialiased canvases.
00393   
00394 
00395   Glib::SignalProxy1< void,GnomeCanvasBuf* > signal_render_background();
00396 
00397   //: Private Virtual methods for groping the canvas inside bonobo.
00398     virtual void request_update_vfunc();
00399 
00400   // Whether the canvas is in antialiased mode or not.
00405   Glib::PropertyProxy<bool> property_aa() ;
00406 
00411   Glib::PropertyProxy_ReadOnly<bool> property_aa() const;
00412 
00413 
00414 };
00415 
00416 //: Antialiased Canvas.
00417 //- Constructor takes care of push/pop actions of the colormap.
00418 class CanvasAA : public Canvas
00419 {
00420   public:
00421     CanvasAA();
00422     virtual ~CanvasAA();
00423 };
00424 
00425 } /* namespace Canvas */
00426 } /* namespace Gnome */
00427 
00428 
00429 namespace Glib
00430 {
00436   Gnome::Canvas::Canvas* wrap(GnomeCanvas* object, bool take_copy = false);
00437 }
00438 #endif /* _LIBGNOMECANVASMM_CANVAS_H */
00439 

Generated on Tue Feb 1 14:17:47 2005 for libgnomecanvasmm by  doxygen 1.4.1