home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / utility / CSaveWindowStatus.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.4 KB  |  107 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef __H_CSaveWindowStatus
  20. #define __H_CSaveWindowStatus
  21. #pragma once
  22.  
  23. /*======================================================================================
  24.     AUTHOR:            Ted Morris <tmorris@netscape.com> - 08 NOV 96
  25.  
  26.     DESCRIPTION:    Defines a mix-in class for saving a window's status to the preferences
  27.                     file.
  28.  
  29.     MODIFICATIONS:
  30.  
  31.     Date            Person            Description
  32.     ----            ------            -----------
  33. ======================================================================================*/
  34.  
  35.  
  36. /*====================================================================================*/
  37.     #pragma mark INCLUDE FILES
  38. /*====================================================================================*/
  39.  
  40. class LWindow;
  41. class LStream;
  42.  
  43.  
  44. #pragma mark -
  45. /*====================================================================================*/
  46.     #pragma mark CLASS DECLARATIONS
  47. /*====================================================================================*/
  48.  
  49. class CSaveWindowStatus {
  50.                       
  51. public:
  52.  
  53.                         CSaveWindowStatus(LWindow *inWindow) {
  54.                             mWindowSelf = inWindow;
  55.                             mCanSaveStatus = true;
  56.                             mHasSavedStatus = false;
  57.                             Assert_(mWindowSelf != nil);
  58.                         }
  59.  
  60.     Boolean                CanSaveStatus() {
  61.                             return mCanSaveStatus;
  62.                         }
  63.     void                SetCanSaveStatus(Boolean inCanSave) {
  64.                             mCanSaveStatus = inCanSave;
  65.                         }
  66.     
  67.                         enum { 
  68.                             cWindowDesktopMargin = 4
  69.                         ,    cMinSavedStatusSize = sizeof(Int16) + sizeof(Rect)
  70.                         };
  71.  
  72.     static void            GetPaneGlobalBounds(LPane *inPane, Rect *outBounds);
  73.     static void            MoveWindowToAlertPosition(LWindow *inWindow);
  74.     static void            MoveWindowTo(LWindow *inWindow, Point inGlobalTopLeft);
  75.     static void            VerifyWindowBounds(LWindow *inWindow, Rect *ioGlobalBounds);
  76.     static LWindow        *CreateWindow(ResIDT inWindowID, LCommander *inSuperCommander);
  77.     
  78. protected:
  79.  
  80.     void                FinishCreateWindow(); // from disk
  81.     void                FinishCreateWindow(CSaveWindowStatus* templateStatus);
  82.     void                AttemptCloseWindow();
  83.     void                SaveStatusInfo();
  84.     
  85.                         // It is only valid to call HasSavedStatus() after
  86.                         // the window has been properly created (i.e. after
  87.                         // calling FinishCreateWindow() ).
  88.                         
  89.     Boolean                HasSavedStatus()
  90.                         {
  91.                             return mHasSavedStatus;
  92.                         }
  93.  
  94.     virtual ResIDT        GetStatusResID() const = 0; // client must provide!
  95.     virtual UInt16        GetValidStatusVersion() const = 0; // client must provide!
  96.     virtual void        ReadWindowStatus(LStream *inStatusData);
  97.     virtual void        WriteWindowStatus(LStream *outStatusData);
  98.     
  99.     LWindow                *mWindowSelf;
  100.     Boolean                mCanSaveStatus;
  101.     
  102. private:
  103.     Boolean                mHasSavedStatus;
  104. };
  105. #endif // __H_CSaveWindowStatus
  106.  
  107.