toplwnd.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:8k
- /*
- * toplwnd.h
- *
- * Top level application 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: toplwnd.h,v $
- * Revision 1.25 1999/03/29 03:39:55 robertj
- * Changed semantics of PTitledWindow::OnClose() function.
- *
- * Revision 1.24 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.23 1999/03/09 08:01:50 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.22 1999/02/16 08:08:47 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.21 1998/09/27 00:41:21 craigs
- * Added RedrawMenu function
- *
- * Revision 1.20 1998/09/23 06:29:28 robertj
- * Added open source copyright license.
- *
- * Revision 1.19 1996/01/02 12:53:34 robertj
- * Mac OS compatibility changes.
- *
- * Revision 1.18 1995/06/17 11:13:40 robertj
- * Documentation update.
- *
- * Revision 1.17 1995/03/14 12:42:55 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.16 1995/02/19 04:19:24 robertj
- * Added dynamically linked command processing.
- *
- * Revision 1.15 1995/01/18 09:01:33 robertj
- * Documentation.
- *
- * Revision 1.14 1994/12/21 11:54:41 robertj
- * Documentation and variable normalisation.
- *
- * Revision 1.13 1994/10/30 11:47:27 robertj
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.12 1994/10/23 04:58:33 robertj
- * Added function for clean close of titled windows.
- *
- * Revision 1.11 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.10 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.9 1994/07/17 10:46:06 robertj
- * Moved help menu function from application to toplevelwindow.
- *
- * Revision 1.8 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.7 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.6 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.5 1993/08/21 17:09:50 robertj
- * Added function to allow setting of menus whenever it is selected.
- *
- * Revision 1.4 1993/08/21 01:50:33 robertj
- * Made Clone() function optional, default will assert if called.
- *
- * Revision 1.3 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PTOPLEVELWINDOW
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PTopLevelWindow : public PTitledWindow
- {
- PCLASSINFO(PTopLevelWindow, PTitledWindow)
- /* This class represents an applications "main" window. An application would
- have at least one instance of a descendent of this class.
-
- Even though it is possible for there to be more than one "main" window for
- an application, it is not recommended as this breaches the user interface
- guidelines of most platforms. On most cases where multiple top level
- windows are required, the Multiple Document Interface (MDI) system should
- be used. See Ref{PMDIFrameWindow} and Ref{PMDIDocWindow} for more
- information.
-
- The first instance of a top level window created is tied to the application
- instance in that when that window is closed, the application is terminated.
- The Ref{PApplication::GetWindow()} function returns this first top level
- window.
- */
- public:
- /**Create a new top level window for the current application.
-
- The first top level window created is remembered by the current
- application and when it closes terminates the application.
-
- The top level window is the only interactor that does not require a
- parent interactor. This will be the root of the hierarchy of
- interactors in the application.
- */
- PTopLevelWindow(
- unsigned CanDo = CanClose|CanGrow|CanIconify|CanZoom
- /// Titled window capabilities for the top level window.
- );
- /**Destroy the top level window, if a menu has been set for the window
- then it is deleted as well. If the application is not in the process of
- terminating and this top level window was the first created then the
- application is terminated as well.
- */
- virtual ~PTopLevelWindow();
- /**@name Overrides from class PTitledWindow */
- /**Close the top level window. This overrides the PTitledWindow version
- and if is the first top level window created, terminates the
- application.
- */
- virtual BOOL Close();
- /**@name New functions for class */
- /**Attach a menu to the top level window.
-
- If the #newMenu# parameter is NULL then no menu for the top
- level window is shown.
- If the #autoDelete# parameter is TRUE then the menu will be
- automatically deleted when the window is destroyed or when another menu
- is set using SetMenu().
- */
- virtual void SetMenu(
- PRootMenu * newMenu, /// New menu bar to attach to the top level window.
- BOOL autoDelete = TRUE
- /**Flag for making the top level window responsible for the deletion of
- the menu object being attached.
- */
- );
- /**Get the currently active menu attached to the top level window.
-
- @return
- pointer to windows menu, or NULL if no menu is set.
- */
- PRootMenu * GetMenu() const;
- /**Get the active menus help sub-menu. The actual placement of the help
- sub-menu is platform dependent.
-
- The menus constructed by the user do {bf not} contain a help menu
- due to the platform dependence. If the user wishes to alter the help
- menu, they must use this function to get an object to manipulate. Note
- that the exact contents of the menu is, again, platform dependent so
- essentially the only thing that can be done is to append items to the
- end of the menu.
-
- @return
- reference to the help sub-menu.
- */
- PSubMenu & GetHelpMenu();
- /**Whenever the menu bar is selected and the process of selecting a menu
- begins, this function is called. It may be used to enable or disable
- menu items before they appear.
-
- The default behaviour does nothing.
- */
- virtual void OnMenuStartSelect();
- /**Every menu selection will go through this function allowing it to
- intercept any or all menu selections.
-
- The default behaviour to call the call back function attached to the
- menu item object.
- */
- virtual void OnMenuItemSelect(
- PMenuItem & item /// Menu item that was selected.
- );
- /**Can be used to redraw the menubar after it has been altered
- */
- void RedrawMenu();
- protected:
- /**@name Overrides from class PInteractor */
- /**Scan through all child interactors and if they are a command source,
- execute their notification function to enable or disable the item.
- The behaviour here is to call Ref{PInteractor::UpdateCommandSources()}
- for the menu bar and then all child interactors.
- This function is used internally by the library. It would normally not
- be called directly.
- */
- virtual void UpdateMyCommandSources();
- /**@name Member variables */
- /** The menu that was last set by SetMenu(). */
- PRootMenu * menu;
- /**An indication that the menu is to be deleted when the window is
- destroyed or when a new menu is set for the window.
- */
- BOOL deleteMenu;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////