Simple Graphics Library  0.9.5
SGL API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sgl::Multidigit Class Reference

#include <sgl.h>

Inheritance diagram for sgl::Multidigit:
Inheritance graph
[legend]
Collaboration diagram for sgl::Multidigit:
Collaboration graph
[legend]

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)
 
- Public Member Functions inherited from sgl::GraphicalObject
 GraphicalObject (double left, double bottom, double width, double height)
 
 GraphicalObject (const GraphicalObject &other)
 
GraphicalObjectoperator= (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 Windowset_window (ObjectWindow *win)
 
virtual Windowget_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< SevenSegmentDigitdigits
 
bool leading_zeros
 
bool visible
 
- Protected Attributes inherited from sgl::GraphicalObject
ObjectWindowwindow
 
double x_hit_offset
 
double y_hit_offset
 
double left
 
double bottom
 
double width
 
double height
 
CursorShape cursor
 
bool mouse_over
 

Additional Inherited Members

- Public Attributes inherited from sgl::GraphicalObject
const unsigned id
 

Detailed Description

A graphical object representing a multi-digit seven-segment display.

Constructor & Destructor Documentation

◆ Multidigit()

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.

Parameters
nthe number of digits
colorthe color of the digits
xthe x coordinate of the leading digit's lower-left corner
ythe y coordinate of the leading digit's lower-left corner
heightthe height of the digits

The constructor sets the display's number of digits, color, position, and height. The digit's value is initially zero.

Parameters
nthe number of digits
colorthe color of the digits
xthe x coordinate of the leading digit's lower-left corner
ythe y coordinate of the leading digit's lower-left corner
heightthe height of the digits

Member Function Documentation

◆ decrement()

void sgl::Multidigit::decrement ( )

Decreases the display's value by 1

Returns
nothing

◆ get_value()

int sgl::Multidigit::get_value ( ) const

Returns the display's current value.

Returns
the current value.

Returns the current value.

Returns
the current value.

◆ increment()

void sgl::Multidigit::increment ( )

Increases the display's value by 1

Returns
nothing

◆ mouse_dragged()

void sgl::Multidigit::mouse_dragged ( double  x,
double  y 
)
overridevirtual

Moves the display to a new location. The display's size is unaffected.

Parameters
xthe new x coordinate of the display's lower-left corner.
ythe new y coordinate of the display's lower-left corner.
Returns
nothing

Moves the display to a new location. The digits' sizes are unaffected.

Parameters
xthe new x coordinate of the display's lower-left corner.
ythe new y coordinate of the display's lower-left corner.
Returns
nothing

Reimplemented from sgl::GraphicalObject.

◆ move_to()

void sgl::Multidigit::move_to ( double  x,
double  y 
)
overridevirtual

Relocates the left-bottom corner of the display to the specified location. The display's size is unaffected.

Parameters
leftthe x coordinate in viewport coordinates of the left-bottom corner of the display
bottomthe y coordinate in viewport coordinates of the left-bottom corner of the display
Returns
nothing

Relocates the left-bottom corner of the display to the specified location. The display's size is unaffected.

Parameters
xthe x coordinate in viewport coordinates of the left-bottom corner of the display
ythe y coordinate in viewport coordinates of the left-bottom corner of the display
Returns
nothing

Reimplemented from sgl::GraphicalObject.

◆ paint()

void sgl::Multidigit::paint ( ) const
overridevirtual

Draws the digits.

Implements sgl::GraphicalObject.

◆ resize()

void sgl::Multidigit::resize ( double  inc)

Changes the height of the display by a given amount. The display's width changes proportionally.

Parameters
thechange in the height of the display
Returns
nothing

Changes the height of the display by a given amount. The display's width changes proportionally.

Parameters
thechange in the height of the digits
Returns
nothing

◆ set_leading_zeros()

void sgl::Multidigit::set_leading_zeros ( bool  flag)

Turns on or off the display of leading zeros.

Parameters
flagif true, leading zeros are displayed; otherwise, leading zeros are not displayed.
Returns
nothing

Turns on or off the display of a leading zero.

Parameters
flagif true, a leading zero is displayed; otherwise, a leading zero is not displayed.
Returns
nothing

◆ set_value()

void sgl::Multidigit::set_value ( int  value)

Set's the value of the display.

Parameters
valuevalue to assign
Returns
nothing

◆ set_visible()

void sgl::Multidigit::set_visible ( bool  flag)

Makes the display visible or invisible.

Parameters
flagif true, the digits are visible otherwise, the digits are invisible.
Returns
nothing

Member Data Documentation

◆ digits

std::vector<SevenSegmentDigit> sgl::Multidigit::digits
protected

Vector of seven segment digits

◆ leading_zeros

bool sgl::Multidigit::leading_zeros
protected

Dynamic array of seven segment digits If true, a leading zeros are visible; otherwise, leading zeros are not displayed.

◆ visible

bool sgl::Multidigit::visible
protected

If true, the display is visible; otherwise, it is invisible.


The documentation for this class was generated from the following files: