Mercurial > ~dholland > hg > ag > index.cgi
diff anagram/vaclgui/frame.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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/anagram/vaclgui/frame.hpp Sat Dec 22 17:52:45 2007 -0500 @@ -0,0 +1,230 @@ +/* + * AnaGram, A System for Syntax Directed Programming + * Copyright 1997-2002 Parsifal Software. All Rights Reserved. + * See the file COPYING for license and usage terms. + * + * frame.hpp + */ + +#ifndef FRAME_HPP +#define FRAME_HPP + +#include <iaccel.hpp> +//#include <icanvas.hpp> +#include <iclipbrd.hpp> +#include <icmdevt.hpp> +#include <icmdhdr.hpp> +#include <iframe.hpp> +#include <iframhdr.hpp> +#include <ikeyevt.hpp> +#include <ikeyhdr.hpp> +#include <imousevt.hpp> +#include <imoushdr.hpp> +//#include <imphdr.hpp> +#include <ipopmenu.hpp> +#include <isizeevt.hpp> +#include <isizehdr.hpp> +//#include <isysmenu.hpp> +#include <ititle.hpp> +//#include <windows.h> + +#include "action.h" +#include "agarray.h" +#include "agstring.h" +#include "wdata.h" +#include "windowreg.h" + + +class AgFrame; + +class AgHelpHandler : public IHandler { +public: + AgHelpHandler &handleEventsFor(IWindow *control) { + //LOGSECTION("AgHelpHandler::attach"); + //LOGV((int) control); + IHandler::handleEventsFor(control); + return *this; + } + AgHelpHandler &stopHandlingEventsFor(IWindow *control) { + //LOGSECTION("AgHelpHandler::detach"); + //LOGV((int) control); + IHandler::stopHandlingEventsFor(control); + return *this; + } + Boolean dispatchHandlerEvent(IEvent &event); + +protected: + virtual Boolean showHelp(IEvent &event);// { return false; } +}; + +class AgUserHandler : public IHandler { +public: + AgUserHandler &handleEventsFor(IWindow *control) { + IHandler::handleEventsFor(control); + return *this; + } + AgUserHandler &stopHandlingEventsFor(IWindow *control) { + IHandler::stopHandlingEventsFor(control); + return *this; + } + Boolean dispatchHandlerEvent(IEvent &event); +}; + +class HelpDemon + : public AgHelpHandler + , public IMouseHandler +{ +private: + IWindow *window; + AgString topic; + +public: + HelpDemon(IWindow *w) : window(w) {} + + HelpDemon(IWindow *w, AgString t); + ~HelpDemon(); + void setTopic(AgString t); + +protected: + virtual Boolean showHelp(IEvent &event); + virtual Boolean mouseClicked(IMouseClickEvent &event); +}; + + + +class AgFrameHandler : public IFrameHandler { +protected: + Boolean dispatchHandlerEvent(IEvent &event); + +public: + AgAction deactivateAction; + AgFrameHandler &setDeactivateAction(AgAction action) { + deactivateAction = action; + return *this; + } + virtual void onDeactivate() { + deactivateAction.performDeferred(); + } + + AgAction activateAction; + AgFrameHandler &setActivateAction(AgAction action) { + activateAction = action; + return *this; + } + virtual void onActivate() { + //LOGSECTION("AgFrameHandler::onActivate"); + activateAction.performDeferred(); + } + + Boolean activated(IFrameEvent &event); + Boolean deactivated(IFrameEvent &event); + AgFrameHandler() + : activateAction(actionObject(this, onActivate)) + , deactivateAction(actionObject(this, onDeactivate)) + {} +}; + + +class AgFrame + : public IFrameWindow + , public ICommandHandler + , public IResizeHandler + , public AgHelpHandler + , public IKeyboardHandler +{ +public: + AgFrame(int); + AgFrame(); + AgFrame(Style); + virtual ~AgFrame(); + + virtual AgFrame &show(Boolean showWindow = true); + virtual AgFrame &setFocus(); + + virtual void popUp(); + virtual void disconnect() {} + + virtual void registerTitle(AgString); + static WindowRegistry windowRegistry; + static AgArray<AgMenuItem> activeAuxMenu; + static IPopUpMenu *activePopUpMenu; + virtual void closeFrame(); + AgAction closeAction; + + + AgUserHandler *userHandler; + AgFrameHandler *frameHandler; + virtual Boolean showHelp(IEvent &event); + + virtual AgFrame &positionFrame(); + + virtual unsigned getLineNumber() { return 0; } + virtual void setLineNumber(unsigned) {} + virtual Boolean findNext(AgString) { return false; } + virtual Boolean findPrev(AgString) { return false; } + virtual AgString copyTitle() { return AgString(); } + virtual AgFrame ©To(IClipboard &) { return *this; } + + + static int activeWindowCount; + static AgFrame *activeWindow; + static IWindow *frameParent; + static IWindow *frameOwner; + static int menuShowingFlag; + + AgString helpTopic; + void showHelpTopic(); + +protected: + Boolean command(ICommandEvent &event); + Boolean systemCommand(ICommandEvent &event); + Boolean windowResize(IResizeEvent &event); + Boolean characterKeyPress(IKeyboardEvent &event); + Boolean virtualKeyPress(IKeyboardEvent &event); + +public: + // Child Windows + ITitle windowTitle; + int activeFlag; + int activationFlag; + int helpCursorSupported; + + IPoint initialPosition; + + // Window parameters + int windowId; + + int syntaxDependent: 1; + IFrameWindow *modalDialog; + + virtual AgFrame &closeModalDialog() { + if (modalDialog) modalDialog->close(); + return *this; + } + AgFrame &close(); + virtual AgFrame &mySetFocus(); + IAccelerator accelerator; +}; + +class AgDialog + : public IFrameWindow + , public ICommandHandler + , public AgHelpHandler +{ +public: + AgDialog(IWindow *); + virtual ~AgDialog(); + + virtual Boolean showHelp(IEvent &event); + Boolean systemCommand(ICommandEvent &event); + +public: + // Child Windows + ITitle windowTitle; + + // Window parameters + int windowId; +}; + + +#endif /* FRAME_HPP */