OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/gfx/chrome_font.h" | 7 #include "app/gfx/chrome_font.h" |
8 #include "views/event.h" | 8 #include "views/event.h" |
9 | 9 |
10 namespace views { | 10 namespace views { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 void Link::SetHighlighted(bool f) { | 125 void Link::SetHighlighted(bool f) { |
126 if (f != highlighted_) { | 126 if (f != highlighted_) { |
127 highlighted_ = f; | 127 highlighted_ = f; |
128 ValidateStyle(); | 128 ValidateStyle(); |
129 SchedulePaint(); | 129 SchedulePaint(); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 void Link::ValidateStyle() { | 133 void Link::ValidateStyle() { |
134 ChromeFont font = GetFont(); | 134 gfx::Font font = GetFont(); |
135 | 135 |
136 if (enabled_) { | 136 if (enabled_) { |
137 if ((font.style() & ChromeFont::UNDERLINED) == 0) { | 137 if ((font.style() & gfx::Font::UNDERLINED) == 0) { |
138 Label::SetFont(font.DeriveFont(0, font.style() | | 138 Label::SetFont(font.DeriveFont(0, font.style() | |
139 ChromeFont::UNDERLINED)); | 139 gfx::Font::UNDERLINED)); |
140 } | 140 } |
141 } else { | 141 } else { |
142 if ((font.style() & ChromeFont::UNDERLINED) != 0) { | 142 if ((font.style() & gfx::Font::UNDERLINED) != 0) { |
143 Label::SetFont(font.DeriveFont(0, font.style() & | 143 Label::SetFont(font.DeriveFont(0, font.style() & |
144 ~ChromeFont::UNDERLINED)); | 144 ~gfx::Font::UNDERLINED)); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 if (enabled_) { | 148 if (enabled_) { |
149 if (highlighted_) { | 149 if (highlighted_) { |
150 Label::SetColor(highlighted_color_); | 150 Label::SetColor(highlighted_color_); |
151 } else { | 151 } else { |
152 Label::SetColor(normal_color_); | 152 Label::SetColor(normal_color_); |
153 } | 153 } |
154 } else { | 154 } else { |
155 Label::SetColor(disabled_color_); | 155 Label::SetColor(disabled_color_); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 void Link::SetFont(const ChromeFont& font) { | 159 void Link::SetFont(const gfx::Font& font) { |
160 Label::SetFont(font); | 160 Label::SetFont(font); |
161 ValidateStyle(); | 161 ValidateStyle(); |
162 } | 162 } |
163 | 163 |
164 void Link::SetEnabled(bool f) { | 164 void Link::SetEnabled(bool f) { |
165 if (f != enabled_) { | 165 if (f != enabled_) { |
166 enabled_ = f; | 166 enabled_ = f; |
167 ValidateStyle(); | 167 ValidateStyle(); |
168 SchedulePaint(); | 168 SchedulePaint(); |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 HCURSOR Link::GetCursorForPoint(Event::EventType event_type, int x, int y) { | 172 HCURSOR Link::GetCursorForPoint(Event::EventType event_type, int x, int y) { |
173 if (enabled_) { | 173 if (enabled_) { |
174 if (!g_hand_cursor) { | 174 if (!g_hand_cursor) { |
175 g_hand_cursor = LoadCursor(NULL, IDC_HAND); | 175 g_hand_cursor = LoadCursor(NULL, IDC_HAND); |
176 } | 176 } |
177 return g_hand_cursor; | 177 return g_hand_cursor; |
178 } else { | 178 } else { |
179 return NULL; | 179 return NULL; |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 } // namespace views | 183 } // namespace views |
OLD | NEW |