Bug 54488 - "[Mac] Non-draggable widgets in background windows should look disabled...
[mozilla-central.git] / layout / generic / nsFrameSetFrame.h
blob4b7de877a43f9297bb6c1634143c0ef88278d95b
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 /* rendering object for HTML <frameset> elements */
40 #ifndef nsHTMLFrameset_h___
41 #define nsHTMLFrameset_h___
43 #include "nsGkAtoms.h"
44 #include "nsHTMLContainerFrame.h"
45 #include "nsColor.h"
46 #include "nsIObserver.h"
47 #include "nsWeakPtr.h"
48 #include "nsIFrameSetElement.h"
50 class nsIContent;
51 class nsIFrame;
52 class nsPresContext;
53 class nsIRenderingContext;
54 struct nsRect;
55 struct nsHTMLReflowState;
56 struct nsSize;
57 class nsIAtom;
58 class nsHTMLFramesetBorderFrame;
59 class nsGUIEvent;
60 class nsHTMLFramesetFrame;
62 #define NS_IFRAMESETFRAME_IID \
63 { 0xf47deac0, 0x4200, 0x11d2, \
64 { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } }
66 #define NO_COLOR 0xFFFFFFFA
68 struct nsBorderColor
70 nscolor mLeft;
71 nscolor mRight;
72 nscolor mTop;
73 nscolor mBottom;
75 nsBorderColor() { Set(NO_COLOR); }
76 ~nsBorderColor() {}
77 void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; }
80 enum nsFrameborder {
81 eFrameborder_Yes = 0,
82 eFrameborder_No,
83 eFrameborder_Notset
86 struct nsFramesetDrag {
87 PRBool mVertical; // vertical if true, otherwise horizontal
88 PRInt32 mIndex; // index of left col or top row of effected area
89 PRInt32 mChange; // pos for left to right or top to bottom, neg otherwise
90 nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize
91 PRBool mActive;
93 nsFramesetDrag();
94 nsFramesetDrag(PRBool aVertical,
95 PRInt32 aIndex,
96 PRInt32 aChange,
97 nsHTMLFramesetFrame* aSource);
98 void Reset(PRBool aVertical,
99 PRInt32 aIndex,
100 PRInt32 aChange,
101 nsHTMLFramesetFrame* aSource);
102 void UnSet();
105 /*******************************************************************************
106 * nsHTMLFramesetFrame
107 ******************************************************************************/
108 class nsHTMLFramesetFrame : public nsHTMLContainerFrame
110 public:
111 // Woohoo, concrete class with an IID!
112 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID)
114 nsHTMLFramesetFrame(nsStyleContext* aContext);
116 virtual ~nsHTMLFramesetFrame();
118 NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
120 NS_IMETHOD Init(nsIContent* aContent,
121 nsIFrame* aParent,
122 nsIFrame* aPrevInFlow);
124 static PRBool gDragInProgress;
126 void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
128 void GetSizeOfChildAt(PRInt32 aIndexInParent,
129 nsSize& aSize,
130 nsPoint& aCellIndex);
132 static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
134 NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
135 nsGUIEvent* aEvent,
136 nsEventStatus* aEventStatus);
138 NS_IMETHOD GetCursor(const nsPoint& aPoint,
139 nsIFrame::Cursor& aCursor);
141 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
142 const nsRect& aDirtyRect,
143 const nsDisplayListSet& aLists);
145 NS_IMETHOD Reflow(nsPresContext* aPresContext,
146 nsHTMLReflowMetrics& aDesiredSize,
147 const nsHTMLReflowState& aReflowState,
148 nsReflowStatus& aStatus);
150 virtual nsIAtom* GetType() const;
151 #ifdef DEBUG
152 NS_IMETHOD GetFrameName(nsAString& aResult) const;
153 #endif
155 virtual PRBool IsLeaf() const;
157 NS_IMETHOD VerifyTree() const;
159 void StartMouseDrag(nsPresContext* aPresContext,
160 nsHTMLFramesetBorderFrame* aBorder,
161 nsGUIEvent* aEvent);
163 void MouseDrag(nsPresContext* aPresContext,
164 nsGUIEvent* aEvent);
166 void EndMouseDrag(nsPresContext* aPresContext);
168 nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
170 void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; }
172 nsFramesetDrag& GetDrag() { return mDrag; }
174 void RecalculateBorderResize();
176 protected:
177 void Scale(nscoord aDesired,
178 PRInt32 aNumIndicies,
179 PRInt32* aIndicies,
180 PRInt32 aNumItems,
181 PRInt32* aItems);
183 void CalculateRowCol(nsPresContext* aPresContext,
184 nscoord aSize,
185 PRInt32 aNumSpecs,
186 const nsFramesetSpec* aSpecs,
187 nscoord* aValues);
189 void GenerateRowCol(nsPresContext* aPresContext,
190 nscoord aSize,
191 PRInt32 aNumSpecs,
192 const nsFramesetSpec* aSpecs,
193 nscoord* aValues,
194 nsString& aNewAttr);
196 virtual void GetDesiredSize(nsPresContext* aPresContext,
197 const nsHTMLReflowState& aReflowState,
198 nsHTMLReflowMetrics& aDesiredSize);
200 PRInt32 GetBorderWidth(nsPresContext* aPresContext,
201 PRBool aTakeForcingIntoAccount);
203 PRInt32 GetParentBorderWidth() { return mParentBorderWidth; }
205 void SetParentBorderWidth(PRInt32 aWidth) { mParentBorderWidth = aWidth; }
207 nscolor GetParentBorderColor() { return mParentBorderColor; }
209 void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; }
211 nsFrameborder GetFrameBorder();
213 nsFrameborder GetFrameBorder(nsIContent* aContent);
215 nscolor GetBorderColor();
217 nscolor GetBorderColor(nsIContent* aFrameContent);
219 PRBool GetNoResize(nsIFrame* aChildFrame);
221 virtual PRIntn GetSkipSides() const;
223 void ReflowPlaceChild(nsIFrame* aChild,
224 nsPresContext* aPresContext,
225 const nsHTMLReflowState& aReflowState,
226 nsPoint& aOffset,
227 nsSize& aSize,
228 nsPoint* aCellIndex = 0);
230 PRBool CanResize(PRBool aVertical,
231 PRBool aLeft);
233 PRBool CanChildResize(PRBool aVertical,
234 PRBool aLeft,
235 PRInt32 aChildX,
236 PRBool aFrameset);
238 void SetBorderResize(PRInt32* aChildTypes,
239 nsHTMLFramesetBorderFrame* aBorderFrame);
241 PRBool ChildIsFrameset(nsIFrame* aChild);
243 static int FrameResizePrefCallback(const char* aPref, void* aClosure);
245 PRInt32 mNumRows;
246 nscoord* mRowSizes; // currently computed row sizes
247 PRInt32 mNumCols;
248 nscoord* mColSizes; // currently computed col sizes
249 PRInt32 mNonBorderChildCount;
250 PRInt32 mNonBlankChildCount;
251 PRInt32 mEdgeVisibility;
252 nsBorderColor mEdgeColors;
253 nsFrameborder mParentFrameborder;
254 nscolor mParentBorderColor;
255 PRInt32 mParentBorderWidth;
257 nsHTMLFramesetBorderFrame* mDragger;
258 nsFramesetDrag mDrag;
259 nsPoint mFirstDragPoint;
260 PRInt32 mPrevNeighborOrigSize; // used during resize
261 PRInt32 mNextNeighborOrigSize;
262 PRInt32 mMinDrag;
263 PRInt32 mChildCount;
264 nsHTMLFramesetFrame* mTopLevelFrameset;
265 nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders
266 nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders
268 PRInt32* mChildTypes; // frameset/frame distinction of children
269 nsFrameborder* mChildFrameborder; // the frameborder attr of children
270 nsBorderColor* mChildBorderColors;
272 PRBool mForceFrameResizability;
275 NS_DEFINE_STATIC_IID_ACCESSOR(nsHTMLFramesetFrame, NS_IFRAMESETFRAME_IID)
277 #endif