blob: 745c94395d95a92f7b6743387b36e801ade779f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "chrome/common/owned_widget_gtk.h"
// Creates a link button that shows |text| in blue and underlined. The cursor
// changes to a hand when over the link.
// TODO(estade): the link should turn red during the user's click.
class LinkButtonGtk {
public:
explicit LinkButtonGtk(const char* text);
virtual ~LinkButtonGtk();
GtkWidget* widget() { return widget_.get(); }
private:
// Called when the pointer enters or leaves the button.
static gboolean OnEnter(GtkWidget* widget, LinkButtonGtk* link_button);
static gboolean OnLeave(GtkWidget* widget, LinkButtonGtk* link_button);
// Called when the pointer moves over the link button's gdk window.
static gboolean OnMotionNotify(GtkWidget* widget,
GdkEventMotion* event,
LinkButtonGtk* link_button);
// Called when the widget is exposed.
static gboolean OnExpose(GtkWidget* widget,
GdkEventExpose* event,
LinkButtonGtk* link_button);
// The button widget.
OwnedWidgetGtk widget_;
// The text widget.
GtkWidget* label_;
// We keep this hand cursor so we don't have to recreate it every time the
// user mouses over the link.
GdkCursor* hand_cursor_;
// Text markup for the link. We use the red one when the link is being
// clicked.
gchar* blue_markup;
gchar* red_markup;
// The current state of the text.
bool is_blue_;
};
|