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

#include <sgl.h>

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

Public Member Functions

 DoubleDigit (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
 
void set_leading_zero (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 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 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 Attributes

SevenSegmentDigit tens
 
SevenSegmentDigit ones
 
bool leading_zero
 
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 two-digit seven-segment display.

Constructor & Destructor Documentation

◆ DoubleDigit()

sgl::DoubleDigit::DoubleDigit ( Color  color,
double  x,
double  y,
double  height 
)

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

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

Member Function Documentation

◆ decrement()

void sgl::DoubleDigit::decrement ( )

Decreases the digit's value by 1, modulo 100.

Returns
nothing

◆ get_value()

int sgl::DoubleDigit::get_value ( ) const

Returns the current value.

Returns
the current value.

◆ increment()

void sgl::DoubleDigit::increment ( )

Increases the digit's value by 1, modulo 100.

Returns
nothing

◆ mouse_dragged()

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

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

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

Reimplemented from sgl::GraphicalObject.

◆ paint()

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

Draws the digits.

Implements sgl::GraphicalObject.

◆ resize()

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

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

Parameters
thechange in the height of the digits
Returns
nothing

◆ set_leading_zero()

void sgl::DoubleDigit::set_leading_zero ( bool  flag)

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::DoubleDigit::set_value ( int  value)

Set's the value of the digits. The assigned value is modulo 100.

Parameters
valuevalue to assign, modulo 100
Returns
nothing

◆ set_visible()

void sgl::DoubleDigit::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

◆ leading_zero

bool sgl::DoubleDigit::leading_zero
protected

If true, a leading zero is visible; otherwise, a leading zero is not displayed.

◆ ones

SevenSegmentDigit sgl::DoubleDigit::ones
protected

The ones digit.

◆ tens

SevenSegmentDigit sgl::DoubleDigit::tens
protected

The tens digit.

◆ visible

bool sgl::DoubleDigit::visible
protected

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


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