home *** CD-ROM | disk | FTP | other *** search
- /* XWindow.h
- *
- * This is the stuff which encapsulates the window functionality
- */
-
- /* YAAF - Yet another application framework
- * Copyright (C) 1997 William Edward Woody and In Phase Consulting
- *
- * This library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Library
- * General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or any
- * later version.
- *
- * This library is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Library General Public License for
- * more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * To contact the author, either e-mail me at
- * woody@alumni.caltech.edu, or write to us at
- *
- * William Edward Woody
- * In Phase Consulting
- * 1545 Ard Eevin Avenue
- * Glendale, CA 91202
- */
-
- #ifndef __XWINDOW_H__
- #define __XWINDOW_H__
-
- #include <XConfig.h>
- #include <XView.h>
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=power
- #endif
- #if defined(__INTEL__)
- #pragma pack(push,2)
- #endif
- #endif
-
- /************************************************************************/
- /* */
- /* Internal Window Storage */
- /* */
- /************************************************************************/
-
- #if OPT_MACOS == 1
-
- /* MyWindowRecord
- *
- * This is an extension to the WindowRecord object which provides
- * me a sleazy way to get the pointer to my XGWindow object
- */
-
- struct _MyWindowRecord {
- WindowRecord w;
- XGWindow *tw;
- };
-
- #endif // OPT_MACOS
-
-
- /************************************************************************/
- /* */
- /* Window Management Attributes */
- /* */
- /************************************************************************/
-
- /*
- * XGWindow types
- */
-
- #define KWinTypeDocument 0
- #define KWinTypeModal 1
- #define KWinTypeMovableModal 2
-
- #if OPT_FLOATWINDOW == 1
- #define KWinTypeFloating 3
- #endif
-
- /*
- * XGWindow::Attributes() values
- *
- * low word is the flags
- * high word is the menu level
- */
-
- #define KAttrNoClose 0x00000001
- #define KAttrNoResize 0x00000002
- #define KAttrHideOnSwitch 0x00000004
- #define KAttrNoMenu 0x00000008
-
- #if OPT_FLOATWINDOW == 1
- #define KAttrFloater 0x00000010
- #endif
-
- /************************************************************************/
- /* */
- /* Window Definition */
- /* */
- /************************************************************************/
-
- /* XGSWindowInitRecord
- *
- * This is the initialization record for creating my window from
- * scratch
- */
-
- struct XGSWindowInitRecord {
- long fViewType;
-
- short windowType;
- short windowID;
- bool fVisible;
-
- /*
- * Window Size
- */
-
- short screenLeft;
- short screenTop;
- short screenRight;
- short screenBottom;
-
- /*
- * Window sizing parameters
- */
-
- short minx;
- short miny;
- short maxx;
- short maxy;
- short initx;
- short inity;
- short zoomx;
- short zoomy;
-
- /*
- * Window name
- */
-
- char windowName[256];
- };
-
-
- /************************************************************************/
- /* */
- /* Window Declaration */
- /* */
- /************************************************************************/
-
- /* XGWindow
- *
- * This is the root class which defines windows and how they are
- * handled
- */
-
- class XGWindow : public XGView, public XGFocus {
- public:
- /*
- * Construction/Destruction
- */
-
- XGWindow(XGSWindowInitRecord &);
- XGWindow(XGArgStream &);
- virtual ~XGWindow();
-
- /*
- * Create/Destroy
- */
-
- static XGWindow *Create(short);
- static XGWindow *Create(XGSWindowInitRecord &);
- virtual bool CloseWindow();
- void SetDocument(XGDocument *d)
- {
- fDocument = d;
- }
-
- /*
- * Initialization
- */
-
- virtual Point MinWindowSize();
- virtual Point MaxWindowSize();
- virtual Point InitWindowSize();
- virtual Point ZoomWindowSize();
- void _LimitWindowSize(Point *);
-
- /*
- * XGView overrides
- */
-
- void DoDrawView(Rect);
-
- /*
- * Document Support
- */
-
- virtual bool IsDirty();
- virtual bool DoSave();
-
- /*
- * Window attributes
- */
-
- void GetWindowName(char *);
- void SetWindowName(char *);
- virtual short GetMenuBarID();
-
- short GetWindowType()
- {
- return fWinType;
- }
- long _Attributes()
- {
- return fAttributes;
- }
-
- /*
- * Window support
- */
-
- void ShowWindow();
- void HideWindow(); // Show/hide this entire window
- bool IsShowWindow();
-
- static XGWindow *GetFrontWindow();
- void SelectWindow();
- static void GetScreenSize(Rect *);
-
- /*
- * Window size
- */
-
- Point GetContentSize() const;
- Rect GetContentRect() const;
-
- void SetWindowSize(Point);
- void SetWindowPos(Point);
- void SetWindowLocation(Rect);
-
- Point GetWindowSize() const;
- Point GetWindowPos() const;
-
- /*
- * Miscellaneous window management routines
- */
-
- XGDocument *_GetDocument() const
- {
- return fDocument;
- }
- bool _IsActiveWindow() const; // Active window?
- XGView *_CapturedView() const;
-
- void _ContentToSize(Point *) const;
- void _ContentToSize(Rect *) const;
- void _SizeToContent(Point *) const;
- void _SizeToContent(Rect *) const;
-
- #if OPT_MACOS == 1
- void _ResetDrawing();
-
- static XGWindow *_GetXGWindow(WindowPtr);
- GrafPtr _GetGrafPtr() const
- {
- return (GrafPtr)(&(fWindow.w));
- }
-
- bool _ProcessMouseDown(Point,short);
- void _ProcessMouseMove(Point,short);
- void _ProcessMouseUp(Point,short);
- void _ProcessUpdateEvent(Rect);
- void _ProcessActivateEvent(bool);
- #endif
-
- void _ProcessSizeEvent(void);
-
- #if OPT_WINOS == 1
- static XGWindow *_GetXGWindow(HWND);
-
- bool IsIconic();
- #endif
-
- protected:
- long fAttributes;
-
- private:
- void IInitRecord(void);
- void IInitWindow(XGSWindowInitRecord &);
- void ICreateWindow(char *name, Rect *size);
-
- XGDocument *fDocument;
-
- short fWinType;
- short fWinID;
- Point fMin;
- Point fMax;
- Point fInit;
- Point fZoom;
-
- #if OPT_MACOS == 1
- XGView *fCapture;
- _MyWindowRecord fWindow;
- #endif
-
- #if OPT_WINOS == 1
- friend LRESULT CALLBACK _GChildWindowProc(HWND w, UINT msg, WPARAM wp, LPARAM lp);
- #endif
- };
-
- #if defined(__MWERKS__)
- #if defined(macintosh)
- #pragma options align=reset
- #endif
- #if defined(__INTEL__)
- #pragma pack(pop)
- #endif
- #endif
-
-
- #endif /* __XWINDOW_H__ */
-