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
00026
00027
00028
#ifndef UINSETS_HPP
00029
#define UINSETS_HPP
00030
00031
#include "../uobject.hpp"
00032
00033
namespace ufo {
00034
00048 class UFO_EXPORT UInsets {
00049
public:
00051
inline UInsets();
00058
inline UInsets(
int top,
int left,
int bottom,
int right);
00059
00060
inline int getTop()
const;
00061
inline int getLeft()
const;
00062
inline int getBottom()
const;
00063
inline int getRight()
const;
00064
00066
inline int getHorizontal()
const;
00068
inline int getVertical()
const;
00069
00073
inline void grow(
const UInsets & add);
00074
00076
inline bool isEmpty()
const;
00077
00078
public:
00080
inline bool operator()();
00082
inline bool operator!();
00083
00088
inline UInsets & operator+=(
const UInsets & in);
00089
00094
inline UInsets & operator-=(
const UInsets & in);
00095
00096
inline friend std::ostream & operator<<(std::ostream & os,
const UInsets & o);
00097
00098
public:
00099
int top;
00100
int left;
00101
int bottom;
00102
int right;
00103 };
00104
00105
00106
00107
00108
00109
inline UInsets operator+(
const UInsets & in1,
const UInsets & in2);
00110
inline UInsets operator-(
const UInsets & in1,
const UInsets & in2);
00111
00113
inline bool operator==(
const UInsets & in1,
const UInsets & in2);
00114
inline bool operator!=(
const UInsets & in1,
const UInsets & in2);
00115
00116
00120 class UFO_EXPORT UInsetsObject :
public UInsets,
public UObject {
00121 UFO_DECLARE_DYNAMIC_CLASS(UInsetsObject)
00122
public:
00123 UInsetsObject();
00124 UInsetsObject(
const UInsets & insets);
00125 UInsetsObject(
int top,
int left,
int bottom,
int right);
00126
00127
00128
00129
00130
virtual unsigned int hashCode()
const;
00131
virtual bool equals(
const UObject * obj);
00132
virtual bool equals(
const UInsets * obj);
00133
virtual UObject * clone()
const;
00134
00135
protected:
00136
virtual std::ostream & paramString(std::ostream & os)
const;
00137 };
00138
00139
00140
00141
00142
00143
00144
00145
00146 inline UInsets::UInsets() : top(0), left(0), bottom(0), right(0) {}
00147
00148 inline UInsets::UInsets(
int top,
int left,
int bottom,
int right)
00149 : top(top)
00150 , left(left)
00151 , bottom(bottom)
00152 , right(right)
00153 {}
00154
00155
00156
inline int
00157 UInsets::getTop()
const {
00158
return top;
00159 }
00160
inline int
00161 UInsets::getLeft()
const {
00162
return left;
00163 }
00164
inline int
00165 UInsets::getBottom()
const {
00166
return bottom;
00167 }
00168
inline int
00169 UInsets::getRight()
const {
00170
return right;
00171 }
00172
00173
inline int
00174 UInsets::getHorizontal()
const {
00175
return left + right;
00176 }
00177
inline int
00178 UInsets::getVertical()
const {
00179
return top + bottom;
00180 }
00181
00182
00183
00184
inline void
00185 UInsets::grow(
const UInsets & add) {
00186 top += add.
top;
00187 left += add.
left;
00188 bottom += add.
bottom;
00189 right += add.
right;
00190 }
00191
00192
inline bool
00193 UInsets::isEmpty()
const {
00194
return (!(top && left && bottom && right));
00195 }
00196
00197
inline bool
00198 UInsets::operator()() {
00199
return !(
isEmpty());
00200 }
00201
00202
inline bool
00203 UInsets::operator!() {
00204
return isEmpty();
00205 }
00206
00207
00208
inline UInsets &
00209 UInsets::operator+=(
const UInsets & in) {
00210 top += in.
top;
00211 left += in.
left;
00212 bottom += in.
bottom;
00213 right += in.
right;
00214
return *
this;
00215 }
00216
00217
inline UInsets &
00218 UInsets::operator-=(
const UInsets & in) {
00219 top -= in.
top;
00220 left -= in.
left;
00221 bottom -= in.
bottom;
00222 right -= in.
right;
00223
return *
this;
00224 }
00225
00226
inline std::ostream &
00227 operator<<(std::ostream & os,
const UInsets & o) {
00228
return os <<
"UInsets["
00229 <<
"top=" << o.
top
00230 <<
", left=" << o.
left
00231 <<
", bottom=" << o.
bottom
00232 <<
", right=" << o.
right
00233 <<
"]";
00234 }
00235
00236
inline UInsets operator+(
const UInsets & in1,
const UInsets & in2) {
00237 UInsets ret(in1);
00238
return ret += in2;
00239 }
00240
inline UInsets operator-(
const UInsets & in1,
const UInsets & in2) {
00241 UInsets ret(in1);
00242
return ret -= in2;
00243 }
00244
00246
inline bool operator==(
const UInsets & in1,
const UInsets & in2) {
00247
return ((in1.top == in2.top) &&
00248 (in1.left == in2.left) &&
00249 (in1.bottom == in2.bottom) &&
00250 (in1.right == in2.right));
00251 }
00252
inline bool operator!=(
const UInsets & in1,
const UInsets & in2) {
00253
return ((in1.top != in2.top) &&
00254 (in1.left != in2.left) &&
00255 (in1.bottom != in2.bottom) &&
00256 (in1.right != in2.right));
00257 }
00258
00259
00260
00261
00262
00263
00264
inline
00265 UInsetsObject::UInsetsObject() {}
00266
00267
inline
00268 UInsetsObject::UInsetsObject(
const UInsets & insets) : UInsets(insets) {}
00269
00270
inline
00271 UInsetsObject::UInsetsObject(
int top,
int left,
int bottom,
int right)
00272 : UInsets(top, left, bottom, right) {}
00273
00274
00275
00276
00277
inline unsigned int
00278 UInsetsObject::hashCode()
const {
00279
00280
00281
int temp = ((top << 16) | bottom);
00282 temp &= ~(right | left);
00283
return temp;
00284 }
00285
00286
inline bool
00287 UInsetsObject::equals(
const UObject * obj) {
00288
if (
const UInsets * insets = dynamic_cast<const UInsets*>(obj)) {
00289
return ((top == insets->
top) &&
00290 (left == insets->
left) &&
00291 (bottom == insets->
bottom) &&
00292 (right == insets->
right));
00293 }
00294
return false;
00295 }
00296
00297
inline bool
00298 UInsetsObject::equals(
const UInsets * obj) {
00299
return ((top == obj->top) &&
00300 (left == obj->left) &&
00301 (bottom == obj->bottom) &&
00302 (right == obj->right));
00303 }
00304
00305
inline UObject *
00306 UInsetsObject::clone()
const {
00307
return new UInsetsObject(top, left, bottom, right);
00308 }
00309
00310
00311
00312
00313
00314
00315
inline std::ostream &
00316 UInsetsObject::paramString(std::ostream & os)
const {
00317
return os <<
"top=" << top
00318 <<
", left=" << left
00319 <<
", bottom=" << bottom
00320 <<
", right=" << right;
00321 }
00322
00323
00324 }
00325
00326
#endif // UINSETS_HPP