Added File and Help menus.
authorspixx <spixx>
Sun, 26 Nov 2006 13:50:59 +0000 (13:50 +0000)
committerspixx <spixx>
Sun, 26 Nov 2006 13:50:59 +0000 (13:50 +0000)
Minor cleanup.

src/gui.h

index 1eae6e02ce4f644d9515e55b9999857def8882fc..6f809ecfcf60a80dd602f8c12767daa6ca34f280 100644 (file)
--- a/src/gui.h
+++ b/src/gui.h
 #ifndef GUI_H
 #define GUI_H
 
+#include <string>
+
 #include "fx.h"
 
 #include "lindenmayersystem.h"
 #include "lsystemparameters.h"
 #include "renderingsurface.h"
 
+using namespace std;
+
 
 
 /**
@@ -44,23 +48,35 @@ public:
     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
@@ -68,16 +84,52 @@ public:
      * @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:
     
@@ -86,10 +138,19 @@ 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
@@ -98,11 +159,12 @@ private:
     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
 };