home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CSimpleDividedView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.9 KB  |  102 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.  
  22. enum
  23. {
  24.     kHorizontalResizeCursor    =    1120,
  25.     kVerticalResizeCursor    =    1136
  26. };
  27.  
  28.  
  29. /*****************************************************************************
  30.     class CSimpleDividedView
  31.     Simplest divided view.
  32.  
  33.  ### Standard usage:
  34.   In Constructor, create the CSimpleDividedView from a template,
  35.   set the IDs and min size of subviews
  36.   
  37.   It should be in the same level of hierarchy as the views it manages.
  38.   It does not do any drawing
  39.   
  40.   It broadcasts msg_SubviewChangedSize after a successful drag. Hook it up
  41.   to your window manually (outside the RidL resource), because it is not a
  42.   LControl subclass. Do this only if you need to do something in response to
  43.   resize. For example, recalc the GrayBevelView.
  44.   
  45.   timm has a more sophisticated class, divview.cp, which takes car of resizing
  46.  *****************************************************************************/
  47.  
  48. #include <LPane.h>
  49. #include <LBroadcaster.h>
  50.  
  51. const MessageT msg_SubviewChangedSize = 32400;    // ioParam is CSimpleDividedView
  52.  
  53. class CSimpleDividedView : public LPane,
  54.                             public LBroadcaster
  55. {
  56.     public:
  57.     
  58.     // constructors
  59.  
  60.         enum { class_ID = 'SDIV' };
  61.         
  62.                             CSimpleDividedView(LStream *inStream);
  63.  
  64.         virtual                ~CSimpleDividedView();
  65.     
  66.         virtual void        FinishCreateSelf();
  67.         
  68.     // access
  69.         
  70.                 void        SetMinSize(Int16 topLeft, Int16 botRight)
  71.                 {
  72.                     fTopLeftMinSize = topLeft;
  73.                     fBottomRightMinSize = botRight;
  74.                     RepositionView();
  75.                 }
  76.  
  77.     // event handling
  78.  
  79.         virtual void        AdaptToSuperFrameSize(Int32 inSurrWidthDelta,
  80.                                         Int32 inSurrHeightDelta,
  81.                                         Boolean inRefresh);
  82.         virtual void        ClickSelf(const SMouseDownEvent    &inMouseDown);
  83.  
  84.         virtual void        AdjustCursorSelf(Point inPortPt, const EventRecord&    inMacEvent );
  85.  
  86.  
  87. #ifdef DEBUG
  88.         virtual void        DrawSelf();
  89. #endif
  90.     private:
  91.     
  92.         void                ReadjustConstraints();
  93.         void                RepositionView();
  94.         Boolean                GetViewRects(Rect& r1, Rect& r2);
  95.  
  96.         PaneIDT                fTopLeftViewID;
  97.         PaneIDT                fBottomRightViewID;
  98.         Int16                fTopLeftMinSize;
  99.         Int16                fBottomRightMinSize;
  100.         Int16                fIsVertical;    // Are views stacked vertically?. -1 means uninitialized, true and false
  101. };
  102.