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

#include <sgl.h>

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

Public Member Functions

 DisplayDigit (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
 
- 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 led
 
- 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 wrapper for a seven-segment digit display.

Constructor & Destructor Documentation

◆ DisplayDigit()

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

The constructor sets the digit's color, position, and height.

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

Member Function Documentation

◆ decrement()

void sgl::DisplayDigit::decrement ( )

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

Returns
nothing

◆ get_value()

int sgl::DisplayDigit::get_value ( ) const

Returns the digit's current value.

Returns
the digit's current value.

◆ increment()

void sgl::DisplayDigit::increment ( )

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

Returns
nothing

◆ mouse_dragged()

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

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

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

Reimplemented from sgl::GraphicalObject.

◆ paint()

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

Draws the digit.

Implements sgl::GraphicalObject.

◆ resize()

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

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

Parameters
thechange in the height of the digit
Returns
nothing

◆ set_value()

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

Set's the value of the digit. The assigned value is modulo ten.

Parameters
valuevalue to assign, modulo 10
Returns
nothing

Member Data Documentation

◆ led

SevenSegmentDigit sgl::DisplayDigit::led
protected

The wrapper seven-segment digit display.


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