Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/vaclgui/gtview.hpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1997-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * gtview.hpp | |
7 */ | |
8 | |
9 #ifndef GTVIEW_HPP | |
10 #define GTVIEW_HPP | |
11 | |
12 #include <icombobx.hpp> | |
13 //#include <iedithdr.hpp> | |
14 #include <ikeyevt.hpp> | |
15 #include <ikeyhdr.hpp> | |
16 #include <imcelcv.hpp> | |
17 #include <imousevt.hpp> | |
18 #include <imoushdr.hpp> | |
19 #include <ipainevt.hpp> | |
20 #include <ipainhdr.hpp> | |
21 #include <isizehdr.hpp> | |
22 #include <islhdr.hpp> | |
23 #include <isplitcv.hpp> | |
24 #include <istattxt.hpp> | |
25 | |
26 //#include "agview.hpp" | |
27 #include "brt.h" | |
28 #include "conflicttrc.h" | |
29 #include "dview.hpp" | |
30 #include "dvplug.hpp" | |
31 #include "frame.hpp" | |
32 #include "ftpar.h" | |
33 #include "ftpardc.h" | |
34 #include "toolbar.hpp" | |
35 | |
36 class trace_window_dc; // from tracedc.h | |
37 | |
38 | |
39 class GTWindow; // below | |
40 | |
41 class GTView | |
42 : public ICanvas | |
43 , public AgFocusHandler | |
44 , public IFocusHandler | |
45 , public IMouseHandler | |
46 , public IPaintHandler | |
47 { | |
48 public: | |
49 GTView(GTWindow *owner_, DcRef<FtParserDc>); | |
50 ~GTView(); | |
51 | |
52 GTView &refreshRules(int); | |
53 DcRef<FtParserDc> parserDc; | |
54 AgDataViewPlug *stackViewData; | |
55 FtParser &parser; | |
56 | |
57 ISplitCanvas mainSplitter; | |
58 ISplitCanvas tracePanels; | |
59 IMultiCellCanvas leftPanel; | |
60 AgDataView stackView; | |
61 IStaticText stackTitle; | |
62 IMultiCellCanvas rightPanel; | |
63 AgDataView tokenListView; | |
64 IStaticText tokenListTitle; | |
65 ISplitCanvas bottomPanel; | |
66 AgDataView reductionChoiceView; | |
67 DcRef<FtParserReductionDc> reductionMenu; | |
68 AgDataView ruleView; | |
69 AgDataViewPlug *ruleConnector; | |
70 | |
71 tsd *itemStack; | |
72 DcRef<rule_stack_dc> ruleControl; | |
73 | |
74 | |
75 virtual Boolean gotFocus(IEvent &); | |
76 virtual Boolean lostFocus(IEvent &); | |
77 virtual Boolean gotFocus(IControlEvent &); | |
78 virtual Boolean lostFocus(IControlEvent &); | |
79 Boolean mouseClicked(IMouseClickEvent &event); | |
80 Boolean paintWindow(IPaintEvent &event); | |
81 //GTView &completeReduction(); | |
82 //GTView &setFocus(); | |
83 | |
84 int focusControl; | |
85 int activePanel; | |
86 | |
87 enum ButtonState { buttonIdle, buttonDown, waitingForClick }; | |
88 ButtonState leftButtonState; | |
89 | |
90 int followUpPending; | |
91 void followUpFocusMsg(); | |
92 | |
93 private: | |
94 AgNotificationAction<GTView> dataColorChange; | |
95 void onColorChange() { stackTitle.refresh(); tokenListTitle.refresh(); } | |
96 AgNotificationAction<GTView> fontChange; | |
97 void onFontChange() { | |
98 stackTitle.setFont(FontSpec::columnHead).refresh(); | |
99 tokenListTitle.setFont(FontSpec::columnHead).refresh(); | |
100 } | |
101 GTWindow *frame; | |
102 //HelpDemon stackViewHelp; | |
103 //HelpDemon tokenViewHelp; | |
104 }; | |
105 | |
106 class GTWindow | |
107 : public AgFrame | |
108 , public IShowListHandler | |
109 /*, public IKeyboardHandler - compiler complains because AgFrame has one */ | |
110 , public IMouseHandler | |
111 { | |
112 public: | |
113 class ComboBox : public IComboBox { | |
114 public: | |
115 ComboBox(IWindow *owner, char *text) | |
116 : IComboBox(nextChildId(), owner, owner, IRectangle(), | |
117 autoScroll | | |
118 dropDownType | horizontalScroll) | |
119 { | |
120 //LOGSECTION("GTWindow::ComboBox::ComboBox"); | |
121 IFont f = font(); | |
122 ISize minimum(f.textWidth(text),f.maxCharHeight() ); | |
123 //LOGV(minimum.asString()); | |
124 setMinimumSize(minimum).show(); | |
125 addAsLast(""); | |
126 } | |
127 | |
128 void saveText(); | |
129 | |
130 AgAction enterAction; | |
131 ComboBox &setEnterAction(AgAction action) { | |
132 enterAction = action; | |
133 return *this; | |
134 } | |
135 virtual void onEnter() { | |
136 enterAction.performDeferred(); | |
137 } | |
138 | |
139 AgAction selectAction; | |
140 ComboBox &setSelectAction(AgAction action) { | |
141 selectAction = action; | |
142 return *this; | |
143 } | |
144 virtual void onSelect() { | |
145 selectAction.performDeferred(); | |
146 } | |
147 | |
148 Boolean enter(IControlEvent &) { onEnter(); return true; } | |
149 Boolean select(IControlEvent &) { onSelect(); return true; } | |
150 | |
151 // otherwise the compiler complains this is hidden | |
152 virtual IBaseComboBox &select(unsigned long a, IBase::Boolean b) { | |
153 return IBaseComboBox::select(a,b); | |
154 } | |
155 }; | |
156 | |
157 FtParser parser; | |
158 DcRef<FtParserDc> parserDc; | |
159 GTWindow(trace_window_dc *); | |
160 GTWindow(tsd *initialStates, | |
161 AgString headTitle, AgString footTitle = AgString()); | |
162 ~GTWindow(); | |
163 void init(); | |
164 //void stackEnter(); | |
165 void stackSelect(); | |
166 void ruleSelect(); | |
167 void tokenEnter(); | |
168 void acceptToken(); | |
169 void tokenProceed(); | |
170 void tokenSelect(); | |
171 void setUpViews(); | |
172 virtual AgString copyTitle(); | |
173 virtual GTWindow ©To(IClipboard &c); | |
174 | |
175 // otherwise the compiler complains this is hidden | |
176 virtual int showHelp(IEvent &e) { return AgFrame::showHelp(e); } | |
177 | |
178 Boolean windowResize(IResizeEvent &event); | |
179 //Boolean command(ICommandEvent &event); | |
180 Boolean listShown(IControlEvent &event); | |
181 Boolean virtualKeyPress(IKeyboardEvent &event); | |
182 Boolean characterKeyPress(IKeyboardEvent &event); | |
183 Boolean mouseClicked(IMouseClickEvent &event); | |
184 | |
185 GTWindow &showReductionSelection(); | |
186 void reductionChoiceEnter(); | |
187 void reductionChoiceSelect(); | |
188 | |
189 //AgInfoField statusField; | |
190 ToolBar toolBar; | |
191 ToolBar containerBar; | |
192 IStaticText statusField; | |
193 HelpDemon statusFieldHelp; | |
194 GTWindow &setStatusField(); | |
195 void resetParser(); | |
196 | |
197 void comboBoxEnter(); | |
198 void comboBoxSelect(); | |
199 void comboBoxProceed(); | |
200 void comboBoxStep(); | |
201 void doStep(); | |
202 void proceed(); | |
203 void showHelp(); | |
204 | |
205 void synchRules(unsigned sn, unsigned token); | |
206 void synchTokenList(unsigned sn, unsigned tn); | |
207 void setLookaheadToken(unsigned tn); | |
208 void onDeactivate(); | |
209 | |
210 ComboBox comboBox; | |
211 //ControlHelpDemon comboBoxHelp; | |
212 //AgToolControl comboBoxTool; | |
213 | |
214 | |
215 | |
216 GTView canvas; | |
217 DcRef<TokenMenuDc> tokenList; | |
218 | |
219 ToolBar buttonGroup; | |
220 ToolButton proceedButton; | |
221 ToolButton stepButton; | |
222 ToolButton resetButton; | |
223 ToolButton helpButton; | |
224 | |
225 static char *processStateText[]; | |
226 int comboBoxActive; | |
227 int comboBoxListShowing; | |
228 int ruleSelectActive; | |
229 | |
230 public: | |
231 int listViewLine; | |
232 int stackViewLine; | |
233 int ruleViewLine; | |
234 int reductionChoiceLine; | |
235 GTWindow &setFocus(); | |
236 | |
237 public: | |
238 virtual Boolean findNext(AgString s); | |
239 virtual Boolean findPrev(AgString s); | |
240 unsigned selectedToken; | |
241 | |
242 void setRuleViewCursor(); | |
243 | |
244 class TabControl { | |
245 public: | |
246 int enabled; | |
247 char *helpTopic; | |
248 AgAction action; | |
249 IWindow *window; | |
250 | |
251 TabControl() {} | |
252 TabControl(IWindow *window_, | |
253 char *helpTopic_, | |
254 AgAction action_ = AgAction()) | |
255 : enabled(1) | |
256 , helpTopic(helpTopic_) | |
257 , action(action_) | |
258 , window(window_) | |
259 {} | |
260 TabControl(const TabControl &x) | |
261 : enabled(x.enabled) | |
262 , helpTopic(x.helpTopic) | |
263 , action(x.action) | |
264 , window(x.window) | |
265 {} | |
266 }; | |
267 enum { | |
268 stackTab, | |
269 tokenTab, | |
270 choiceTab, | |
271 ruleTab, | |
272 comboTab, | |
273 proceedTab, | |
274 stepTab, | |
275 resetTab, | |
276 helpTab, | |
277 nTabs | |
278 }; | |
279 TabControl tabControl[nTabs]; | |
280 }; | |
281 | |
282 | |
283 #endif /* GTVIEW_HPP */ |