Add an custom Status Bar to your Realt-ime Application in TurtleBrains.
The following guide is a continuation of HowTo: Start a Real-time Application which provides a great way to start an application if you haven't already.
The following steps are the same basic steps taken to add a Status Bar, Menu, or Dialog Prompt to your application.
- Create the necessary identifiers for the status bar and status items. (ex. StatusIdentifier / StatusItemIdentifier)
- Create and customized the status bar as desired, setting up everything as needed. (ex. ApplicationStatus / AddStatusItem)
- Handle events in the ApplicationHandler when the user interacts with the object.
Creating a status bar, is not so different from creating a Menu or Dialog, first create the identifiers, then customize the status bar. With a status bar there is no user interaction to handle, so it is even easier!
MyApplicationValues.h (modify to add status bar values)
enum MyStatusBars { kMyStatusBar, }
enum MyStatusItems { kStatusName, kStatusAge, kStatusHeight }
MyApplicationHandler.cpp (modify to add status bar)
void MyApplicationHandler::OnWindowOpen(void)
{
statusBar.AddStatusItem(kStatusName,
tb_string(
"Current Name: Unknown"), 0);
statusBar.AddStatusItem(kStatusAge,
tb_string(
"Current Age: 42"), 50);
statusBar.AddStatusItem(kStatusHeight,
tb_string(
"Height: 5ft"), 75);
theApplication.SetWindowStatus(statusBar);
}
MyApplicationHandler.cpp (modify to add status bar)
void MyApplicationHandler::OnMenuAction(const MenuIdentifier& menu, const MenuItemIdentifier& menuItem)
{
statusBar.SetStatusItem(kStatusAge,
tb_string(
"Old Age: 100"));
statusBar.SetStatusItem(kStatusHeight,
tb_string(
"Height: 4ft"));
theApplication.SetWindowStatus(statusBar);
}
- Note
- The status bar currently only works on Windows, no Mac support at this time. Also there is no way to remove a status bar once added to the application, although the status items can be changed easily as shown above.