00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "qwt_rect.h"
00011
00013
00014 QwtRect::QwtRect():
00015 QRect()
00016 {
00017 }
00018
00020 QwtRect::QwtRect(const QRect &r):
00021 QRect(r)
00022 {
00023 }
00024
00025 QRect QwtRect::cutTop(int h, int distTop, int distBottom)
00026 {
00027 QRect rv;
00028 rv.setTop(top() + distTop);
00029 rv.setHeight(h);
00030 setTop(rv.bottom() + distBottom + 1);
00031 rv.setLeft(left());
00032 rv.setRight(right());
00033 return rv;
00034 }
00035
00036
00037 QRect QwtRect::cutBottom(int h, int distTop, int distBottom)
00038 {
00039 QRect rv;
00040 setBottom(bottom() - h - distBottom - distTop);
00041 rv.setTop(bottom() + 1 + distTop);
00042 rv.setHeight(h);
00043 rv.setLeft(left());
00044 rv.setRight(right());
00045 return rv;
00046 }
00047
00048 QRect QwtRect::cutLeft(int w, int distLeft, int distRight)
00049 {
00050 QRect rv;
00051 rv.setLeft(left() + distLeft);
00052 rv.setWidth(w);
00053 setLeft(rv.right() + distRight + 1);
00054 rv.setTop(top());
00055 rv.setBottom(bottom());
00056 return rv;
00057 }
00058
00059
00060 QRect QwtRect::cutRight(int w, int distLeft, int distRight)
00061 {
00062 QRect rv;
00063 setRight(right() - w - distRight - distLeft);
00064 rv.setLeft(right() + 1 + distLeft);
00065 rv.setWidth(w);
00066 rv.setTop(top());
00067 rv.setBottom(bottom());
00068 return rv;
00069 }
00070
00071 const QwtRect& QwtRect::cutMargin(int mLeft, int mRight, int mTop, int mBottom)
00072 {
00073 setHeight(height() - mTop - mBottom);
00074 setWidth(width() - mLeft - mRight);
00075 moveBy(mLeft, mTop);
00076 return *this;
00077 }