position.hpp
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
00021
00022
00023
00024
00025 #ifndef POSITION_HPP
00026 #define POSITION_HPP
00027
00028 #include "variable.hpp"
00029 #include "observer.hpp"
00030 #include "pointer.hpp"
00031
00032
00033
00034 class Box
00035 {
00036 public:
00037 virtual ~Box() { }
00038
00039
00040 virtual int getWidth() const = 0;
00041 virtual int getHeight() const = 0;
00042 };
00043
00044
00045
00046 class GenericRect: public Box
00047 {
00048 public:
00049 virtual int getLeft() const = 0;
00050 virtual int getTop() const = 0;
00051 };
00052
00053
00054
00055 class SkinsRect: public GenericRect
00056 {
00057 public:
00058 SkinsRect( int left, int top, int right, int bottom );
00059
00060 virtual int getLeft() const { return m_left; }
00061 virtual int getTop() const { return m_top; }
00062 virtual int getRight() const { return m_right; }
00063 virtual int getBottom() const { return m_bottom; }
00064 virtual int getWidth() const { return m_right - m_left; }
00065 virtual int getHeight() const { return m_bottom - m_top; }
00066
00067 private:
00068 int m_left;
00069 int m_top;
00070 int m_right;
00071 int m_bottom;
00072 };
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 class Position: public GenericRect
00083 {
00084 public:
00085
00086 enum Ref_t
00087 {
00088
00089 kLeftTop,
00090
00091 kRightTop,
00092
00093 kLeftBottom,
00094
00095 kRightBottom
00096 };
00097
00098
00099 Position( int left, int top, int right, int bottom,
00100 const GenericRect &rRect,
00101 Ref_t refLeftTop, Ref_t refRightBottom,
00102 bool xKeepRatio, bool yKeepRatio );
00103
00104 ~Position() { }
00105
00106
00107 virtual int getLeft() const;
00108 virtual int getTop() const;
00109 int getRight() const;
00110 int getBottom() const;
00111
00112 virtual int getWidth() const;
00113 virtual int getHeight() const;
00114
00115 Ref_t getRefLeftTop() const { return m_refLeftTop; }
00116 Ref_t getRefRightBottom() const { return m_refRighBottom; }
00117
00118 private:
00119
00120 int m_left;
00121 int m_top;
00122 int m_right;
00123 int m_bottom;
00124 const GenericRect &m_rRect;
00125 Ref_t m_refLeftTop;
00126 Ref_t m_refRighBottom;
00127
00128 bool m_xKeepRatio;
00129 bool m_yKeepRatio;
00130
00131 double m_xRatio;
00132
00133 double m_yRatio;
00134 };
00135
00136 typedef CountedPtr<Position> PositionPtr;
00137
00138
00139
00140 class VarBox: public Variable, public Box, public Subject<VarBox>
00141 {
00142 public:
00143 VarBox( intf_thread_t *pIntf, int width = 0, int height = 0 );
00144
00145 virtual ~VarBox() { }
00146
00147
00148 virtual const string &getType() const { return m_type; }
00149
00150
00151 virtual int getWidth() const;
00152 virtual int getHeight() const;
00153
00154
00155 void setSize( int width, int height );
00156
00157 private:
00158
00159 static const string m_type;
00160
00161 int m_width, m_height;
00162 };
00163
00164
00165 #endif