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 "chrome/browser/ui/gtk/find_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
20 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 20 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
21 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 21 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
22 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 22 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
23 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 23 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
24 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" | |
25 #include "chrome/browser/ui/gtk/custom_button.h" | 24 #include "chrome/browser/ui/gtk/custom_button.h" |
26 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 25 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
27 #include "chrome/browser/ui/gtk/gtk_util.h" | 26 #include "chrome/browser/ui/gtk/gtk_util.h" |
28 #include "chrome/browser/ui/gtk/nine_box.h" | 27 #include "chrome/browser/ui/gtk/nine_box.h" |
29 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 28 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
30 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" | 29 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h" |
31 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" | 30 #include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h" |
32 #include "chrome/browser/ui/gtk/view_id_util.h" | 31 #include "chrome/browser/ui/gtk/view_id_util.h" |
33 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 32 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
34 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
35 #include "content/browser/renderer_host/render_view_host.h" | 34 #include "content/browser/renderer_host/render_view_host.h" |
36 #include "content/browser/tab_contents/tab_contents.h" | 35 #include "content/browser/tab_contents/tab_contents.h" |
37 #include "content/public/browser/notification_source.h" | 36 #include "content/public/browser/notification_source.h" |
38 #include "content/public/browser/native_web_keyboard_event.h" | 37 #include "content/public/browser/native_web_keyboard_event.h" |
39 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
40 #include "grit/theme_resources.h" | 39 #include "grit/theme_resources.h" |
41 #include "grit/theme_resources_standard.h" | 40 #include "grit/theme_resources_standard.h" |
42 #include "ui/base/gtk/gtk_floating_container.h" | 41 #include "ui/base/gtk/gtk_floating_container.h" |
43 #include "ui/base/gtk/gtk_hig_constants.h" | 42 #include "ui/base/gtk/gtk_hig_constants.h" |
44 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
45 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
| 45 #include "ui/gfx/image/cairo_cached_surface.h" |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 // Used as the color of the text in the entry box and the text for the results | 49 // Used as the color of the text in the entry box and the text for the results |
50 // label for failure searches. | 50 // label for failure searches. |
51 const GdkColor& kEntryTextColor = ui::kGdkBlack; | 51 const GdkColor& kEntryTextColor = ui::kGdkBlack; |
52 | 52 |
53 // Used as the color of the background of the entry box and the background of | 53 // Used as the color of the background of the entry box and the background of |
54 // the find label for successful searches. | 54 // the find label for successful searches. |
55 const GdkColor& kEntryBackgroundColor = ui::kGdkWhite; | 55 const GdkColor& kEntryBackgroundColor = ui::kGdkWhite; |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin, | 881 gtk_util::DrawThemedToolbarBackground(widget, cr, e, tabstrip_origin, |
882 bar->theme_service_); | 882 bar->theme_service_); |
883 | 883 |
884 // During chrome theme mode, we need to draw the border around content_hbox | 884 // During chrome theme mode, we need to draw the border around content_hbox |
885 // now instead of when we render |border_bin_|. We don't use stacked event | 885 // now instead of when we render |border_bin_|. We don't use stacked event |
886 // boxes to simulate the effect because we need to blend them with this | 886 // boxes to simulate the effect because we need to blend them with this |
887 // background. | 887 // background. |
888 GtkAllocation border_allocation = bar->border_bin_->allocation; | 888 GtkAllocation border_allocation = bar->border_bin_->allocation; |
889 | 889 |
890 // Blit the left part of the background image once on the left. | 890 // Blit the left part of the background image once on the left. |
891 CairoCachedSurface* background_left = | 891 gfx::CairoCachedSurface* background_left = |
892 bar->theme_service_->GetRTLEnabledSurfaceNamed( | 892 bar->theme_service_->GetRTLEnabledSurfaceNamed( |
893 IDR_FIND_BOX_BACKGROUND_LEFT, widget); | 893 IDR_FIND_BOX_BACKGROUND_LEFT, widget); |
894 background_left->SetSource(cr, border_allocation.x, border_allocation.y); | 894 background_left->SetSource(cr, widget, |
| 895 border_allocation.x, border_allocation.y); |
895 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); | 896 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
896 cairo_rectangle(cr, border_allocation.x, border_allocation.y, | 897 cairo_rectangle(cr, border_allocation.x, border_allocation.y, |
897 background_left->Width(), background_left->Height()); | 898 background_left->Width(), background_left->Height()); |
898 cairo_fill(cr); | 899 cairo_fill(cr); |
899 | 900 |
900 // Blit the center part of the background image in all the space between. | 901 // Blit the center part of the background image in all the space between. |
901 CairoCachedSurface* background = bar->theme_service_->GetSurfaceNamed( | 902 gfx::CairoCachedSurface* background = bar->theme_service_->GetSurfaceNamed( |
902 IDR_FIND_BOX_BACKGROUND, widget); | 903 IDR_FIND_BOX_BACKGROUND, widget); |
903 background->SetSource(cr, | 904 background->SetSource(cr, widget, |
904 border_allocation.x + background_left->Width(), | 905 border_allocation.x + background_left->Width(), |
905 border_allocation.y); | 906 border_allocation.y); |
906 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); | 907 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
907 cairo_rectangle(cr, | 908 cairo_rectangle(cr, |
908 border_allocation.x + background_left->Width(), | 909 border_allocation.x + background_left->Width(), |
909 border_allocation.y, | 910 border_allocation.y, |
910 border_allocation.width - background_left->Width(), | 911 border_allocation.width - background_left->Width(), |
911 background->Height()); | 912 background->Height()); |
912 cairo_fill(cr); | 913 cairo_fill(cr); |
913 | 914 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 return FALSE; // Continue propagation. | 973 return FALSE; // Continue propagation. |
973 } | 974 } |
974 | 975 |
975 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { | 976 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { |
976 g_signal_handlers_disconnect_by_func( | 977 g_signal_handlers_disconnect_by_func( |
977 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), | 978 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), |
978 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); | 979 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); |
979 | 980 |
980 return FALSE; // Continue propagation. | 981 return FALSE; // Continue propagation. |
981 } | 982 } |
OLD | NEW |