Added File and Help menus.
[lsystem3d.git] / src / gui.h
CommitLineData
3025996b 1// Copyright (C) 2006 Erik Dahlberg
2//
891f5a54 3// This file is part of LSystem3D.
3025996b 4//
5// LSystem3D is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// LSystem3D is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with LSystem3D; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
22#ifndef GUI_H
23#define GUI_H
24
3ef0adbf 25#include <string>
26
3025996b 27#include "fx.h"
28
29#include "lindenmayersystem.h"
30#include "lsystemparameters.h"
31#include "renderingsurface.h"
32
3ef0adbf 33using namespace std;
34
3025996b 35
36
37/**
38 * The GUI window
39 */
40class GUI : public FXMainWindow
41{
42 // macro to set up class declaration
43 FXDECLARE(GUI)
44
45public:
46
47 // message ID's
48 enum
49 {
50 ID_GENERATE = FXMainWindow::ID_LAST,
3ef0adbf 51 ID_LOAD,
52 ID_SAVE,
53 ID_QUIT,
54 ID_HELP_USAGE,
55 ID_HELP_RULES,
3025996b 56 ID_LAST
57 };
3ef0adbf 58
59
3025996b 60 /**
61 * Constructor
3ef0adbf 62 * @param application the application object
3025996b 63 * @param renderingSurface the rendering surface
3ef0adbf 64 * @param lsystem the Lindenmayer system generator
3025996b 65 */
66 GUI(FXApp *application, RenderingSurface *renderingSurface, LindenmayerSystem *lsystem);
3ef0adbf 67
68 /**
69 * Destructor
70 */
71 virtual ~GUI();
72
73
3025996b 74 /**
75 * Create and initialize the window
76 */
3ef0adbf 77 virtual void create();
78
79
3025996b 80 /**
891f5a54 81 * Called by the system when the "Generate" button is pressed
3025996b 82 * @param sender the sender object
83 * @param selector message type and id
84 * @param data event related data
85 * @return
86 */
3ef0adbf 87 long onGenerate(FXObject *sender, FXSelector selector, void *data);
88
89 /**
90 * Called by the system when the File->Load menu command is selected
91 * @param sender the sender object
92 * @param selector message type and id
93 * @param data event related data
94 * @return
95 */
96 long onLoad(FXObject *sender, FXSelector selector, void *data);
97
891f5a54 98 /**
3ef0adbf 99 * Called by the system when the File->Save menu command is selected
891f5a54 100 * @param sender the sender object
101 * @param selector message type and id
102 * @param data event related data
103 * @return
104 */
3ef0adbf 105 long onSave(FXObject *sender, FXSelector selector, void *data);
106
107 /**
108 * Called by the system when the close button or the File->Quit menu command is selected
109 * @param sender the sender object
110 * @param selector message type and id
111 * @param data event related data
112 * @return
113 */
114 long onQuit(FXObject *sender, FXSelector selector, void *data);
115
116 /**
117 * Called by the system when the Help->Usage menu command is selected
118 * @param sender the sender object
119 * @param selector message type and id
120 * @param data event related data
121 * @return
122 */
123 long onHelpUsage(FXObject *sender, FXSelector selector, void *data);
124
125 /**
126 * Called by the system when the Help->Rules menu command is selected
127 * @param sender the sender object
128 * @param selector message type and id
129 * @param data event related data
130 * @return
131 */
132 long onHelpRules(FXObject *sender, FXSelector selector, void *data);
891f5a54 133
3025996b 134protected:
135
136 /**
137 * Constructor
138 */
139 GUI() {}
140
3ef0adbf 141
142 /**
143 * Load L-system from file and sync with GUI
144 * @param filename path of the L-system file
145 */
146 void loadLSystem(string filename);
147
3025996b 148
149 // GUI widgets
150
3ef0adbf 151 FXMenuPane *_fileMenuPane; // File menu
152 FXMenuPane *_helpMenuPane; // Help menu
153
3025996b 154 FXTextField *_axiomTextField; // Axiom
155 FXText *_rulesText; // Rules
156 FXRealSpinner *_angleRealSpinner; // Angle
891f5a54 157 FXSpinner *_depthSpinner; // Depth
3025996b 158
159 FXRealSpinner *_diameterRealSpinner; // Diameter
891f5a54 160 FXRealSpinner *_diameterFactorRealSpinner; // Diameter factor
161
3ef0adbf 162 FXMessageBox *_helpUsageMessageBox; // Usage help dialog
163 FXMessageBox *_helpRulesMessageBox; // Rules help dialog
3025996b 164
165
3ef0adbf 166 LindenmayerSystem *_lsystem; // The Lindenmayer system generator
167 LSystemParameters _lsystemParameters; // Saver and loader for L-system parameters
3025996b 168 RenderingSurface *_renderingSurface; // The rendering surface
169};
170
171
172
173#endif