Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / printing / page_setup.h
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.
4
5 #ifndef PRINTING_PAGE_SETUP_H_
6 #define PRINTING_PAGE_SETUP_H_
7
8 #include "printing/printing_export.h"
9 #include "ui/gfx/geometry/rect.h"
10
11 namespace printing {
12
13 // Margins for a page setup.
14 class PRINTING_EXPORT PageMargins {
15  public:
16   PageMargins();
17
18   void Clear();
19
20   // Equality operator.
21   bool Equals(const PageMargins& rhs) const;
22
23   // Vertical space for the overlay from the top of the sheet.
24   int header;
25   // Vertical space for the overlay from the bottom of the sheet.
26   int footer;
27   // Margin on each side of the sheet.
28   int left;
29   int right;
30   int top;
31   int bottom;
32 };
33
34 // Settings that define the size and printable areas of a page. Unit is
35 // unspecified.
36 class PRINTING_EXPORT PageSetup {
37  public:
38   PageSetup();
39   PageSetup(const PageSetup& other);
40   ~PageSetup();
41
42   // Gets a symmetrical printable area.
43   static gfx::Rect GetSymmetricalPrintableArea(const gfx::Size& page_size,
44                                                const gfx::Rect& printable_area);
45
46   void Clear();
47
48   // Equality operator.
49   bool Equals(const PageSetup& rhs) const;
50
51   void Init(const gfx::Size& physical_size, const gfx::Rect& printable_area,
52             int text_height);
53
54   // Use |requested_margins| as long as they fall inside the printable area.
55   void SetRequestedMargins(const PageMargins& requested_margins);
56
57   // Ignore the printable area, and set the margins to |requested_margins|.
58   void ForceRequestedMargins(const PageMargins& requested_margins);
59
60   // Flips the orientation of the page and recalculates all page areas.
61   void FlipOrientation();
62
63   const gfx::Size& physical_size() const { return physical_size_; }
64   const gfx::Rect& overlay_area() const { return overlay_area_; }
65   const gfx::Rect& content_area() const { return content_area_; }
66   const gfx::Rect& printable_area() const { return printable_area_; }
67   const PageMargins& effective_margins() const {
68     return effective_margins_;
69   }
70
71  private:
72   // Store |requested_margins_| and update page setup values.
73   void SetRequestedMarginsAndCalculateSizes(
74       const PageMargins& requested_margins);
75
76   // Calculate overlay_area_, effective_margins_, and content_area_, based on
77   // a constraint of |bounds| and |text_height|.
78   void CalculateSizesWithinRect(const gfx::Rect& bounds, int text_height);
79
80   // Physical size of the page, including non-printable margins.
81   gfx::Size physical_size_;
82
83   // The printable area as specified by the printer driver. We can't get
84   // larger than this.
85   gfx::Rect printable_area_;
86
87   // The printable area for headers and footers.
88   gfx::Rect overlay_area_;
89
90   // The printable area as selected by the user's margins.
91   gfx::Rect content_area_;
92
93   // Effective margins.
94   PageMargins effective_margins_;
95
96   // Requested margins.
97   PageMargins requested_margins_;
98
99   // True when |effective_margins_| respects |printable_area_| else false.
100   bool forced_margins_;
101
102   // Space that must be kept free for the overlays.
103   int text_height_;
104 };
105
106 }  // namespace printing
107
108 #endif  // PRINTING_PAGE_SETUP_H_