OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef UI_GFX_SCREEN_H_ | |
6 #define UI_GFX_SCREEN_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/macros.h" | |
11 #include "ui/gfx/display.h" | |
12 #include "ui/gfx/gfx_export.h" | |
13 #include "ui/gfx/native_widget_types.h" | |
14 | |
15 namespace gfx { | |
16 | |
17 class DisplayObserver; | |
18 class Point; | |
19 class Rect; | |
20 | |
21 // A utility class for getting various info about screen size, displays, | |
22 // cursor position, etc. | |
23 // | |
24 // Note that this class does not represent an individual display connected to a | |
25 // computer -- see the Display class for that. A single Screen object exists | |
26 // regardless of the number of connected displays. | |
27 class GFX_EXPORT Screen { | |
28 public: | |
29 Screen(); | |
30 virtual ~Screen(); | |
31 | |
32 // Retrieves the single Screen object. | |
33 static Screen* GetScreen(); | |
34 | |
35 // Sets the global screen. NOTE: this does not take ownership of |screen|. | |
36 // Tests must be sure to reset any state they install. | |
37 static void SetScreenInstance(Screen* instance); | |
38 | |
39 // Returns the current absolute position of the mouse pointer. | |
40 virtual gfx::Point GetCursorScreenPoint() = 0; | |
41 | |
42 // Returns true if the cursor is directly over |window|. | |
43 virtual bool IsWindowUnderCursor(gfx::NativeWindow window) = 0; | |
44 | |
45 // Returns the window at the given screen coordinate |point|. | |
46 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0; | |
47 | |
48 // Returns the number of displays. | |
49 // Mirrored displays are excluded; this method is intended to return the | |
50 // number of distinct, usable displays. | |
51 virtual int GetNumDisplays() const = 0; | |
52 | |
53 // Returns the list of displays that are currently available. | |
54 virtual std::vector<gfx::Display> GetAllDisplays() const = 0; | |
55 | |
56 // Returns the display nearest the specified window. | |
57 // If the window is NULL or the window is not rooted to a display this will | |
58 // return the primary display. | |
59 virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; | |
60 | |
61 // Returns the display nearest the specified point. |point| should be in DIPs. | |
62 virtual gfx::Display GetDisplayNearestPoint( | |
63 const gfx::Point& point) const = 0; | |
64 | |
65 // Returns the display that most closely intersects the provided bounds. | |
66 virtual gfx::Display GetDisplayMatching( | |
67 const gfx::Rect& match_rect) const = 0; | |
68 | |
69 // Returns the primary display. | |
70 virtual gfx::Display GetPrimaryDisplay() const = 0; | |
71 | |
72 // Adds/Removes display observers. | |
73 virtual void AddObserver(DisplayObserver* observer) = 0; | |
74 virtual void RemoveObserver(DisplayObserver* observer) = 0; | |
75 | |
76 // Converts |screen_rect| to DIP coordinates in the context of |view| clamping | |
77 // to the enclosing rect if the coordinates do not fall on pixel boundaries. | |
78 // If |view| is null, the primary display is used as the context. | |
79 virtual gfx::Rect ScreenToDIPRectInWindow(NativeView view, | |
80 const gfx::Rect& screen_rect) const; | |
81 | |
82 // Converts |dip_rect| to screen coordinates in the context of |view| clamping | |
83 // to the enclosing rect if the coordinates do not fall on pixel boundaries. | |
84 // If |view| is null, the primary display is used as the context. | |
85 virtual gfx::Rect DIPToScreenRectInWindow(NativeView view, | |
86 const gfx::Rect& dip_rect) const; | |
87 | |
88 private: | |
89 DISALLOW_COPY_AND_ASSIGN(Screen); | |
90 }; | |
91 | |
92 Screen* CreateNativeScreen(); | |
93 | |
94 } // namespace gfx | |
95 | |
96 #endif // UI_GFX_SCREEN_H_ | |
OLD | NEW |