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