#include <BaseDialog.h>
Public Member Functions | |
BaseDialog () | |
void | setButtons (ButtonType btn1, ButtonType btn2, int defVal=0) |
void | show (const char *headerPgm, bool allowRemote, CompletedHandlerFn completedHandler=NULL) |
void | showRam (const char *headerRam, bool allowRemote, CompletedHandlerFn completedHandler=NULL) |
void | showController (bool allowRemote, BaseDialogController *controller) |
void | setUserData (void *data) |
virtual void | copyIntoBuffer (const char *sz) |
virtual void | internalSetVisible (bool visible) |
virtual char * | getBufferData () |
void | hide () |
bool | isUsingOOController () |
bool | isInUse () |
bool | isCompressedMode () |
void | dialogRendering (unsigned int currentValue, bool userClicked) |
bool | isMenuItemBased () |
bool | isRenderNeeded () |
bool | isRemoteUpdateNeeded (int remote) |
void | setRemoteUpdateNeeded (int remote, bool b) |
void | setRemoteUpdateNeededAll () |
void | clearRemoteUpdateNeededAll () |
void | setRemoteAllowed (bool allowed) |
void | encodeMessage (TagValueRemoteConnector *remote) |
void | remoteAction (ButtonType type) |
bool | copyButtonText (char *data, int buttonNum, int currentValue, bool isActive) |
bool | copyButtonText (char *data, int buttonNum, int currentValue) |
void | actionPerformed (int btnNum) |
Protected Member Functions | |
void | setInUse (bool b) |
virtual void | internalRender (int currentValue)=0 |
void | setNeedsDrawing (bool b) |
ButtonType | findActiveBtn (unsigned int currentValue) |
void | internalShow (bool allowRemote) |
Protected Attributes | |
char | header [20] |
const char * | headerPgm |
union { | |
BaseDialogController * | controller |
CompletedHandlerFn | completedHandler |
}; | |
void * | userData |
ButtonType | button1 |
ButtonType | button2 |
uint8_t | lastBtnVal |
uint16_t | flags |
MenuRedrawState | needsDrawing |
A dialog is able to take over the display completely in order to present the user with information or a question. Similar to a message box on desktop platforms. These allow for the simplest of user interactions in a display independent way. This base class has most of the functions needed to handle the non-rendering related activities. Never create one directly, always use the instance that's available from the renderer using renderer.getDialog()
.
BaseDialog::BaseDialog | ( | ) |
Create the base dialog and clear down all the fields
void BaseDialog::setButtons | ( | ButtonType | btn1, |
ButtonType | btn2, | ||
int | defVal = 0 |
||
) |
Sets the buttons that are available for pressing. One of the ButtonType definitions. You can optionally define if 0 or 1 should be the default.
btn1 | the first button type (can be BTNTYPE_NONE, and btn2 becomes the only button) |
btn2 | the second button type |
defVal | optionally, set which button is active (0 based). |
void BaseDialog::show | ( | const char * | headerPgm, |
bool | allowRemote, | ||
CompletedHandlerFn | completedHandler = NULL |
||
) |
Create a dialog that takes over the display and presents the header and buffer, the header text is in program memory, with the buttons set up as per setButtons
void BaseDialog::showRam | ( | const char * | headerRam, |
bool | allowRemote, | ||
CompletedHandlerFn | completedHandler = NULL |
||
) |
Create a dialog that takes over the display and presents the header and buffer, the header text is in RAM, with the buttons set up as per setButtons
void BaseDialog::showController | ( | bool | allowRemote, |
BaseDialogController * | controller | ||
) |
Create a dialog that takes over the display and presents the header and buffer, the header text is in program memory, with the buttons set up as per setButtons
A valid controller object pointer is mandatory.
|
inline |
You can set an item of data that will be passed to the callback when executed.
data | a pointer to your own data that will be given back to you in the call back. |
|
virtual |
Copy text into the buffer, that will be displayed along with the header.
sz | the text to copy |
Reimplemented in MenuBasedDialog.
|
virtual |
overriden in other types to handle show and hide differently
Reimplemented in MenuBasedDialog.
void BaseDialog::hide | ( | ) |
Close the current dialog by taking off the display and clearing the inuse flag.
|
inline |
Indicates that the registered completion / callback is a controller
|
inline |
Indicates that this dialog is presently in use
|
inline |
Indicates that this menu is on a very limited display size
void BaseDialog::dialogRendering | ( | unsigned int | currentValue, |
bool | userClicked | ||
) |
Called by the renderer to draw our dialog, in a game loop style as per all tcMenu rendering.
currentValue | the value of the encoder used to handle which button is active. |
userClicked | indicates when the user clicks an item. |
bool BaseDialog::copyButtonText | ( | char * | data, |
int | buttonNum, | ||
int | currentValue, | ||
bool | isActive | ||
) |
Copies button text into the buffer provided by data, based on the button number (0 or 1) and the current value of the encoder.
data | the buffer to copy into, must fit at least the largest button copyButtonText |
buttonNum | the button number either 0, 1 |
currentValue | current value from encoder. |
void BaseDialog::actionPerformed | ( | int | btnNum | ) |
Perform the action of the button numbered in the parameter. For example if button 1 is set to OK, then OK is pressed.
btnNum |
|
inlineprotected |
Sets the inuse flag to true or false
|
protectedpure virtual |
Needs to be overriden by each leaf renderer implementation in order to draw the actual dialog onto the display.
currentValue | the encoder currentValue |
Implemented in NoRenderDialog, and MenuBasedDialog.
|
inlineprotected |
Set if redraw is needed
b | true for redraw needed |
|
protected |
Finds the button that is currently selected
the | current value of the encoder |