papyrus logo

canvas.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUSCANVAS_H
00021 #define PAPYRUSCANVAS_H
00022 
00023 #include <papyrus/enums.h>
00024 #include <papyrus/group.h>
00025 
00026 #include <cairomm/cairomm.h>
00027 
00028 namespace Papyrus
00029 {
00030 
00035   class Canvas: public Group
00036   {
00037 
00038       // TODO change inheritance to eliminate the drawable matrix transformation functions
00039 
00040     protected:
00041 
00042       Canvas ( const Glib::ustring& id, double width, double height, double scale );
00043 
00044     public:
00045       PAPYRUS_DRAWABLE(Canvas);
00046 
00047       static pointer create ( double width=0.0, double height=0.0, double scale=1.0 );
00048 
00049       static pointer create ( const Glib::ustring& id, double width=0.0, double height=0.0, double scale=1.0 );
00050 
00051       virtual ~Canvas();
00052 
00053       virtual Matrix global_matrix() const;
00054 
00055       virtual Region global_extents() const;
00056 
00057       Region anchor_extents() const;
00058 
00059       double width() const;
00060 
00061       double height() const;
00062 
00063       void size ( double& width, double& height ) const;
00064 
00065       void set_width ( double width );
00066 
00067       void set_height ( double height );
00068 
00069       void set_size ( double width, double height );
00070 
00071       Units units() const;
00072 
00073       void set_units( Units u );
00074 
00075       void device_resolution( double& x, double& y ) const;
00076 
00077       bool set_device_resolution( double x, double y );
00078 
00079       Paint::pointer background() const;
00080 
00081       void set_background ( Paint::pointer background );
00082 
00083       void scroll_to ( double offset_x, double offset_y );
00084 
00085       void scroll_to_x( double offset_x );
00086 
00087       void scroll_to_y( double offset_y );
00088 
00089       void scroll_to_center();
00090 
00091       void scroll_position ( double& x, double& y ) const;
00092 
00093       double scroll_x() const;
00094 
00095       double scroll_y() const;
00096 
00097       void set_scroll_anchor ( ScrollAnchor scroll_achor = SCROLL_ANCHOR_CENTER );
00098 
00099       ScrollAnchor scroll_anchor() const;
00100 
00101       void scroll_anchor_offsets( double& x, double& y ) const;
00102 
00103       double scroll_anchor_x_offset() const;
00104 
00105       double scroll_anchor_y_offset() const;
00106 
00114       void window_to_canvas ( double& x, double& y ) const;
00115 
00123       void canvas_to_window ( double& x, double& y ) const;
00124 
00125       virtual Selection select ( double x, double y, unsigned depth = 1 );
00126 
00127       sigc::signal<void> signal_size_changed();
00128 
00129       sigc::signal<void,Units> signal_units();
00130 
00131       sigc::signal<void,double,double> signal_display_resolution();
00132 
00133       sigc::signal<void,double,double> signal_scrolled();
00134 
00135       sigc::signal<void,ScrollAnchor> signal_scroll_anchor_changed();
00136       
00137     protected:
00138       double m_width, m_height;
00139       double m_scale;
00140 
00145       ScrollAnchor m_scroll_anchor;
00146 
00148       double m_scroll_anchor_offset_x;
00149       
00151       double m_scroll_anchor_offset_y;
00152 
00154       double m_scroll_x;
00155 
00157       double m_scroll_y;
00158       
00159       Units m_units;
00160       double m_display_x_resolution, m_display_y_resolution;
00161 
00162       Paint::pointer m_background;
00163 
00164       sigc::signal<void> m_signal_size_changed;
00165 
00166       sigc::signal<void,Units> m_signal_units;
00167 
00168       sigc::signal<void,double,double> m_signal_display_resolution;
00169 
00170       sigc::signal<void,double,double> m_signal_scrolled;
00171 
00172       sigc::signal<void,ScrollAnchor> m_signal_scroll_anchor_changed;
00173 
00174       virtual void draw ( Context& cairo ) const;
00175 
00176       virtual Matrix calculate_composed_matrix() const;
00177   
00178       void update_scroll_anchor_offsets();
00179 
00180 //       virtual void calculate_raw_extents();
00181 
00182 
00183   };
00184 
00485 }
00486 
00487 #endif

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1