nsIGridPart.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef nsIGridPart_h___
  6. #define nsIGridPart_h___
  7. #include "nsISupports.h"
  8. class nsGridRowGroupLayout;
  9. class nsGrid;
  10. class nsGridRowLayout;
  11. class nsGridRow;
  12. class nsGridLayout2;
  13. // 07373ed7-e947-4a5e-b36c-69f7c195677b
  14. #define NS_IGRIDPART_IID \
  15. { 0x07373ed7, 0xe947, 0x4a5e, \
  16. { 0xb3, 0x6c, 0x69, 0xf7, 0xc1, 0x95, 0x67, 0x7b } }
  17. /**
  18. * An additional interface implemented by nsBoxLayout implementations
  19. * for parts of a grid (excluding cells, which are not special).
  20. */
  21. class nsIGridPart : public nsISupports {
  22. public:
  23. NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGRIDPART_IID)
  24. virtual nsGridRowGroupLayout* CastToRowGroupLayout()=0;
  25. virtual nsGridLayout2* CastToGridLayout()=0;
  26. /**
  27. * @param aBox [IN] The other half of the |this| parameter, i.e., the box
  28. * whose layout manager is |this|.
  29. * @param aIndex [INOUT] For callers not setting aRequestor, the value
  30. * pointed to by aIndex is incremented by the index
  31. * of the row (aBox) within its row group; if aBox
  32. * is not a row/column, it is untouched.
  33. * The implementation does this by doing the aIndex
  34. * incrementing in the call to the parent row group
  35. * when aRequestor is non-null.
  36. * @param aRequestor [IN] Non-null if and only if this is a recursive
  37. * call from the GetGrid method on a child grid part,
  38. * in which case it is a pointer to that grid part.
  39. * (This may only be non-null for row groups and
  40. * grids.)
  41. * @return The grid of which aBox (a row, row group, or grid) is a part.
  42. */
  43. virtual nsGrid* GetGrid(nsIFrame* aBox, int32_t* aIndex, nsGridRowLayout* aRequestor=nullptr)=0;
  44. /**
  45. * @param aBox [IN] The other half of the |this| parameter, i.e., the box
  46. * whose layout manager is |this|.
  47. * @param aParentBox [OUT] The box representing the next level up in
  48. * the grid (i.e., row group for a row, grid for a
  49. * row group).
  50. * @returns The layout manager for aParentBox.
  51. */
  52. virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) = 0;
  53. /**
  54. * @param aBox [IN] The other half of the |this| parameter, i.e., the box
  55. * whose layout manager is |this|.
  56. * @param aRowCount [INOUT] Row count
  57. * @param aComputedColumnCount [INOUT] Column count
  58. */
  59. virtual void CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)=0;
  60. virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)=0;
  61. virtual int32_t BuildRows(nsIFrame* aBox, nsGridRow* aRows)=0;
  62. virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)=0;
  63. virtual int32_t GetRowCount() { return 1; }
  64. /**
  65. * Return the level of the grid hierarchy this grid part represents.
  66. */
  67. enum Type { eGrid, eRowGroup, eRowLeaf };
  68. virtual Type GetType()=0;
  69. /**
  70. * Return whether this grid part is an appropriate parent for the argument.
  71. */
  72. bool CanContain(nsIGridPart* aPossibleChild) {
  73. Type thisType = GetType(), childType = aPossibleChild->GetType();
  74. return thisType + 1 == childType || (thisType == eRowGroup && childType == eRowGroup);
  75. }
  76. };
  77. NS_DEFINE_STATIC_IID_ACCESSOR(nsIGridPart, NS_IGRIDPART_IID)
  78. #endif