Back to index

lightning-sunbird  0.9+nobinonly
nsPageFrame.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 nsPageFrame_h___
00038 #define nsPageFrame_h___
00039 
00040 #include "nsContainerFrame.h"
00041 #include "nsIPrintSettings.h"
00042 #include "nsLeafFrame.h"
00043 
00044 class nsSharedPageData;
00045 
00046 // Page frame class used by the simple page sequence frame
00047 class nsPageFrame : public nsContainerFrame {
00048 
00049 public:
00050   friend nsresult NS_NewPageFrame(nsIPresShell* aPresShell, nsIFrame** aResult);
00051 
00052   // nsIFrame
00053   NS_IMETHOD  SetInitialChildList(nsPresContext* aPresContext,
00054                                   nsIAtom*        aListName,
00055                                   nsIFrame*       aChildList);
00056 
00057   NS_IMETHOD  Reflow(nsPresContext*      aPresContext,
00058                      nsHTMLReflowMetrics& aDesiredSize,
00059                      const nsHTMLReflowState& aMaxSize,
00060                      nsReflowStatus&      aStatus);
00061 
00062   NS_IMETHOD  Paint(nsPresContext*      aPresContext,
00063                     nsIRenderingContext& aRenderingContext,
00064                     const nsRect&        aDirtyRect,
00065                     nsFramePaintLayer    aWhichLayer,
00066                     PRUint32             aFlags = 0);
00067 
00068   virtual PRBool IsContainingBlock() const;
00069 
00075   virtual nsIAtom* GetType() const;
00076   
00077 #ifdef NS_DEBUG
00078   NS_IMETHOD  GetFrameName(nsAString& aResult) const;
00079 #endif
00080 
00082   // For Printing
00084 
00085   // Tell the page which page number it is out of how many
00086   virtual void  SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages);
00087 
00088   virtual void  SuppressHeadersAndFooters(PRBool aDoSup) { mSupressHF = aDoSup; }
00089   virtual void  SetClipRect(nsRect* aClipRect);
00090 
00091   virtual void SetSharedPageData(nsSharedPageData* aPD);
00092 
00093 // XXX Part of Temporary fix for Bug 127263
00094   static  void   SetCreateWidget(PRBool aDoCreateWidget)  { mDoCreateWidget = aDoCreateWidget; }
00095   static  PRBool GetCreateWidget()                        { return mDoCreateWidget; }
00096 
00097 protected:
00098   nsPageFrame();
00099   virtual ~nsPageFrame();
00100 
00101   typedef enum {
00102     eHeader,
00103     eFooter
00104   } nsHeaderFooterEnum;
00105 
00106   nscoord GetXPosition(nsIRenderingContext& aRenderingContext, 
00107                        const nsRect&        aRect, 
00108                        PRInt32              aJust,
00109                        const nsString&      aStr);
00110 
00111   void DrawHeaderFooter(nsPresContext*      aPresContext,
00112                         nsIRenderingContext& aRenderingContext,
00113                         nsIFrame *           aFrame,
00114                         nsHeaderFooterEnum   aHeaderFooter,
00115                         PRInt32              aJust,
00116                         const nsString&      sStr,
00117                         const nsRect&        aRect,
00118                         nscoord              aHeight,
00119                         nscoord              aAscent,
00120                         nscoord              aWidth);
00121 
00122   void DrawHeaderFooter(nsPresContext*      aPresContext,
00123                         nsIRenderingContext& aRenderingContext,
00124                         nsIFrame *           aFrame,
00125                         nsHeaderFooterEnum   aHeaderFooter,
00126                         PRInt32              aJust,
00127                         const nsString&      aStr1,
00128                         const nsString&      aStr2,
00129                         const nsString&      aStr3,
00130                         const nsRect&        aRect,
00131                         nscoord              aAscent,
00132                         nscoord              aHeight);
00133 
00134   void ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr);
00135 
00136   nsCOMPtr<nsIPrintSettings> mPrintOptions;
00137   PRInt32     mPageNum;
00138   PRInt32     mTotNumPages;
00139   nsMargin    mMargin;
00140 
00141   PRPackedBool mSupressHF;
00142   nsRect       mClipRect;
00143 
00144   nsSharedPageData* mPD;
00145 
00146 // XXX Part of Temporary fix for Bug 127263
00147   static PRBool mDoCreateWidget;
00148 
00149 private:
00150   void DrawBackground(nsPresContext* aPresContext,
00151                       nsIRenderingContext& aRenderingContext,
00152                       const nsRect&  aDirtyRect);
00153 };
00154 
00155 
00156 class nsPageBreakFrame : public nsLeafFrame {
00157 
00158   nsPageBreakFrame();
00159   ~nsPageBreakFrame();
00160 
00161   NS_IMETHOD Reflow(nsPresContext*          aPresContext,
00162                     nsHTMLReflowMetrics&     aDesiredSize,
00163                     const nsHTMLReflowState& aReflowState,
00164                     nsReflowStatus&          aStatus);
00165 
00166   virtual nsIAtom* GetType() const;
00167 
00168 protected:
00169 
00170     virtual void GetDesiredSize(nsPresContext*        aPresContext,
00171                               const nsHTMLReflowState& aReflowState,
00172                               nsHTMLReflowMetrics&     aDesiredSize);
00173     PRBool mHaveReflowed;
00174 
00175     friend nsresult NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame);
00176 };
00177 
00178 #endif /* nsPageFrame_h___ */
00179