Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / screen.h
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/gfx_export.h"
13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/point.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   static void SetScreenInstance(ScreenType type, Screen* instance);
41
42   // Returns the global screen for a particular type. Types other than _NATIVE
43   // may be NULL.
44   static Screen* GetScreenByType(ScreenType type);
45
46   // Sets the global ScreenTypeDelegate. May be left unset if the platform
47   // uses only the _NATIVE ScreenType.
48   static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate);
49
50   Screen();
51   virtual ~Screen();
52
53   // Returns the current absolute position of the mouse pointer.
54   virtual gfx::Point GetCursorScreenPoint() = 0;
55
56   // Returns the window under the cursor.
57   virtual gfx::NativeWindow GetWindowUnderCursor() = 0;
58
59   // Returns the window at the given screen coordinate |point|.
60   virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
61
62   // Returns the number of displays.
63   // Mirrored displays are excluded; this method is intended to return the
64   // number of distinct, usable displays.
65   virtual int GetNumDisplays() const = 0;
66
67   // Returns the list of displays that are currently available.
68   virtual std::vector<gfx::Display> GetAllDisplays() const = 0;
69
70   // Returns the display nearest the specified window.
71   // If the window is NULL or the window is not rooted to a display this will
72   // return the primary display.
73   virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0;
74
75   // Returns the display nearest the specified point.
76   virtual gfx::Display GetDisplayNearestPoint(
77       const gfx::Point& point) const = 0;
78
79   // Returns the display that most closely intersects the provided bounds.
80   virtual gfx::Display GetDisplayMatching(
81       const gfx::Rect& match_rect) const = 0;
82
83   // Returns the primary display.
84   virtual gfx::Display GetPrimaryDisplay() const = 0;
85
86   // Adds/Removes display observers.
87   virtual void AddObserver(DisplayObserver* observer) = 0;
88   virtual void RemoveObserver(DisplayObserver* observer) = 0;
89
90  private:
91   DISALLOW_COPY_AND_ASSIGN(Screen);
92 };
93
94 Screen* CreateNativeScreen();
95
96 }  // namespace gfx
97
98 #endif  // UI_GFX_SCREEN_H_