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.
5 #ifndef UI_VIEWS_CONTROLS_LINK_H_
6 #define UI_VIEWS_CONTROLS_LINK_H_
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/views/controls/label.h"
17 ////////////////////////////////////////////////////////////////////////////////
21 // A Link is a label subclass that looks like an HTML link. It has a
22 // controller which is notified when a click occurs.
24 ////////////////////////////////////////////////////////////////////////////////
25 class VIEWS_EXPORT Link
: public Label
{
28 explicit Link(const base::string16
& title
);
31 static SkColor
GetDefaultEnabledColor();
33 const LinkListener
* listener() { return listener_
; }
34 void set_listener(LinkListener
* listener
) { listener_
= listener
; }
37 const char* GetClassName() const override
;
38 gfx::NativeCursor
GetCursor(const ui::MouseEvent
& event
) override
;
39 bool CanProcessEventsWithinSubtree() const override
;
40 bool OnMousePressed(const ui::MouseEvent
& event
) override
;
41 bool OnMouseDragged(const ui::MouseEvent
& event
) override
;
42 void OnMouseReleased(const ui::MouseEvent
& event
) override
;
43 void OnMouseCaptureLost() override
;
44 bool OnKeyPressed(const ui::KeyEvent
& event
) override
;
45 void OnGestureEvent(ui::GestureEvent
* event
) override
;
46 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent
& event
) override
;
47 void GetAccessibleState(ui::AXViewState
* state
) override
;
48 void OnEnabledChanged() override
;
49 void OnFocus() override
;
50 void OnBlur() override
;
51 void SetFontList(const gfx::FontList
& font_list
) override
;
52 void SetText(const base::string16
& text
) override
;
53 void SetEnabledColor(SkColor color
) override
;
55 void SetPressedColor(SkColor color
);
56 void SetUnderline(bool underline
);
58 static const char kViewClassName
[];
63 void SetPressed(bool pressed
);
65 void RecalculateFont();
67 LinkListener
* listener_
;
69 // Whether the link should be underlined when enabled.
72 // Whether the link is currently pressed.
75 // The color when the link is neither pressed nor disabled.
76 SkColor requested_enabled_color_
;
78 // The color when the link is pressed.
79 SkColor requested_pressed_color_
;
81 DISALLOW_COPY_AND_ASSIGN(Link
);
86 #endif // UI_VIEWS_CONTROLS_LINK_H_