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 |
33 | using namespace std; |
34 | |
3025996b |
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, |
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 |
134 | protected: |
135 | |
136 | /** |
137 | * Constructor |
138 | */ |
139 | GUI() {} |
321fc17c |
140 | |
3025996b |
141 | |
321fc17c |
142 | /** |
143 | * Put content of widgets into the L-system |
144 | */ |
145 | void widgetsToLsystem(); |
3ef0adbf |
146 | |
147 | /** |
321fc17c |
148 | * Put content of the L-system into widgets |
3ef0adbf |
149 | */ |
321fc17c |
150 | void lsystemToWidgets(); |
3ef0adbf |
151 | |
3025996b |
152 | |
153 | // GUI widgets |
154 | |
3ef0adbf |
155 | FXMenuPane *_fileMenuPane; // File menu |
156 | FXMenuPane *_helpMenuPane; // Help menu |
157 | |
3025996b |
158 | FXTextField *_axiomTextField; // Axiom |
159 | FXText *_rulesText; // Rules |
160 | FXRealSpinner *_angleRealSpinner; // Angle |
891f5a54 |
161 | FXSpinner *_depthSpinner; // Depth |
3025996b |
162 | |
163 | FXRealSpinner *_diameterRealSpinner; // Diameter |
891f5a54 |
164 | FXRealSpinner *_diameterFactorRealSpinner; // Diameter factor |
165 | |
3ef0adbf |
166 | FXMessageBox *_helpUsageMessageBox; // Usage help dialog |
167 | FXMessageBox *_helpRulesMessageBox; // Rules help dialog |
3025996b |
168 | |
169 | |
3ef0adbf |
170 | LindenmayerSystem *_lsystem; // The Lindenmayer system generator |
171 | LSystemParameters _lsystemParameters; // Saver and loader for L-system parameters |
3025996b |
172 | RenderingSurface *_renderingSurface; // The rendering surface |
173 | }; |
174 | |
175 | |
176 | |
177 | #endif |