C++ DevKit
C++ set of OOP library
Loading...
Searching...
No Matches
GraphicWidget Class Referenceabstract

The graphical version of a Widget. More...

#include <widget.h>

Inheritance diagram for GraphicWidget:
Inheritance graph
Collaboration diagram for GraphicWidget:
Collaboration graph

Public Member Functions

void update_widget_anchor (uint8_t x, uint8_t y)
 Modify the anchor of the widget on the display screen.
 
virtual void draw_border (ColorIndex color=ColorIndex::WHITE)
 draw a rectangle around the widget.
 
void show ()
 A short way to call GraphicDisplayDevice::show(&canvas, anchor x, anchor y)
 
 GraphicWidget (GraphicDisplayDevice *graphic_display_screen, struct_ConfigGraphicWidget graph_cfg, CanvasFormat canvas_format, Model *displayed_object=nullptr)
 Construct a new Graphic Widget object.
 
 GraphicWidget (GraphicDisplayDevice *graphic_display_screen, struct_ConfigTextWidget text_cfg, CanvasFormat canvas_format, Model *displayed_object=nullptr)
 Construct a new Graphic Widget object from the TextWidget Constructor.
 
 GraphicWidget (GraphicDisplayDevice *graphic_display_screen, struct_ConfigTextWidget text_cfg, CanvasFormat canvas_format, size_t frame_width, size_t frame_height, Model *displayed_object=nullptr)
 Construct a new Graphic Widget object from the TextWidget Constructor.
 
 ~GraphicWidget ()
 Destroy the Widget object.
 
struct_ConfigGraphicWidget get_graph_frame_config ()
 Get the graphic frame config object.
 
void hline (uint8_t x, uint8_t y, size_t w, ColorIndex color=ColorIndex::WHITE)
 Draw a color horizontal line, starting at frame position (x,y), on w number of pixel.
 
void vline (uint8_t x, uint8_t y, size_t h, ColorIndex color=ColorIndex::WHITE)
 Draw a color vertical line, starting at frame position (x,y), on w number of pixel.
 
void line (int x0, int y0, int x1, int y1, ColorIndex color=ColorIndex::WHITE)
 Draw a color line, starting at frame position (x0,y0), ending at frame position (x1,y1)
 
void rect (uint8_t start_x, uint8_t start_y, size_t w, size_t h, bool fill=false, ColorIndex color=ColorIndex::WHITE)
 Draw a rectangle, starting at frame position (x,y), w wide and h high.
 
void circle (int radius, int x_center, int y_center, bool fill=false, ColorIndex color=ColorIndex::WHITE)
 draw a cercle of size radius, centered at (x_center, y_center) https://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham https://en.wikipedia.org/wiki/Midpoint_circle_algorithm procédure tracerCercle (entier rayon, entier x_centre, entier y_centre) déclarer entier x, y, m ; x ← 0 ; y ← rayon ; // on se place en haut du cercle m ← 5 - 4*rayon ; // initialisation Tant que x <= y // tant qu'on est dans le second octant tracerPixel( x+x_centre, y+y_centre ) ; tracerPixel( y+x_centre, x+y_centre ) ; tracerPixel( -x+x_centre, y+y_centre ) ; tracerPixel( -y+x_centre, x+y_centre ) ; tracerPixel( x+x_centre, -y+y_centre ) ; tracerPixel( y+x_centre, -x+y_centre ) ; tracerPixel( -x+x_centre, -y+y_centre ) ; tracerPixel( -y+x_centre, -x+y_centre ) ; si m > 0 alors //choix du point F y ← y - 1 ; m ← m - 8*y ; fin si ; x ← x + 1 ; m ← m + 8*x + 4 ; fin tant que ; fin de procédure ;
 
- Public Member Functions inherited from Widget
 Widget (Model *actual_displayed_model, DisplayDevice *graphic_display_device=nullptr)
 contructor for generic widget
 
void add_widget (Widget *_sub_widget)
 add sub_widget to the current widget
 
void set_display_device (DisplayDevice *_new_display_device)
 Set the display screen object.
 
virtual void draw ()=0
 a pure virtual member that is called to effectively draw the widget.
 

Public Attributes

Canvascanvas
 the associated canvas in which the widget writes text and draws graphics
 
ColorIndex fg_color
 the foregroung color of the graphic frame //TODO voir si fg_color n'est pas mieux dans canvas
 
ColorIndex bg_color
 the background color of the graphic frame //TODO voir si bg_color n'est pas mieux dans canvas
 
uint8_t widget_anchor_x
 location in x of the widget within the hosting framebuffer
 
uint8_t widget_anchor_y
 location in y of the widget within the hosting framebuffer
 

Protected Member Functions

void clear_widget ()
 fill the graphic pixel buffer with 0x00.
 
virtual void get_value_of_interest ()=0
 A pure virtual method that results in the transfer of the displayed values of the displayed model to the widget.
 

Protected Attributes

bool widget_with_border {false}
 if true, the widget is surrounded by a one-pixel border
 
size_t widget_width {128}
 As a widget can be surrounded by a border, the actual widget width is not the associated framebuffer width.
 
size_t widget_height {8}
 As a widget can be surrounded by a border, the actual widget height is not the associated framebuffer height.
 
uint8_t widget_start_x
 this is the actual horizontal start of the widget drawing area, taken into account the presence of border.
 
uint8_t widget_start_y
 this is the actual vertical start of the widget drawing area, taken into account the presence of border.
 
uint8_t widget_border_width
 this is the border size of the widget. 0 if no border, 1 if border
 
- Protected Attributes inherited from Widget
DisplayDevicedisplay_device {nullptr}
 the display device where the attached to the frame buffer
 
Modelactual_displayed_model {nullptr}
 a pointer to the Model actually displayed by the widget
 
std::vector< Widget * > widgets
 A widget can be composed by several widgets.
 

Detailed Description

The graphical version of a Widget.

Constructor & Destructor Documentation

◆ GraphicWidget() [1/3]

GraphicWidget::GraphicWidget ( GraphicDisplayDevice * graphic_display_screen,
struct_ConfigGraphicWidget graph_cfg,
CanvasFormat canvas_format,
Model * displayed_object = nullptr )

Construct a new Graphic Widget object.

Note
USAGE: when we need a pure graphic widget defined by the struct_ConfigGraphicFramebuffer
Parameters
graphic_display_screenThe display device on which the widget is drawn.
graph_cfgthe configuration data structure of the graphic framebuffer
canvas_formatthe format of the associated canvas (see CanvasFormat)
displayed_objectthe displayed object of the widget
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GraphicWidget() [2/3]

GraphicWidget::GraphicWidget ( GraphicDisplayDevice * graphic_display_screen,
struct_ConfigTextWidget text_cfg,
CanvasFormat canvas_format,
Model * displayed_object = nullptr )

Construct a new Graphic Widget object from the TextWidget Constructor.

Note
USAGE: When we need a textual framebuffer defined by the struct_ConfigTextWidget
Parameters
graphic_display_screenThe display device on which the widget is drawn.
text_cfgthe configuration data structure of the text framebuffer
canvas_formatthe format of the associated canvas (see CanvasFormat)
displayed_objectthe displayed object of the widget
Here is the call graph for this function:

◆ GraphicWidget() [3/3]

GraphicWidget::GraphicWidget ( GraphicDisplayDevice * graphic_display_screen,
struct_ConfigTextWidget text_cfg,
CanvasFormat canvas_format,
size_t frame_width,
size_t frame_height,
Model * displayed_object = nullptr )

Construct a new Graphic Widget object from the TextWidget Constructor.

Note
When we need a textual framebuffer defined by the pixel size frame_width, frame_height. The number of column and line are computed with regard to the size of the font
Parameters
graphic_display_screen
text_cfgthe configuration data structure of the text framebuffer
canvas_formatthe format of the associated canvas (see CanvasFormat)
frame_widththe frame width in pixel
frame_heightthe frame height in pixel
displayed_objectthe displayed object of the widget
Here is the call graph for this function:

Member Function Documentation

◆ circle()

void GraphicWidget::circle ( int radius,
int x_center,
int y_center,
bool fill = false,
ColorIndex color = ColorIndex::WHITE )

draw a cercle of size radius, centered at (x_center, y_center) https://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham https://en.wikipedia.org/wiki/Midpoint_circle_algorithm procédure tracerCercle (entier rayon, entier x_centre, entier y_centre) déclarer entier x, y, m ; x ← 0 ; y ← rayon ; // on se place en haut du cercle m ← 5 - 4*rayon ; // initialisation Tant que x <= y // tant qu'on est dans le second octant tracerPixel( x+x_centre, y+y_centre ) ; tracerPixel( y+x_centre, x+y_centre ) ; tracerPixel( -x+x_centre, y+y_centre ) ; tracerPixel( -y+x_centre, x+y_centre ) ; tracerPixel( x+x_centre, -y+y_centre ) ; tracerPixel( y+x_centre, -x+y_centre ) ; tracerPixel( -x+x_centre, -y+y_centre ) ; tracerPixel( -y+x_centre, -x+y_centre ) ; si m > 0 alors //choix du point F y ← y - 1 ; m ← m - 8*y ; fin si ; x ← x + 1 ; m ← m + 8*x + 4 ; fin tant que ; fin de procédure ;

Parameters
radiusradius, in pixel, of the circle
x_centerhorizontal position of the center of the cercle
y_centervertical position of the center on the cercle
fillif true, the circle is filled with color c
colorcolor of the border of the circle, default to WHITE
Here is the call graph for this function:

◆ clear_widget()

void GraphicWidget::clear_widget ( )
protected

fill the graphic pixel buffer with 0x00.

Note
USAGE: used at the begining of the draw() method.
Here is the caller graph for this function:

◆ draw_border()

void GraphicWidget::draw_border ( ColorIndex color = ColorIndex::WHITE)
virtual

draw a rectangle around the widget.

Note
As the border is a rectangle with fill=false, the border width can only be 1 pixel.
Parameters
colorthe color of the border

Reimplemented in TextWidget.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_graph_frame_config()

struct_ConfigGraphicWidget GraphicWidget::get_graph_frame_config ( )

Get the graphic frame config object.

Returns
struct_ConfigGraphicFramebuffer
Here is the caller graph for this function:

◆ get_value_of_interest()

virtual void GraphicWidget::get_value_of_interest ( )
protectedpure virtual

A pure virtual method that results in the transfer of the displayed values of the displayed model to the widget.

Implemented in WidgetFocusIndicator, WidgetHorizontalBargraph, and WidgetVerticalBargraph.

Here is the caller graph for this function:

◆ hline()

void GraphicWidget::hline ( uint8_t x,
uint8_t y,
size_t w,
ColorIndex color = ColorIndex::WHITE )

Draw a color horizontal line, starting at frame position (x,y), on w number of pixel.

Parameters
xhorizontal start of line
yvertical start of line
wlength of the line in number of pixel
colorcolor of the line, default to WHITE
Here is the caller graph for this function:

◆ line()

void GraphicWidget::line ( int x0,
int y0,
int x1,
int y1,
ColorIndex color = ColorIndex::WHITE )

Draw a color line, starting at frame position (x0,y0), ending at frame position (x1,y1)

Parameters
x0horizontal start of line
y0vertical start of line
x1horizontal end of line
y1vertical end of line
colorcolor of the line, default to WHITE

◆ rect()

void GraphicWidget::rect ( uint8_t start_x,
uint8_t start_y,
size_t w,
size_t h,
bool fill = false,
ColorIndex color = ColorIndex::WHITE )

Draw a rectangle, starting at frame position (x,y), w wide and h high.

Parameters
start_xhorizontal start of the rectangle
start_yvertical start of the rectangle
wnumber of pixel of the rectangle width
hnumber of pixel of the rectangle height
fillif true, the rectangle is filled with color
colorcolor of the border of the rectangle, default to WHITE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_widget_anchor()

void GraphicWidget::update_widget_anchor ( uint8_t x,
uint8_t y )

Modify the anchor of the widget on the display screen.

Parameters
xanchor x coordinate
yanchor y coordinate

◆ vline()

void GraphicWidget::vline ( uint8_t x,
uint8_t y,
size_t h,
ColorIndex color = ColorIndex::WHITE )

Draw a color vertical line, starting at frame position (x,y), on w number of pixel.

Parameters
xhorizontal start of line
yvertical start of line
hlength of the line in number of pixel
colorcolor of the line, default to WHITE
Here is the caller graph for this function:

Member Data Documentation

◆ widget_start_x

uint8_t GraphicWidget::widget_start_x
protected

this is the actual horizontal start of the widget drawing area, taken into account the presence of border.

Note
WARNING: when the FramebufferFormat format is MONO_VLSB, works fine only if widget_height is a multiple of 8.

◆ widget_start_y

uint8_t GraphicWidget::widget_start_y
protected

this is the actual vertical start of the widget drawing area, taken into account the presence of border.

Note
when the FramebufferFormat format is MONO_VLSB, works fine only if widget_start_y is a multiple of 8

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