michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsIGridPart_h___ michael@0: #define nsIGridPart_h___ michael@0: michael@0: #include "nsISupports.h" michael@0: michael@0: class nsGridRowGroupLayout; michael@0: class nsGrid; michael@0: class nsGridRowLayout; michael@0: class nsGridRow; michael@0: class nsGridLayout2; michael@0: michael@0: // 07373ed7-e947-4a5e-b36c-69f7c195677b michael@0: #define NS_IGRIDPART_IID \ michael@0: { 0x07373ed7, 0xe947, 0x4a5e, \ michael@0: { 0xb3, 0x6c, 0x69, 0xf7, 0xc1, 0x95, 0x67, 0x7b } } michael@0: michael@0: /** michael@0: * An additional interface implemented by nsBoxLayout implementations michael@0: * for parts of a grid (excluding cells, which are not special). michael@0: */ michael@0: class nsIGridPart : public nsISupports { michael@0: michael@0: public: michael@0: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGRIDPART_IID) michael@0: michael@0: virtual nsGridRowGroupLayout* CastToRowGroupLayout()=0; michael@0: virtual nsGridLayout2* CastToGridLayout()=0; michael@0: michael@0: /** michael@0: * @param aBox [IN] The other half of the |this| parameter, i.e., the box michael@0: * whose layout manager is |this|. michael@0: * @param aIndex [INOUT] For callers not setting aRequestor, the value michael@0: * pointed to by aIndex is incremented by the index michael@0: * of the row (aBox) within its row group; if aBox michael@0: * is not a row/column, it is untouched. michael@0: * The implementation does this by doing the aIndex michael@0: * incrementing in the call to the parent row group michael@0: * when aRequestor is non-null. michael@0: * @param aRequestor [IN] Non-null if and only if this is a recursive michael@0: * call from the GetGrid method on a child grid part, michael@0: * in which case it is a pointer to that grid part. michael@0: * (This may only be non-null for row groups and michael@0: * grids.) michael@0: * @return The grid of which aBox (a row, row group, or grid) is a part. michael@0: */ michael@0: virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex, nsGridRowLayout* aRequestor=nullptr)=0; michael@0: michael@0: /** michael@0: * @param aBox [IN] The other half of the |this| parameter, i.e., the box michael@0: * whose layout manager is |this|. michael@0: * @param aParentBox [OUT] The box representing the next level up in michael@0: * the grid (i.e., row group for a row, grid for a michael@0: * row group). michael@0: * @returns The layout manager for aParentBox. michael@0: */ michael@0: virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) = 0; michael@0: michael@0: /** michael@0: * @param aBox [IN] The other half of the |this| parameter, i.e., the box michael@0: * whose layout manager is |this|. michael@0: * @param aRowCount [INOUT] Row count michael@0: * @param aComputedColumnCount [INOUT] Column count michael@0: */ michael@0: virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)=0; michael@0: virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)=0; michael@0: virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows)=0; michael@0: virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)=0; michael@0: virtual int32_t GetRowCount() { return 1; } michael@0: michael@0: /** michael@0: * Return the level of the grid hierarchy this grid part represents. michael@0: */ michael@0: enum Type { eGrid, eRowGroup, eRowLeaf }; michael@0: virtual Type GetType()=0; michael@0: michael@0: /** michael@0: * Return whether this grid part is an appropriate parent for the argument. michael@0: */ michael@0: bool CanContain(nsIGridPart* aPossibleChild) { michael@0: Type thisType = GetType(), childType = aPossibleChild->GetType(); michael@0: return thisType + 1 == childType || (thisType == eRowGroup && childType == eRowGroup); michael@0: } michael@0: michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(nsIGridPart, NS_IGRIDPART_IID) michael@0: michael@0: #endif michael@0: