Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/vaclgui/frame.cpp @ 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 * frame.cpp | |
7 */ | |
8 | |
9 #include <imnitem.hpp> | |
10 #include <ipopmenu.hpp> | |
11 #include <windows.h> | |
12 | |
13 #include "action.h" | |
14 #include "agstring.h" | |
15 #include "ctrlpanel.hpp" | |
16 #include "frame.hpp" | |
17 #include "helpview.hpp" | |
18 #include "myalloc.h" | |
19 #include "vaclgui-res.h" | |
20 #include "vaclgui.hpp" | |
21 | |
22 //#define INCLUDE_LOGGING | |
23 #include "log.h" | |
24 | |
25 | |
26 int AgFrame::activeWindowCount = 0; | |
27 AgFrame *AgFrame::activeWindow = 0; | |
28 IPopUpMenu *AgFrame::activePopUpMenu = 0; | |
29 | |
30 IWindow *AgFrame::frameParent = 0; | |
31 IWindow *AgFrame::frameOwner = 0; | |
32 AgArray<AgMenuItem> AgFrame::activeAuxMenu; | |
33 int AgFrame::menuShowingFlag = 0; | |
34 | |
35 | |
36 Boolean AgHelpHandler::showHelp(IEvent &event) { | |
37 LOGSECTION("AgHelpHandler::showHelp"); | |
38 return false; | |
39 } | |
40 | |
41 Boolean HelpDemon::showHelp(IEvent &event) { | |
42 AgHelpWindow::showHelp(topic); | |
43 return true; | |
44 } | |
45 | |
46 Boolean HelpDemon::mouseClicked(IMouseClickEvent &event) { | |
47 LOGSECTION("HelpDemon::mouseClicked"); | |
48 LOGV(event.mouseButton()) LCV(event.mouseAction()); | |
49 LOGV(ControlPanel::helpCursorSet); | |
50 if (ControlPanel::helpCursorSet) { | |
51 if (event.mouseButton() == IMouseClickEvent::button2) { | |
52 return false; | |
53 } | |
54 if (event.mouseAction() == IMouseClickEvent::down) { | |
55 AgHelpWindow::showHelp(topic); | |
56 ControlPanel::helpCursorSet = 0; | |
57 ControlPanel::resetCursor(); | |
58 } | |
59 return true; | |
60 } | |
61 return false; | |
62 } | |
63 | |
64 HelpDemon::HelpDemon(IWindow *w, AgString t) | |
65 : window(w) | |
66 , topic(t) | |
67 { | |
68 AgHelpHandler::handleEventsFor(window); | |
69 IMouseHandler::handleEventsFor(window); | |
70 } | |
71 | |
72 HelpDemon::~HelpDemon() { | |
73 //if (!topic.exists()) return; | |
74 LOGSECTION("HelpDemon::~HelpDemon"); | |
75 LOGV((int) &window); | |
76 AgHelpHandler::stopHandlingEventsFor(window); | |
77 LOGS("Help handler released") LCV((int) &window); | |
78 IMouseHandler::stopHandlingEventsFor(window); | |
79 LOGS("Mouse handler released"); | |
80 } | |
81 | |
82 void HelpDemon::setTopic(AgString t) { | |
83 //AgString oldTopic = topic; | |
84 topic = t; | |
85 //if (oldTopic.exists()) return; | |
86 //AgHelpHandler::handleEventsFor(window); | |
87 //IMouseHandler::handleEventsFor(window); | |
88 } | |
89 | |
90 | |
91 class ActivateKluge { | |
92 private: | |
93 AgFrame *window; | |
94 | |
95 void pingWindow() { | |
96 LOGSECTION("ActivateKluge::pingWindow"); | |
97 LOGV((int) window) LCV(window->id()); | |
98 window->setFocus(); | |
99 delete this; | |
100 } | |
101 void pingActionWindow() { | |
102 LOGSECTION("ActivateKluge::pingActionWindow"); | |
103 LOGV((int) window) LCV(window->id()); | |
104 pActionWindow->setFocus(); | |
105 defer(this, pingWindow); | |
106 } | |
107 void pingControlPanel() { | |
108 LOGSECTION("ActivateKluge::pingControlPanel"); | |
109 LOGV((int) window) LCV(window->id()); | |
110 controlPanel->setFocus(); | |
111 defer(this, pingActionWindow); | |
112 } | |
113 | |
114 public: | |
115 ActivateKluge(AgFrame *w) : window(w) { | |
116 LOGSECTION("ActivateKluge::ActivateKluge"); | |
117 LOGV((int) window) LCV(window->id()); | |
118 defer(this, pingControlPanel); | |
119 } | |
120 ~ActivateKluge() {} | |
121 }; | |
122 | |
123 class FocusKluge { | |
124 AgFrame *window; | |
125 | |
126 void pingWindow() { | |
127 LOGSECTION("FocusKluge::pingWindow"); | |
128 LOGV((int) window) LCV(window->id()); | |
129 window->setFocus(); | |
130 delete this; | |
131 } | |
132 | |
133 public: | |
134 FocusKluge(AgFrame *w) : window(w) { | |
135 LOGSECTION("FocusKluge::FocusKluge"); | |
136 LOGV((int) window) LCV(window->id()); | |
137 defer(this, pingWindow); | |
138 } | |
139 ~FocusKluge() {} | |
140 }; | |
141 | |
142 Boolean AgFrameHandler::activated(IFrameEvent &event) { | |
143 LOGSECTION_OFF("AgFrameHandler::activated"); | |
144 //int protectHelp = ControlPanel::helpCursorSet; | |
145 //ControlPanel::helpCursorSet = 0; | |
146 AgFrame *window = (AgFrame *) event.controlWindow(); | |
147 window->activeFlag = 1; | |
148 LOGV(AgFrame::menuShowingFlag) LCV(ControlPanel::helpCursorSet); | |
149 int windowId = window->id(); | |
150 LOGV(windowId) LCV((int) window); | |
151 LOGV((int) controlPanel) LCV((int) pActionWindow); | |
152 AgFrame::activeWindowCount++; | |
153 AgFrame::windowRegistry.markActive(windowId); | |
154 AgFrame::activeWindow = (AgFrame *) window; | |
155 IWindowHandle previous = (void *) event.parameter2(); | |
156 IWindow *previousWindow = IWindow::windowWithHandle(previous); | |
157 if (previousWindow == 0 && controlPanel != 0) { | |
158 new ActivateKluge(window); | |
159 } | |
160 else if (previousWindow != pActionWindow) { | |
161 window->setFocus(); | |
162 } | |
163 LOGV((int) window); | |
164 LOGV((int) event.parameter2().asLong()) LCV((int) previousWindow); | |
165 //ControlPanel::helpCursorSet = protectHelp; | |
166 | |
167 return true; | |
168 } | |
169 | |
170 Boolean AgFrameHandler::deactivated(IFrameEvent &event) { | |
171 LOGSECTION_OFF("AgFrameHandler::deactivated"); | |
172 AgFrame *window = (AgFrame *) event.controlWindow(); | |
173 window->activeFlag = 0; | |
174 #ifdef INCLUDE_LOGGING | |
175 int windowId = window->id(); | |
176 LOGV(windowId) LCV((int) window); | |
177 #endif | |
178 AgFrame::activeWindowCount--; | |
179 LOGV(AgFrame::activeWindowCount); | |
180 if (AgFrame::activeWindow == window) { | |
181 AgFrame::activeWindow = 0; | |
182 } | |
183 //onDeactivate(); | |
184 return false; | |
185 } | |
186 | |
187 | |
188 Boolean AgFrameHandler::dispatchHandlerEvent(IEvent &event) { | |
189 //LOGSECTION("AgFrameHandler::dispatchHandlerEvent", Log::off); | |
190 LOGSECTION_OFF("AgFrameHandler::dispatchHandlerEvent"); | |
191 LOGV(event.eventId()); | |
192 LOGV((int) event.controlWindow()) LCV(event.controlWindow()->id()); | |
193 ok_ptr(this); | |
194 if (event.eventId()==WM_WINDOWPOSCHANGED || event.eventId()==WM_KILLFOCUS) { | |
195 if (controlPanel) { | |
196 controlPanel->makeTopmost(); | |
197 } | |
198 } | |
199 return IFrameHandler::dispatchHandlerEvent(event); | |
200 } | |
201 | |
202 Boolean AgUserHandler::dispatchHandlerEvent(IEvent &event) { | |
203 //LOGSECTION("AgUserHandler::dispatchHandlerEvent", Log::off); | |
204 LOGSECTION_OFF("AgUserHandler::dispatchHandlerEvent"); | |
205 LOGV(event.eventId()); | |
206 LOGV((int) event.controlWindow()) LCV(event.controlWindow()->id()); | |
207 if (event.eventId() == WM_USER) { | |
208 AgAction::Kernel *kernel = | |
209 (AgAction::Kernel *) (void *) event.parameter1().asLong(); | |
210 kernel->perform(); | |
211 if (kernel->unlock()) { | |
212 delete kernel; | |
213 kernel = 0; | |
214 } | |
215 event.setResult(true); | |
216 return true; | |
217 } | |
218 return false; | |
219 } | |
220 | |
221 Boolean AgHelpHandler::dispatchHandlerEvent(IEvent &event) { | |
222 //LOGSECTION("AgHelpHandler", Log::off); | |
223 LOGSECTION_OFF("AgHelpHandler"); | |
224 LOGV(event.eventId()); | |
225 if (event.eventId() == WM_HELP || event.eventId() == IC_ID_HELP) { | |
226 LOGSECTION("WM_HELP message"); | |
227 if (!showHelp(event)) { | |
228 return false; | |
229 } | |
230 event.setResult(true); | |
231 return true; | |
232 } | |
233 return false; | |
234 } | |
235 | |
236 /* | |
237 Boolean AgFrame::mousePointerChange(IMousePointerEvent &event) { | |
238 LOGSECTION("AgFrame::mousePointerChange"); | |
239 if (ControlPanel::helpCursorSet && helpCursorSupported) { | |
240 event.setMousePointer(ControlPanel::helpCursor); | |
241 } | |
242 else { | |
243 event.setMousePointer(ControlPanel::activeCursor); | |
244 } | |
245 LOGS("Pointer changed"); | |
246 return true; | |
247 } | |
248 */ | |
249 | |
250 void AgFrame::showHelpTopic() { | |
251 LOGSECTION("AgFrame::showHelpTopic"); | |
252 if (AgFrame::menuShowingFlag) { | |
253 defer(this, showHelpTopic); | |
254 return; | |
255 } | |
256 AgHelpWindow::showHelp(helpTopic); | |
257 } | |
258 | |
259 Boolean AgFrame::showHelp(IEvent &event) { | |
260 AgString topic; | |
261 | |
262 LOGSECTION("AgFrame::showHelp"); | |
263 // look for active pop up menu | |
264 LOGV((int) AgFrame::activePopUpMenu); | |
265 LOGV(AgFrame::activeAuxMenu.exists()); | |
266 if (AgFrame::activePopUpMenu && AgFrame::activeAuxMenu.exists()) { | |
267 int n = AgFrame::activePopUpMenu->numberOfItems(); | |
268 for (int i = 0; i++ < n;) { | |
269 IMenuItem item = AgFrame::activePopUpMenu->menuItem(i); | |
270 if (item.isHighlighted()) { | |
271 topic = AgFrame::activeAuxMenu[i-1].text; | |
272 break; | |
273 } | |
274 } | |
275 } | |
276 if (!topic.exists() && AgFrame::activeWindow) { | |
277 topic = AgFrame::windowRegistry.getTitle(AgFrame::activeWindow->id()); | |
278 } | |
279 if (!topic.exists()) { | |
280 topic = "Using Help"; | |
281 } | |
282 LOGV(topic) LCV(topic.size()); | |
283 //LOGV(simple_file_name) LCV(simple_file_name.size()); | |
284 helpTopic = topic; | |
285 defer(this, showHelpTopic); | |
286 event.setResult(true); | |
287 return true; | |
288 } | |
289 | |
290 WindowRegistry AgFrame::windowRegistry; | |
291 | |
292 AgFrame::AgFrame() | |
293 : IFrameWindow(nextChildId(), frameParent, frameOwner, IRectangle(), | |
294 titleBar | |
295 | systemMenu | |
296 | minimizeButton | |
297 | sizingBorder | |
298 | noMoveWithOwner) | |
299 , windowTitle(this, "AnaGram") | |
300 , syntaxDependent(0) | |
301 , activeFlag(1) | |
302 , helpCursorSupported(0) | |
303 , accelerator(IDW_FRAME_WINDOW, this) | |
304 , modalDialog(0) | |
305 , closeAction(actionObject(this, closeFrame)) | |
306 { | |
307 LOGSECTION("AgFrame::AgFrame()"); | |
308 windowId = id(); | |
309 //useExtensionMinimumSize(&windowTitle); | |
310 LOGV(windowId) LCV((int) this); | |
311 setIcon(IDI_ICON); | |
312 frameHandler = new AgFrameHandler; | |
313 IFrameWindow::removeDefaultHandler(); | |
314 frameHandler->handleEventsFor(this); | |
315 ICommandHandler::handleEventsFor(this); | |
316 IResizeHandler::handleEventsFor(this); | |
317 LOGS("command handler attached"); | |
318 AgHelpHandler::handleEventsFor(this); | |
319 userHandler = new AgUserHandler; | |
320 userHandler->handleEventsFor(this); | |
321 IKeyboardHandler::handleEventsFor(this); | |
322 //IMousePointerHandler::handleEventsFor(this); | |
323 activeWindow = this; | |
324 } | |
325 | |
326 AgFrame::AgFrame(Style s) | |
327 : IFrameWindow(nextChildId(), frameParent, frameOwner, IRectangle(), | |
328 s | titleBar | minimizeButton | noMoveWithOwner) | |
329 , windowTitle(this, "AnaGram") | |
330 , syntaxDependent(0) | |
331 , activeFlag(1) | |
332 , helpCursorSupported(0) | |
333 , accelerator(IDW_FRAME_WINDOW, this) | |
334 , modalDialog(0) | |
335 , closeAction(actionObject(this, closeFrame)) | |
336 { | |
337 LOGSECTION("AgFrame::AgFrame(Style)"); | |
338 windowId = id(); | |
339 //useExtensionMinimumSize(&windowTitle); | |
340 LOGV(windowId) LCV((int) this); | |
341 setIcon(IDI_ICON); | |
342 LOGV("Icon set"); | |
343 frameHandler = new AgFrameHandler; | |
344 LOGS("frameHandler built"); | |
345 IFrameWindow::removeDefaultHandler(); | |
346 LOGS("Old frame handler removed"); | |
347 frameHandler->handleEventsFor(this); | |
348 LOGS("New frame handler atteched"); | |
349 ICommandHandler::handleEventsFor(this); | |
350 LOGS("Command handler attached"); | |
351 IResizeHandler::handleEventsFor(this); | |
352 LOGS("resize handler attached"); | |
353 AgHelpHandler::handleEventsFor(this); | |
354 LOGS("help handler attached"); | |
355 userHandler = new AgUserHandler; | |
356 LOGS("user handler created"); | |
357 userHandler->handleEventsFor(this); | |
358 LOGS("user handler attached"); | |
359 IKeyboardHandler::handleEventsFor(this); | |
360 LOGS("keyboard handler attached"); | |
361 //IMousePointerHandler::handleEventsFor(this); | |
362 activeWindow = this; | |
363 } | |
364 | |
365 AgFrame::AgFrame(int id_) | |
366 : IFrameWindow(id_, frameParent, frameOwner, IRectangle(), | |
367 titleBar | |
368 | systemMenu | |
369 | minimizeButton | |
370 | maximizeButton | |
371 | sizingBorder | |
372 | noMoveWithOwner) | |
373 , windowTitle(this, "AnaGram") | |
374 , syntaxDependent(0) | |
375 , activeFlag(1) | |
376 , helpCursorSupported(0) | |
377 , accelerator(IDW_FRAME_WINDOW, this) | |
378 , modalDialog(0) | |
379 , closeAction(actionObject(this, closeFrame)) | |
380 { | |
381 LOGSECTION("AgFrame::AgFrame(int id)"); | |
382 windowId = id(); | |
383 //useExtensionMinimumSize(&windowTitle); | |
384 LOGV(windowId) LCV((int) this); | |
385 setIcon(IDI_ICON); | |
386 frameHandler = new AgFrameHandler; | |
387 IFrameWindow::removeDefaultHandler(); | |
388 frameHandler->handleEventsFor(this); | |
389 ICommandHandler::handleEventsFor(this); | |
390 IResizeHandler::handleEventsFor(this); | |
391 LOGS("command handler attached"); | |
392 AgHelpHandler::handleEventsFor(this); | |
393 userHandler = new AgUserHandler; | |
394 userHandler->handleEventsFor(this); | |
395 IKeyboardHandler::handleEventsFor(this); | |
396 //IMousePointerHandler::handleEventsFor(this); | |
397 activeWindow = this; | |
398 } | |
399 | |
400 AgFrame::~AgFrame() { | |
401 LOGSECTION("AgFrame::~AgFrame"); | |
402 LOGV(windowId) LCV((int) this); | |
403 IPoint cascadeRestore = cascadeOffset - cascadeIncrement; | |
404 if (cascadeRestore == initialPosition) { | |
405 cascadeOffset = cascadeRestore; | |
406 } | |
407 ICommandHandler::stopHandlingEventsFor(this); | |
408 LOGS("command handler detached"); | |
409 AgHelpHandler::stopHandlingEventsFor(this); | |
410 LOGS("help handler detached"); | |
411 userHandler->stopHandlingEventsFor(this); | |
412 LOGS("user handler detached"); | |
413 frameHandler->stopHandlingEventsFor(this); | |
414 LOGS("frame handler detached"); | |
415 delete frameHandler; | |
416 LOGS("frame handler deleted"); | |
417 delete userHandler; | |
418 LOGS("user handler deleted"); | |
419 | |
420 IResizeHandler::stopHandlingEventsFor(this); | |
421 LOGS("resize handler detached"); | |
422 IKeyboardHandler::stopHandlingEventsFor(this); | |
423 //IMousePointerHandler::stopHandlingEventsFor(this); | |
424 LOGS("~AgFrame completed"); | |
425 } | |
426 | |
427 void AgFrame::closeFrame() { | |
428 LOGSECTION("AgFrame::closeFrame"); | |
429 LOGV(windowId) LCV((int) this); | |
430 if (modalDialog) { | |
431 closeAction.performDeferred(); | |
432 return; | |
433 } | |
434 close(); | |
435 } | |
436 | |
437 AgFrame &AgFrame::close() { | |
438 LOGSECTION("AgFrame::close"); | |
439 LOGV(id()) LCV(syntaxFileId); | |
440 IFrameWindow::close(); | |
441 return *this; | |
442 } | |
443 | |
444 Boolean AgFrame::characterKeyPress(IKeyboardEvent &event) { | |
445 LOGSECTION("AgFrame::characterKeyPress"); | |
446 if (event.isCtrlDown()) { | |
447 return false; | |
448 } | |
449 if (event.isShiftDown()) { | |
450 return false; | |
451 } | |
452 if (!event.isAltDown()) { | |
453 return false; | |
454 } | |
455 //IMenuBar &menu = controlPanel->menuBar; | |
456 switch (event.character()) { | |
457 /* | |
458 case 'a': | |
459 controlPanel->selectMenuItem(IDM_FILE); | |
460 return true; | |
461 case 'b': | |
462 controlPanel->selectMenuItem(IDM_BROWSE); | |
463 return true; | |
464 case 'o': | |
465 controlPanel->selectMenuItem(IDM_OPTIONS); | |
466 return true; | |
467 case 'w': | |
468 controlPanel->selectMenuItem(IDM_WINDOWS); | |
469 return true; | |
470 case 'h': | |
471 controlPanel->selectMenuItem(IDM_HELP); | |
472 return true; | |
473 */ | |
474 default: | |
475 return false; | |
476 } | |
477 } | |
478 | |
479 Boolean AgFrame::virtualKeyPress(IKeyboardEvent &event) { | |
480 LOGSECTION("AgFrame::virtualKeyPress"); | |
481 LOGV((int) event.virtualKey()); | |
482 LOGV(event.isShiftDown()) LCV(event.isCtrlDown()) LCV(event.isAltDown()); | |
483 switch (event.virtualKey()) { | |
484 case IKeyboardEvent::esc: { | |
485 //IWindow *waiting = controlPanel; | |
486 AgFrame::windowRegistry.remove(id()); | |
487 close(); | |
488 return true; | |
489 } | |
490 case IKeyboardEvent::f10: { | |
491 if (event.isShiftDown()) { | |
492 return true; | |
493 } | |
494 if (event.isCtrlDown() || event.isAltDown()) { | |
495 return false; | |
496 } | |
497 if (controlPanel) { | |
498 controlPanel->setFocus(); | |
499 } | |
500 return false; | |
501 } | |
502 case IKeyboardEvent::f3: { | |
503 if (event.isShiftDown() || event.isCtrlDown() || event.isAltDown()) { | |
504 return false; | |
505 } | |
506 if (controlPanel) { | |
507 controlPanel->findNext(); | |
508 } | |
509 return true; | |
510 } | |
511 case IKeyboardEvent::f4: { | |
512 if (event.isShiftDown() || event.isCtrlDown() || event.isAltDown()) { | |
513 return false; | |
514 } | |
515 if (controlPanel) { | |
516 controlPanel->findPrev(); | |
517 } | |
518 return true; | |
519 } | |
520 case IKeyboardEvent::f8: { | |
521 if (event.isShiftDown() || event.isCtrlDown() || event.isAltDown()) { | |
522 return false; | |
523 } | |
524 if (controlPanel) { | |
525 controlPanel->setFocus(); | |
526 } | |
527 return true; | |
528 } | |
529 } | |
530 return false; | |
531 } | |
532 | |
533 void AgFrame::popUp() { | |
534 if (modalDialog) { | |
535 modalDialog->show().setFocus(); | |
536 return; | |
537 } | |
538 if (isMinimized()) { | |
539 restore(); | |
540 } | |
541 show().setFocus(); | |
542 } | |
543 | |
544 AgFrame &AgFrame::show(Boolean showWindow) { | |
545 IFrameWindow::show(showWindow); | |
546 return *this; | |
547 } | |
548 | |
549 AgFrame &AgFrame::setFocus() { | |
550 IFrameWindow::setFocus(); | |
551 return *this; | |
552 } | |
553 | |
554 AgFrame &AgFrame::mySetFocus() { | |
555 LOGSECTION("AgFrame::mySetFocus"); | |
556 LOGV((int) modalDialog); | |
557 IHandle h = handle(); | |
558 if (modalDialog) { | |
559 modalDialog->setFocus(); | |
560 h = modalDialog->handle(); | |
561 } | |
562 else { | |
563 setFocus(); | |
564 } | |
565 //BringWindowToTop(h); | |
566 return *this; | |
567 } | |
568 | |
569 AgFrame &AgFrame::positionFrame() { | |
570 LOGSECTION("AgFrame::positionFrame"); | |
571 LOGV(size()); | |
572 if (!(size() + cascadeOffset <= desktopWindow()->size())) { | |
573 cascadeOffset = cascadeOrigin; | |
574 } | |
575 | |
576 LOGV(cascadeOffset); | |
577 moveTo(cascadeOffset); | |
578 initialPosition = cascadeOffset; | |
579 cascadeOffset += cascadeIncrement; | |
580 return *this; | |
581 } | |
582 | |
583 Boolean AgFrame::windowResize(IResizeEvent &event) { | |
584 LOGSECTION("AgFrame::windowResize"); | |
585 LOGV(windowId) LCV((int) this); | |
586 LOGV(event.newSize().asString()); | |
587 LOGV(minimumSize().asString()); | |
588 return false; | |
589 } | |
590 | |
591 void AgFrame::registerTitle(AgString name) { | |
592 LOGSECTION("Register title"); | |
593 LOGV(windowId) LCV((int) this) LCV(name); | |
594 windowRegistry.registerId(this, name, actionObject(this, popUp)); | |
595 LOGS("registration complete"); | |
596 } | |
597 | |
598 Boolean AgFrame::command(ICommandEvent &event) { | |
599 LOGSECTION("AgFrame::command"); | |
600 if (messageBoxShowing) { | |
601 messageBeep(); | |
602 return true; | |
603 } | |
604 switch(event.commandId()) { | |
605 case IDM_EDIT_FIND: | |
606 if (controlPanel) { | |
607 controlPanel->searchKeyBox.setFocus(); | |
608 } | |
609 break; | |
610 case IDM_EDIT_FINDNEXT: { | |
611 LOGSECTION("AgFrame::FINDNEXT"); | |
612 if (controlPanel) { | |
613 controlPanel->findNext(); | |
614 } | |
615 break; | |
616 } | |
617 case IDM_EDIT_FINDPREV: | |
618 LOGSECTION("AgFrame::FINDPREV"); | |
619 if (controlPanel) { | |
620 controlPanel->findPrev(); | |
621 } | |
622 break; | |
623 } | |
624 return true; | |
625 } | |
626 | |
627 Boolean AgFrame::systemCommand(ICommandEvent &event) { | |
628 LOGSECTION("AgFrame::systemCommand"); | |
629 int commandId = event.commandId() & 0xfff0; | |
630 LOGV(commandId); | |
631 if (messageBoxShowing) { | |
632 messageBeep(); | |
633 return true; | |
634 } | |
635 if (commandId == ISystemMenu::idClose) { | |
636 LOGSECTION("AgFrame::systemCommand::idClose"); | |
637 LOGV(windowId) LCV((int) this); | |
638 | |
639 LOGV((int)event.dispatchingWindow()); | |
640 LOGV((int)event.controlWindow()); | |
641 LOGV((int)this); | |
642 if (event.dispatchingWindow() != this) { | |
643 return false; | |
644 } | |
645 | |
646 AgFrame *window = windowRegistry.find(windowId); | |
647 if (window && window->modalDialog) { | |
648 window->modalDialog->close(); | |
649 } | |
650 //IWindow *waiting = controlPanel; | |
651 windowRegistry.remove(windowId); | |
652 /* | |
653 int n = AgFrame::windowRegistry.size(); | |
654 if (n) { | |
655 waiting = AgFrame::windowRegistry[n-1].window; | |
656 } | |
657 waiting->setFocus(); | |
658 */ | |
659 closeAction.performDeferred(); | |
660 LOGS("finished"); | |
661 //return false; | |
662 return true; | |
663 } | |
664 else if (commandId == ISystemMenu::idMinimize) { | |
665 LOGSECTION("AgFrame::systemCommand::idMinimize"); | |
666 hide(); | |
667 return true; | |
668 } | |
669 return false; | |
670 } | |
671 | |
672 AgDialog::AgDialog(IWindow *owner) | |
673 : IFrameWindow(nextChildId(), AgFrame::frameParent, owner, IRectangle(), | |
674 titleBar | |
675 | systemMenu | |
676 | dialogBorder | |
677 | dialogBackground | |
678 | noMoveWithOwner | |
679 | synchPaint) | |
680 , windowTitle(this, "AnaGram") | |
681 { | |
682 LOGSECTION("AgDialog::AgDialog"); | |
683 windowId = id(); | |
684 LOGV(windowId); | |
685 setIcon(IDI_ICON); | |
686 ICommandHandler::handleEventsFor(this); | |
687 IResizeHandler::handleEventsFor(this); | |
688 AgHelpHandler::handleEventsFor(this); | |
689 } | |
690 | |
691 AgDialog::~AgDialog() { | |
692 LOGSECTION("AgDialog::~AgDialog"); | |
693 LOGV(windowId); | |
694 ICommandHandler::stopHandlingEventsFor(this); | |
695 IResizeHandler::stopHandlingEventsFor(this); | |
696 AgHelpHandler::stopHandlingEventsFor(this); | |
697 } | |
698 | |
699 Boolean AgDialog::showHelp(IEvent &event) { | |
700 AgString topic; | |
701 | |
702 LOGSECTION("AgDialog::showHelp"); | |
703 topic = AgFrame::windowRegistry.getTitle(AgFrame::activeWindow->id()); | |
704 if (!topic.exists()) { | |
705 topic = "Using Help"; | |
706 } | |
707 AgString title; | |
708 if (topic.exists()) { | |
709 title = topic.firstCut(' ').leftX(); | |
710 LOGV(topic.pointer()); | |
711 LOGV(title.pointer()); | |
712 if (!title.exists()) { | |
713 title = topic; | |
714 } | |
715 if (title == "Help") { | |
716 topic = "Using Help"; | |
717 } | |
718 title = AgString::format("Help - %s", topic.pointer()); | |
719 } | |
720 LOGV(topic.pointer()); | |
721 IFrameWindow *helpWindow = AgFrame::windowRegistry.find(title); | |
722 LOGV((int) helpWindow); | |
723 if (helpWindow == 0) { | |
724 helpWindow = new AgHelpWindow(topic); | |
725 helpWindow->setAutoDeleteObject(); | |
726 } | |
727 helpWindow->setFocus(); | |
728 event.setResult(true); | |
729 return true; | |
730 } | |
731 | |
732 Boolean AgDialog::systemCommand(ICommandEvent &event) { | |
733 LOGSECTION("AgDialog::systemCommand"); | |
734 int commandId = event.commandId() & 0xfff0; | |
735 if (commandId == ISystemMenu::idClose) { | |
736 LOGSECTION("AgDialog::systemCommand::idClose"); | |
737 LOGV(windowId); | |
738 | |
739 LOGV((int)event.dispatchingWindow()); | |
740 LOGV((int)event.controlWindow()); | |
741 LOGV((int)this); | |
742 if (event.dispatchingWindow() != this) { | |
743 return false; | |
744 } | |
745 | |
746 //IWindow *waiting = controlPanel; | |
747 AgFrame::windowRegistry.remove(windowId); | |
748 /* | |
749 int n = AgFrame::windowRegistry.size(); | |
750 if (n) { | |
751 waiting = AgFrame::windowRegistry[n-1].window; | |
752 } | |
753 waiting->setFocus(); | |
754 */ | |
755 LOGS("finished"); | |
756 return false; | |
757 } | |
758 else if (commandId == ISystemMenu::idMinimize) { | |
759 LOGSECTION("AgDialog::systemCommand::idMinimize"); | |
760 hide(); | |
761 return true; | |
762 } | |
763 return false; | |
764 } | |
765 | |
766 |