Add exclamation and question mark to the accent keys.
[chromium-blink-merge.git] / ui / gfx / display.h
blob2282cb0a568681526409238ec47209b455a9854a
1 // Copyright (c) 2012 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 UI_GFX_DISPLAY_H_
6 #define UI_GFX_DISPLAY_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "ui/base/ui_export.h"
11 #include "ui/gfx/rect.h"
13 namespace gfx {
15 // Note: The screen and display currently uses pixel coordinate
16 // system. For platforms that support DIP (density independent pixel),
17 // |bounds()| and |work_area| will return values in DIP coordinate
18 // system, not in backing pixels.
19 class UI_EXPORT Display {
20 public:
21 // Screen Rotation in clock-wise degrees.
22 enum Rotation {
23 ROTATE_0 = 0,
24 ROTATE_90,
25 ROTATE_180,
26 ROTATE_270,
29 // Creates a display with kInvalidDisplayID as default.
30 Display();
31 explicit Display(int64 id);
32 Display(int64 id, const Rect& bounds);
33 ~Display();
35 // Returns the forced device scale factor, which is given by
36 // "--force-device-scale-factor".
37 static float GetForcedDeviceScaleFactor();
39 // Indicates if a device scale factor is being explicitly enforced from the
40 // command line via "--force-device-scale-factor".
41 static bool HasForceDeviceScaleFactor();
43 // Sets/Gets unique identifier associated with the display.
44 // -1 means invalid display and it doesn't not exit.
45 int64 id() const { return id_; }
46 void set_id(int64 id) { id_ = id; }
48 // Gets/Sets the display's bounds in gfx::Screen's coordinates.
49 const Rect& bounds() const { return bounds_; }
50 void set_bounds(const Rect& bounds) { bounds_ = bounds; }
52 // Gets/Sets the display's work area in gfx::Screen's coordinates.
53 const Rect& work_area() const { return work_area_; }
54 void set_work_area(const Rect& work_area) { work_area_ = work_area; }
56 // Output device's pixel scale factor. This specifies how much the
57 // UI should be scaled when the actual output has more pixels than
58 // standard displays (which is around 100~120dpi.) The potential return
59 // values depend on each platforms.
60 float device_scale_factor() const { return device_scale_factor_; }
61 void set_device_scale_factor(float scale) { device_scale_factor_ = scale; }
63 Rotation rotation() const { return rotation_; }
64 void set_rotation(Rotation rotation) { rotation_ = rotation; }
66 // Utility functions that just return the size of display and
67 // work area.
68 const Size& size() const { return bounds_.size(); }
69 const Size& work_area_size() const { return work_area_.size(); }
71 // Returns the work area insets.
72 Insets GetWorkAreaInsets() const;
74 // Sets the device scale factor and display bounds in pixel. This
75 // updates the work are using the same insets between old bounds and
76 // work area.
77 void SetScaleAndBounds(float device_scale_factor,
78 const gfx::Rect& bounds_in_pixel);
80 // Sets the display's size. This updates the work area using the same insets
81 // between old bounds and work area.
82 void SetSize(const gfx::Size& size_in_pixel);
84 // Computes and updates the display's work are using
85 // |work_area_insets| and the bounds.
86 void UpdateWorkAreaFromInsets(const gfx::Insets& work_area_insets);
88 // Returns the display's size in pixel coordinates.
89 gfx::Size GetSizeInPixel() const;
91 // Returns a string representation of the display;
92 std::string ToString() const;
94 // True if the display contains valid display id.
95 bool is_valid() const { return id_ != kInvalidDisplayID; }
97 // True if the display corresponds to internal panel.
98 bool IsInternal() const;
100 // Gets/Sets an id of display corresponding to internal panel.
101 static int64 InternalDisplayId();
102 static void SetInternalDisplayId(int64 internal_display_id);
104 static const int64 kInvalidDisplayID;
106 private:
107 int64 id_;
108 Rect bounds_;
109 Rect work_area_;
110 float device_scale_factor_;
111 Rotation rotation_;
114 } // namespace gfx
116 #endif // UI_GFX_DISPLAY_H_