A GRect is a graphical object whose appearance consists of a rectangular box. More...
#include "gobjects.h"
Public Types | |
enum | LineStyle { LINE_NONE, LINE_SOLID, LINE_DASH, LINE_DOT, LINE_DASH_DOT, LINE_DASH_DOT_DOT } |
Styles that can be used for the outline around various shapes. More... | |
Public Member Functions | |
GRect(double x=0, double y=0, double width=0, double height=0) | |
Constructs a rectangle with the specified width and height. More... | |
bool | contains(double x, double y) const |
Returns true if the specified point is inside the object. More... | |
bool | contains(const GPoint &pt) const |
Returns true if the specified point is inside the object. More... | |
GPoint | getBottomRightLocation() const |
Returns the x/y coordinates of the bottom/right corner of the object. More... | |
double | getBottomY() const |
Returns the y-coordinate of the bottom of the object. More... | |
GRectangle | getBounds() const |
Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure. More... | |
GPoint | getCenterLocation() const |
Returns the x/y-coordinates of the center of the object. More... | |
double | getCenterX() const |
Returns the x-coordinate of the center of the object. More... | |
double | getCenterY() const |
Returns the y-coordinate of the center of the object. More... | |
string | getColor() const |
Returns the color used to display this object. More... | |
string | getFillColor() const |
Returns the color used to display the filled region of this object. More... | |
double | getHeight() const |
Returns the height of this object, which is the same as the height of its bounding box. More... | |
LineStyle | getLineStyle() const |
Returns the object's style such as solid or dashed. More... | |
double | getLineWidth() const |
Returns the width of the line used to draw this object. More... | |
GPoint | getLocation() const |
Returns the location of the top-left corner of object. More... | |
double | getOpacity() const |
Returns how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default). More... | |
GCompound * | getParent() const |
Returns a pointer to the GCompound that contains this object. More... | |
double | getRightX() const |
Returns the x-coordinate of the right side of the object. More... | |
GDimension | getSize() const |
Returns the size of the object as a GDimension . More... | |
string | getType() const override |
Returns the type of the object as a string, such as "GOval" or "GRect" . More... | |
double | getWidth() const |
Returns the width of this object, which is equal to the width of the bounding box. More... | |
double | getX() const |
Returns the leftmost x-coordinate of the object. More... | |
double | getY() const |
Returns the topmost y-coordinate of the object. More... | |
bool | isFilled() const |
Returns true if the object is filled with color. More... | |
bool | isTransformed() const |
Returns true if this object has been transformed by calling methods such as rotate() or scale() on it. More... | |
bool | isVisible() const |
Returns true if this object is visible on screen. More... | |
void | move(double dx, double dy) |
Moves the object on the screen using the displacements dx and dy . More... | |
void | repaint() |
Instructs the object to redraw itself on screen. More... | |
void | resetTransform() |
Undoes any previous scale/rotate transformations on this object. More... | |
void | rotate(double theta) |
Transforms the object by rotating it theta degrees counterclockwise around its origin. More... | |
void | scale(double sf) |
Scales the object by the specified scale factor. More... | |
void | scale(double sx, double sy) |
Scales the object by the specified scale factors. More... | |
void | sendBackward() |
Moves this object one step toward the back in the z dimension. More... | |
void | sendForward() |
Moves this object one step toward the front in the z dimension. More... | |
void | sendToBack() |
Moves this object to the back of the display in the z dimension. More... | |
void | sendToFront() |
Moves this object to the front of the display in the z dimension. More... | |
void | setBottomRightLocation(double x, double y) |
Sets the location of the bottom/right of this object. More... | |
void | setBottomRightLocation(const GPoint &pt) |
Sets the location of the bottom/right of this object. More... | |
void | setBottomY(double y) |
Sets the location of the bottom y-coordinate of this object. More... | |
void | setBounds(double x, double y, double width, double height) |
Changes the bounds of this object to the specified values. More... | |
void | setBounds(const GRectangle &size) |
Changes the bounds of this object to the specified rectangle. More... | |
void | setCenterLocation(double x, double y) |
Sets the location of the center of this object. More... | |
void | setCenterLocation(const GPoint &pt) |
Sets the location of the center of this object. More... | |
void | setCenterX(double x) |
Sets the x-coordinate of the center of this object. More... | |
void | setCenterY(double y) |
Sets the y-coordinate of the center of this object. More... | |
void | setColor(int r, int g, int b) |
Sets the color used to display this object. More... | |
void | setColor(int rgb) |
Sets the color used to display this object. More... | |
void | setColor(string color) |
Sets the color used to display this object. More... | |
void | setFillColor(int r, int g, int b) |
Sets the color used to display the filled region of this object, if any. More... | |
void | setFillColor(int rgb) |
Sets the color used to display the filled region of this object, if any. More... | |
void | setFillColor(string color) |
Sets the color used to display the filled region of this object, if any. More... | |
void | setFilled(bool flag) |
Sets the fill status for the object, where false is outlined and true is filled. More... | |
void | setFont(const QFont &font) |
Changes the font used to display the object as specified by the given Qt font. More... | |
void | setFont(string font) |
Changes the font used to display the object as specified by the string font , which has the following format: More... | |
void | setForeground(int r, int g, int b) |
Sets the color used to display this object. More... | |
void | setForeground(int rgb) |
Sets the color used to display this object. More... | |
void | setForeground(string color) |
Sets the color used to display this object. More... | |
void | setHeight(double height) |
Changes the height of this object to the specified height without changing its width. More... | |
void | setLineStyle(LineStyle lineStyle) |
Sets the object's style such as solid (GObject::LINE_SOLID) or dashed (GObject::LINE_DASH). More... | |
void | setLineWidth(double lineWidth) |
Sets the width of the line used to draw this object. More... | |
void | setLocation(double x, double y) |
Sets the location of the top-left corner of this object to the specified coordinates. More... | |
void | setLocation(const GPoint &pt) |
Sets the location of the top-left corner of this object to the specified point. More... | |
void | setOpacity(double opacity) |
Sets how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default). More... | |
void | setRightX(double x) |
Sets the location of the rightmost x-coordinate of this object. More... | |
void | setSize(double width, double height) |
Changes the size of this object to the specified width and height. More... | |
void | setSize(const GDimension &size) |
Changes the size of this object to the specified width and height. More... | |
void | setVisible(bool flag) |
Sets whether this object is visible. More... | |
void | setWidth(double width) |
Changes the width of this object to the specified width without changing its height. More... | |
void | setX(double x) |
Sets the x location of the left side of this object. More... | |
void | setY(double y) |
Sets the y location of the top of this object. More... | |
string | toString() const |
Returns a printable representation of the object. More... | |
Static Public Member Functions | |
static bool | isAntiAliasing() |
Returns whether we should globally anti-alias graphical objects. More... | |
static void | setAntiAliasing(bool value) |
Globally turns on/off the anti-aliasing feature that smooths out the edges of onscreen shapes. More... | |
Protected Member Functions | |
string | toStringExtra() const |
Returns a string containing any extra unique information about this type of graphical object. More... | |
Protected Attributes | |
QBrush | _brush |
string | _color |
int | _colorInt |
string | _fillColor |
int | _fillColorInt |
bool | _fillFlag |
string | _font |
double | _height |
LineStyle | _lineStyle |
double | _lineWidth |
double | _opacity |
GCompound * | _parent |
QPen | _pen |
QTransform | _transform |
bool | _transformed |
bool | _visible |
double | _width |
double | _x |
double | _y |
A GRect is a graphical object whose appearance consists of a rectangular box.
|
inherited |
Styles that can be used for the outline around various shapes.
Call setLineStyle on a GObject and pass one of these values.
Enumerator | |
---|---|
LINE_NONE | |
LINE_SOLID | |
LINE_DASH | |
LINE_DOT | |
LINE_DASH_DOT | |
LINE_DASH_DOT_DOT |
GRect | ( | double | x = 0 , |
double | y = 0 , |
||
double | width = 0 , |
||
double | height = 0 |
||
) |
Constructs a rectangle with the specified width and height.
The first form is positioned at the origin; the second at the coordinates given by x
and y
.
|
virtualinherited |
|
virtualinherited |
Returns true
if the specified point is inside the object.
|
virtualinherited |
Returns the x/y coordinates of the bottom/right corner of the object.
|
virtualinherited |
Returns the y-coordinate of the bottom of the object.
Equivalent to the top y-coordinate plus the object's height.
|
virtualinherited |
Returns the bounding box of this object, which is defined to be the smallest rectangle that covers everything drawn by the figure.
The coordinates of this rectangle do not necessarily match the location returned by getLocation
. Given a GText
object, for example, getLocation
returns the coordinates of the point on the baseline at which the string begins; the getBounds
method, by contrast, returns a rectangle that covers the entire window area occupied by the string.
Reimplemented in GText, GPolygon, GLine, GCompound, and GArc.
|
virtualinherited |
Returns the x/y-coordinates of the center of the object.
Equivalent to the top/left plus half the object's size.
|
virtualinherited |
Returns the x-coordinate of the center of the object.
Equivalent to the top/left plus half the object's width.
|
virtualinherited |
Returns the y-coordinate of the center of the object.
Equivalent to the top/left plus half the object's height.
|
virtualinherited |
Returns the color used to display this object.
This color is always returned as a string in the form "#rrggbb"
, where rr
, gg
, and bb
are the red, green, and blue components of the color, expressed as two-digit hexadecimal values.
|
virtualinherited |
Returns the color used to display the filled region of this object.
If none has been set, returns the empty string.
|
virtualinherited |
|
virtualinherited |
Returns the object's style such as solid or dashed.
|
virtualinherited |
Returns the width of the line used to draw this object.
|
virtualinherited |
Returns the location of the top-left corner of object.
|
virtualinherited |
Returns how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default).
|
virtualinherited |
Returns a pointer to the GCompound
that contains this object.
Every GWindow
is initialized to contain a single GCompound
that is aligned with the window. Adding objects to the window adds them to that GCompound
, which means that every object you add to the window has a parent. Calling getParent
on the top-level GCompound
returns nullptr
.
|
virtualinherited |
Returns the x-coordinate of the right side of the object.
Equivalent to the left x-coordinate plus the object's width.
|
virtualinherited |
Returns the size of the object as a GDimension
.
|
overridevirtual |
Returns the type of the object as a string, such as "GOval"
or "GRect"
.
Each GObject subtype must override this method.
Implements GObject.
Reimplemented in GRoundRect.
|
virtualinherited |
|
virtualinherited |
Returns the leftmost x-coordinate of the object.
|
virtualinherited |
Returns the topmost y-coordinate of the object.
|
staticinherited |
Returns whether we should globally anti-alias graphical objects.
On by default.
|
virtualinherited |
Returns true
if the object is filled with color.
|
virtualinherited |
|
virtualinherited |
Returns true
if this object is visible on screen.
|
virtualinherited |
Moves the object on the screen using the displacements dx
and dy
.
|
virtualinherited |
Instructs the object to redraw itself on screen.
Reimplemented in GCompound.
|
virtualinherited |
Undoes any previous scale/rotate transformations on this object.
|
virtualinherited |
Transforms the object by rotating it theta
degrees counterclockwise around its origin.
After calling this method on a graphical object, isTransformed
will return true
for that object unless you subsequently call resetTransform
on it.
|
virtualinherited |
Scales the object by the specified scale factor.
This form scales the object by sf
in both dimensions, so that invoking gobj->scale(2);
doubles the size of the object. After calling this method on a graphical object, isTransformed
will return true
for that object unless you subsequently call resetTransform
on it.
|
virtualinherited |
Scales the object by the specified scale factors.
For example, gobj->scale(2, 2);
doubles the size of the object. This form applies independent scale factors to the x and y dimensions. After calling this method on a graphical object, isTransformed
will return true
for that object unless you subsequently call resetTransform
on it.
|
inherited |
Moves this object one step toward the back in the z dimension.
If it was already at the back of the stack, nothing happens.
|
inherited |
Moves this object one step toward the front in the z dimension.
If it was already at the front of the stack, nothing happens.
|
inherited |
Moves this object to the back of the display in the z dimension.
By moving it to the back, this object will appear to be behind the other graphical objects on the display and may be obscured by other objects in front.
|
inherited |
Moves this object to the front of the display in the z dimension.
By moving it to the front, this object will appear to be on top of the other graphical objects on the display and may hide any objects that are further back.
|
staticinherited |
Globally turns on/off the anti-aliasing feature that smooths out the edges of onscreen shapes.
On by default. Does not repaint any onscreen objects when called; you must do this yourself.
|
virtualinherited |
Sets the location of the bottom/right of this object.
|
virtualinherited |
Sets the location of the bottom/right of this object.
|
virtualinherited |
Sets the location of the bottom y-coordinate of this object.
|
virtualinherited |
Changes the bounds of this object to the specified values.
|
virtualinherited |
Changes the bounds of this object to the specified rectangle.
|
virtualinherited |
Sets the location of the center of this object.
|
virtualinherited |
Sets the location of the center of this object.
|
virtualinherited |
Sets the x-coordinate of the center of this object.
|
virtualinherited |
Sets the y-coordinate of the center of this object.
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setForeground.
r | redness from 0-255 |
g | greenness from 0-255 |
b | blueness from 0-255 |
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setForeground.
rgb | an RGB integer value such as 0x7700ff |
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setForeground.
color | color string such as "#7700ff" or "purple" |
|
virtualinherited |
Sets the color used to display the filled region of this object, if any.
As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors. If an empty string is passed, sets filled to false.
r | redness from 0-255 |
g | greenness from 0-255 |
b | blueness from 0-255 |
|
virtualinherited |
Sets the color used to display the filled region of this object, if any.
As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors.
rgb | an RGB integer value such as 0x7700ff |
|
virtualinherited |
Sets the color used to display the filled region of this object, if any.
As a side effect, sets this object to be filled (setFilled(true)). See gcolor.h for more detail about how to specify colors. If an empty string is passed, sets filled to false.
color | color string such as "#7700ff" or "purple" |
|
virtualinherited |
Sets the fill status for the object, where false
is outlined and true
is filled.
|
virtualinherited |
|
virtualinherited |
Changes the font used to display the object as specified by the string font
, which has the following format:
"family-style-size"
where both style
and size
are optional. If any of these elements are missing or specified as an asterisk, the existing value is retained. See gfont.h for more detail about how to specify fonts.
Reimplemented in GText.
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setColor.
r | redness from 0-255 |
g | greenness from 0-255 |
b | blueness from 0-255 |
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setColor.
rgb | an RGB integer value such as 0x7700ff |
|
virtualinherited |
Sets the color used to display this object.
See gcolor.h for more detail about how to specify colors.
Equivalent to setColor.
color | color string such as "#7700ff" or "purple" |
|
virtualinherited |
Changes the height of this object to the specified height without changing its width.
|
virtualinherited |
Sets the object's style such as solid (GObject::LINE_SOLID) or dashed (GObject::LINE_DASH).
|
virtualinherited |
Sets the width of the line used to draw this object.
The default line width is 1.
|
virtualinherited |
Sets the location of the top-left corner of this object to the specified coordinates.
|
virtualinherited |
Sets the location of the top-left corner of this object to the specified point.
|
virtualinherited |
Sets how opaque (non-transparent) this object will appear from 0.0 (completely transparent) to 1.0 (completely opaque, default).
ErrorException | if opacity is out of range [0.0, 1.0] |
|
virtualinherited |
Sets the location of the rightmost x-coordinate of this object.
|
virtualinherited |
Changes the size of this object to the specified width and height.
|
virtualinherited |
Changes the size of this object to the specified width and height.
|
virtualinherited |
Sets whether this object is visible.
Graphical objects are initially visible when created.
|
virtualinherited |
Changes the width of this object to the specified width without changing its height.
|
virtualinherited |
Sets the x location of the left side of this object.
|
virtualinherited |
Sets the y location of the top of this object.
|
virtualinherited |
Returns a printable representation of the object.
Reimplemented in GCompound.
|
protectedvirtualinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |