region.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 PAPYRUSREGION_H
00021 #define PAPYRUSREGION_H
00022
00023 #include <cairomm/cairomm.h>
00024
00025 #include <papyrus/object.h>
00026 #include <papyrus/matrix.h>
00027
00028 namespace Papyrus
00029 {
00030
00038 class Region: public sigc::trackable
00039 {
00040 public:
00041
00042 Region ( double x=NAN, double y=NAN, double w=NAN, double h=NAN );
00043
00044 virtual ~Region();
00045
00046 double x() const;
00047 double y() const;
00048 double width() const;
00049 double height() const;
00050
00051 void xywh ( double& x, double& y, double& w, double& h ) const;
00052
00053 double left() const;
00054 double right() const;
00055 double top() const;
00056 double bottom() const;
00057 void lrtb ( double& l, double& r, double& t, double& b ) const;
00058 void set_lrtb( double l, double r, double t, double b );
00059
00060 void center ( double& x, double& y ) const;
00061
00062
00063 void set_x ( double x );
00064 void set_y ( double y );
00065 void set_width ( double w );
00066 void set_height ( double h );
00067 void set_xywh ( double x, double y, double w, double h );
00068
00070 void invalidate();
00071
00080 bool include ( const Region& other );
00081
00087 bool include ( double x, double y );
00088
00093 bool include_x ( double x );
00094
00099 bool include_y ( double y );
00100
00101 void left_bottom ( double& l, double& b ) const;
00102 void right_top ( double& r, double& t ) const;
00103
00104 Region& operator= ( const Region& other );
00105
00107 bool operator== ( const Region& other ) const;
00108
00109 bool operator!= ( const Region& other ) const;
00110
00112 bool operator< ( const Region& other ) const;
00113
00114 bool operator<= ( const Region& other ) const;
00115
00117 bool operator> ( const Region& other ) const;
00118
00119 bool operator>= ( const Region& other ) const;
00120
00121 operator bool() const;
00122
00124 bool is_inside ( double x, double y ) const ;
00125
00127 bool is_interior ( double x, double y ) const ;
00128
00130 bool is_boundary ( double x, double y ) const ;
00131
00133 bool overlaps( const Region& other ) const;
00134
00135 void transform ( const Matrix& matrix );
00136
00137 sigc::signal<void>& signal_changed();
00138
00139 protected:
00140 double m_x, m_y, m_w, m_h;
00141 bool m_suppress_change_signal;
00142 sigc::signal<void> m_signal_changed;
00143
00144 bool include_point(double x, double y);
00145
00146
00147 };
00148
00149 }
00150
00151 #endif