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
4 : *
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/
9 : *
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.
14 : *
15 : * The Original Code is Mozilla Communicator client code.
16 : *
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.
21 : *
22 : * Contributor(s):
23 : *
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.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef nsIGridPart_h___
39 : #define nsIGridPart_h___
40 :
41 : #include "nsISupports.h"
42 : #include "nsFrame.h"
43 :
44 : class nsGridRowGroupLayout;
45 : class nsGrid;
46 : class nsGridRowLayout;
47 : class nsGridRow;
48 : class nsGridLayout2;
49 :
50 : // 07373ed7-e947-4a5e-b36c-69f7c195677b
51 : #define NS_IGRIDPART_IID \
52 : { 0x07373ed7, 0xe947, 0x4a5e, \
53 : { 0xb3, 0x6c, 0x69, 0xf7, 0xc1, 0x95, 0x67, 0x7b } }
54 :
55 : /**
56 : * An additional interface implemented by nsBoxLayout implementations
57 : * for parts of a grid (excluding cells, which are not special).
58 : */
59 0 : class nsIGridPart : public nsISupports {
60 :
61 : public:
62 :
63 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGRIDPART_IID)
64 :
65 : virtual nsGridRowGroupLayout* CastToRowGroupLayout()=0;
66 : virtual nsGridLayout2* CastToGridLayout()=0;
67 :
68 : /**
69 : * @param aBox [IN] The other half of the |this| parameter, i.e., the box
70 : * whose layout manager is |this|.
71 : * @param aIndex [INOUT] For callers not setting aRequestor, the value
72 : * pointed to by aIndex is incremented by the index
73 : * of the row (aBox) within its row group; if aBox
74 : * is not a row/column, it is untouched.
75 : * The implementation does this by doing the aIndex
76 : * incrementing in the call to the parent row group
77 : * when aRequestor is non-null.
78 : * @param aRequestor [IN] Non-null if and only if this is a recursive
79 : * call from the GetGrid method on a child grid part,
80 : * in which case it is a pointer to that grid part.
81 : * (This may only be non-null for row groups and
82 : * grids.)
83 : * @return The grid of which aBox (a row, row group, or grid) is a part.
84 : */
85 : virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull)=0;
86 :
87 : /**
88 : * @param aBox [IN] The other half of the |this| parameter, i.e., the box
89 : * whose layout manager is |this|.
90 : * @param aParentBox [OUT] The box representing the next level up in
91 : * the grid (i.e., row group for a row, grid for a
92 : * row group).
93 : * @returns The layout manager for aParentBox.
94 : */
95 : virtual nsIGridPart* GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox) = 0;
96 :
97 : /**
98 : * @param aBox [IN] The other half of the |this| parameter, i.e., the box
99 : * whose layout manager is |this|.
100 : * @param aRowCount [INOUT] Row count
101 : * @param aComputedColumnCount [INOUT] Column count
102 : */
103 : virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)=0;
104 : virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)=0;
105 : virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows)=0;
106 : virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal)=0;
107 0 : virtual PRInt32 GetRowCount() { return 1; }
108 :
109 : /**
110 : * Return the level of the grid hierarchy this grid part represents.
111 : */
112 : enum Type { eGrid, eRowGroup, eRowLeaf };
113 : virtual Type GetType()=0;
114 :
115 : /**
116 : * Return whether this grid part is an appropriate parent for the argument.
117 : */
118 0 : bool CanContain(nsIGridPart* aPossibleChild) {
119 0 : Type thisType = GetType(), childType = aPossibleChild->GetType();
120 0 : return thisType + 1 == childType || (thisType == eRowGroup && childType == eRowGroup);
121 : }
122 :
123 : };
124 :
125 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIGridPart, NS_IGRIDPART_IID)
126 :
127 : #endif
128 :
|