6f809ecfcf60a80dd602f8c12767daa6ca34f280
[lsystem3d.git] / src / gui.h
1 // Copyright (C) 2006 Erik Dahlberg
2 //
3 // This file is part of LSystem3D.
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
25 #include <string>
26
27 #include "fx.h"
28
29 #include "lindenmayersystem.h"
30 #include "lsystemparameters.h"
31 #include "renderingsurface.h"
32
33 using namespace std;
34
35
36
37 /**
38 * The GUI window
39 */
40 class GUI : public FXMainWindow
41 {
42 // macro to set up class declaration
43 FXDECLARE(GUI)
44
45 public:
46
47 // message ID's
48 enum
49 {
50 ID_GENERATE = FXMainWindow::ID_LAST,
51 ID_LOAD,
52 ID_SAVE,
53 ID_QUIT,
54 ID_HELP_USAGE,
55 ID_HELP_RULES,
56 ID_LAST
57 };
58
59
60 /**
61 * Constructor
62 * @param application the application object
63 * @param renderingSurface the rendering surface
64 * @param lsystem the Lindenmayer system generator
65 */
66 GUI(FXApp *application, RenderingSurface *renderingSurface, LindenmayerSystem *lsystem);
67
68 /**
69 * Destructor
70 */
71 virtual ~GUI();
72
73
74 /**
75 * Create and initialize the window
76 */
77 virtual void create();
78
79
80 /**
81 * Called by the system when the "Generate" button is pressed
82 * @param sender the sender object
83 * @param selector message type and id
84 * @param data event related data
85 * @return
86 */
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
98 /**
99 * Called by the system when the File->Save menu command is selected
100 * @param sender the sender object
101 * @param selector message type and id
102 * @param data event related data
103 * @return
104 */
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);
133
134 protected:
135
136 /**
137 * Constructor
138 */
139 GUI() {}
140
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
148
149 // GUI widgets
150
151 FXMenuPane *_fileMenuPane; // File menu
152 FXMenuPane *_helpMenuPane; // Help menu
153
154 FXTextField *_axiomTextField; // Axiom
155 FXText *_rulesText; // Rules
156 FXRealSpinner *_angleRealSpinner; // Angle
157 FXSpinner *_depthSpinner; // Depth
158
159 FXRealSpinner *_diameterRealSpinner; // Diameter
160 FXRealSpinner *_diameterFactorRealSpinner; // Diameter factor
161
162 FXMessageBox *_helpUsageMessageBox; // Usage help dialog
163 FXMessageBox *_helpRulesMessageBox; // Rules help dialog
164
165
166 LindenmayerSystem *_lsystem; // The Lindenmayer system generator
167 LSystemParameters _lsystemParameters; // Saver and loader for L-system parameters
168 RenderingSurface *_renderingSurface; // The rendering surface
169 };
170
171
172
173 #endif