| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/link.h" | 5 #include "views/controls/link.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_LINUX) | 9 #if defined(OS_LINUX) |
| 10 #include <gdk/gdk.h> | 10 #include <gdk/gdk.h> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } else { | 56 } else { |
| 57 *highlighted_color = kHighlightedColor; | 57 *highlighted_color = kHighlightedColor; |
| 58 *disabled_color = kDisabledColor; | 58 *disabled_color = kDisabledColor; |
| 59 *normal_color = kNormalColor; | 59 *normal_color = kNormalColor; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 namespace views { | 64 namespace views { |
| 65 | 65 |
| 66 #if defined(OS_WIN) | |
| 67 static HCURSOR g_hand_cursor = NULL; | |
| 68 #endif | |
| 69 | |
| 70 const char Link::kViewClassName[] = "views/Link"; | 66 const char Link::kViewClassName[] = "views/Link"; |
| 71 | 67 |
| 72 Link::Link() : Label(L""), | 68 Link::Link() : Label(L""), |
| 73 listener_(NULL), | 69 listener_(NULL), |
| 74 highlighted_(false) { | 70 highlighted_(false) { |
| 75 Init(); | 71 Init(); |
| 76 SetFocusable(true); | 72 SetFocusable(true); |
| 77 } | 73 } |
| 78 | 74 |
| 79 Link::Link(const std::wstring& title) : Label(title), | 75 Link::Link(const std::wstring& title) : Label(title), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 void Link::GetAccessibleState(ui::AccessibleViewState* state) { | 146 void Link::GetAccessibleState(ui::AccessibleViewState* state) { |
| 151 Label::GetAccessibleState(state); | 147 Label::GetAccessibleState(state); |
| 152 state->role = ui::AccessibilityTypes::ROLE_LINK; | 148 state->role = ui::AccessibilityTypes::ROLE_LINK; |
| 153 } | 149 } |
| 154 | 150 |
| 155 void Link::SetFont(const gfx::Font& font) { | 151 void Link::SetFont(const gfx::Font& font) { |
| 156 Label::SetFont(font); | 152 Label::SetFont(font); |
| 157 ValidateStyle(); | 153 ValidateStyle(); |
| 158 } | 154 } |
| 159 | 155 |
| 160 void Link::SetEnabled(bool f) { | 156 void Link::SetEnabled(bool flag) { |
| 161 if (f != enabled_) { | 157 if (flag != enabled_) { |
| 162 enabled_ = f; | 158 enabled_ = flag; |
| 163 ValidateStyle(); | 159 ValidateStyle(); |
| 164 SchedulePaint(); | 160 SchedulePaint(); |
| 165 } | 161 } |
| 166 } | 162 } |
| 167 | 163 |
| 168 gfx::NativeCursor Link::GetCursorForPoint(ui::EventType event_type, | 164 gfx::NativeCursor Link::GetCursorForPoint(ui::EventType event_type, |
| 169 const gfx::Point& p) { | 165 const gfx::Point& p) { |
| 170 if (!enabled_) | 166 if (!enabled_) |
| 171 return NULL; | 167 return NULL; |
| 172 #if defined(OS_WIN) | 168 #if defined(OS_WIN) |
| 173 if (!g_hand_cursor) | 169 static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND); |
| 174 g_hand_cursor = LoadCursor(NULL, IDC_HAND); | |
| 175 return g_hand_cursor; | 170 return g_hand_cursor; |
| 176 #elif defined(OS_LINUX) | 171 #elif defined(OS_LINUX) |
| 177 return gfx::GetCursor(GDK_HAND2); | 172 return gfx::GetCursor(GDK_HAND2); |
| 178 #endif | 173 #endif |
| 179 } | 174 } |
| 180 | 175 |
| 181 std::string Link::GetClassName() const { | 176 std::string Link::GetClassName() const { |
| 182 return kViewClassName; | 177 return kViewClassName; |
| 183 } | 178 } |
| 184 | 179 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } else { | 215 } else { |
| 221 if (font().GetStyle() & gfx::Font::UNDERLINED) { | 216 if (font().GetStyle() & gfx::Font::UNDERLINED) { |
| 222 Label::SetFont( | 217 Label::SetFont( |
| 223 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); | 218 font().DeriveFont(0, font().GetStyle() & ~gfx::Font::UNDERLINED)); |
| 224 } | 219 } |
| 225 Label::SetColor(disabled_color_); | 220 Label::SetColor(disabled_color_); |
| 226 } | 221 } |
| 227 } | 222 } |
| 228 | 223 |
| 229 } // namespace views | 224 } // namespace views |
| OLD | NEW |