Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXSize.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * S i z e C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1994,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXSize.h,v 1.15 2006/01/22 17:58:09 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXSIZE_H
25 #define FXSIZE_H
26 
27 
28 namespace FX {
29 
30 
31 /// Size
32 class FXAPI FXSize {
33 public:
36 public:
37 
38  /// Constructors
39  FXSize(){ }
40  FXSize(const FXSize& s):w(s.w),h(s.h){ }
41  FXSize(FXshort ww,FXshort hh):w(ww),h(hh){ }
42 
43  /// Test if empty
44  bool empty() const { return w<=0 || h<=0; }
45 
46  /// Test if zero
47  bool operator!() const { return w==0 && h==0; }
48 
49  /// Equality
50  bool operator==(const FXSize& s) const { return w==s.w && h==s.h; }
51  bool operator!=(const FXSize& s) const { return w!=s.w || h!=s.h; }
52 
53  /// Grow by amount
54  FXSize& grow(FXshort margin);
55  FXSize& grow(FXshort hormargin,FXshort vermargin);
56  FXSize& grow(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
57 
58  /// Shrink by amount
59  FXSize& shrink(FXshort margin);
60  FXSize& shrink(FXshort hormargin,FXshort vermargin);
61  FXSize& shrink(FXshort leftmargin,FXshort rightmargin,FXshort topmargin,FXshort bottommargin);
62 
63  /// Assignment
64  FXSize& operator=(const FXSize& s){ w=s.w; h=s.h; return *this; }
65 
66  /// Set value from another size
67  FXSize& set(const FXSize& s){ w=s.w; h=s.h; return *this; }
68 
69  /// Set value from components
70  FXSize& set(FXshort ww,FXshort hh){ w=ww; h=hh; return *this; }
71 
72  /// Assignment operators
73  FXSize& operator+=(const FXSize& s){ w+=s.w; h+=s.h; return *this; }
74  FXSize& operator-=(const FXSize& s){ w-=s.w; h-=s.h; return *this; }
75  FXSize& operator*=(FXshort c){ w*=c; h*=c; return *this; }
76  FXSize& operator/=(FXshort c){ w/=c; h/=c; return *this; }
77 
78  /// Negation
79  FXSize operator-(){ return FXSize(-w,-h); }
80 
81  /// Addition operators
82  FXSize operator+(const FXSize& s) const { return FXSize(w+s.w,h+s.h); }
83  FXSize operator-(const FXSize& s) const { return FXSize(w-s.w,h-s.h); }
84 
85  /// Scale operators
86  friend inline FXSize operator*(const FXSize& s,FXshort c);
87  friend inline FXSize operator*(FXshort c,const FXSize& s);
88  friend inline FXSize operator/(const FXSize& s,FXshort c);
89  friend inline FXSize operator/(FXshort c,const FXSize& s);
90 
91  /// Save object to a stream
92  friend FXAPI FXStream& operator<<(FXStream& store,const FXSize& s);
93 
94  /// Load object from a stream
95  friend FXAPI FXStream& operator>>(FXStream& store,FXSize& s);
96  };
97 
98 inline FXSize operator*(const FXSize& s,FXshort c){ return FXSize(s.w*c,s.h*c); }
99 inline FXSize operator*(FXshort c,const FXSize& s){ return FXSize(c*s.w,c*s.h); }
100 inline FXSize operator/(const FXSize& s,FXshort c){ return FXSize(s.w/c,s.h/c); }
101 inline FXSize operator/(FXshort c,const FXSize& s){ return FXSize(c/s.w,c/s.h); }
102 
103 extern FXAPI FXStream& operator<<(FXStream& store,const FXSize& s);
104 extern FXAPI FXStream& operator>>(FXStream& store,FXSize& s);
105 
106 }
107 
108 #endif
FXMat3d operator/(const FXMat3d &a, FXdouble x)
FXStream & operator>>(FXStream &store, FXDate &d)
bool operator==(const FXSize &s) const
Equality.
Definition: FXSize.h:50
short FXshort
Definition: fxdefs.h:388
FXSize & operator-=(const FXSize &s)
Definition: FXSize.h:74
Size.
Definition: FXSize.h:32
#define FXAPI
Definition: fxdefs.h:122
FXSize & operator*=(FXshort c)
Definition: FXSize.h:75
FXshort h
Definition: FXSize.h:35
FXSize & set(const FXSize &s)
Set value from another size.
Definition: FXSize.h:67
FXSize & operator+=(const FXSize &s)
Assignment operators.
Definition: FXSize.h:73
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:99
bool empty() const
Test if empty.
Definition: FXSize.h:44
FXSize & set(FXshort ww, FXshort hh)
Set value from components.
Definition: FXSize.h:70
Definition: FX4Splitter.h:31
FXSize()
Constructors.
Definition: FXSize.h:39
FXSize operator+(const FXSize &s) const
Addition operators.
Definition: FXSize.h:82
FXSize operator-()
Negation.
Definition: FXSize.h:79
FXSize & operator/=(FXshort c)
Definition: FXSize.h:76
FXSize(FXshort ww, FXshort hh)
Definition: FXSize.h:41
bool operator!=(const FXSize &s) const
Definition: FXSize.h:51
bool operator!() const
Test if zero.
Definition: FXSize.h:47
FXSize & operator=(const FXSize &s)
Assignment.
Definition: FXSize.h:64
FXStream & operator<<(FXStream &store, const FXDate &d)
FXSize(const FXSize &s)
Definition: FXSize.h:40
FXSize operator-(const FXSize &s) const
Definition: FXSize.h:83
FXshort w
Definition: FXSize.h:34
FXMat3d operator*(FXdouble x, const FXMat3d &a)

Copyright © 1997-2005 Jeroen van der Zijp