| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/find_bar_view.h" | 5 #include "chrome/browser/views/find_bar_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_theme_provider.h" | 14 #include "chrome/browser/browser_theme_provider.h" |
| 15 #include "chrome/browser/find_bar_controller.h" | 15 #include "chrome/browser/find_bar_controller.h" |
| 16 #include "chrome/browser/find_bar_state.h" | 16 #include "chrome/browser/find_bar_state.h" |
| 17 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/tab_contents/tab_contents.h" | 18 #include "chrome/browser/tab_contents/tab_contents.h" |
| 19 #include "chrome/browser/views/find_bar_host.h" | 19 #include "chrome/browser/views/find_bar_host.h" |
| 20 #include "chrome/browser/views/frame/browser_view.h" |
| 20 #include "chrome/browser/view_ids.h" | 21 #include "chrome/browser/view_ids.h" |
| 21 #include "gfx/canvas.h" | 22 #include "gfx/canvas.h" |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 24 #include "third_party/skia/include/effects/SkGradientShader.h" | 25 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 25 #include "views/background.h" | 26 #include "views/background.h" |
| 26 #include "views/controls/button/image_button.h" | 27 #include "views/controls/button/image_button.h" |
| 27 #include "views/controls/label.h" | 28 #include "views/controls/label.h" |
| 29 #include "views/widget/widget.h" |
| 28 | 30 |
| 29 // The amount of whitespace to have before the find button. | 31 // The amount of whitespace to have before the find button. |
| 30 static const int kWhiteSpaceAfterMatchCountLabel = 1; | 32 static const int kWhiteSpaceAfterMatchCountLabel = 1; |
| 31 | 33 |
| 32 // The margins around the search field and the close button. | 34 // The margins around the search field and the close button. |
| 33 static const int kMarginLeftOfCloseButton = 3; | 35 static const int kMarginLeftOfCloseButton = 3; |
| 34 static const int kMarginRightOfCloseButton = 7; | 36 static const int kMarginRightOfCloseButton = 7; |
| 35 static const int kMarginLeftOfFindTextfield = 12; | 37 static const int kMarginLeftOfFindTextfield = 12; |
| 36 | 38 |
| 37 // The margins around the match count label (We add extra space so that the | 39 // The margins around the match count label (We add extra space so that the |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 if (select_all && !find_text_->text().empty()) | 227 if (select_all && !find_text_->text().empty()) |
| 226 find_text_->SelectAll(); | 228 find_text_->SelectAll(); |
| 227 } | 229 } |
| 228 | 230 |
| 229 /////////////////////////////////////////////////////////////////////////////// | 231 /////////////////////////////////////////////////////////////////////////////// |
| 230 // FindBarView, views::View overrides: | 232 // FindBarView, views::View overrides: |
| 231 | 233 |
| 232 void FindBarView::Paint(gfx::Canvas* canvas) { | 234 void FindBarView::Paint(gfx::Canvas* canvas) { |
| 233 SkPaint paint; | 235 SkPaint paint; |
| 234 | 236 |
| 237 // Determine the find bar size as well as the offset from which to tile the |
| 238 // toolbar background image. First, get the widget bounds. |
| 239 gfx::Rect bounds; |
| 240 GetWidget()->GetBounds(&bounds, true); |
| 241 // Now convert from screen to parent coordinates. |
| 242 gfx::Point origin(bounds.origin()); |
| 243 BrowserView* browser_view = host()->browser_view(); |
| 244 ConvertPointToView(NULL, browser_view, &origin); |
| 245 bounds.set_origin(origin); |
| 246 // Finally, calculate the background image tiling offset. |
| 247 origin = browser_view->OffsetPointForToolbarBackgroundImage(origin); |
| 248 |
| 235 // First, we draw the background image for the whole dialog (3 images: left, | 249 // First, we draw the background image for the whole dialog (3 images: left, |
| 236 // middle and right). Note, that the window region has been set by the | 250 // middle and right). Note, that the window region has been set by the |
| 237 // controller, so the whitespace in the left and right background images is | 251 // controller, so the whitespace in the left and right background images is |
| 238 // actually outside the window region and is therefore not drawn. See | 252 // actually outside the window region and is therefore not drawn. See |
| 239 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details. | 253 // FindInPageWidgetWin::CreateRoundedWindowEdges() for details. |
| 240 ThemeProvider* tp = GetThemeProvider(); | 254 ThemeProvider* tp = GetThemeProvider(); |
| 241 gfx::Rect bounds; | 255 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), origin.x(), |
| 242 host()->GetThemePosition(&bounds); | 256 origin.y(), 0, 0, bounds.width(), bounds.height()); |
| 243 canvas->TileImageInt(*tp->GetBitmapNamed(IDR_THEME_TOOLBAR), bounds.x(), | |
| 244 bounds.y(), 0, 0, bounds.width(), bounds.height()); | |
| 245 | 257 |
| 246 // Now flip the canvas for the rest of the graphics if in RTL mode. | 258 // Now flip the canvas for the rest of the graphics if in RTL mode. |
| 247 canvas->Save(); | 259 canvas->Save(); |
| 248 if (base::i18n::IsRTL()) { | 260 if (base::i18n::IsRTL()) { |
| 249 canvas->TranslateInt(width(), 0); | 261 canvas->TranslateInt(width(), 0); |
| 250 canvas->ScaleInt(-1, 1); | 262 canvas->ScaleInt(-1, 1); |
| 251 } | 263 } |
| 252 | 264 |
| 253 canvas->DrawBitmapInt(*kDialog_left, 0, 0); | 265 canvas->DrawBitmapInt(*kDialog_left, 0, 0); |
| 254 | 266 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 517 |
| 506 void FindBarView::OnThemeChanged() { | 518 void FindBarView::OnThemeChanged() { |
| 507 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 519 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 508 if (GetThemeProvider()) { | 520 if (GetThemeProvider()) { |
| 509 close_button_->SetBackground( | 521 close_button_->SetBackground( |
| 510 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 522 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
| 511 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 523 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
| 512 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 524 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
| 513 } | 525 } |
| 514 } | 526 } |
| OLD | NEW |