comparison anagram/vaclgui/ctrlpanel.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 * ctrlpanel.hpp
7 */
8
9 #ifndef CTRLPANEL_HPP
10 #define CTRLPANEL_HPP
11
12 #include <time.h>
13 #include "port.h"
14
15 //#include <icanvas.hpp>
16 #include <icmdhdr.hpp>
17 #include <icombobx.hpp>
18 //#include <ifiledlg.hpp>
19 #include <iflyhhdr.hpp>
20 #include <iflytext.hpp>
21 #include <ifocshdr.hpp>
22 #include <ifont.hpp>
23 #include <iframe.hpp>
24 #include <igraphbt.hpp>
25 #include <imenubar.hpp>
26 #include <imenuhdr.hpp>
27 #include <imousevt.hpp>
28 #include <imoushdr.hpp>
29 //#include <imphdr.hpp>
30 #include <ipainevt.hpp>
31 #include <ipainhdr.hpp>
32 #include <iselhdr.hpp>
33 #include <isetcv.hpp>
34 #include <islhdr.hpp>
35 #include <istattxt.hpp>
36 //#include <istring.hpp>
37 #include <isubmenu.hpp>
38 #include <isysmenu.hpp>
39 #include <ithread.hpp>
40 #include <itimer.hpp>
41 #include <ititle.hpp>
42
43 #include "action.h"
44 #include "agstring.h"
45 #include "frame.hpp"
46 #include "openfile.hpp"
47 #include "statwin.hpp"
48
49
50 class ControlPanel
51 : public IFrameWindow
52 , public ICommandHandler
53 , public IMenuHandler
54 , public AgHelpHandler
55 , public IFrameHandler
56 , public IMouseHandler
57 // , public IMousePointer
58 , public IPaintHandler
59 , public IFocusHandler
60 , public IKeyboardHandler
61 // , public IResizeHandler
62 {
63
64 // Declare friendship with the AnalyzeGrammarFn class which encapsulates
65 // a thread function that executes a member function of this class
66 //-------
67 friend class AnalyzeGrammarFn;
68 friend class BuildParserFn;
69 friend class TimerFn;
70
71 //Boolean busyFlag;
72 //int errorCount;
73 //int minimized;
74 //ISize minimumSize;
75
76 public:
77
78 Boolean autobuildFlag;
79 Boolean showSyntaxFlag;
80 Boolean showStatsFlag;
81 Boolean stayOnTopFlag;
82
83 // Constructor and destructor
84
85 ControlPanel(unsigned long windowId);
86 ~ControlPanel();
87 static void makeControlPanel();
88 void openCommandLineFile();
89 //Boolean busy() { return busyFlag; }
90 void idSyntaxFile(AgString);
91 void loadSyntaxFile();
92 char *removeTilde(char *);
93 AgThread analyzeThread;
94
95 //int maxDataPanelWidth;
96
97 AgUserHandler *userHandler;
98 static AgString selectedMenuText;
99 //void checkTopmost();
100 //AgClassAction<ControlPanel> topmostAction;
101 void setStatus();
102
103
104 // Command event handler function
105
106 Boolean command(ICommandEvent&);
107 Boolean activated(IFrameEvent &);
108 Boolean deactivated(IFrameEvent &);
109 Boolean gotFocus(IControlEvent &);
110 //Boolean lostFocus(IControlEvent &);
111 Boolean virtualKeyPress(IKeyboardEvent &);
112 //Boolean mousePointerChange(IMousePointerEvent &event);
113 ControlPanel &makeTopmost();
114 //ControlPanel &makeNotTopmost();
115 //Boolean dispatchHandlerEvent(IEvent &event);
116 Boolean systemCommand(ICommandEvent&);
117 Boolean menuShowing(IMenuEvent &event, ISubmenu &submenu);
118 Boolean menuEnded(IMenuEvent &event);
119 Boolean menuSelected(IMenuEvent &event);
120 Boolean mouseClicked(IMouseClickEvent &event);
121 Boolean paintWindow(IPaintEvent &event);
122 //Boolean windowResize(IResizeEvent &event);
123 void showErrors();
124 void closeWindows();
125 void hideWindows();
126 void restoreWindows();
127 void closeSyntaxWindows();
128 virtual Boolean showHelp(IEvent &event);
129 virtual ControlPanel &close();
130 void gatherProfile();
131 void rememberFile(AgString);
132 void selectMenuItem(long);
133 void restoreDirectory();
134
135 class TimerFn : public ITimerFn {
136 private:
137 ITimer &timer;
138 //StatusControl &window;
139 StatisticsWindow &window;
140 IThread &thread;
141 void timerExpired(unsigned long timerId);
142
143 public:
144 TimerFn(ITimer &timer_, StatisticsWindow &window_, IThread &thread_)
145 : timer(timer_)
146 , window(window_)
147 , thread(thread_)
148 {}
149 };
150
151 class ComboBox
152 : public IComboBox
153 , public IShowListHandler
154 , public ISelectHandler
155 {
156 private:
157 int listShowing;
158
159 public:
160 AgAction enterAction;
161 AgAction selectAction;
162 ComboBox(long id, IWindow *owner, char *text)
163 : IComboBox(id, owner, owner, IRectangle(),
164 autoScroll |
165 dropDownType | horizontalScroll | tabStop)
166 , listShowing(0)
167 {
168 //LOGSECTION("ControlPanel::ComboBox::ComboBox");
169 IFont f = font();
170 ISize minimum(f.textWidth(text),f.maxCharHeight() );
171 //LOGV(minimum.asString());
172 setMinimumSize(minimum).show();
173 addAsLast("");
174 ISelectHandler::handleEventsFor(this);
175 IShowListHandler::handleEventsFor(this);
176 }
177 ~ComboBox() {
178 ISelectHandler::stopHandlingEventsFor(this);
179 IShowListHandler::stopHandlingEventsFor(this);
180 }
181
182 Boolean listShown(IControlEvent &event);
183 Boolean enter(IControlEvent &event);
184 };
185
186 void findNext();
187 void findPrev();
188
189 void monitor(IThread &thread);
190
191 ITimer timer;
192
193 AgAction quitAction;
194 void quit();
195
196 AgNotificationAction<ControlPanel> textColorChange;
197 AgNotificationAction<ControlPanel> linkColorChange;
198 AgNotificationAction<ControlPanel> traversedColorChange;
199 void onTextColorChange();
200 void onLinkColorChange();
201 void onTraversedColorChange();
202
203
204 //private:
205
206 // Shows product information dialog
207 //virtual void productInfo();
208
209 AgString openFileName;
210 time_t openFileTimestamp;
211 AgString sourceText;
212
213 IMenuBar menuBar;
214 ISystemMenu systemMenu;
215 IFont systemMenuFont;
216
217 ISetCanvas canvas;
218 ISetCanvas buttonCanvas;
219 IGraphicPushButton agButton;
220 IGraphicPushButton bpButton;
221 IGraphicPushButton ftButton;
222 IGraphicPushButton gtButton;
223 IGraphicPushButton warnButton;
224 IGraphicPushButton confButton;
225 IGraphicPushButton helpButton;
226 IStaticText statusControl;
227 ISetCanvas searchCanvas;
228 ComboBox searchKeyBox;
229 IGraphicPushButton findNextButton;
230 IGraphicPushButton findPrevButton;
231
232 IFlyText flyText;
233 IFlyOverHelpHandler flyOver;
234 IAccelerator accelerator;
235
236 public:
237 ITitle windowTitle;
238
239 AgStack<AgString> recentFiles;
240
241 int topmostFlag;
242
243 //void showHelpTopic();
244 int helpRequested;
245
246 HelpDemon statusControlHelp;
247 HelpDemon searchKeyHelp;
248
249 IRectangle closeRect;
250
251 static IPointerHandle helpCursor;
252 static IPointerHandle activeCursor;
253 static ISystemPointerHandle waitCursor;
254 static int helpCursorSet;
255 static void resetCursor();
256 };
257
258 extern ControlPanel *controlPanel;
259 extern IPoint controlPanelLocation;
260
261 extern int syntaxFileId;
262 extern IRectangle syntaxFileRect;
263
264
265 #endif /* CTRLPANEL_HPP */