Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / views / controls / link.h
blobfb577c8256b05ea8f90b8899425a21f541febbc9
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_
8 #include <string>
10 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/views/controls/label.h"
13 namespace views {
15 class LinkListener;
17 ////////////////////////////////////////////////////////////////////////////////
19 // Link class
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 {
26 public:
27 Link();
28 explicit Link(const base::string16& title);
29 ~Link() override;
31 const LinkListener* listener() { return listener_; }
32 void set_listener(LinkListener* listener) { listener_ = listener; }
34 // Label:
35 const char* GetClassName() const override;
36 gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
37 bool CanProcessEventsWithinSubtree() const override;
38 bool OnMousePressed(const ui::MouseEvent& event) override;
39 bool OnMouseDragged(const ui::MouseEvent& event) override;
40 void OnMouseReleased(const ui::MouseEvent& event) override;
41 void OnMouseCaptureLost() override;
42 bool OnKeyPressed(const ui::KeyEvent& event) override;
43 void OnGestureEvent(ui::GestureEvent* event) override;
44 bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) override;
45 void GetAccessibleState(ui::AXViewState* state) override;
46 void OnEnabledChanged() override;
47 void OnFocus() override;
48 void OnBlur() override;
49 void SetFontList(const gfx::FontList& font_list) override;
50 void SetText(const base::string16& text) override;
51 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
52 void SetEnabledColor(SkColor color) override;
54 void SetPressedColor(SkColor color);
55 void SetUnderline(bool underline);
57 static const char kViewClassName[];
59 private:
60 void Init();
62 void SetPressed(bool pressed);
64 void RecalculateFont();
66 SkColor GetEnabledColor();
67 SkColor GetPressedColor();
69 LinkListener* listener_;
71 // Whether the link should be underlined when enabled.
72 bool underline_;
74 // Whether the link is currently pressed.
75 bool pressed_;
77 // The color when the link is neither pressed nor disabled.
78 SkColor requested_enabled_color_;
79 bool requested_enabled_color_set_;
81 // The color when the link is pressed.
82 SkColor requested_pressed_color_;
83 bool requested_pressed_color_set_;
85 DISALLOW_COPY_AND_ASSIGN(Link);
88 } // namespace views
90 #endif // UI_VIEWS_CONTROLS_LINK_H_