Back to index

lightning-sunbird  0.9+nobinonly
nsFrameSetFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsHTMLFrameset_h___
00038 #define nsHTMLFrameset_h___
00039 
00040 #include "nsHTMLAtoms.h"
00041 #include "nsHTMLContainerFrame.h"
00042 #include "nsColor.h"
00043 #include "nsIObserver.h"
00044 #include "nsWeakPtr.h"
00045 #include "nsIFrameSetElement.h"
00046 
00047 class  nsIContent;
00048 class  nsIFrame;
00049 class  nsPresContext;
00050 class  nsIRenderingContext;
00051 struct nsRect;
00052 struct nsHTMLReflowState;
00053 struct nsSize;
00054 class  nsIAtom;
00055 class  nsHTMLFramesetBorderFrame;
00056 class  nsGUIEvent;
00057 class  nsHTMLFramesetFrame;
00058 
00059 #define NS_IFRAMESETFRAME_IID \
00060 { 0xf47deac0, 0x4200, 0x11d2, \
00061   { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
00062 
00063 #define NO_COLOR 0xFFFFFFFA
00064 
00065 struct nsBorderColor 
00066 {
00067   nscolor mLeft;
00068   nscolor mRight;
00069   nscolor mTop;
00070   nscolor mBottom;
00071 
00072   nsBorderColor() { Set(NO_COLOR); }
00073   ~nsBorderColor() {}
00074   void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; }
00075 };
00076 
00077 enum nsFrameborder {
00078   eFrameborder_Yes = 0,
00079   eFrameborder_No,
00080   eFrameborder_Notset
00081 };
00082 
00083 struct nsFramesetDrag {
00084   PRBool               mVertical;  // vertical if true, otherwise horizontal
00085   PRInt32              mIndex;     // index of left col or top row of effected area
00086   PRInt32              mChange;    // pos for left to right or top to bottom, neg otherwise
00087   nsHTMLFramesetFrame* mSource;    // frameset whose border was dragged to cause the resize
00088   PRBool               mActive;
00089 
00090   nsFramesetDrag();
00091   nsFramesetDrag(PRBool               aVertical, 
00092                  PRInt32              aIndex, 
00093                  PRInt32              aChange, 
00094                  nsHTMLFramesetFrame* aSource); 
00095   void Reset(PRBool               aVertical, 
00096              PRInt32              aIndex, 
00097              PRInt32              aChange, 
00098              nsHTMLFramesetFrame* aSource); 
00099   void UnSet();
00100 };
00101 
00102 /*******************************************************************************
00103  * nsHTMLFramesetFrame
00104  ******************************************************************************/
00105 class nsHTMLFramesetFrame : public nsHTMLContainerFrame
00106 {
00107 public:
00108   // Woohoo, concrete class with an IID!
00109   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID)
00110 
00111   nsHTMLFramesetFrame();
00112 
00113   virtual ~nsHTMLFramesetFrame();
00114 
00115   NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
00116 
00117   NS_IMETHOD Init(nsPresContext*  aPresContext,
00118                   nsIContent*      aContent,
00119                   nsIFrame*        aParent,
00120                   nsStyleContext*  aContext,
00121                   nsIFrame*        aPrevInFlow);
00122 
00123   static PRBool  gDragInProgress;
00124 
00125   void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
00126 
00127   void GetSizeOfChildAt(PRInt32  aIndexInParent, 
00128                         nsSize&  aSize, 
00129                         nsPoint& aCellIndex);
00130 
00131   static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
00132 
00133   NS_IMETHOD HandleEvent(nsPresContext* aPresContext, 
00134                          nsGUIEvent*     aEvent,
00135                          nsEventStatus*  aEventStatus);
00136 
00137   NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, 
00138                               nsFramePaintLayer aWhichLayer,
00139                               nsIFrame**     aFrame);
00140 
00141   NS_IMETHOD GetCursor(const nsPoint&    aPoint,
00142                        nsIFrame::Cursor& aCursor);
00143 
00144   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00145                    nsIRenderingContext& aRenderingContext,
00146                    const nsRect&        aDirtyRect,
00147                    nsFramePaintLayer    aWhichLayer,
00148                    PRUint32             aFlags = 0);
00149 
00150   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
00151                     nsHTMLReflowMetrics&     aDesiredSize,
00152                     const nsHTMLReflowState& aReflowState,
00153                     nsReflowStatus&          aStatus);
00154 
00155   virtual nsIAtom* GetType() const;
00156 
00157   virtual PRBool IsLeaf() const;
00158   
00159   NS_IMETHOD  VerifyTree() const;
00160 
00161   void StartMouseDrag(nsPresContext*            aPresContext, 
00162                       nsHTMLFramesetBorderFrame* aBorder, 
00163                       nsGUIEvent*                aEvent);
00164 
00165   void MouseDrag(nsPresContext* aPresContext, 
00166                  nsGUIEvent*     aEvent);
00167 
00168   void EndMouseDrag(nsPresContext* aPresContext);
00169 
00170   nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
00171 
00172   void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; }
00173 
00174   nsFramesetDrag& GetDrag() { return mDrag; }
00175 
00176   void RecalculateBorderResize();
00177 
00178 protected:
00179   void Scale(nscoord  aDesired, 
00180              PRInt32  aNumIndicies, 
00181              PRInt32* aIndicies, 
00182              PRInt32  aNumItems,
00183              PRInt32* aItems);
00184 
00185   void CalculateRowCol(nsPresContext*       aPresContext, 
00186                        nscoord               aSize, 
00187                        PRInt32               aNumSpecs, 
00188                        const nsFramesetSpec* aSpecs, 
00189                        nscoord*              aValues);
00190 
00191   void GenerateRowCol(nsPresContext*       aPresContext,
00192                       nscoord               aSize,
00193                       PRInt32               aNumSpecs,
00194                       const nsFramesetSpec* aSpecs,
00195                       nscoord*              aValues,
00196                       nsString&             aNewAttr);
00197 
00198   virtual void GetDesiredSize(nsPresContext*          aPresContext,
00199                               const nsHTMLReflowState& aReflowState,
00200                               nsHTMLReflowMetrics&     aDesiredSize);
00201 
00202   PRInt32 GetBorderWidth(nsPresContext* aPresContext,
00203                          PRBool aTakeForcingIntoAccount);
00204 
00205   PRInt32 GetParentBorderWidth() { return mParentBorderWidth; }
00206 
00207   void SetParentBorderWidth(PRInt32 aWidth) { mParentBorderWidth = aWidth; }
00208 
00209   nscolor GetParentBorderColor() { return mParentBorderColor; }
00210 
00211   void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; }
00212 
00213   nsFrameborder GetFrameBorder();
00214 
00215   nsFrameborder GetFrameBorder(nsIContent* aContent);
00216 
00217   nscolor GetBorderColor();
00218 
00219   nscolor GetBorderColor(nsIContent* aFrameContent);
00220 
00221   PRBool GetNoResize(nsIFrame* aChildFrame); 
00222   
00223   virtual PRIntn GetSkipSides() const;
00224 
00225   void ReflowPlaceChild(nsIFrame*                aChild,
00226                         nsPresContext*          aPresContext,
00227                         const nsHTMLReflowState& aReflowState,
00228                         nsPoint&                 aOffset,
00229                         nsSize&                  aSize,
00230                         nsPoint*                 aCellIndex = 0);
00231   
00232   PRBool CanResize(PRBool aVertical, 
00233                    PRBool aLeft); 
00234 
00235   PRBool CanChildResize(PRBool  aVertical, 
00236                         PRBool  aLeft, 
00237                         PRInt32 aChildX,
00238                         PRBool  aFrameset);
00239   
00240   void SetBorderResize(PRInt32*                   aChildTypes, 
00241                        nsHTMLFramesetBorderFrame* aBorderFrame);
00242 
00243   PRBool ChildIsFrameset(nsIFrame* aChild); 
00244 
00245   static int FrameResizePrefCallback(const char* aPref, void* aClosure);
00246 
00247   PRInt32          mNumRows;
00248   nscoord*         mRowSizes;  // currently computed row sizes 
00249   PRInt32          mNumCols;
00250   nscoord*         mColSizes;  // currently computed col sizes 
00251   PRInt32          mNonBorderChildCount; 
00252   PRInt32          mNonBlankChildCount; 
00253   PRInt32          mEdgeVisibility;
00254   nsBorderColor    mEdgeColors;
00255   nsFrameborder    mParentFrameborder;
00256   nscolor          mParentBorderColor;
00257   PRInt32          mParentBorderWidth;
00258 
00259   nsHTMLFramesetBorderFrame* mDragger;
00260   nsFramesetDrag   mDrag;
00261   nsPoint          mFirstDragPoint;
00262   PRInt32          mPrevNeighborOrigSize; // used during resize
00263   PRInt32          mNextNeighborOrigSize;
00264   PRInt32          mMinDrag;
00265   PRInt32          mChildCount;
00266   nsHTMLFramesetFrame* mTopLevelFrameset;
00267   nsHTMLFramesetBorderFrame** mVerBorders;  // vertical borders
00268   nsHTMLFramesetBorderFrame** mHorBorders;  // horizontal borders
00269 
00270   PRInt32*         mChildTypes; // frameset/frame distinction of children  
00271   nsFrameborder*   mChildFrameborder; // the frameborder attr of children 
00272   nsBorderColor*   mChildBorderColors;
00273   
00274   PRBool mForceFrameResizability;
00275 };
00276 
00277 
00278 #endif