| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/base/gtk/tooltip_window_gtk.h" | 5 #include "ui/base/gtk/tooltip_window_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 gtk_label_set_line_wrap(GTK_LABEL(label_), TRUE); | 57 gtk_label_set_line_wrap(GTK_LABEL(label_), TRUE); |
| 58 gtk_container_add(GTK_CONTAINER(alignment_), label_); | 58 gtk_container_add(GTK_CONTAINER(alignment_), label_); |
| 59 gtk_widget_show(label_); | 59 gtk_widget_show(label_); |
| 60 | 60 |
| 61 // Associates the tooltip window with given widget | 61 // Associates the tooltip window with given widget |
| 62 gtk_widget_set_tooltip_window(host_, GTK_WINDOW(window_)); | 62 gtk_widget_set_tooltip_window(host_, GTK_WINDOW(window_)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Paints our customized tooltip window. | 65 // Paints our customized tooltip window. |
| 66 gboolean TooltipWindowGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { | 66 gboolean TooltipWindowGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) { |
| 67 gtk_paint_flat_box(widget->style, | 67 GtkAllocation allocation; |
| 68 widget->window, | 68 gtk_widget_get_allocation(widget, &allocation); |
| 69 gtk_paint_flat_box(gtk_widget_get_style(widget), |
| 70 gtk_widget_get_window(widget), |
| 69 GTK_STATE_NORMAL, | 71 GTK_STATE_NORMAL, |
| 70 GTK_SHADOW_OUT, | 72 GTK_SHADOW_OUT, |
| 71 NULL, | 73 NULL, |
| 72 widget, | 74 widget, |
| 73 "tooltip", | 75 "tooltip", |
| 74 0, 0, | 76 0, 0, |
| 75 widget->allocation.width, | 77 allocation.width, |
| 76 widget->allocation.height); | 78 allocation.height); |
| 77 | 79 |
| 78 return FALSE; | 80 return FALSE; |
| 79 } | 81 } |
| 80 | 82 |
| 81 // Style change handler. | 83 // Style change handler. |
| 82 void TooltipWindowGtk::OnStyleSet(GtkWidget* widget, | 84 void TooltipWindowGtk::OnStyleSet(GtkWidget* widget, |
| 83 GtkStyle* previous_style) { | 85 GtkStyle* previous_style) { |
| 86 GtkStyle* style = gtk_widget_get_style(widget); |
| 84 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), | 87 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_), |
| 85 widget->style->ythickness, | 88 style->ythickness, |
| 86 widget->style->ythickness, | 89 style->ythickness, |
| 87 widget->style->xthickness, | 90 style->xthickness, |
| 88 widget->style->xthickness); | 91 style->xthickness); |
| 89 | 92 |
| 90 gtk_widget_queue_draw(widget); | 93 gtk_widget_queue_draw(widget); |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace ui | 96 } // namespace ui |
| OLD | NEW |