layout/xul/grid/nsIGridPart.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/xul/grid/nsIGridPart.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsIGridPart_h___
    1.10 +#define nsIGridPart_h___
    1.11 +
    1.12 +#include "nsISupports.h"
    1.13 +
    1.14 +class nsGridRowGroupLayout;
    1.15 +class nsGrid;
    1.16 +class nsGridRowLayout;
    1.17 +class nsGridRow;
    1.18 +class nsGridLayout2;
    1.19 +
    1.20 +// 07373ed7-e947-4a5e-b36c-69f7c195677b
    1.21 +#define NS_IGRIDPART_IID \
    1.22 +{ 0x07373ed7, 0xe947, 0x4a5e, \
    1.23 +  { 0xb3, 0x6c, 0x69, 0xf7, 0xc1, 0x95, 0x67, 0x7b } }
    1.24 +
    1.25 +/**
    1.26 + * An additional interface implemented by nsBoxLayout implementations
    1.27 + * for parts of a grid (excluding cells, which are not special).
    1.28 + */
    1.29 +class nsIGridPart : public nsISupports {
    1.30 +
    1.31 +public:
    1.32 +
    1.33 +  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGRIDPART_IID)
    1.34 +
    1.35 +  virtual nsGridRowGroupLayout* CastToRowGroupLayout()=0;
    1.36 +  virtual nsGridLayout2* CastToGridLayout()=0;
    1.37 +
    1.38 +  /**
    1.39 +   * @param aBox [IN] The other half of the |this| parameter, i.e., the box
    1.40 +   *                  whose layout manager is |this|.
    1.41 +   * @param aIndex [INOUT] For callers not setting aRequestor, the value
    1.42 +   *                       pointed to by aIndex is incremented by the index
    1.43 +   *                       of the row (aBox) within its row group; if aBox
    1.44 +   *                       is not a row/column, it is untouched.
    1.45 +   *                       The implementation does this by doing the aIndex
    1.46 +   *                       incrementing in the call to the parent row group
    1.47 +   *                       when aRequestor is non-null.
    1.48 +   * @param aRequestor [IN] Non-null if and only if this is a recursive
    1.49 +   *                   call from the GetGrid method on a child grid part,
    1.50 +   *                   in which case it is a pointer to that grid part.
    1.51 +   *                   (This may only be non-null for row groups and
    1.52 +   *                   grids.)
    1.53 +   * @return The grid of which aBox (a row, row group, or grid) is a part.
    1.54 +   */
    1.55 +  virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex, nsGridRowLayout* aRequestor=nullptr)=0;
    1.56 +
    1.57 +  /**
    1.58 +   * @param aBox [IN] The other half of the |this| parameter, i.e., the box
    1.59 +   *                  whose layout manager is |this|.
    1.60 +   * @param aParentBox [OUT] The box representing the next level up in
    1.61 +   *                   the grid (i.e., row group for a row, grid for a
    1.62 +   *                   row group).
    1.63 +   * @returns The layout manager for aParentBox.
    1.64 +   */
    1.65 +  virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) = 0;
    1.66 +
    1.67 +  /**
    1.68 +   * @param aBox [IN] The other half of the |this| parameter, i.e., the box
    1.69 +   *                  whose layout manager is |this|.
    1.70 +   * @param aRowCount [INOUT] Row count
    1.71 +   * @param aComputedColumnCount [INOUT] Column count
    1.72 +   */
    1.73 +  virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)=0;
    1.74 +  virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)=0;
    1.75 +  virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows)=0;
    1.76 +  virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)=0;
    1.77 +  virtual int32_t GetRowCount() { return 1; }
    1.78 +  
    1.79 +  /**
    1.80 +   * Return the level of the grid hierarchy this grid part represents.
    1.81 +   */
    1.82 +  enum Type { eGrid, eRowGroup, eRowLeaf };
    1.83 +  virtual Type GetType()=0;
    1.84 +
    1.85 +  /**
    1.86 +   * Return whether this grid part is an appropriate parent for the argument.
    1.87 +   */
    1.88 +  bool CanContain(nsIGridPart* aPossibleChild) {
    1.89 +    Type thisType = GetType(), childType = aPossibleChild->GetType();
    1.90 +    return thisType + 1 == childType || (thisType == eRowGroup && childType == eRowGroup);
    1.91 +  }
    1.92 +
    1.93 +};
    1.94 +
    1.95 +NS_DEFINE_STATIC_IID_ACCESSOR(nsIGridPart, NS_IGRIDPART_IID)
    1.96 +
    1.97 +#endif
    1.98 +

mercurial