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 #include "ui/gfx/screen.h" | 5 #include "ui/gfx/screen.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/gfx/display.h" | 10 #include "ui/gfx/display.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class ScreenIos : public gfx::Screen { | 14 class ScreenIos : public gfx::Screen { |
15 virtual bool IsDIPEnabled() OVERRIDE { | 15 virtual bool IsDIPEnabled() override { |
16 return true; | 16 return true; |
17 } | 17 } |
18 | 18 |
19 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { | 19 virtual gfx::Point GetCursorScreenPoint() override { |
20 NOTIMPLEMENTED(); | 20 NOTIMPLEMENTED(); |
21 return gfx::Point(0, 0); | 21 return gfx::Point(0, 0); |
22 } | 22 } |
23 | 23 |
24 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { | 24 virtual gfx::NativeWindow GetWindowUnderCursor() override { |
25 NOTIMPLEMENTED(); | 25 NOTIMPLEMENTED(); |
26 return gfx::NativeWindow(); | 26 return gfx::NativeWindow(); |
27 } | 27 } |
28 | 28 |
29 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) | 29 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) |
30 OVERRIDE { | 30 override { |
31 NOTIMPLEMENTED(); | 31 NOTIMPLEMENTED(); |
32 return gfx::NativeWindow(); | 32 return gfx::NativeWindow(); |
33 } | 33 } |
34 | 34 |
35 virtual int GetNumDisplays() const OVERRIDE { | 35 virtual int GetNumDisplays() const override { |
36 #if TARGET_IPHONE_SIMULATOR | 36 #if TARGET_IPHONE_SIMULATOR |
37 // UIScreen does not reliably return correct results on the simulator. | 37 // UIScreen does not reliably return correct results on the simulator. |
38 return 1; | 38 return 1; |
39 #else | 39 #else |
40 return [[UIScreen screens] count]; | 40 return [[UIScreen screens] count]; |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
44 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { | 44 virtual std::vector<gfx::Display> GetAllDisplays() const override { |
45 NOTIMPLEMENTED(); | 45 NOTIMPLEMENTED(); |
46 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); | 46 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); |
47 } | 47 } |
48 | 48 |
49 // Returns the display nearest the specified window. | 49 // Returns the display nearest the specified window. |
50 virtual gfx::Display GetDisplayNearestWindow( | 50 virtual gfx::Display GetDisplayNearestWindow( |
51 gfx::NativeView view) const OVERRIDE { | 51 gfx::NativeView view) const override { |
52 NOTIMPLEMENTED(); | 52 NOTIMPLEMENTED(); |
53 return gfx::Display(); | 53 return gfx::Display(); |
54 } | 54 } |
55 | 55 |
56 // Returns the the display nearest the specified point. | 56 // Returns the the display nearest the specified point. |
57 virtual gfx::Display GetDisplayNearestPoint( | 57 virtual gfx::Display GetDisplayNearestPoint( |
58 const gfx::Point& point) const OVERRIDE { | 58 const gfx::Point& point) const override { |
59 NOTIMPLEMENTED(); | 59 NOTIMPLEMENTED(); |
60 return gfx::Display(); | 60 return gfx::Display(); |
61 } | 61 } |
62 | 62 |
63 // Returns the display that most closely intersects the provided bounds. | 63 // Returns the display that most closely intersects the provided bounds. |
64 virtual gfx::Display GetDisplayMatching( | 64 virtual gfx::Display GetDisplayMatching( |
65 const gfx::Rect& match_rect) const OVERRIDE { | 65 const gfx::Rect& match_rect) const override { |
66 NOTIMPLEMENTED(); | 66 NOTIMPLEMENTED(); |
67 return gfx::Display(); | 67 return gfx::Display(); |
68 } | 68 } |
69 | 69 |
70 // Returns the primary display. | 70 // Returns the primary display. |
71 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { | 71 virtual gfx::Display GetPrimaryDisplay() const override { |
72 UIScreen* mainScreen = [UIScreen mainScreen]; | 72 UIScreen* mainScreen = [UIScreen mainScreen]; |
73 CHECK(mainScreen); | 73 CHECK(mainScreen); |
74 gfx::Display display(0, gfx::Rect(mainScreen.bounds)); | 74 gfx::Display display(0, gfx::Rect(mainScreen.bounds)); |
75 display.set_device_scale_factor([mainScreen scale]); | 75 display.set_device_scale_factor([mainScreen scale]); |
76 return display; | 76 return display; |
77 } | 77 } |
78 | 78 |
79 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE { | 79 virtual void AddObserver(gfx::DisplayObserver* observer) override { |
80 // no display change on iOS. | 80 // no display change on iOS. |
81 } | 81 } |
82 | 82 |
83 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE { | 83 virtual void RemoveObserver(gfx::DisplayObserver* observer) override { |
84 // no display change on iOS. | 84 // no display change on iOS. |
85 } | 85 } |
86 }; | 86 }; |
87 | 87 |
88 } // namespace | 88 } // namespace |
89 | 89 |
90 namespace gfx { | 90 namespace gfx { |
91 | 91 |
92 Screen* CreateNativeScreen() { | 92 Screen* CreateNativeScreen() { |
93 return new ScreenIos; | 93 return new ScreenIos; |
94 } | 94 } |
95 | 95 |
96 } // namespace gfx | 96 } // namespace gfx |
OLD | NEW |