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/basictypes.h" |
| 11 #include "ui/gfx/display.h" |
| 12 #include "ui/gfx/geometry/point.h" |
| 13 #include "ui/gfx/gfx_export.h" |
| 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "ui/gfx/screen_type_delegate.h" |
| 16 |
| 17 namespace gfx { |
| 18 class DisplayObserver; |
| 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 on |
| 26 // most operating systems regardless of the number of connected displays. On |
| 27 // Windows 8, two Screens exist: one for Metro UI and another for the desktop. |
| 28 class GFX_EXPORT Screen { |
| 29 public: |
| 30 // Retrieves the Screen that the specified NativeView belongs to. A value of |
| 31 // NULL is treated as |SCREEN_TYPE_NATIVE|. |
| 32 static Screen* GetScreenFor(NativeView view); |
| 33 |
| 34 // Returns the SCREEN_TYPE_NATIVE Screen. This should be used with caution, |
| 35 // as it is likely to be incorrect for code that runs on Windows. |
| 36 static Screen* GetNativeScreen(); |
| 37 |
| 38 // Sets the global screen for a particular screen type. Only the _NATIVE |
| 39 // ScreenType must be provided. |
| 40 // NOTE: this does not take ownership of |screen|. Tests must be sure to |
| 41 // reset any state they install. |
| 42 static void SetScreenInstance(ScreenType type, Screen* instance); |
| 43 |
| 44 // Returns the global screen for a particular type. Types other than _NATIVE |
| 45 // may be NULL. |
| 46 static Screen* GetScreenByType(ScreenType type); |
| 47 |
| 48 // Sets the global ScreenTypeDelegate. May be left unset if the platform |
| 49 // uses only the _NATIVE ScreenType. |
| 50 // NOTE: this does not take ownership of |delegate|. Tests must be sure to |
| 51 // reset any state they install. |
| 52 static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate); |
| 53 |
| 54 Screen(); |
| 55 virtual ~Screen(); |
| 56 |
| 57 // Returns the current absolute position of the mouse pointer. |
| 58 virtual gfx::Point GetCursorScreenPoint() = 0; |
| 59 |
| 60 // Returns the window under the cursor. |
| 61 virtual gfx::NativeWindow GetWindowUnderCursor() = 0; |
| 62 |
| 63 // Returns the window at the given screen coordinate |point|. |
| 64 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0; |
| 65 |
| 66 // Returns the number of displays. |
| 67 // Mirrored displays are excluded; this method is intended to return the |
| 68 // number of distinct, usable displays. |
| 69 virtual int GetNumDisplays() const = 0; |
| 70 |
| 71 // Returns the list of displays that are currently available. |
| 72 virtual std::vector<gfx::Display> GetAllDisplays() const = 0; |
| 73 |
| 74 // Returns the display nearest the specified window. |
| 75 // If the window is NULL or the window is not rooted to a display this will |
| 76 // return the primary display. |
| 77 virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; |
| 78 |
| 79 // Returns the display nearest the specified point. |point| should be in DIPs. |
| 80 virtual gfx::Display GetDisplayNearestPoint( |
| 81 const gfx::Point& point) const = 0; |
| 82 |
| 83 // Returns the display that most closely intersects the provided bounds. |
| 84 virtual gfx::Display GetDisplayMatching( |
| 85 const gfx::Rect& match_rect) const = 0; |
| 86 |
| 87 // Returns the primary display. |
| 88 virtual gfx::Display GetPrimaryDisplay() const = 0; |
| 89 |
| 90 // Adds/Removes display observers. |
| 91 virtual void AddObserver(DisplayObserver* observer) = 0; |
| 92 virtual void RemoveObserver(DisplayObserver* observer) = 0; |
| 93 |
| 94 private: |
| 95 DISALLOW_COPY_AND_ASSIGN(Screen); |
| 96 }; |
| 97 |
| 98 Screen* CreateNativeScreen(); |
| 99 |
| 100 } // namespace gfx |
| 101 |
| 102 #endif // UI_GFX_SCREEN_H_ |
OLD | NEW |