Simple Graphics Library  0.9.5
SGL API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
sgl::TimeDisplay Class Reference
Inheritance diagram for sgl::TimeDisplay:
Inheritance graph
[legend]
Collaboration diagram for sgl::TimeDisplay:
Collaboration graph
[legend]

Public Member Functions

 TimeDisplay (Color color, double x, double y, int height)
 
void paint () const override
 
void set_value (int sec)
 
int get_value () const
 
void increment ()
 
void decrement ()
 
void resize (double inc)
 
void mouse_dragged (double x, double y) override
 
void move_to (double x, double y) override
 
void set_leading_units (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 draw_separator (const SevenSegmentDigit &left_ones, const SevenSegmentDigit &right_tens) const
 
void paint_without_leading_units () const
 

Protected Attributes

SevenSegmentDigit hours_tens
 
SevenSegmentDigit hours_ones
 
SevenSegmentDigit minutes_tens
 
SevenSegmentDigit minutes_ones
 
SevenSegmentDigit seconds_tens
 
SevenSegmentDigit seconds_ones
 
int seconds
 
bool leading_units
 
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
 

Constructor & Destructor Documentation

◆ TimeDisplay()

sgl::TimeDisplay::TimeDisplay ( Color  color,
double  x,
double  y,
int  height 
)

The constructor sets the display's color, position, and height. The time 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::TimeDisplay::decrement ( )

Decreases the time by one second.

Returns
nothing

◆ draw_separator()

void sgl::TimeDisplay::draw_separator ( const SevenSegmentDigit left_ones,
const SevenSegmentDigit right_tens 
) const
protected

Draw the hours-minutes or minutes-seconds colon separator.

Parameters
left_onesthe ones digit of the left quantity
right_tensthe tens digit of the right quantity
Returns
nothing

◆ get_value()

int sgl::TimeDisplay::get_value ( ) const

Returns the current time, in seconds.

Returns
the current value.

◆ increment()

void sgl::TimeDisplay::increment ( )

Increases the time by one second.

Returns
nothing

◆ mouse_dragged()

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

Reimplemented from sgl::GraphicalObject.

◆ move_to()

void sgl::TimeDisplay::move_to ( 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

Reimplemented from sgl::GraphicalObject.

◆ paint()

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

Draws the display.

Returns
nothing

Implements sgl::GraphicalObject.

◆ paint_without_leading_units()

void sgl::TimeDisplay::paint_without_leading_units ( ) const
protected

Draw the display without leading units that are zero; for example, 1:03:23 instead of 01:03:23, 4:10 instead of 00:04:10, and 3 instead of 00:00:03.

Returns
nothing

◆ resize()

void sgl::TimeDisplay::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_units()

void sgl::TimeDisplay::set_leading_units ( 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::TimeDisplay::set_value ( int  sec)

Sets the time.

Parameters
secdesired time, in seconds
Returns
nothing

◆ set_visible()

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

◆ hours_ones

SevenSegmentDigit sgl::TimeDisplay::hours_ones
protected

The hours unit ones digit.

◆ hours_tens

SevenSegmentDigit sgl::TimeDisplay::hours_tens
protected

The hours unit tens digit.

◆ leading_units

bool sgl::TimeDisplay::leading_units
protected

If true, leading units are visible; otherwise, leading units are not displayed.

◆ minutes_ones

SevenSegmentDigit sgl::TimeDisplay::minutes_ones
protected

The minutes unit ones digit.

◆ minutes_tens

SevenSegmentDigit sgl::TimeDisplay::minutes_tens
protected

The minutes unit tens digit.

◆ seconds

int sgl::TimeDisplay::seconds
protected

The time, in seconds.

◆ seconds_ones

SevenSegmentDigit sgl::TimeDisplay::seconds_ones
protected

The seconds unit ones digit.

◆ seconds_tens

SevenSegmentDigit sgl::TimeDisplay::seconds_tens
protected

The seconds unit tens digit.

◆ visible

bool sgl::TimeDisplay::visible
protected

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


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