1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_PAGE_SETUP_H_
6 #define PRINTING_PAGE_SETUP_H_
8 #include "printing/printing_export.h"
9 #include "ui/gfx/rect.h"
13 // Margins for a page setup.
14 class PRINTING_EXPORT PageMargins
{
21 bool Equals(const PageMargins
& rhs
) const;
23 // Vertical space for the overlay from the top of the sheet.
25 // Vertical space for the overlay from the bottom of the sheet.
27 // Margin on each side of the sheet.
34 // Settings that define the size and printable areas of a page. Unit is
36 class PRINTING_EXPORT PageSetup
{
44 bool Equals(const PageSetup
& rhs
) const;
46 void Init(const gfx::Size
& physical_size
, const gfx::Rect
& printable_area
,
49 // Use |requested_margins| as long as they fall inside the printable area.
50 void SetRequestedMargins(const PageMargins
& requested_margins
);
52 // Ignore the printable area, and set the margins to |requested_margins|.
53 void ForceRequestedMargins(const PageMargins
& requested_margins
);
55 // Flips the orientation of the page and recalculates all page areas.
56 void FlipOrientation();
58 const gfx::Size
& physical_size() const { return physical_size_
; }
59 const gfx::Rect
& overlay_area() const { return overlay_area_
; }
60 const gfx::Rect
& content_area() const { return content_area_
; }
61 const gfx::Rect
& printable_area() const { return printable_area_
; }
62 const PageMargins
& effective_margins() const {
63 return effective_margins_
;
67 // Store |requested_margins_| and update page setup values.
68 void SetRequestedMarginsAndCalculateSizes(
69 const PageMargins
& requested_margins
);
71 // Calculate overlay_area_, effective_margins_, and content_area_, based on
72 // a constraint of |bounds| and |text_height|.
73 void CalculateSizesWithinRect(const gfx::Rect
& bounds
, int text_height
);
75 // Physical size of the page, including non-printable margins.
76 gfx::Size physical_size_
;
78 // The printable area as specified by the printer driver. We can't get
80 gfx::Rect printable_area_
;
82 // The printable area for headers and footers.
83 gfx::Rect overlay_area_
;
85 // The printable area as selected by the user's margins.
86 gfx::Rect content_area_
;
89 PageMargins effective_margins_
;
92 PageMargins requested_margins_
;
94 // True when |effective_margins_| respects |printable_area_| else false.
97 // Space that must be kept free for the overlays.
101 } // namespace printing
103 #endif // PRINTING_PAGE_SETUP_H_