home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / divview.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.1 KB  |  121 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 <LView.h>
  22. #include <LStream.h>
  23. #include <LBroadcaster.h>
  24.  
  25.  
  26. const Int32 kOutsideSlop = 0x80008000;
  27. const MessageT msg_DividerChangedPosition = 'divc';
  28.  
  29. class LDividedView :
  30.     public LView,
  31.     public LBroadcaster,
  32.     public LListener
  33. {
  34. public:
  35.     enum            {class_ID = 'DIVV'};
  36.     
  37.                     LDividedView( LStream* inStream );
  38.     virtual            ~LDividedView();
  39.     
  40.     virtual void    FinishCreateSelf();
  41.     
  42.     void            SetSlidesHorizontally( Boolean isHoriz );
  43.     Boolean            GetSlidesHorizontally() const { return mSlidesHorizontally; };
  44.     UInt16            GetDividerSize() const { return mDivSize; }
  45.     void            ToggleFirstPane();
  46.     
  47.     virtual void    ListenToMessage(MessageT inMessage, void* ioParam);
  48.     
  49.     virtual    void    ClickSelf( const SMouseDownEvent& inMouseDown );
  50.     
  51.     virtual    void    AdjustCursorSelf( Point inPortPt, const EventRecord& inMacEvent );
  52.     virtual void    ChangeDividerPosition( Int16 delta );
  53.     virtual void    ResizeFrameBy(
  54.                         Int16        inWidthDelta,
  55.                         Int16        inHeightDelta,
  56.                         Boolean        inRefresh);
  57.  
  58.     virtual void    SavePlace( LStream* inStream );
  59.     virtual void    RestorePlace( LStream* inStream );
  60.     
  61.     void            SetCollapseByDragging(Boolean inFirst, Boolean inSecond)
  62.                         { mCollapseFirstByDragging = inFirst; mCollapseSecondByDragging = inSecond; }
  63.     void            GetCollapseByDragging(Boolean& outFirst, Boolean& outSecond)
  64.                         { outFirst = mCollapseFirstByDragging;  outSecond = mCollapseSecondByDragging; }
  65.  
  66.     Boolean            IsSecondPaneCollapsed() const
  67.                         { return GetDividerPosition() >= (mSlidesHorizontally ? mFrameSize.width : mFrameSize.height) - mDivSize; }
  68.     Boolean            IsFirstPaneCollapsed() const
  69.                         { return GetDividerPosition() <= 0; }
  70.     static void        PlayClosingSound() { PlaySound(128); }
  71.     static void        PlayOpeningSound() { PlaySound(129); }
  72.     static void        PlaySound(ResIDT id);
  73. protected:
  74.  
  75.     LPane*            GetZapButton();
  76.     void            PositionZapButton();
  77.     Int32            GetDividerPosition() const;
  78.     
  79.                     // Ñ╩the area representing the divider rect (only when dragging)
  80.     void            CalcDividerRect( Rect& outRect );
  81.     
  82.     void            SyncFrameBindings();
  83.     
  84.                     // Ñ lays out the subpanes (after reanimating, changing horiz./vert.)
  85.     void            PositionViews( Boolean willBeHoriz );
  86.  
  87.                     // Ñ╩the following two routines are called just prior to
  88.                     //        dragging
  89.     void            CalcLimitRect( Rect& lRect );
  90.     void            CalcSlopRect( Rect& sRect );
  91.  
  92.                     // Ñ╩this routine is called to invalidate the rectangle between
  93.                     //        the two panes (which is larger than divider rect) when
  94.                     //        the divider is moved
  95.     void            CalcRectBetweenPanes( Rect& rect );
  96.     
  97.                     // Ñ allows the user to drag the closed pane to open it.
  98.     bool            CanExpandByDragging ( ) const { return false; } ;
  99.  
  100. // Data
  101. protected:
  102.  
  103.     PaneIDT            mFirstSubview;        // pane ID of the top or left pane
  104.     PaneIDT            mSecondSubview;        // pane ID of the bottom or right pane
  105.  
  106.     UInt16            mDivSize;            // Width of the divider
  107.     Int16            mMinFirstSize;        // mimimum size of top (or left) pane
  108.     Int16            mMinSecondSize;        // minimum size of bottom (or right) pane
  109.     
  110.     Boolean            mCollapseFirstByDragging;
  111.     Boolean            mCollapseSecondByDragging;
  112.     Int16            mDividerPosBeforeCollapsing;
  113.  
  114.     Int16            mFirstIndent;
  115.     Int16            mSecondIndent;
  116.     
  117.     Boolean            mSlidesHorizontally;        // top/bottom or left/right configuration?
  118.  
  119.     LPane*            fFirstView;            // top or left view
  120.     LPane*            fSecondView;        // bottom or right view    
  121. };