#ifndef GUI_H
#define GUI_H
+#include <string>
+
#include "fx.h"
#include "lindenmayersystem.h"
#include "lsystemparameters.h"
#include "renderingsurface.h"
+using namespace std;
+
/**
enum
{
ID_GENERATE = FXMainWindow::ID_LAST,
- ID_HELP,
+ ID_LOAD,
+ ID_SAVE,
+ ID_QUIT,
+ ID_HELP_USAGE,
+ ID_HELP_RULES,
ID_LAST
};
-
+
+
/**
* Constructor
- * @param application the FOX application object
+ * @param application the application object
* @param renderingSurface the rendering surface
- * @param lsystem the Lindenmayer-system
+ * @param lsystem the Lindenmayer system generator
*/
GUI(FXApp *application, RenderingSurface *renderingSurface, LindenmayerSystem *lsystem);
-
+
+ /**
+ * Destructor
+ */
+ virtual ~GUI();
+
+
/**
* Create and initialize the window
*/
- void create();
-
+ virtual void create();
+
+
/**
* Called by the system when the "Generate" button is pressed
* @param sender the sender object
* @param data event related data
* @return
*/
- long onGenerateButtonPressed(FXObject *sender, FXSelector selector, void *data);
-
+ long onGenerate(FXObject *sender, FXSelector selector, void *data);
+
+ /**
+ * Called by the system when the File->Load menu command is selected
+ * @param sender the sender object
+ * @param selector message type and id
+ * @param data event related data
+ * @return
+ */
+ long onLoad(FXObject *sender, FXSelector selector, void *data);
+
/**
- * Called by the system when the "Help" button is pressed
+ * Called by the system when the File->Save menu command is selected
* @param sender the sender object
* @param selector message type and id
* @param data event related data
* @return
*/
- long onHelpButtonPressed(FXObject *sender, FXSelector selector, void *data);
+ long onSave(FXObject *sender, FXSelector selector, void *data);
+
+ /**
+ * Called by the system when the close button or the File->Quit menu command is selected
+ * @param sender the sender object
+ * @param selector message type and id
+ * @param data event related data
+ * @return
+ */
+ long onQuit(FXObject *sender, FXSelector selector, void *data);
+
+ /**
+ * Called by the system when the Help->Usage menu command is selected
+ * @param sender the sender object
+ * @param selector message type and id
+ * @param data event related data
+ * @return
+ */
+ long onHelpUsage(FXObject *sender, FXSelector selector, void *data);
+
+ /**
+ * Called by the system when the Help->Rules menu command is selected
+ * @param sender the sender object
+ * @param selector message type and id
+ * @param data event related data
+ * @return
+ */
+ long onHelpRules(FXObject *sender, FXSelector selector, void *data);
protected:
*/
GUI() {}
-private:
+
+ /**
+ * Load L-system from file and sync with GUI
+ * @param filename path of the L-system file
+ */
+ void loadLSystem(string filename);
+
// GUI widgets
+ FXMenuPane *_fileMenuPane; // File menu
+ FXMenuPane *_helpMenuPane; // Help menu
+
FXTextField *_axiomTextField; // Axiom
FXText *_rulesText; // Rules
FXRealSpinner *_angleRealSpinner; // Angle
FXRealSpinner *_diameterRealSpinner; // Diameter
FXRealSpinner *_diameterFactorRealSpinner; // Diameter factor
- FXMessageBox *_helpMessageBox; // Help dialog
+ FXMessageBox *_helpUsageMessageBox; // Usage help dialog
+ FXMessageBox *_helpRulesMessageBox; // Rules help dialog
- LindenmayerSystem *_lsystem; // The Lindenmayer-system
- LSystemParameters _lsystemParameters; // Saves/loads l-system parameters from file
+ LindenmayerSystem *_lsystem; // The Lindenmayer system generator
+ LSystemParameters _lsystemParameters; // Saver and loader for L-system parameters
RenderingSurface *_renderingSurface; // The rendering surface
};