|
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 nsPageFrame_h___ |
|
6 #define nsPageFrame_h___ |
|
7 |
|
8 #include "mozilla/Attributes.h" |
|
9 #include "nsContainerFrame.h" |
|
10 #include "nsLeafFrame.h" |
|
11 |
|
12 class nsSharedPageData; |
|
13 |
|
14 // Page frame class used by the simple page sequence frame |
|
15 class nsPageFrame : public nsContainerFrame { |
|
16 |
|
17 public: |
|
18 NS_DECL_FRAMEARENA_HELPERS |
|
19 |
|
20 friend nsIFrame* NS_NewPageFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
21 |
|
22 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
23 nsHTMLReflowMetrics& aDesiredSize, |
|
24 const nsHTMLReflowState& aMaxSize, |
|
25 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
26 |
|
27 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
28 const nsRect& aDirtyRect, |
|
29 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
30 |
|
31 /** |
|
32 * Get the "type" of the frame |
|
33 * |
|
34 * @see nsGkAtoms::pageFrame |
|
35 */ |
|
36 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
37 |
|
38 #ifdef DEBUG_FRAME_DUMP |
|
39 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
40 #endif |
|
41 |
|
42 ////////////////// |
|
43 // For Printing |
|
44 ////////////////// |
|
45 |
|
46 // Tell the page which page number it is out of how many |
|
47 virtual void SetPageNumInfo(int32_t aPageNumber, int32_t aTotalPages); |
|
48 |
|
49 virtual void SetSharedPageData(nsSharedPageData* aPD); |
|
50 |
|
51 // We must allow Print Preview UI to have a background, no matter what the |
|
52 // user's settings |
|
53 virtual bool HonorPrintBackgroundSettings() MOZ_OVERRIDE { return false; } |
|
54 |
|
55 void PaintHeaderFooter(nsRenderingContext& aRenderingContext, |
|
56 nsPoint aPt); |
|
57 |
|
58 protected: |
|
59 nsPageFrame(nsStyleContext* aContext); |
|
60 virtual ~nsPageFrame(); |
|
61 |
|
62 typedef enum { |
|
63 eHeader, |
|
64 eFooter |
|
65 } nsHeaderFooterEnum; |
|
66 |
|
67 nscoord GetXPosition(nsRenderingContext& aRenderingContext, |
|
68 const nsRect& aRect, |
|
69 int32_t aJust, |
|
70 const nsString& aStr); |
|
71 |
|
72 void DrawHeaderFooter(nsRenderingContext& aRenderingContext, |
|
73 nsHeaderFooterEnum aHeaderFooter, |
|
74 int32_t aJust, |
|
75 const nsString& sStr, |
|
76 const nsRect& aRect, |
|
77 nscoord aHeight, |
|
78 nscoord aAscent, |
|
79 nscoord aWidth); |
|
80 |
|
81 void DrawHeaderFooter(nsRenderingContext& aRenderingContext, |
|
82 nsHeaderFooterEnum aHeaderFooter, |
|
83 const nsString& aStrLeft, |
|
84 const nsString& aStrRight, |
|
85 const nsString& aStrCenter, |
|
86 const nsRect& aRect, |
|
87 nscoord aAscent, |
|
88 nscoord aHeight); |
|
89 |
|
90 void ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr); |
|
91 |
|
92 int32_t mPageNum; |
|
93 int32_t mTotNumPages; |
|
94 |
|
95 nsSharedPageData* mPD; |
|
96 }; |
|
97 |
|
98 |
|
99 class nsPageBreakFrame : public nsLeafFrame |
|
100 { |
|
101 NS_DECL_FRAMEARENA_HELPERS |
|
102 |
|
103 nsPageBreakFrame(nsStyleContext* aContext); |
|
104 ~nsPageBreakFrame(); |
|
105 |
|
106 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
107 nsHTMLReflowMetrics& aDesiredSize, |
|
108 const nsHTMLReflowState& aReflowState, |
|
109 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
110 |
|
111 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
112 |
|
113 #ifdef DEBUG_FRAME_DUMP |
|
114 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
115 #endif |
|
116 |
|
117 protected: |
|
118 |
|
119 virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE; |
|
120 virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE; |
|
121 |
|
122 bool mHaveReflowed; |
|
123 |
|
124 friend nsIFrame* NS_NewPageBreakFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
|
125 }; |
|
126 |
|
127 #endif /* nsPageFrame_h___ */ |
|
128 |