Shellminator V3.0.1
Simple Terminal
|
This class can create a simple plotter object. More...
#include <Shellminator-Buttons.hpp>
Public Member Functions | |
ShellminatorButton () | |
Empty constructor. More... | |
ShellminatorButton (const char *name_p) | |
Constructor with name. More... | |
void | init (Shellminator *parent_p, Stream *channel_p) override |
Init function. More... | |
void | draw (bool noClear=false) override |
Draw function. More... | |
void | update (int width_p, int height_p) override |
Update function. More... | |
void | attachEvent (Shellminator::shellEvent_t event_p) |
Attach optional event. More... | |
void | attachTriggerFunction (void(*func_p)(ShellminatorScreen *)) |
Attach a callback. More... | |
void | setColor (Shellminator::textColor_t color_p) |
You can modify the color of the frame. More... | |
void | forceRedraw () override |
![]() | |
virtual void | draw (bool noClear=false) |
Draw function. More... | |
virtual void | init (Shellminator *parent_p, Stream *channel_p) |
Init function. More... | |
virtual void | setOrigin (int x, int y) |
Origin of the top left corner. More... | |
virtual void | update (int width_p, int height_p) |
Update function. More... | |
virtual void | forceRedraw () |
int | left () |
Return the coordinate of the left column next to the object. More... | |
int | right () |
Return the coordinate of the right column next to the object. More... | |
int | up () |
Return the coordinate of the upper row next to the object. More... | |
int | down () |
Return the coordinate of the lower row next to the object. More... | |
Shellminator * | getParent () |
void | attachEndFunction (void(*end_func_p)(Shellminator *)) |
void | removeEndFunction () |
Private Member Functions | |
bool | isUpper (char c) |
Check if the character is uppercase. More... | |
bool | isLower (char c) |
Check if the character is lowercase. More... | |
char | toUpper (char c) |
Make the character uppercase. More... | |
Private Attributes | |
const char * | name |
This variable stores a pointer to the name text. More... | |
int | textWidth |
This variable stores the name text width. More... | |
bool | redraw = true |
This flag shows that redraw is necessary. More... | |
Shellminator::shellEvent_t | event |
This variable stores the custom trigger event data. More... | |
char | eventText [6] |
This is a buffer to store the event key text. More... | |
int | eventTextSize = 0 |
This variable stores the event key text size. More... | |
void(* | func )(ShellminatorScreen *) = NULL |
Pointer to the event callback function. More... | |
Shellminator::textColor_t | color = Shellminator::WHITE |
Button frame color. Default is White. More... | |
Friends | |
class | ShellminatorButtonUT |
Additional Inherited Members | |
![]() | |
int | row = 1 |
It is used by the grid layout. More... | |
int | column = 1 |
It is used by the grid layout. More... | |
int | columnSpan = 1 |
It is used by the grid layout. More... | |
int | rowSpan = 1 |
It is used by the grid layout. More... | |
ShellminatorScreen * | nextElement = NULL |
It is used by the grid layout. More... | |
void(*)(Shellminator *) | getEndFunction () |
![]() | |
Shellminator * | parent = NULL |
Pointer to the caller terminal object. More... | |
Stream * | channel = NULL |
int | width = 1 |
Actual width of the object. More... | |
int | height = 1 |
Actual height of the object. More... | |
int | originX = 1 |
X coordinate of the origin. More... | |
int | originY = 1 |
Y coordinate of the origin. More... | |
void(* | end_func )(Shellminator *) = NULL |
This class can create a simple plotter object.
With this class, you can easily create a plotter object, which is capable of real time plotting. It can be attached to the main terminal with the beginScreen function.
Definition at line 60 of file Shellminator-Buttons.hpp.
ShellminatorButton::ShellminatorButton | ( | ) |
Empty constructor.
Definition at line 37 of file Shellminator-Buttons.cpp.
ShellminatorButton::ShellminatorButton | ( | const char * | name_p | ) |
Constructor with name.
This constructor must be used to use the object properly.
name_p | This is a string, which will be displayed on the center of the button. |
Definition at line 46 of file Shellminator-Buttons.cpp.
void ShellminatorButton::attachEvent | ( | Shellminator::shellEvent_t | event_p | ) |
Attach optional event.
Optionally, you can attach a keyboard event to the button. It could be handy when the host terminal emulator does not support keyboard reporting( sadly, Windows currently does this in the emulator... ).
event_p | A configured structure, that contains the event data. |
Example code:
Definition at line 66 of file Shellminator-Buttons.cpp.
void ShellminatorButton::attachTriggerFunction | ( | void(*)(ShellminatorScreen *) | func_p | ) |
Attach a callback.
You can attach a callback function to the button. When a mouse click event is detected on the button, or the attached event triggers, this function will be called.
func_p | Pointer to a function, which will be called. |
Example callback function prototype: void buttonEvent( ShellminatorScreen* parent );
A pointer to the caller button is passed to the callback. This way the callback function can access the caller button.
Definition at line 106 of file Shellminator-Buttons.cpp.
|
overridevirtual |
Draw function.
This function is called by the caller terminal if redraw is requested. If you need to draw your screen, the requestRedraw function must be called on the parent terminal object. The reason for this is to save some CPU time and do not waste it to draw something unnecessarily.
Reimplemented from ShellminatorScreen.
Definition at line 185 of file Shellminator-Buttons.cpp.
|
overridevirtual |
Reimplemented from ShellminatorScreen.
Definition at line 290 of file Shellminator-Buttons.cpp.
|
overridevirtual |
Init function.
This function is called by the host terminal, when the plot object gets registered to it. You can put all the initialisation section here.
parent_p | Pointer to the caller terminal object. |
channel_p | This is a pointer to a Stream object, which can be used to print the output data. |
channel_p
object instead of parent -> channel
method. This object can be a regular channel or a buffer accelerated one. The logic behind the buffering and flushing is handled by the caller terminal. Reimplemented from ShellminatorScreen.
Definition at line 115 of file Shellminator-Buttons.cpp.
|
private |
Check if the character is lowercase.
c | Character to be checked. |
Definition at line 278 of file Shellminator-Buttons.cpp.
|
private |
Check if the character is uppercase.
c | Character to be checked. |
Definition at line 274 of file Shellminator-Buttons.cpp.
void ShellminatorButton::setColor | ( | Shellminator::textColor_t | color_p | ) |
You can modify the color of the frame.
Definition at line 110 of file Shellminator-Buttons.cpp.
|
private |
Make the character uppercase.
c | Character to convert to uppercase. |
Definition at line 282 of file Shellminator-Buttons.cpp.
|
overridevirtual |
Update function.
The update function must be used to process events and not to draw the objects. It is called much frequently than, the draw function. All the event handling should be done in the update function, including key and mouse detection along with various events.
width_p | The width of the screen area in characters. |
height_p | The height of the screen area in characters. |
Reimplemented from ShellminatorScreen.
Definition at line 121 of file Shellminator-Buttons.cpp.
|
friend |
Definition at line 189 of file Shellminator-Buttons.hpp.
|
private |
Button frame color. Default is White.
Definition at line 170 of file Shellminator-Buttons.hpp.
|
private |
This variable stores the custom trigger event data.
Definition at line 157 of file Shellminator-Buttons.hpp.
|
private |
This is a buffer to store the event key text.
Definition at line 160 of file Shellminator-Buttons.hpp.
|
private |
This variable stores the event key text size.
Definition at line 163 of file Shellminator-Buttons.hpp.
|
private |
Pointer to the event callback function.
It it is null, the callback is disabled.
Definition at line 167 of file Shellminator-Buttons.hpp.
|
private |
This variable stores a pointer to the name text.
Definition at line 146 of file Shellminator-Buttons.hpp.
|
private |
This flag shows that redraw is necessary.
In this implementation redraw is only required when the screen is resized.
Definition at line 154 of file Shellminator-Buttons.hpp.
|
private |
This variable stores the name text width.
Definition at line 149 of file Shellminator-Buttons.hpp.