Hasty Badger
Small UI library (a branch of Turbo Badger)
|
TBMessageHandler handles a list of pending messages posted to itself. More...
#include <tb_msg.h>
Public Member Functions | |
bool | PostMessageDelayed (TBID message, TBMessageData *data, uint32_t delay_in_ms) |
Posts a message to the target after a delay. More... | |
bool | PostMessageOnTime (TBID message, TBMessageData *data, double fire_time) |
Posts a message to the target at the given time (relative to TBSystem::GetTimeMS()). More... | |
bool | PostMessage (TBID message, TBMessageData *data) |
Posts a message to the target. More... | |
TBMessage * | GetMessageByID (TBID message) |
Check if this messagehandler has a pending message with the given id. More... | |
void | DeleteMessage (TBMessage *msg) |
Delete the message from this message handler. More... | |
void | DeleteAllMessages () |
Delete all messages from this message handler. More... | |
virtual void | OnMessageReceived (TBMessage *) |
Called when a message is delivered. More... | |
Static Public Member Functions | |
static void | ProcessMessages () |
Process any messages in queue. More... | |
static double | GetNextMessageFireTime () |
Get when the time when ProcessMessages needs to be called again. More... | |
TBMessageHandler handles a list of pending messages posted to itself.
Messages can be delivered immediately or after a delay. Delayed message are delivered as close as possible to the time they should fire. Immediate messages are put on a queue and delivered as soon as possible, after any delayed messages that has passed their delivery time. This queue is global (among all TBMessageHandlers)
void tb::TBMessageHandler::DeleteAllMessages | ( | ) |
Delete all messages from this message handler.
void tb::TBMessageHandler::DeleteMessage | ( | TBMessage * | msg | ) |
Delete the message from this message handler.
Check if this messagehandler has a pending message with the given id.
Returns the message if found, or nullptr. If you want to delete the message, call DeleteMessage.
|
static |
Get when the time when ProcessMessages needs to be called again.
Always returns 0 if there is nondelayed messages to process, which means it needs to be called asap. If there's only delayed messages to process, it returns the time that the earliest delayed message should be fired. If there's no more messages to process at the moment, it returns TB_NOT_SOON (No call to ProcessMessages is needed).
|
inlinevirtual |
Called when a message is delivered.
This message won't be found using GetMessageByID. It is already removed from the list. You should not call DeleteMessage on this message. That is done automatically after this method exit.
Reimplemented in tb::TBProgressSpinner, tb::TBEditField, tb::TBButton, and tb::TBLongClickTimer.
bool tb::TBMessageHandler::PostMessage | ( | TBID | message, |
TBMessageData * | data | ||
) |
Posts a message to the target.
data may be nullptr if no extra data need to be sent. It will be deleted automatically when the message is deleted.
bool tb::TBMessageHandler::PostMessageDelayed | ( | TBID | message, |
TBMessageData * | data, | ||
uint32_t | delay_in_ms | ||
) |
Posts a message to the target after a delay.
data may be nullptr if no extra data need to be sent. It will be deleted automatically when the message is deleted.
bool tb::TBMessageHandler::PostMessageOnTime | ( | TBID | message, |
TBMessageData * | data, | ||
double | fire_time | ||
) |
Posts a message to the target at the given time (relative to TBSystem::GetTimeMS()).
data may be nullptr if no extra data need to be sent. It will be deleted automatically when the message is deleted.
|
static |
Process any messages in queue.