Public Member Functions | |
Rectangle | bottom (double portion=0.5) const |
Produce a Rectangle with the portion % height, same width, position moved downwards. | |
Rectangle | col (int column, int columns) const |
Produce a Rectangle with the 1/cols % width, same height, colth position. | |
Rectangle | cropBottom (const int a_ToRemove) const |
Produce a Rectangle with the bottom portion removed. | |
Rectangle | cropLeft (const int a_ToRemove) const |
Produce a Rectangle with the left portion removed. | |
Rectangle | cropRight (const int a_ToRemove) const |
Produce a Rectangle with the right portion removed. | |
Rectangle | cropTop (const int a_ToRemove) const |
Produce a Rectangle with the top portion removed. | |
Rectangle | getBottom (long y) const |
Return the lower rectangle starting from y. | |
Rectangle | getLeft (long x) const |
Return the left rectangle of widght x. | |
Rectangle | getRight (long x) const |
Return the right rectangle of widght x. | |
Rectangle | getTop (long y) const |
Return the upper rectangle of height y. | |
Rectangle | left (double portion=0.5) const |
same position. | |
Rectangle | lowerRightAdjust (const Point &adjust) const |
Move the Lower Right position by adjust, and keep the same Upper Left corner. | |
Point | lowRight () const |
Return the lower right point of the rectangle. | |
Rectangle (const Rectangle &rect, double xFraction, double yFraction, double widthFraction, double heightFraction) | |
the old rect. | |
Rectangle (long x, long y, long width, long height) | |
Constructor initializing the rectangle with longs instead of Points. | |
Rectangle (const Point &pSize) | |
Constructor initializing the rectangle with a size. | |
Rectangle (const Point &pPos, const Point &pSize) | |
Constructor initializing the rectangle with a position and size. | |
Rectangle () | |
Constructor initializing the rectangle to (0, 0, 0, 0). | |
Rectangle | right (double portion=0.5) const |
Produce a Rectangle with the portion % width, same height, position moved to right. | |
Rectangle | row (int row, int rows) const |
Produce a Rectangle with the 1/rows % height, same width, rowth position. | |
Rectangle | shrink (long border) const |
For both dimensions, move inwards by Border and shrink the size by 2*Border. | |
Rectangle | shrink (long xBorder, long yBorder) const |
and 2*xBorder | |
Rectangle | shrink (double factor) const |
Size of the rectangle will be * factor, Position adjusted for the same center. | |
Rectangle | shrinkHeight (long yBorder) const |
Move inwards by yBorder and shrink the size by 2*yBorder. | |
Rectangle | shrinkWidth (long xBorder) const |
Move inwards by xBorder and shrink the size by 2*xBorder. | |
Rectangle | subRect (double xFraction, double yFraction, double widthFraction, double heightFraction) const |
Creates a sub rectangle from an old rectangle. | |
Rectangle | top (double portion=0.5) const |
Produce a Rectangle with the portion % height, same width, same position. | |
Rectangle | upperLeftAdjust (const Point &adjust) const |
Move the Upper Left position by adjust, and keep the same Lower Right corner. | |
Static Public Member Functions | |
static Rectangle | FromRECT (const ::RECT &) |
Creates a new rectangle from a Windows RECT. | |
Public Attributes | |
Point | pos |
Position of the upper left corner of the Rectangle. | |
Point | size |
Size of the Rectangle. |
The two Point data members, pos and size, define a rectangle.
pos has the x,y position of the upper-left rectangle coordinate.
size defines the x and y distance between the upper left and the lower right coordinate.
(pos + size) defines the lower right coordinate.
Many window functions takes or returns a Rectangle.
See the Layout module documentation for the use of Rectangle in positioning widgets.
The member functions are helpful in dividing large rectangles into smaller ones, which is exactly what is needed to layout widgets in windows.
Rectangle | ( | ) |
Constructor initializing the rectangle to (0, 0, 0, 0).
Default constructor initializing everything to zero (0)
Constructor initializing the rectangle with a position and size.
Note that the pSize is actually a size and NOT the lower right Point.
Constructor initializing the rectangle with a size.
Note that the pSize is actually a size and NOT the lower right Point, position is defaulted to 0,0.
Rectangle | ( | long | x, | |
long | y, | |||
long | width, | |||
long | height | |||
) |
Constructor initializing the rectangle with longs instead of Points.
( x,y ) defines the upper right corner, ( x+width, y+height ) defines the lower left corner.
Rectangle | ( | const Rectangle & | rect, | |
double | xFraction, | |||
double | yFraction, | |||
double | widthFraction, | |||
double | heightFraction | |||
) |
the old rect.
It computes the new rectangle by using subrect():
(xFraction * size.x) is the amount to add to pos.x
size.x *= widthFraction
Examples : upper half is r2( r1, 0, 0, 1, 0.5 ) (Same position, same width, 0.5 height ) lower half is r2( r1, 0, 0.5, 1, 0.5 ) (y half down, same width, 0.5 height ) left half is r2( r1, 0, 0, 0.5, 1 ) (Same position, 0.5 width, same height ) right half is r2( r1, 0.5, 0, 0.5, 1 ) Lower right quarter is r2( r1, .5, .5, .5, .5) center r2 inside r1 is r2( r1, .334, .334, .334, .334)
Rectangle bottom | ( | double | portion = 0.5 |
) | const |
Rectangle col | ( | int | column, | |
int | columns | |||
) | const |
Rectangle FromRECT | ( | const ::RECT & | ) | [static] |
Creates a new rectangle from a Windows RECT.
Windows RECT structure uses the coordinates of the top-left and bottom-right points. SmartWin::Rectangle, on the other hand, uses top-left, width-height.
Rectangle getBottom | ( | long | y | ) | const |
Rectangle getLeft | ( | long | x | ) | const |
Rectangle getRight | ( | long | x | ) | const |
Rectangle getTop | ( | long | y | ) | const |
Rectangle left | ( | double | portion = 0.5 |
) | const |
same position.
If the original rectangle is as below:
XXXOOOOOOO XXXOOOOOOO XXXOOOOOOO XXXOOOOOOOleft( 0.3 )returns the X rectangle.
Move the Lower Right position by adjust, and keep the same Upper Left corner.
++++O ++++O OOOOOlowerRightAdjust( Point( -1, -1 ) ); will give the + rectangle afterwards.
Point lowRight | ( | ) | const |
Rectangle right | ( | double | portion = 0.5 |
) | const |
Rectangle row | ( | int | row, | |
int | rows | |||
) | const |
Rectangle shrink | ( | long | border | ) | const |
For both dimensions, move inwards by Border and shrink the size by 2*Border.
We add border to the position, and subtract it twice from the size. Same as shrink( long xBorder, long yBorder ); except the x and y border are the same. shrink( double factor ) is similar, but expresses the new rectangle as a fraction of the old.
Rectangle shrink | ( | long | xBorder, | |
long | yBorder | |||
) | const |
and 2*xBorder
#### #### -> ## #### ## ####The rectangle shrinks, but has the same center.
Rectangle shrink | ( | double | factor | ) | const |
Size of the rectangle will be * factor, Position adjusted for the same center.
Creates a smaller rectangle from the old rectangle.
size.x *= factor, and pos.x is adjusted inwards to compensate.
#### #### -> ## #### ## ####shows the effect of shrink( 0.5 )
Rectangle shrinkHeight | ( | long | yBorder | ) | const |
Move inwards by yBorder and shrink the size by 2*yBorder.
#### #### -> #### #### #### ####
The rectangle becomes smaller at the top and bottom, but has the same center.
Rectangle shrinkWidth | ( | long | xBorder | ) | const |
Move inwards by xBorder and shrink the size by 2*xBorder.
A rectangle of #### changes to ##.
The rectangle becomes smaller at the left and right, but has the same center.
Rectangle subRect | ( | double | xFraction, | |
double | yFraction, | |||
double | widthFraction, | |||
double | heightFraction | |||
) | const |
Creates a sub rectangle from an old rectangle.
The pos is adjusted by the xFraction and yFraction of the width and height of r. The size is also shrunk. r1.SubRect( 0, 0, 1, 0.5 ) gives the upper half of r1
r1.SubRect( 0.5, 0, 0.5, 1 ) gives the right half of r1
r1.SubRect( .334, .334, .334, .334 ) centers r2 inside r1
r1.SubRect( .2, .2, .6, .6 ) also centers r2 inside r1
OOOOOOOOOO is given by subRect( 0.3, 0.5, 0.4, 0.5 ); OOOOOOOOOO (x moved 30%, y moved 50% ) OOO++++OOO (x resized to 40%, y resized to 50% ) OOO++++OOO
Rectangle top | ( | double | portion = 0.5 |
) | const |
Move the Upper Left position by adjust, and keep the same Lower Right corner.
OOOOOO OOOO++ OOOO++upperLeftAdjust( Point( 4, 1 ) ); will give the + rectangle afterwards.