For an idea of what this library will be like, here is a sample class that I created using it:
// GUI Class. Inherited from BasicGui
class MainMenuGui : public BasicGui {
// protected member variables
protected:
GuiControl button1;
GuiControl button2;
// this is a protected function. Should not be called from outside class!!!
void InitializeComponent ();
// public members
public:
MainMenuGui () { this->InitializeComponent (); }
~MainMenuGui () { }
static void DetectButtonPress (int press);
};
// void MainMenuGui::InitializecComponent (): Initialize this GUI
// Inputs: None
// Returns: None
void MainMenuGui::InitializeComponent () {
// set up the buttons for this GUI
button1.setCaption ("Test Start Button");
button1.setSize (100, 40);
button1.setPosition (100, 100);
button1.setID (10);
button1.setStyle (BORDER_CTRL);
button2.setCaption ("Test Exit Button");
button2.setSize (100, 40);
button2.setPosition (100, 180);
button2.setID (11);
button2.setStyle (BORDER_CTRL);
this->addControl (button1);
this->addControl (button2);
this->addActionListener ((ActionListener) DetectButtonPress);
}
// void MainMenuGui::DetectButtonPress (int press): Action listener for button presses
// Inputs: the button ID pressed
// Returns: None
void MainMenuGui::DetectButtonPress (int press) {
if (press == 11)
exit (0);
}
If anyone would like more info feel free to ask me!
Edit: To call this menu from your code, just use
MainMenuGui menu;
menu.Display ();
Now the subclass BasicGui defines a function Display that should not be modified. This function runs a menu loop that will freeze the program from any other processing during the menu time other than menu handling
ActionListeners (taken from Java haha) are just function pointers. ActionListeners that are defined within classes should be declared as static members as shown. Non-class functions should NOT by good practice be used, but can be used due to the fact that C++ pretty much lets you do whatever you want lol. Again, more info, contact me. Thanks for looking and showing interest!