OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_SCREEN_H_ | 5 #ifndef UI_GFX_SCREEN_H_ |
6 #define UI_GFX_SCREEN_H_ | 6 #define UI_GFX_SCREEN_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "ui/base/ui_export.h" | 9 #include "ui/base/ui_export.h" |
10 #include "ui/gfx/display.h" | 10 #include "ui/gfx/display.h" |
11 #include "ui/gfx/native_widget_types.h" | 11 #include "ui/gfx/native_widget_types.h" |
12 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
| 13 #include "ui/gfx/screen_type_delegate.h" |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Rect; | 16 class Rect; |
16 class ScreenImpl; | |
17 | 17 |
18 // A utility class for getting various info about screen size, displays, | 18 // A utility class for getting various info about screen size, displays, |
19 // cursor position, etc. | 19 // cursor position, etc. |
20 class UI_EXPORT Screen { | 20 class UI_EXPORT Screen { |
21 public: | 21 public: |
22 #if defined(USE_AURA) | 22 // Retrieves the Screen that the specified NativeView belongs to. |
23 // Sets the instance to use. This takes owernship of |screen|, deleting the | 23 static Screen* GetScreenFor(NativeView view); |
24 // old instance. This is used on aura to avoid circular dependencies between | 24 |
25 // ui and aura. | 25 // Returns the SCREEN_TYPE_NATIVE Screen. This should be used with caution, |
26 static void SetInstance(ScreenImpl* screen); | 26 // as it is likely to be incorrect for code that runs on Windows. |
27 #endif | 27 static Screen* GetNativeScreen(); |
| 28 |
| 29 // Sets the global screen for a particular screen type. Only the _NATIVE |
| 30 // ScreenType must be provided. |
| 31 static void SetScreenInstance(ScreenType type, Screen* instance); |
| 32 |
| 33 // Sets the global ScreenTypeDelegate. May be left unset if the platform |
| 34 // uses only the _NATIVE ScreenType. |
| 35 static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate); |
| 36 |
| 37 Screen(); |
| 38 virtual ~Screen(); |
28 | 39 |
29 // Returns true if DIP is enabled. | 40 // Returns true if DIP is enabled. |
30 static bool IsDIPEnabled(); | 41 virtual bool IsDIPEnabled() = 0; |
31 | 42 |
32 // Returns the current absolute position of the mouse pointer. | 43 // Returns the current absolute position of the mouse pointer. |
33 static gfx::Point GetCursorScreenPoint(); | 44 virtual gfx::Point GetCursorScreenPoint() = 0; |
34 | 45 |
35 // Returns the window under the cursor. | 46 // Returns the window under the cursor. |
36 static gfx::NativeWindow GetWindowAtCursorScreenPoint(); | 47 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() = 0; |
37 | 48 |
38 // Returns the number of displays. | 49 // Returns the number of displays. |
39 // Mirrored displays are excluded; this method is intended to return the | 50 // Mirrored displays are excluded; this method is intended to return the |
40 // number of distinct, usable displays. | 51 // number of distinct, usable displays. |
41 static int GetNumDisplays(); | 52 virtual int GetNumDisplays() = 0; |
42 | 53 |
43 // Returns the display nearest the specified window. | 54 // Returns the display nearest the specified window. |
44 static gfx::Display GetDisplayNearestWindow(gfx::NativeView view); | 55 virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; |
45 | 56 |
46 // Returns the the display nearest the specified point. | 57 // Returns the the display nearest the specified point. |
47 static gfx::Display GetDisplayNearestPoint(const gfx::Point& point); | 58 virtual gfx::Display GetDisplayNearestPoint( |
| 59 const gfx::Point& point) const = 0; |
48 | 60 |
49 // Returns the display that most closely intersects the provided bounds. | 61 // Returns the display that most closely intersects the provided bounds. |
50 static gfx::Display GetDisplayMatching(const gfx::Rect& match_rect); | 62 virtual gfx::Display GetDisplayMatching( |
| 63 const gfx::Rect& match_rect) const = 0; |
51 | 64 |
52 // Returns the primary display. | 65 // Returns the primary display. |
53 static gfx::Display GetPrimaryDisplay(); | 66 virtual gfx::Display GetPrimaryDisplay() const = 0; |
54 | 67 |
55 private: | 68 private: |
56 DISALLOW_IMPLICIT_CONSTRUCTORS(Screen); | 69 DISALLOW_COPY_AND_ASSIGN(Screen); |
57 }; | 70 }; |
58 | 71 |
| 72 Screen* CreateNativeScreen(); |
| 73 |
59 } // namespace gfx | 74 } // namespace gfx |
60 | 75 |
61 #endif // UI_GFX_SCREEN_H_ | 76 #endif // UI_GFX_SCREEN_H_ |
OLD | NEW |