titlewnd.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:14k
- /*
- * titlewnd.h
- *
- * Titled window.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: titlewnd.h,v $
- * Revision 1.23 1999/03/29 03:39:55 robertj
- * Changed semantics of PTitledWindow::OnClose() function.
- *
- * Revision 1.22 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.21 1999/03/09 08:01:50 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.20 1999/02/16 08:08:47 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.19 1998/09/23 06:29:27 robertj
- * Added open source copyright license.
- *
- * Revision 1.18 1996/04/30 12:34:05 robertj
- * Changed "inPixels" boolean to enum for three coordinate systems.
- *
- * Revision 1.17 1996/01/02 12:53:16 robertj
- * Moved constructor to platform dependent code.
- *
- * Revision 1.16 1995/12/23 03:48:12 robertj
- * Moved constructor to platform dependent code.
- *
- * Revision 1.15 1995/08/12 22:35:08 robertj
- * Fixed comment.
- *
- * Revision 1.14 1995/06/17 11:13:37 robertj
- * Documentation update.
- *
- * Revision 1.13 1995/03/14 12:42:52 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.12 1995/02/19 04:15:00 robertj
- * Added AllowClose() function for PTitledWindow descendents.
- *
- * Revision 1.11 1995/01/16 13:02:24 robertj
- * Documentation.
- *
- * Revision 1.10 1994/09/25 10:46:59 robertj
- * Removed irrelevent parameter in OnActivate().
- *
- * Revision 1.9 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.8 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.7 1994/08/21 23:43:02 robertj
- * Added delayed close of interactors to avoid the "delete this" problem.
- * Added ability to get coordinates in pixels.
- *
- * Revision 1.6 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.5 1994/04/03 08:34:18 robertj
- * Added help and focus functionality.
- *
- * Revision 1.4 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.3 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PTITLEDWINDOW
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PTitledWindow : public PInteractor
- {
- PCLASSINFO(PTitledWindow, PInteractor)
- /* This class represents the first real "Window". The user inteface element it
- describes is a framed window with a title bar. This type of window may be
- moved, resized and closed dynamically by the user.
- */
- public:
- enum {
- /// Window has a mechanism for begin closed by the user.
- CanClose = 1,
- /// Window has a mechanism for being resized by the user.
- CanGrow = 2,
- /**Window has a mechanism for being shrunk to a system standard "unused"
- size by the user. For MS-Windows and X-Windows the window is
- substituted by an icon. For the Macintosh only the windows title bar
- is shown.
- */
- CanIconify = 4,
- /**Window has a mechanism for being enlarged to a standard "zoomed"
- size by the user.
- */
- CanZoom = 8
- };
- /** Destroy the titled window. */
- virtual ~PTitledWindow();
- /**@name Overrides from class PInteractor */
- /**Set the child interactor that has the focus in the
- Ref{PTitledWindow} or Ref{PInteractorLayout}.
- The interactor set here may not actually have the focus. It is the
- interactor that will be given the focus if the parent interactor,
- eg a dialog, is given the focus. The dialog itself never requires the
- focus directly.
- The behaviour here is to save the interactor for return by the
- Ref{GetFocusInteractor()} function.
- */
- virtual void SetFocusInteractor(
- PInteractor * interactor /// Interactor that received focus.
- );
- /**Get the child interactor that has the focus in the Ref{PTitledWindow}
- or Ref{PInteractorLayout}.
- The interactor returned here may not actually have the focus. It is
- the interactor that will be given the focus if the parent interactor,
- eg a dialog, is given the focus. The dialog itself never requires the
- focus directly.
- The default behaviour is to get the saved interactor set by the
- Ref{SetFocusInteractor()} function.
- @return
- pointer to child or grandchild interactor that has focus.
- */
- virtual PInteractor * GetFocusInteractor() const;
- /**@name New functions for class */
- /**Set the windows title string. This will be updated on the screen
- immediately (subject to OS constraints).
- */
- virtual void SetTitle(
- const PString & title /// New title for window.
- );
- /**Get the titled windows title string.
- @return
- string used in title.
- */
- virtual PString GetTitle() const;
- /**Make the window the "active" window by giving it the focus and bringing
- it to the top of all the windows at the same level.
- */
- virtual void Activate();
- /**Set and the minimum size of the client area that the window can be
- grown to via user interaction.
- */
- void SetMinSize(
- PDIMENSION width, /// New minimum width to apply to titled window.
- PDIMENSION height, /// New minimum height to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- void SetMinSize(
- const PDim & dim, /// New minimum dimensions to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Get and the minimum size of the client area that the window can be
- grown to via user interaction.
- @return
- minimum dimensions for titled window.
- */
- PDim GetMinSize(
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Set and the maximum size of the client area that the window can be
- grown to via user interaction.
- */
- void SetMaxSize(
- PDIMENSION width, /// New maximum width to apply to titled window.
- PDIMENSION height, /// New maximum height to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- void SetMaxSize(
- const PDim & dim, /// New maximum dimensions to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Get and the maximum size of the client area that the window can be
- grown to via user interaction.
- @return
- maximum dimensions for titled window.
- */
- PDim GetMaxSize(
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Set and the size of the client area when the window is set to the
- "zoomed" state via user interaction.
- */
- void SetZoomSize(
- PDIMENSION width, /// New zoomed width to apply to titled window.
- PDIMENSION height, /// New zoomed height to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- void SetZoomSize(
- const PDim & dim, /// New zoomed dimensions to apply to titled window.
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Get and the size of the client area when the window is set to the
- "zoomed" state via user interaction.
- @return
- zoomed dimensions for titled window.
- */
- PDim GetZoomSize(
- CoordinateSystem coords /// Coordinate system to use.
- );
- /**Set the icon that will be used when a titled window is in the "iconic"
- mode. This may not be used if the platform does not use an icon for
- an "iconised" window.
- */
- virtual void SetIcon(
- const PIcon & icn /// New icon for a window in "iconic" mode.
- );
- /**Get the icon that will be used when a titled window is in the "iconic"
- mode. This may not be used if the platform does not use an icon for
- an "iconised" window.
- @return
- reference to the icon instance being used by the window.
- */
- const PIcon & GetIcon();
- /**Make the titled window "iconic". This will place the window in the
- "iconic" state exactly as though the user had executed the platform
- dependent mechanism, eg clicked on an icon or button.
- */
- virtual void MakeIconic();
- /**Make the titled window the "zoomed" size. This will chaneg the size of
- the window to a platform dependent "zoomed" state exactly as though the
- user had executed the platform dependent mechanism, eg clicked on an
- icon or button.
- */
- virtual void Zoom();
- /**Make the titled window "normal" after being "zoomed" or "iconic". This
- will place the window in the "normal" state exactly as though the user
- had executed the platform dependent mechanism, eg clicked on an icon or
- button.
- */
- virtual void Normalise();
- /**Close the PTitledWindow. This will do a "safe" delete of the titled
- window object, ie after all the member functions on the object have
- returned and the programme is in the main message handling loop then
- the delete operator is executed on the object. This will prevent
- problems with the "this" pointer being invalid when a PTitledWindow is
- closed via the windowing system.
- The default behavour here calls the Ref{AllowClose()} function before
- actually closing the window. Note, if you override this function, make
- sure you always call the ancestor version.
- @return
- TRUE if close has been queued.
- */
- virtual BOOL Close();
- /**See if a close of the PTitledWindow is allowed. This is called when the
- Ref{Close()} function is called to verify that the window may be
- closed. It is also called when the top level window is closed and all
- the child titled windows, especially Ref{PMDIDocWindow} instances,
- are to be closed as well.
- The default behavour is to return TRUE.
- @return
- TRUE if close is allowed.
- */
- virtual BOOL AllowClose(
- BOOL closingAll
- /**Flag indicating all titled windows are being closed as the top level
- window is being closed.
- */
- );
- /**@name System callback functions. */
- /**The system calls this whenever the window is being closed. There is no
- way to prevent this action at this point. Override the Ref{Close()}
- or Ref{AllowClose()} functions if you wish to control if the close
- operation occurs.
- The application writer may override this function to do any clean up
- or state saving operations.
-
- The default action does nothing.
- */
- virtual void OnClose();
- /**The system calls this when the window has just been made active or
- deactive via mouse click or some other platform dependent method.
- */
- virtual void OnActivate(
- BOOL active /// Flag indicating the new activation state of the window.
- );
- /**The system calls this whenever the window has been dynamically
- repositioned by the user.
- */
- virtual void OnReposition(
- const PPoint & newPos /// New position that window was moved to.
- );
- /**Window resize state chages passed to the Ref{OnResize()} function.
- */
- enum ResizeType {
- /// The user resized the window into the "iconic" state.
- Iconic,
- /// The user resized the window into the "zoomed" state.
- Zoomed,
- /**The user resized the window into the "normal" state, or the window was
- already in the "normal" state and the window was just dynamically
- resized by the user using a platform dependent mechanism.
- */
- Normalised
- };
- /**The system calls this whenever the window has been dynamically resized
- by the user or by the program. The resize may be due to the window
- being made "iconic" or zoomed" as well as just having its size changed.
- This function is especially usefull for resizing child interactors that
- are contained within the titled window, eg tool bars, status bars etc.
-
- The #newSize# parameter is in pixels.
- */
- virtual void OnResize(
- const PDim & newSize, /// New size of the titled window.
- ResizeType type /// New state of the titled window.
- );
- protected:
- /**@name Member variables */
- /** User size adjustment minimum limits. */
- PDim minSize;
- /** User size adjustment maximum limits. */
- PDim maxSize;
- /** User size adjustment for "zoomed" windows. */
- PDim zoomSize;
- /** Icon to be used for window. */
- PIcon icon;
- /** Child interactor that gets the focus when this window gets focus. */
- PInteractor * focusInteractor;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////