1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 :
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Mozilla Communicator client code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 1998
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Eric D Vaughan (original author)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsGridLayout2_h___
41 : #define nsGridLayout2_h___
42 :
43 : #include "nsStackLayout.h"
44 : #include "nsIGridPart.h"
45 : #include "nsCOMPtr.h"
46 : #include "nsIFrame.h"
47 : #include "nsGrid.h"
48 :
49 : class nsGridRowGroupLayout;
50 : class nsGridRowLayout;
51 : class nsGridRow;
52 : class nsBoxLayoutState;
53 : class nsGridCell;
54 :
55 : /**
56 : * The nsBoxLayout implementation for a grid.
57 : */
58 : class nsGridLayout2 : public nsStackLayout,
59 : public nsIGridPart
60 0 : {
61 : public:
62 :
63 : friend nsresult NS_NewGridLayout2(nsIPresShell* aPresShell, nsBoxLayout** aNewLayout);
64 :
65 : NS_DECL_ISUPPORTS_INHERITED
66 :
67 : NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
68 : virtual void IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
69 :
70 0 : virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return nsnull; }
71 0 : virtual nsGridLayout2* CastToGridLayout() { return this; }
72 : virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull);
73 0 : virtual nsIGridPart* GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox) {
74 0 : NS_NOTREACHED("Should not be called"); return nsnull;
75 : }
76 : virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
77 : virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
78 : virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
79 0 : virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount) { aRowCount++; }
80 0 : virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState) { }
81 : virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
82 : virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal);
83 0 : virtual Type GetType() { return eGrid; }
84 : virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
85 : nsIBox* aPrevBox,
86 : const nsFrameList::Slice& aNewChildren);
87 : virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
88 : const nsFrameList::Slice& aNewChildren);
89 : virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
90 : nsIBox* aChildList);
91 : virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState,
92 : nsIBox* aChildList);
93 :
94 0 : virtual nsIGridPart* AsGridPart() { return this; }
95 :
96 : static void AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize);
97 :
98 : protected:
99 :
100 : nsGridLayout2(nsIPresShell* aShell);
101 : nsGrid mGrid;
102 :
103 : private:
104 : void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
105 :
106 :
107 : }; // class nsGridLayout2
108 :
109 :
110 : #endif
111 :
|