Back to index

lightning-sunbird  0.9+nobinonly
nsTableColGroupFrame.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsTableColGroupFrame_h__
00038 #define nsTableColGroupFrame_h__
00039 
00040 #include "nscore.h"
00041 #include "nsHTMLContainerFrame.h"
00042 #include "nsTableColFrame.h"
00043 #include "nsTablePainter.h"
00044 
00045 class nsTableColFrame;
00046 
00047 enum nsTableColGroupType {
00048   eColGroupContent            = 0, // there is real col group content associated   
00049   eColGroupAnonymousCol       = 1, // the result of a col
00050   eColGroupAnonymousCell      = 2  // the result of a cell alone
00051 };
00052 
00059 class nsTableColGroupFrame : public nsHTMLContainerFrame
00060 {
00061 public:
00062 
00063   // default constructor supplied by the compiler
00064 
00070   friend nsresult 
00071   NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
00072 
00076   NS_IMETHOD Init(nsPresContext*  aPresContext,
00077                   nsIContent*      aContent,
00078                   nsIFrame*        aParent,
00079                   nsStyleContext*  aContext,
00080                   nsIFrame*        aPrevInFlow);
00081 
00085   NS_IMETHOD SetInitialChildList(nsPresContext* aPresContext,
00086                                  nsIAtom*        aListName,
00087                                  nsIFrame*       aChildList);
00088 
00097   nsTableColGroupType GetColType() const;
00098 
00102   void SetColType(nsTableColGroupType aType);
00103   
00113   static PRBool GetLastRealColGroup(nsTableFrame* aTableFrame, 
00114                                     nsIFrame**    aLastColGroup);
00115 
00118   NS_IMETHOD AppendFrames(nsIAtom*        aListName,
00119                           nsIFrame*       aFrameList);
00120   NS_IMETHOD InsertFrames(nsIAtom*        aListName,
00121                           nsIFrame*       aPrevFrame,
00122                           nsIFrame*       aFrameList);
00123   NS_IMETHOD RemoveFrame(nsIAtom*        aListName,
00124                          nsIFrame*       aOldFrame);
00125 
00133   void RemoveChild(nsTableColFrame& aChild,
00134                    PRBool           aResetSubsequentColIndices);
00135 
00139   NS_IMETHOD Paint(nsPresContext*      aPresContext,
00140                    nsIRenderingContext& aRenderingContext,
00141                    const nsRect&        aDirtyRect,
00142                    nsFramePaintLayer    aWhichLayer,
00143                    PRUint32             aFlags = 0);
00144 
00145   // column groups don't paint their own background -- the cells do
00146   virtual PRBool CanPaintBackground() { return PR_FALSE; }
00147 
00150   NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, 
00151                               nsFramePaintLayer aWhichLayer,
00152                               nsIFrame**     aFrame);
00153 
00160   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
00161                     nsHTMLReflowMetrics&     aDesiredSize,
00162                     const nsHTMLReflowState& aReflowState,
00163                     nsReflowStatus&          aStatus);
00164 
00170   virtual nsIAtom* GetType() const;
00171 
00187   nsresult AddColsToTable(PRInt32          aFirstColIndex,
00188                           PRBool           aResetSubsequentColIndices,
00189                           nsIFrame*        aFirstFrame,
00190                           nsIFrame*        aLastFrame = nsnull);
00191 
00192 #ifdef DEBUG
00193   NS_IMETHOD GetFrameName(nsAString& aResult) const;
00194   void Dump(PRInt32 aIndent);
00195 #endif
00196 
00201   virtual PRInt32 GetColCount() const;
00202 
00204   nsTableColFrame * GetFirstColumn();
00208   nsTableColFrame * GetNextColumn(nsIFrame *aChildFrame);
00209 
00213   PRInt32 GetStartColumnIndex();
00214   
00218   void SetStartColumnIndex(PRInt32 aIndex);
00219 
00221   PRInt32 GetSpan();
00222 
00225   nsFrameList& GetChildList();
00226 
00235   static void ResetColIndices(nsIFrame*       aFirstColGroup,
00236                               PRInt32         aFirstColIndex,
00237                               nsIFrame*       aStartColFrame = nsnull);
00238 
00245   void GetContinuousBCBorderWidth(float     aPixelsToTwips,
00246                                   nsMargin& aBorder);
00251   void SetContinuousBCBorderWidth(PRUint8     aForSide,
00252                                   BCPixelSize aPixelValue);
00253 protected:
00254   nsTableColGroupFrame();
00255 
00256   void InsertColsReflow(PRInt32         aColIndex,
00257                         nsIFrame*       aFirstFrame,
00258                         nsIFrame*       aLastFrame = nsnull);
00259 
00261   virtual PRIntn GetSkipSides() const;
00262 
00263   NS_IMETHOD IncrementalReflow(nsHTMLReflowMetrics&     aDesiredSize,
00264                                const nsHTMLReflowState& aReflowState,
00265                                nsReflowStatus&          aStatus);
00266 
00267   NS_IMETHOD IR_TargetIsMe(nsHTMLReflowMetrics&     aDesiredSize,
00268                            const nsHTMLReflowState& aReflowState,
00269                            nsReflowStatus&          aStatus);
00270 
00271   NS_IMETHOD IR_StyleChanged(nsHTMLReflowMetrics&     aDesiredSize,
00272                              const nsHTMLReflowState& aReflowState,
00273                              nsReflowStatus&          aStatus);
00274 
00275 
00276   NS_IMETHOD IR_TargetIsChild(nsHTMLReflowMetrics&     aDesiredSize,
00277                               const nsHTMLReflowState& aReflowState,
00278                               nsReflowStatus&          aStatus,
00279                               nsIFrame *               aNextFrame);
00280 
00281   // data members
00282   PRInt32 mColCount;
00283   // the starting column index this col group represents. Must be >= 0. 
00284   PRInt32 mStartColIndex;
00285 
00286   // border width in pixels
00287   BCPixelSize mTopContBorderWidth;
00288   BCPixelSize mBottomContBorderWidth;
00289 };
00290 
00291 inline nsTableColGroupFrame::nsTableColGroupFrame()
00292 : mColCount(0), mStartColIndex(0)
00293 { 
00294   SetColType(eColGroupContent);
00295 }
00296   
00297 inline PRInt32 nsTableColGroupFrame::GetStartColumnIndex()
00298 {  
00299   return mStartColIndex;
00300 }
00301 
00302 inline void nsTableColGroupFrame::SetStartColumnIndex (PRInt32 aIndex)
00303 {
00304   mStartColIndex = aIndex;
00305 }
00306 
00307 inline PRInt32 nsTableColGroupFrame::GetColCount() const
00308 {  
00309   return mColCount;
00310 }
00311 
00312 inline nsFrameList& nsTableColGroupFrame::GetChildList()
00313 {  
00314   return mFrames;
00315 }
00316 
00317 #endif
00318