1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is mozilla.org code.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * Netscape Communications Corporation.
19 : * Portions created by the Initial Developer are Copyright (C) 1998
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either of the GNU General Public License Version 2 or later (the "GPL"),
26 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 : #ifndef nsPageFrame_h___
38 : #define nsPageFrame_h___
39 :
40 : #include "nsContainerFrame.h"
41 : #include "nsLeafFrame.h"
42 :
43 : class nsSharedPageData;
44 :
45 : // Page frame class used by the simple page sequence frame
46 : class nsPageFrame : public nsContainerFrame {
47 :
48 : public:
49 : NS_DECL_FRAMEARENA_HELPERS
50 :
51 : friend nsIFrame* NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
52 :
53 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
54 : nsHTMLReflowMetrics& aDesiredSize,
55 : const nsHTMLReflowState& aMaxSize,
56 : nsReflowStatus& aStatus);
57 :
58 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
59 : const nsRect& aDirtyRect,
60 : const nsDisplayListSet& aLists);
61 :
62 : /**
63 : * Get the "type" of the frame
64 : *
65 : * @see nsGkAtoms::pageFrame
66 : */
67 : virtual nsIAtom* GetType() const;
68 :
69 : #ifdef NS_DEBUG
70 : NS_IMETHOD GetFrameName(nsAString& aResult) const;
71 : #endif
72 :
73 : //////////////////
74 : // For Printing
75 : //////////////////
76 :
77 : // Tell the page which page number it is out of how many
78 : virtual void SetPageNumInfo(PRInt32 aPageNumber, PRInt32 aTotalPages);
79 :
80 : virtual void SetSharedPageData(nsSharedPageData* aPD);
81 :
82 : // We must allow Print Preview UI to have a background, no matter what the
83 : // user's settings
84 0 : virtual bool HonorPrintBackgroundSettings() { return false; }
85 :
86 : void PaintHeaderFooter(nsRenderingContext& aRenderingContext,
87 : nsPoint aPt);
88 : void PaintPageContent(nsRenderingContext& aRenderingContext,
89 : const nsRect& aDirtyRect,
90 : nsPoint aPt);
91 :
92 : protected:
93 : nsPageFrame(nsStyleContext* aContext);
94 : virtual ~nsPageFrame();
95 :
96 : typedef enum {
97 : eHeader,
98 : eFooter
99 : } nsHeaderFooterEnum;
100 :
101 : nscoord GetXPosition(nsRenderingContext& aRenderingContext,
102 : const nsRect& aRect,
103 : PRInt32 aJust,
104 : const nsString& aStr);
105 :
106 : void DrawHeaderFooter(nsRenderingContext& aRenderingContext,
107 : nsHeaderFooterEnum aHeaderFooter,
108 : PRInt32 aJust,
109 : const nsString& sStr,
110 : const nsRect& aRect,
111 : nscoord aHeight,
112 : nscoord aAscent,
113 : nscoord aWidth);
114 :
115 : void DrawHeaderFooter(nsRenderingContext& aRenderingContext,
116 : nsHeaderFooterEnum aHeaderFooter,
117 : const nsString& aStrLeft,
118 : const nsString& aStrRight,
119 : const nsString& aStrCenter,
120 : const nsRect& aRect,
121 : nscoord aAscent,
122 : nscoord aHeight);
123 :
124 : void ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr);
125 :
126 : PRInt32 mPageNum;
127 : PRInt32 mTotNumPages;
128 :
129 : nsSharedPageData* mPD;
130 : };
131 :
132 :
133 : class nsPageBreakFrame : public nsLeafFrame
134 : {
135 : NS_DECL_FRAMEARENA_HELPERS
136 :
137 : nsPageBreakFrame(nsStyleContext* aContext);
138 : ~nsPageBreakFrame();
139 :
140 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
141 : nsHTMLReflowMetrics& aDesiredSize,
142 : const nsHTMLReflowState& aReflowState,
143 : nsReflowStatus& aStatus);
144 :
145 : virtual nsIAtom* GetType() const;
146 :
147 : #ifdef NS_DEBUG
148 : NS_IMETHOD GetFrameName(nsAString& aResult) const;
149 : #endif
150 :
151 : protected:
152 :
153 : virtual nscoord GetIntrinsicWidth();
154 : virtual nscoord GetIntrinsicHeight();
155 :
156 : bool mHaveReflowed;
157 :
158 : friend nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
159 : };
160 :
161 : #endif /* nsPageFrame_h___ */
162 :
|