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/base/cursor/cursor_loader_win.h" | 5 #include "ui/base/cursor/cursor_loader_win.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "grit/ui_unscaled_resources.h" | 9 #include "grit/ui_unscaled_resources.h" |
10 | |
11 #if defined(USE_AURA) | |
12 #include "ui/base/cursor/cursor.h" | 10 #include "ui/base/cursor/cursor.h" |
13 #endif | |
14 | 11 |
15 namespace ui { | 12 namespace ui { |
16 | 13 |
17 #if defined(USE_AURA) | |
18 | |
19 namespace { | 14 namespace { |
20 | 15 |
21 base::LazyInstance<base::string16> g_cursor_resource_module_name; | 16 base::LazyInstance<base::string16> g_cursor_resource_module_name; |
22 | 17 |
23 const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) { | 18 const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) { |
24 switch (native_cursor.native_type()) { | 19 switch (native_cursor.native_type()) { |
25 case kCursorNull: | 20 case kCursorNull: |
26 return IDC_ARROW; | 21 return IDC_ARROW; |
27 case kCursorPointer: | 22 case kCursorPointer: |
28 return IDC_ARROW; | 23 return IDC_ARROW; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
114 return IDC_ARROW; | 109 return IDC_ARROW; |
115 default: | 110 default: |
116 NOTREACHED(); | 111 NOTREACHED(); |
117 return IDC_ARROW; | 112 return IDC_ARROW; |
118 } | 113 } |
119 } | 114 } |
120 | 115 |
121 } // namespace | 116 } // namespace |
122 | 117 |
123 #endif | |
124 | |
125 CursorLoader* CursorLoader::Create() { | 118 CursorLoader* CursorLoader::Create() { |
126 return new CursorLoaderWin; | 119 return new CursorLoaderWin; |
127 } | 120 } |
128 | 121 |
129 CursorLoaderWin::CursorLoaderWin() { | 122 CursorLoaderWin::CursorLoaderWin() { |
130 } | 123 } |
131 | 124 |
132 CursorLoaderWin::~CursorLoaderWin() { | 125 CursorLoaderWin::~CursorLoaderWin() { |
133 } | 126 } |
134 | 127 |
135 void CursorLoaderWin::LoadImageCursor(int id, | 128 void CursorLoaderWin::LoadImageCursor(int id, |
136 int resource_id, | 129 int resource_id, |
137 const gfx::Point& hot) { | 130 const gfx::Point& hot) { |
138 // NOTIMPLEMENTED(); | 131 // NOTIMPLEMENTED(); |
139 } | 132 } |
140 | 133 |
141 void CursorLoaderWin::LoadAnimatedCursor(int id, | 134 void CursorLoaderWin::LoadAnimatedCursor(int id, |
142 int resource_id, | 135 int resource_id, |
143 const gfx::Point& hot, | 136 const gfx::Point& hot, |
144 int frame_delay_ms) { | 137 int frame_delay_ms) { |
145 // NOTIMPLEMENTED(); | 138 // NOTIMPLEMENTED(); |
146 } | 139 } |
147 | 140 |
148 void CursorLoaderWin::UnloadAll() { | 141 void CursorLoaderWin::UnloadAll() { |
149 // NOTIMPLEMENTED(); | 142 // NOTIMPLEMENTED(); |
150 } | 143 } |
151 | 144 |
152 void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) { | 145 void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) { |
153 #if defined(USE_AURA) | |
154 if (cursor->native_type() != kCursorCustom) { | 146 if (cursor->native_type() != kCursorCustom) { |
155 if (cursor->platform()) { | 147 if (cursor->platform()) { |
156 cursor->SetPlatformCursor(cursor->platform()); | 148 cursor->SetPlatformCursor(cursor->platform()); |
157 } else { | 149 } else { |
158 const wchar_t* cursor_id = GetCursorId(*cursor); | 150 const wchar_t* cursor_id = GetCursorId(*cursor); |
159 PlatformCursor platform_cursor = LoadCursor(NULL, cursor_id); | 151 PlatformCursor platform_cursor = LoadCursor(NULL, cursor_id); |
160 if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) { | 152 if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) { |
161 platform_cursor = LoadCursor( | 153 platform_cursor = LoadCursor( |
162 GetModuleHandle(g_cursor_resource_module_name.Get().c_str()), | 154 GetModuleHandle(g_cursor_resource_module_name.Get().c_str()), |
163 cursor_id); | 155 cursor_id); |
164 } | 156 } |
165 cursor->SetPlatformCursor(platform_cursor); | 157 cursor->SetPlatformCursor(platform_cursor); |
166 } | 158 } |
167 } | 159 } |
168 #endif | |
169 } | 160 } |
170 | 161 |
171 #if defined(USE_AURA) | |
172 // static | 162 // static |
173 void CursorLoaderWin::SetCursorResourceModule( | 163 void CursorLoaderWin::SetCursorResourceModule( |
174 const base::string16& module_name) { | 164 const base::string16& module_name) { |
175 g_cursor_resource_module_name.Get() = module_name; | 165 g_cursor_resource_module_name.Get() = module_name; |
176 } | 166 } |
177 #endif | |
178 | 167 |
179 } // namespace ui | 168 } // namespace ui |
OLD | NEW |