Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/gtk/link_button_gtk.cc

Issue 113970: Paint a focus indication on LinkButtonGtk buttons.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/gtk/link_button_gtk.h ('k') | chrome/common/gtk_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/gtk/link_button_gtk.h" 5 #include "chrome/browser/gtk/link_button_gtk.h"
6 6
7 static const char* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>"; 7 static const char* kLinkMarkup = "<u><span color=\"%s\">%s</span></u>";
8 8
9 namespace { 9 namespace {
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return FALSE; 72 return FALSE;
73 } 73 }
74 74
75 // static 75 // static
76 gboolean LinkButtonGtk::OnLeave(GtkWidget* widget, 76 gboolean LinkButtonGtk::OnLeave(GtkWidget* widget,
77 LinkButtonGtk* link_button) { 77 LinkButtonGtk* link_button) {
78 gdk_window_set_cursor(widget->window, NULL); 78 gdk_window_set_cursor(widget->window, NULL);
79 return FALSE; 79 return FALSE;
80 } 80 }
81 81
82 // TODO(estade): we need some visual indication when this widget is focused.
83 // static 82 // static
84 gboolean LinkButtonGtk::OnExpose(GtkWidget* widget, 83 gboolean LinkButtonGtk::OnExpose(GtkWidget* widget,
85 GdkEventExpose* event, 84 GdkEventExpose* event,
86 LinkButtonGtk* link_button) { 85 LinkButtonGtk* link_button) {
86 GtkWidget* label = link_button->label_;
87
87 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE && link_button->is_blue_) { 88 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE && link_button->is_blue_) {
88 gtk_label_set_markup(GTK_LABEL(link_button->label_), 89 gtk_label_set_markup(GTK_LABEL(label), link_button->red_markup);
89 link_button->red_markup);
90 link_button->is_blue_ = false; 90 link_button->is_blue_ = false;
91 } else if (GTK_WIDGET_STATE(widget) != GTK_STATE_ACTIVE && 91 } else if (GTK_WIDGET_STATE(widget) != GTK_STATE_ACTIVE &&
92 !link_button->is_blue_) { 92 !link_button->is_blue_) {
93 gtk_label_set_markup(GTK_LABEL(link_button->label_), 93 gtk_label_set_markup(GTK_LABEL(label), link_button->blue_markup);
94 link_button->blue_markup);
95 link_button->is_blue_ = true; 94 link_button->is_blue_ = true;
96 } 95 }
97 96
98 // Draw the link inside the button. 97 // Draw the link inside the button.
99 gtk_container_propagate_expose(GTK_CONTAINER(widget), 98 gtk_container_propagate_expose(GTK_CONTAINER(widget), label, event);
100 gtk_bin_get_child(GTK_BIN(widget)), 99
101 event); 100 // Draw the focus rectangle.
101 if (GTK_WIDGET_HAS_FOCUS(widget)) {
102 gtk_paint_focus(widget->style, widget->window,
103 static_cast<GtkStateType>(GTK_WIDGET_STATE(widget)),
104 &event->area, widget, NULL,
105 widget->allocation.x, widget->allocation.y,
106 widget->allocation.width, widget->allocation.height);
107 }
108
102 // Don't let the button draw itself, ever. 109 // Don't let the button draw itself, ever.
103 return TRUE; 110 return TRUE;
104 } 111 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/link_button_gtk.h ('k') | chrome/common/gtk_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698