canvas.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00039
00040 protected:
00041
00042 Canvas ( const Glib::ustring& id, double width, double height, double scale );
00043
00044 public:
00045 typedef PapyrusPointer<Canvas> pointer;
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 double width();
00056
00057 double height();
00058
00059 void size ( double& width, double& height );
00060
00061 void set_width ( double width );
00062
00063 void set_height ( double height );
00064
00065 void set_size ( double width, double height );
00066
00067 Units units() const;
00068
00069 void set_units( Units u );
00070
00071 void device_resolution( double& x, double& y ) const;
00072
00073 bool set_device_resolution( double x, double y );
00074
00075 Paint::pointer background();
00076
00077 void set_background ( Paint::pointer background );
00078
00079 void scroll_to ( double offset_x, double offset_y );
00080
00081 void scroll_to_center();
00082
00083 void scroll_position ( double& x, double& y );
00084
00085 void set_scroll_anchor ( ScrollAnchor scroll_achor = SCROLL_ANCHOR_CENTER );
00086
00087 ScrollAnchor scroll_anchor();
00088
00096 void window_to_canvas ( double& x, double& y ) const;
00097
00105 void canvas_to_window ( double& x, double& y ) const;
00106
00107 virtual Selection select ( double x, double y, unsigned depth = 1 );
00108
00109 sigc::signal<void> signal_size();
00110
00111 sigc::signal<void,Units> signal_units();
00112
00113 sigc::signal<void,double,double> signal_display_resolution();
00114
00115 PAPYRUS_CLASS_NAME ( "Canvas" );
00116
00117 PAPYRUS_CLONE_METHOD ( Canvas );
00118
00119 protected:
00120 double m_width, m_height;
00121 double m_scale;
00122
00127 ScrollAnchor m_scroll_anchor;
00128
00130 double m_scroll_anchor_offset_x;
00131
00133 double m_scroll_anchor_offset_y;
00134
00136 double m_scroll_x;
00137
00139 double m_scroll_y;
00140
00141 Units m_units;
00142 double m_display_x_resolution, m_display_y_resolution;
00143
00144 Paint::pointer m_background;
00145
00146 sigc::signal<void> m_signal_size;
00147
00148 sigc::signal<void,Units> m_signal_units;
00149
00150 sigc::signal<void,double,double> m_signal_display_resolution;
00151
00152 virtual void draw ( Cairo::RefPtr<Cairo::Context> cairo ) const;
00153
00154 virtual Matrix calculate_composed_matrix() const;
00155
00156 void update_scroll_anchor_offsets();
00157
00158
00159
00160
00161 };
00162
00458 }
00459
00460 #endif