Bug 574454 - Cleanup nsNativeThemeWin's GetMinimumWidgetSize a bit. r=roc.
[mozilla-central.git] / layout / generic / nsFrameSetFrame.h
blob9903bb80c0d234b152c14db7ec0033b80d116aca
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 NO_COLOR 0xFFFFFFFA
64 struct nsBorderColor
66 nscolor mLeft;
67 nscolor mRight;
68 nscolor mTop;
69 nscolor mBottom;
71 nsBorderColor() { Set(NO_COLOR); }
72 ~nsBorderColor() {}
73 void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; }
76 enum nsFrameborder {
77 eFrameborder_Yes = 0,
78 eFrameborder_No,
79 eFrameborder_Notset
82 struct nsFramesetDrag {
83 nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize
84 PRInt32 mIndex; // index of left col or top row of effected area
85 PRInt32 mChange; // pos for left to right or top to bottom, neg otherwise
86 PRPackedBool mVertical; // vertical if true, otherwise horizontal
87 PRPackedBool mActive;
89 nsFramesetDrag();
90 void Reset(PRBool aVertical,
91 PRInt32 aIndex,
92 PRInt32 aChange,
93 nsHTMLFramesetFrame* aSource);
94 void UnSet();
97 /*******************************************************************************
98 * nsHTMLFramesetFrame
99 ******************************************************************************/
100 class nsHTMLFramesetFrame : public nsHTMLContainerFrame
102 public:
103 NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame)
104 NS_DECL_QUERYFRAME
105 NS_DECL_FRAMEARENA_HELPERS
107 nsHTMLFramesetFrame(nsStyleContext* aContext);
109 virtual ~nsHTMLFramesetFrame();
111 NS_IMETHOD Init(nsIContent* aContent,
112 nsIFrame* aParent,
113 nsIFrame* aPrevInFlow);
115 NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
116 nsFrameList& aChildList);
118 static PRBool gDragInProgress;
120 void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
122 void GetSizeOfChildAt(PRInt32 aIndexInParent,
123 nsSize& aSize,
124 nsIntPoint& aCellIndex);
126 static nsHTMLFramesetFrame* GetFramesetParent(nsIFrame* aChild);
128 NS_IMETHOD HandleEvent(nsPresContext* aPresContext,
129 nsGUIEvent* aEvent,
130 nsEventStatus* aEventStatus);
132 NS_IMETHOD GetCursor(const nsPoint& aPoint,
133 nsIFrame::Cursor& aCursor);
135 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
136 const nsRect& aDirtyRect,
137 const nsDisplayListSet& aLists);
139 NS_IMETHOD Reflow(nsPresContext* aPresContext,
140 nsHTMLReflowMetrics& aDesiredSize,
141 const nsHTMLReflowState& aReflowState,
142 nsReflowStatus& aStatus);
144 virtual nsIAtom* GetType() const;
145 #ifdef DEBUG
146 NS_IMETHOD GetFrameName(nsAString& aResult) const;
147 #endif
149 virtual PRBool IsLeaf() const;
151 void StartMouseDrag(nsPresContext* aPresContext,
152 nsHTMLFramesetBorderFrame* aBorder,
153 nsGUIEvent* aEvent);
155 void MouseDrag(nsPresContext* aPresContext,
156 nsGUIEvent* aEvent);
158 void EndMouseDrag(nsPresContext* aPresContext);
160 nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
162 void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; }
164 nsFramesetDrag& GetDrag() { return mDrag; }
166 void RecalculateBorderResize();
168 protected:
169 void Scale(nscoord aDesired,
170 PRInt32 aNumIndicies,
171 PRInt32* aIndicies,
172 PRInt32 aNumItems,
173 PRInt32* aItems);
175 void CalculateRowCol(nsPresContext* aPresContext,
176 nscoord aSize,
177 PRInt32 aNumSpecs,
178 const nsFramesetSpec* aSpecs,
179 nscoord* aValues);
181 void GenerateRowCol(nsPresContext* aPresContext,
182 nscoord aSize,
183 PRInt32 aNumSpecs,
184 const nsFramesetSpec* aSpecs,
185 nscoord* aValues,
186 nsString& aNewAttr);
188 virtual void GetDesiredSize(nsPresContext* aPresContext,
189 const nsHTMLReflowState& aReflowState,
190 nsHTMLReflowMetrics& aDesiredSize);
192 PRInt32 GetBorderWidth(nsPresContext* aPresContext,
193 PRBool aTakeForcingIntoAccount);
195 PRInt32 GetParentBorderWidth() { return mParentBorderWidth; }
197 void SetParentBorderWidth(PRInt32 aWidth) { mParentBorderWidth = aWidth; }
199 nscolor GetParentBorderColor() { return mParentBorderColor; }
201 void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; }
203 nsFrameborder GetFrameBorder();
205 nsFrameborder GetFrameBorder(nsIContent* aContent);
207 nscolor GetBorderColor();
209 nscolor GetBorderColor(nsIContent* aFrameContent);
211 PRBool GetNoResize(nsIFrame* aChildFrame);
213 virtual PRIntn GetSkipSides() const;
215 void ReflowPlaceChild(nsIFrame* aChild,
216 nsPresContext* aPresContext,
217 const nsHTMLReflowState& aReflowState,
218 nsPoint& aOffset,
219 nsSize& aSize,
220 nsIntPoint* aCellIndex = 0);
222 PRBool CanResize(PRBool aVertical,
223 PRBool aLeft);
225 PRBool CanChildResize(PRBool aVertical,
226 PRBool aLeft,
227 PRInt32 aChildX,
228 PRBool aFrameset);
230 void SetBorderResize(PRInt32* aChildTypes,
231 nsHTMLFramesetBorderFrame* aBorderFrame);
233 PRBool ChildIsFrameset(nsIFrame* aChild);
235 static int FrameResizePrefCallback(const char* aPref, void* aClosure);
237 nsFramesetDrag mDrag;
238 nsBorderColor mEdgeColors;
239 nsHTMLFramesetBorderFrame* mDragger;
240 nsHTMLFramesetFrame* mTopLevelFrameset;
241 nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders
242 nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders
243 PRInt32* mChildTypes; // frameset/frame distinction of children
244 nsFrameborder* mChildFrameborder; // the frameborder attr of children
245 nsBorderColor* mChildBorderColors;
246 nscoord* mRowSizes; // currently computed row sizes
247 nscoord* mColSizes; // currently computed col sizes
248 nsIntPoint mFirstDragPoint;
249 PRInt32 mNumRows;
250 PRInt32 mNumCols;
251 PRInt32 mNonBorderChildCount;
252 PRInt32 mNonBlankChildCount;
253 PRInt32 mEdgeVisibility;
254 nsFrameborder mParentFrameborder;
255 nscolor mParentBorderColor;
256 PRInt32 mParentBorderWidth;
257 PRInt32 mPrevNeighborOrigSize; // used during resize
258 PRInt32 mNextNeighborOrigSize;
259 PRInt32 mMinDrag;
260 PRInt32 mChildCount;
261 PRBool mForceFrameResizability;
264 #endif