Simple Graphics Library
0.9.5
SGL API
|
#include <sgl.h>
Public Member Functions | |
GraphicalObject (double left, double bottom, double width, double height) | |
GraphicalObject (const GraphicalObject &other) | |
GraphicalObject & | operator= (const GraphicalObject &other) |
virtual | ~GraphicalObject () |
virtual double | get_left () const |
virtual double | get_bottom () const |
virtual double | get_width () const |
virtual double | get_height () const |
virtual void | set (double x, double y, double width, double height) |
virtual void | paint () const =0 |
virtual void | move_to (double left, double bottom) |
virtual void | mouse_pressed (double x, double y, MouseButton button) |
virtual void | mouse_released (double x, double y, MouseButton button) |
virtual void | mouse_moved (double x, double y) |
virtual void | mouse_dragged (double x, double y) |
virtual void | key_pressed (int k, double x, double y) |
virtual bool | hit (double x, double y) |
virtual Window * | set_window (ObjectWindow *win) |
virtual Window * | get_window () const |
virtual void | set_mouse_over (bool flag) |
virtual CursorShape | set_cursor (CursorShape cursor) |
virtual CursorShape | get_cursor () |
Public Attributes | |
const unsigned | id |
Protected Attributes | |
ObjectWindow * | window |
double | x_hit_offset |
double | y_hit_offset |
double | left |
double | bottom |
double | width |
double | height |
CursorShape | cursor |
bool | mouse_over |
Represents a persistent graphical object used within a window. A graphical object is owned by a particular window.
sgl::GraphicalObject::GraphicalObject | ( | double | left, |
double | bottom, | ||
double | width, | ||
double | height | ||
) |
Constructor specifies the bounding box extent.
left | the x coordinate in viewport coordinates of the left-bottom corner of the graphical object's bounding box |
left | the y coordinate in viewport coordinates of the left-bottom corner of the graphical object's bounding box |
width | the width in viewport coordinates of the graphical object's bounding box |
height | the height in viewport coordinates of the graphical object's bounding box |
sgl::GraphicalObject::GraphicalObject | ( | const GraphicalObject & | other | ) |
Copy construction creates a new graphical object with identical location. The new graphical object has the same containing window but has a unique id. The pre-existing graphical object is not affected by the copy.
other | the graphical object from which this new graphical object is being created. |
|
virtual |
Destroys a graphical object.
|
virtual |
Returns the y value of the left-bottom corner of the graphical object's bounding box. The value is given in the viewport coordinate system.
|
virtual |
Returns the cursor shape associated with this graphical object.
|
virtual |
Returns the height in viewport coordinates of the graphical object's bounding box.
|
virtual |
Returns the x value of the left-bottom corner of the graphical object's bounding box. The value is given in the viewport coordinate system.
|
virtual |
Returns the width in viewport coordinates of the graphical object's bounding box.
|
virtual |
Get the containing window of this graphical object.
|
virtual |
Returns true if the coordinate provided is within the graphical object's bounding box; otherwise, it returns false.
x | the x coordinate in viewport coordinates of the location to check |
y | the y coordinate in viewport coordinates of the location to check |
|
virtual |
Called by the containing window when the user types a key when the window has keyboard focus and the mouse pointer is over the graphical object. The key pressed and the location of the mouse pointer in viewport coordinates is reported.
k | the key typed by the user |
x | the x coordinate in viewport coordinates of the location of the mouse pointer within the window |
y | the y coordinate in viewport coordinates of the location of the mouse pointer within the window |
|
virtual |
Called by the containing window's mouse_dragged method when the user drags the mouse By default it relocates the (left,bottom) location of the graphical object's bounding box relative to a mouse drag event. The move is relative to the location of the last mouse event on the object. This allows the user to drag the graphical object without it "jumping" slightly at first movement. The graphical object's width and height are unaffected.
x | the x coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
Called by the containing window's mouse_dragged method when the user drags the mouse when the mouse pointer is over the graphical object.
x | the x coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
Reimplemented in sgl::TimeDisplay, sgl::Multidigit, sgl::DoubleDigit, and sgl::DisplayDigit.
|
virtual |
Called by the containing window's mouse_moved method when the user moves the mouse when the mouse pointer is over the graphical object.
x | the x coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
|
virtual |
Called by the containing window's mouse_pressed method when the user depresses any mouse button when the mouse pointer is over the graphical object.
x | the x coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
button | the button that was depressed, left (LEFT_BUTTON) or right (RIGHT_BUTTON) during the current mouse event. |
|
virtual |
Called by the containing window's mouse_released method when the user releases any mouse button when the mouse pointer is over the graphical object.
x | the x coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
y | the y coordinate in viewport coordinates of the mouse pointer location during the current mouse event. |
button | the button that was depressed, left (LEFT_BUTTON) or right (RIGHT_BUTTON) during the current mouse event. |
|
virtual |
Relocates the left-bottom corner of the graphical object's bounding box to the specified location. The graphical object's width and height are unaffected.
left | the x coordinate in viewport coordinates of the left-bottom corner of the graphical object's bounding box |
bottom | the y coordinate in viewport coordinates of the left-bottom corner of the graphical object's bounding box |
Reimplemented in sgl::TimeDisplay, sgl::Multidigit, and sgl::CompositeObject.
GraphicalObject & sgl::GraphicalObject::operator= | ( | const GraphicalObject & | other | ) |
Assignment copies the location, size, and window container from another graphical object. The id of the window being assigned is not affected. The source graphical object is not affected by the copy.
other | the source graphical object from which this graphical object is being assigned. |
|
pure virtual |
The paint method is called by the containing window's paint method when it renders this graphical object. This method is abstract, so concrete derived classes must provide a concrete imppementation.
Implemented in sgl::TimeDisplay, sgl::Multidigit, sgl::DoubleDigit, sgl::DisplayDigit, sgl::BitmapObject, and sgl::CompositeObject.
|
virtual |
Sets the location and size of the graphical object. Values given are in the containing viewport's coordinates. the x coordinate of the left-bottom corner of the graphical object's bounding rectangle. the y coordinate of the left-bottom corner of the graphical object's bounding rectangle. the graphical object's width in viewport coordinates. the graphical object's height in viewport coordinates.
|
virtual |
Sets the graphical object's cursor shape.
cursor | the object's cursor shape |
|
virtual |
Activates or deactivates the graphical object
flag | if true, activates the object; otherwise, deactivates the object |
|
virtual |
Set the containing window.
win | a pointer to the window to make the containing window for this graphical object. |
|
protected |
y coordinate of the left-bottom corner of the graphical object's bounding box
|
protected |
Shape that the cursor should assume when the mouse hovers over this graphical object.
|
protected |
Height of the graphical object's bounding box in the viewport coordinate system
const unsigned sgl::GraphicalObject::id |
This graphical object's unique ID
|
protected |
x coordinate of the left-bottom corner of the graphical object's bounding box
|
protected |
Indicates if this object is the one that the mouse is currently hovering over.
|
protected |
Width of the graphical object's bounding box in the viewport coordinate system
|
protected |
The window in which this graphical object is a component
|
protected |
Location of the mouse pointer's x coordinate relative to the graphical object's bounding box
|
protected |
Location of the mouse pointer's y coordinate relative to the graphical object's bounding box