Simple Graphics Library
0.9.5
SGL API
|
#include <sgl.h>
Public Member Functions | |
Multidigit (int n, Color color, double x, double y, double height) | |
void | paint () const override |
void | set_value (int value) |
int | get_value () const |
void | increment () |
void | decrement () |
void | resize (double inc) |
void | mouse_dragged (double x, double y) override |
virtual void | move_to (double left, double bottom) override |
void | set_leading_zeros (bool flag) |
void | set_visible (bool flag) |
![]() | |
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 | 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 | 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 () |
Protected Member Functions | |
void | increment_helper (int n) |
void | decrement_helper (int n) |
Protected Attributes | |
std::vector< SevenSegmentDigit > | digits |
bool | leading_zeros |
bool | visible |
![]() | |
ObjectWindow * | window |
double | x_hit_offset |
double | y_hit_offset |
double | left |
double | bottom |
double | width |
double | height |
CursorShape | cursor |
bool | mouse_over |
Additional Inherited Members | |
![]() | |
const unsigned | id |
A graphical object representing a multi-digit seven-segment display.
sgl::Multidigit::Multidigit | ( | int | n, |
Color | color, | ||
double | x, | ||
double | y, | ||
double | height | ||
) |
The constructor sets the seven-segment display's number of digits, color, position, and height. The display's value is initially zero.
n | the number of digits |
color | the color of the digits |
x | the x coordinate of the leading digit's lower-left corner |
y | the y coordinate of the leading digit's lower-left corner |
height | the height of the digits |
The constructor sets the display's number of digits, color, position, and height. The digit's value is initially zero.
n | the number of digits |
color | the color of the digits |
x | the x coordinate of the leading digit's lower-left corner |
y | the y coordinate of the leading digit's lower-left corner |
height | the height of the digits |
void sgl::Multidigit::decrement | ( | ) |
Decreases the display's value by 1
int sgl::Multidigit::get_value | ( | ) | const |
Returns the display's current value.
Returns the current value.
void sgl::Multidigit::increment | ( | ) |
Increases the display's value by 1
|
overridevirtual |
Moves the display to a new location. The display's size is unaffected.
x | the new x coordinate of the display's lower-left corner. |
y | the new y coordinate of the display's lower-left corner. |
Moves the display to a new location. The digits' sizes are unaffected.
x | the new x coordinate of the display's lower-left corner. |
y | the new y coordinate of the display's lower-left corner. |
Reimplemented from sgl::GraphicalObject.
|
overridevirtual |
Relocates the left-bottom corner of the display to the specified location. The display's size is unaffected.
left | the x coordinate in viewport coordinates of the left-bottom corner of the display |
bottom | the y coordinate in viewport coordinates of the left-bottom corner of the display |
Relocates the left-bottom corner of the display to the specified location. The display's size is unaffected.
x | the x coordinate in viewport coordinates of the left-bottom corner of the display |
y | the y coordinate in viewport coordinates of the left-bottom corner of the display |
Reimplemented from sgl::GraphicalObject.
|
overridevirtual |
Draws the digits.
Implements sgl::GraphicalObject.
void sgl::Multidigit::resize | ( | double | inc | ) |
Changes the height of the display by a given amount. The display's width changes proportionally.
the | change in the height of the display |
Changes the height of the display by a given amount. The display's width changes proportionally.
the | change in the height of the digits |
void sgl::Multidigit::set_leading_zeros | ( | bool | flag | ) |
Turns on or off the display of leading zeros.
flag | if true, leading zeros are displayed; otherwise, leading zeros are not displayed. |
Turns on or off the display of a leading zero.
flag | if true, a leading zero is displayed; otherwise, a leading zero is not displayed. |
void sgl::Multidigit::set_value | ( | int | value | ) |
Set's the value of the display.
value | value to assign |
void sgl::Multidigit::set_visible | ( | bool | flag | ) |
Makes the display visible or invisible.
flag | if true, the digits are visible otherwise, the digits are invisible. |
|
protected |
Vector of seven segment digits
|
protected |
Dynamic array of seven segment digits If true, a leading zeros are visible; otherwise, leading zeros are not displayed.
|
protected |
If true, the display is visible; otherwise, it is invisible.