home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / CExpandoDivider.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.8 KB  |  137 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. #pragma once
  20.  
  21. #include "divview.h"
  22.  
  23. //-----------------------------------
  24. class CExpansionData
  25. // persistent data about both states of a CExpandable.
  26. //-----------------------------------
  27. {
  28. public:
  29.     virtual void    ReadStatus(LStream* inStream) = 0;
  30.     virtual void    WriteStatus(LStream* inStream) = 0;
  31. }; //  class CExpansionData
  32.  
  33. enum { closed_state = false, open_state = true };
  34. typedef Boolean ExpandStateT;
  35.  
  36. //======================================
  37. class CExpandable
  38. //======================================
  39. {
  40. public:
  41.     virtual void    ReadStatus(LStream* inStream);
  42.     virtual void    WriteStatus(LStream* inStream);
  43.     ExpandStateT    GetExpandState() const { return mExpandState; }
  44.     void            NoteExpandState(ExpandStateT inExpanded) { mExpandState = inExpanded; }
  45. protected:
  46.     virtual void    SetExpandState(ExpandStateT inExpanded) = 0;
  47. private:
  48.     virtual void    StoreDimensions(CExpansionData& outState) = 0;
  49.     virtual void    RecallDimensions(const CExpansionData& inState) = 0;    
  50. protected:
  51.                     CExpandable(CExpansionData* closedState, CExpansionData* openState);
  52.                         // clients that mix this class in should have two members that are
  53.                         // CExpansionData, and pass the references in here.
  54. protected:
  55.     void            StoreCurrentDimensions();
  56.     void            RecallCurrentDimensions();
  57.     void            RecallOtherDimensions();
  58. protected:
  59.     ExpandStateT    mExpandState;
  60.     CExpansionData*    mStates[2];
  61. }; // class CExpandable
  62.  
  63. //======================================
  64. class CExpandoListener : public LListener, public CExpandable
  65. //======================================
  66. {
  67. public:
  68.     enum            { msg_TwistieMessage = 'Twst' }; // Broadcast by twistie control
  69.                     CExpandoListener(
  70.                         CExpansionData* closedState, CExpansionData* openState)
  71.                         :    CExpandable(closedState, openState) {}
  72.     virtual void    ListenToMessage(MessageT inMessage, void *ioParam);
  73.         // Listen to the twistie
  74. }; // class CExpandoListener
  75.  
  76. //======================================
  77. class CDividerData : public CExpansionData
  78. //======================================
  79. {
  80. public:
  81.     CDividerData();
  82.         // default is set for the open state, because the closed state is in the PPOb.
  83. // Overrides
  84.     virtual void    ReadStatus(LStream* inStream);
  85.     virtual void    WriteStatus(LStream* inStream);
  86. // Data
  87.     SInt32            mDividerPosition;
  88. }; // class CDividerData
  89.  
  90. //======================================
  91. class CExpandoDivider : public LDividedView, public CExpandable
  92. // This class acts like a divider between two panes, one above the other.
  93. // In addition to the LDividedView behavior, it also has an "expando" twistie, that
  94. // hides/shows the bottom pane.
  95. //======================================
  96. {
  97. private:
  98.     typedef LDividedView Inherited;
  99. public:
  100.     enum            { class_ID = 'Expo' };
  101.                     CExpandoDivider(LStream* inStream);
  102.     virtual            ~CExpandoDivider();
  103.  
  104. // PowerPlant overrides
  105. protected:    
  106.     virtual void    FinishCreateSelf();
  107.     virtual    void    ClickSelf(const SMouseDownEvent& inMouseDown);
  108.     virtual    void    AdjustCursorSelf(Point inPortPt, const EventRecord& inMacEvent);
  109. public:
  110.     virtual void    ResizeFrameBy(
  111.                         Int16        inWidthDelta,
  112.                         Int16        inHeightDelta,
  113.                         Boolean        inRefresh);
  114. // CExpandable overrides
  115. public:
  116.     virtual void    SetExpandState(ExpandStateT inExpanded);
  117.     virtual void    StoreDimensions(CExpansionData& outState);
  118.     virtual void    RecallDimensions(const CExpansionData& inState);
  119. // Special interfaces
  120. public:
  121.     Int16            GetCorrectDistanceFromBottom() const { return mDistanceFromWindowBottom; }
  122.     Int16            GetCorrectDividerDistanceFromBottom() const
  123.                         { return mDividerDistanceFromWindowBottom; }
  124. // Down to business:
  125. protected:
  126.     virtual void    ChangeDividerPosition(Int16 delta); // also changes the twistie+caption
  127.     virtual void    ChangeTwistiePosition(Int16 delta); // only changes the twistie+caption
  128.     void            SetStickToBottom(LPane* inPane, Boolean inStick);
  129.     void            SetStickToBottom(Boolean inStick);
  130. // Data:
  131. protected:
  132.     Int16            mDistanceFromWindowBottom;
  133.     Int16            mDividerDistanceFromWindowBottom;
  134.     LPane            *mTwistie, *mCaption;
  135.     CDividerData    mClosedData, mOpenData;
  136. }; // class CExpandoDivider
  137.