OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <gdk/gdk.h> | 5 #include <gdk/gdk.h> |
6 #include <gtk/gtk.h> | 6 #include <gtk/gtk.h> |
7 | 7 |
8 #include "chrome/common/owned_widget_gtk.h" | 8 #include "chrome/common/owned_widget_gtk.h" |
9 | 9 |
10 // Creates a link button that shows |text| in blue and underlined. The cursor | 10 // Creates a link button that shows |text| in blue and underlined. The cursor |
11 // changes to a hand when over the link. | 11 // changes to a hand when over the link. |
12 // TODO(estade): the link should turn red during the user's click. | 12 // TODO(estade): the link should turn red during the user's click. |
13 class LinkButtonGtk { | 13 class LinkButtonGtk { |
14 public: | 14 public: |
15 explicit LinkButtonGtk(const char* text); | 15 explicit LinkButtonGtk(const char* text); |
16 virtual ~LinkButtonGtk(); | 16 virtual ~LinkButtonGtk(); |
17 | 17 |
18 GtkWidget* widget() { return widget_.get(); } | 18 GtkWidget* widget() { return widget_.get(); } |
19 | 19 |
| 20 GtkWidget* label() { return label_; } |
| 21 |
20 private: | 22 private: |
21 // Called when the pointer enters or leaves the button. | 23 // Called when the pointer enters or leaves the button. |
22 static gboolean OnEnter(GtkWidget* widget, LinkButtonGtk* link_button); | 24 static gboolean OnEnter(GtkWidget* widget, LinkButtonGtk* link_button); |
23 static gboolean OnLeave(GtkWidget* widget, LinkButtonGtk* link_button); | 25 static gboolean OnLeave(GtkWidget* widget, LinkButtonGtk* link_button); |
24 | 26 |
25 // Called when the pointer moves over the link button's gdk window. | 27 // Called when the pointer moves over the link button's gdk window. |
26 static gboolean OnMotionNotify(GtkWidget* widget, | 28 static gboolean OnMotionNotify(GtkWidget* widget, |
27 GdkEventMotion* event, | 29 GdkEventMotion* event, |
28 LinkButtonGtk* link_button); | 30 LinkButtonGtk* link_button); |
29 | 31 |
(...skipping 12 matching lines...) Expand all Loading... |
42 // user mouses over the link. | 44 // user mouses over the link. |
43 GdkCursor* hand_cursor_; | 45 GdkCursor* hand_cursor_; |
44 | 46 |
45 // Text markup for the link. We use the red one when the link is being | 47 // Text markup for the link. We use the red one when the link is being |
46 // clicked. | 48 // clicked. |
47 gchar* blue_markup; | 49 gchar* blue_markup; |
48 gchar* red_markup; | 50 gchar* red_markup; |
49 // The current state of the text. | 51 // The current state of the text. |
50 bool is_blue_; | 52 bool is_blue_; |
51 }; | 53 }; |
OLD | NEW |