#include "Toolkit/GUIToolkit.h" int main ( void ) { bool done = false; WidgetApplication *MyApp = new WidgetApplication(); //MyApp->setuniformbackgroundcolor(100, 100, 100); MyApp->setbackgroundpicture( (char*) "/documents/Widget/Wallpapers/001.bmp.tns" ); DesktopWidget *desktop1 = new DesktopWidget( (char*) "First Desktop", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, nullptr ); WindowWidget *window = new WindowWidget( (char*) "GUI Toolkit for nSpire rev 0.6 Demo", 45, 15, 240, 170, desktop1 ); window->setminimaldimensions( 90, 75 ); ContainerVWidget *containervert = new ContainerVWidget( (char*) "container", 1, 1, 1, 1, window ); LabelWidget *label1 = new LabelWidget( (char*) "Please pick a theme for the Toolkit : ", 1, 1, 1, 1, containervert ); label1->setalignment( left ); // this is the new DropBow Widget DropBoxWidget *mydropbox = new DropBoxWidget( (char*) "Test Drop", 1, 1, 1, 1, containervert ); // this is a spacer widget (blank one, do nothing, jsut for the layout) // note , this may disappear if contraint layout is implemented in later revisions //SpacerWidget *spacer1 = new SpacerWidget( (char*) "Spacer1", 1, 1, 1, 1, containervert ); //SpacerWidget *spacer2 = new SpacerWidget( (char*) "Spacer2", 1, 1, 1, 1, containervert ); //SpacerWidget *spacer3 = new SpacerWidget( (char*) "Spacer3", 1, 1, 1, 1, containervert ); LabelWidget *label2 = new LabelWidget( (char*) "This is an InputBox", 1, 1, 1, 1, containervert ); label2->setalignment( left ); InputWidget *input = new InputWidget( (char*) "I am an Inputbox", 1, 1, 1, 1, containervert ); input->setcontent( (char *) "Please enter something here !!!" ); LabelWidget *label3 = new LabelWidget( (char*) "Some Radio/Checkbox examples", 1, 1, 1, 1, containervert ); label3->setalignment( left ); CheckBoxWidget *check = new CheckBoxWidget( (char*) "I am a CheckBox", 1, 1, 1, 1, containervert ); RadioControlWidget *radio = new RadioControlWidget( (char*) "I am a RadioControl", 1, 1, 1, 1, containervert ); LabelWidget *label4 = new LabelWidget( (char*) "ProgressBars (use + and - keys)", 1, 1, 1, 1, containervert ); label4->setalignment( left ); ContainerHWidget *contH5 = new ContainerHWidget( (char*) "container", 1, 1, 1, 1, containervert ); ProgressBarWidget *bar = new ProgressBarWidget( (char*) "ProgressBar", 1, 1, 1, 1, contH5 ); bar->setstyle( Continuous ); bar->setprintvalue( true ); ProgressBarWidget *bars = new ProgressBarWidget( (char*) "ProgressBar", 1, 1, 1, 1, contH5 ); bars->setstyle( Bricks ); bars->setnumberbricks( 10 ); bars->setprintvalue( true ); ContainerHWidget *containerH = new ContainerHWidget( (char*) "containerH", 1, 1, 1, 1, containervert ); SpacerWidget *spacer1H = new SpacerWidget( (char*) "Spacer1", 1, 1, 1, 1, containerH ); ButtonWidget *buttonQuit = new ButtonWidget( (char*) "Quit !!", 1, 1, 1, 1, containerH ); SpacerWidget *spacer2H = new SpacerWidget( (char*) "Spacer2", 1, 1, 1, 1, containerH ); // We ask for an automatic positioning of the widgets in the grid // Note : this will fully override the dimensions given to the Widgets manually window->adjust(); MyApp->addchild( desktop1 ); // We fill the list of the dropbox with items to be selectable by the user mydropbox->additem( (char*) "Default GUI Toolkit Theme" ); mydropbox->additem( (char*) "Bright GUI Toolkit Theme" ); mydropbox->additem( (char*) "Dark GUI Toolkit Theme" ); mydropbox->additem( (char*) "Hyrule GUI Toolkit Theme" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" );; mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); mydropbox->additem( (char*) "Dummy Value - Do Nothing" ); // We need to init the theme engine, by default, this is not done at startup to save memory MyApp->initthemeengine(); // We apply the default theme while using theme (this is for safe use and avoid any risk of crash) MyApp->setdefaulttheme(); KeyboardTask *keyboard = MyApp->getkeyboardhandler(); // We render the app for the first time so what we can see what's happening on the screen MyApp->render(); while (!done) { MyApp->logic(); // Check if the dropbox has been updated by the user and if there is actually something selected (-1 means no selection yet if (mydropbox->isupdated() && (mydropbox->getselected()!=-1)) { if (mydropbox->getselected() == 0) { // We reset the theme to default MyApp->setdefaulttheme(); } if (mydropbox->getselected() == 1) { // We load a theme file and aply it on-the-fly // the theme NrmClr.CFG.tns is the default theme MyApp->loadtheme( (char*) "/documents/widget/Themes/NrmClr.CFG.tns" ); } if (mydropbox->getselected() == 2) { // We load a theme file and aply it on-the-fly // the theme DrkClr.CFG.tns is the dark theme MyApp->loadtheme( (char*) "/documents/widget/Themes/DrkClr.CFG.tns" ); } if (mydropbox->getselected() == 3) { // We load a theme file and aply it on-the-fly // the theme Hyrule.CFG.tns is the theme used is the LinkSDL example (put in a theme file) MyApp->loadtheme( (char*) "/documents/widget/Themes/Hyrule.CFG.tns" ); } } // As usual, Quit is pressed or the magic keyboard shortcut is activated (CTRL+ESC) if ((keyboard->kbCTRL && keyboard->kbESC) || buttonQuit->ispressed()) done = true; if (keyboard->kbPLUS) { float percentage = bar->getcurrentpercentage(); bar->setcurrentpercentage( percentage + 1.0 ); bars->setcurrentpercentage( percentage + 1.0 ); } if (keyboard->kbMINUS) { float percentage = bar->getcurrentpercentage(); bar->setcurrentpercentage( percentage - 1.0 ); bars->setcurrentpercentage( percentage - 1.0 ); } } return 0; }