Index: ash/app_list/search_box_view.cc |
diff --git a/ash/app_list/search_box_view.cc b/ash/app_list/search_box_view.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..75b4cc3d44a131bfd1b8967b8533c9efa241f2c0 |
--- /dev/null |
+++ b/ash/app_list/search_box_view.cc |
@@ -0,0 +1,80 @@ |
+// Copyright (c) 2012 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 "ash/app_list/search_box_view.h" |
+ |
+#include "base/utf_string_conversions.h" |
+#include "grit/ui_resources.h" |
+#include "ui/base/resource/resource_bundle.h" |
+#include "ui/gfx/image/image.h" |
+#include "ui/views/background.h" |
+#include "ui/views/border.h" |
+#include "ui/views/controls/image_view.h" |
+#include "ui/views/controls/textfield/textfield.h" |
+ |
+namespace ash { |
+ |
+namespace { |
+ |
+const int kPadding = 9; |
+ |
+// 0.5 white |
+const SkColor kBorderColor = SkColorSetARGB(0x7F, 0xFF, 0xFF, 0xFF); |
+ |
+// 0.2 white |
+const SkColor kBackgroundColor = SkColorSetARGB(0x33, 0xFF, 0xFF, 0xFF); |
+ |
+// 0.9 white |
+const SkColor kTextColor = SkColorSetARGB(0xE5, 0xFF, 0xFF, 0xFF); |
+ |
+} // namespace |
+ |
+SearchBoxView::SearchBoxView() { |
+ set_border(views::Border::CreateSolidBorder(1, kBorderColor)); |
+ set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
+ |
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
+ |
+ white_search_ = new views::ImageView; |
+ white_search_->SetImage( |
+ *rb.GetImageNamed(IDR_AURA_WHITE_SEARCH).ToSkBitmap()); |
+ AddChildView(white_search_); |
+ |
+ search_box_ = new views::Textfield; |
+ search_box_->RemoveBorder(); |
+ search_box_->SetBackgroundColor(0); // Clear color. |
+ search_box_->SetTextColor(kTextColor); |
+ search_box_->SetFont(rb.GetFont(ResourceBundle::BaseFont).DeriveFont( |
+ 2, gfx::Font::BOLD)); |
+ AddChildView(search_box_); |
+} |
+ |
+std::string SearchBoxView::search_text() const { |
+ return UTF16ToUTF8(search_box_->text()); |
+} |
+ |
+void SearchBoxView::Layout() { |
+ gfx::Rect rect(GetContentsBounds()); |
+ |
+ gfx::Size icon_size = white_search_->GetPreferredSize(); |
+ gfx::Rect icon_frame(rect); |
+ icon_frame.set_width(icon_size.width() + 2 * kPadding); |
+ white_search_->SetBoundsRect(icon_frame); |
+ |
+ gfx::Rect edit_frame(rect); |
+ edit_frame.set_x(icon_frame.right()); |
+ edit_frame.set_width(rect.width() - icon_frame.width() - kPadding); |
+ search_box_->SetBoundsRect(edit_frame); |
+} |
+ |
+void SearchBoxView::ContentsChanged(views::Textfield* sender, |
+ const string16& new_contents) { |
+} |
+ |
+bool SearchBoxView::HandleKeyEvent(views::Textfield* sender, |
+ const views::KeyEvent& key_event) { |
+ return false; |
+} |
+ |
+} // namespace ash |