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/views/find_bar_view.h" | 5 #include "chrome/browser/ui/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" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 find_next_button_(NULL), | 95 find_next_button_(NULL), |
96 close_button_(NULL) { | 96 close_button_(NULL) { |
97 SetID(VIEW_ID_FIND_IN_PAGE); | 97 SetID(VIEW_ID_FIND_IN_PAGE); |
98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 98 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
99 | 99 |
100 find_text_ = new views::Textfield(); | 100 find_text_ = new views::Textfield(); |
101 find_text_->SetID(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 101 find_text_->SetID(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
102 find_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); | 102 find_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); |
103 find_text_->set_default_width_in_chars(kDefaultCharWidth); | 103 find_text_->set_default_width_in_chars(kDefaultCharWidth); |
104 find_text_->SetController(this); | 104 find_text_->SetController(this); |
105 find_text_->SetAccessibleName( | 105 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); |
106 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND))); | |
107 AddChildView(find_text_); | 106 AddChildView(find_text_); |
108 | 107 |
109 match_count_text_ = new views::Label(); | 108 match_count_text_ = new views::Label(); |
110 match_count_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); | 109 match_count_text_->SetFont(rb.GetFont(ResourceBundle::BaseFont)); |
111 match_count_text_->SetColor(kTextColorMatchCount); | 110 match_count_text_->SetColor(kTextColorMatchCount); |
112 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); | 111 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); |
113 AddChildView(match_count_text_); | 112 AddChildView(match_count_text_); |
114 | 113 |
115 // Create a focus forwarder view which sends focus to find_text_. | 114 // Create a focus forwarder view which sends focus to find_text_. |
116 focus_forwarder_view_ = new FocusForwarderView(find_text_); | 115 focus_forwarder_view_ = new FocusForwarderView(find_text_); |
117 AddChildView(focus_forwarder_view_); | 116 AddChildView(focus_forwarder_view_); |
118 | 117 |
119 find_previous_button_ = new views::ImageButton(this); | 118 find_previous_button_ = new views::ImageButton(this); |
120 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); | 119 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); |
121 find_previous_button_->SetFocusable(true); | 120 find_previous_button_->SetFocusable(true); |
122 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, | 121 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, |
123 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV)); | 122 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV)); |
124 find_previous_button_->SetImage(views::CustomButton::BS_HOT, | 123 find_previous_button_->SetImage(views::CustomButton::BS_HOT, |
125 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_H)); | 124 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_H)); |
126 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, | 125 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, |
127 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_P)); | 126 rb.GetBitmapNamed(IDR_FINDINPAGE_PREV_P)); |
128 find_previous_button_->SetTooltipText(UTF16ToWide( | 127 find_previous_button_->SetTooltipText(UTF16ToWide( |
129 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP))); | 128 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP))); |
130 find_previous_button_->SetAccessibleName( | 129 find_previous_button_->SetAccessibleName( |
131 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS))); | 130 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); |
132 AddChildView(find_previous_button_); | 131 AddChildView(find_previous_button_); |
133 | 132 |
134 find_next_button_ = new views::ImageButton(this); | 133 find_next_button_ = new views::ImageButton(this); |
135 find_next_button_->set_tag(FIND_NEXT_TAG); | 134 find_next_button_->set_tag(FIND_NEXT_TAG); |
136 find_next_button_->SetFocusable(true); | 135 find_next_button_->SetFocusable(true); |
137 find_next_button_->SetImage(views::CustomButton::BS_NORMAL, | 136 find_next_button_->SetImage(views::CustomButton::BS_NORMAL, |
138 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT)); | 137 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT)); |
139 find_next_button_->SetImage(views::CustomButton::BS_HOT, | 138 find_next_button_->SetImage(views::CustomButton::BS_HOT, |
140 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT_H)); | 139 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT_H)); |
141 find_next_button_->SetImage(views::CustomButton::BS_DISABLED, | 140 find_next_button_->SetImage(views::CustomButton::BS_DISABLED, |
142 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT_P)); | 141 rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT_P)); |
143 find_next_button_->SetTooltipText( | 142 find_next_button_->SetTooltipText( |
144 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP))); | 143 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP))); |
145 find_next_button_->SetAccessibleName( | 144 find_next_button_->SetAccessibleName( |
146 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT))); | 145 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); |
147 AddChildView(find_next_button_); | 146 AddChildView(find_next_button_); |
148 | 147 |
149 close_button_ = new views::ImageButton(this); | 148 close_button_ = new views::ImageButton(this); |
150 close_button_->set_tag(CLOSE_TAG); | 149 close_button_->set_tag(CLOSE_TAG); |
151 close_button_->SetFocusable(true); | 150 close_button_->SetFocusable(true); |
152 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 151 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
153 rb.GetBitmapNamed(IDR_CLOSE_BAR)); | 152 rb.GetBitmapNamed(IDR_CLOSE_BAR)); |
154 close_button_->SetImage(views::CustomButton::BS_HOT, | 153 close_button_->SetImage(views::CustomButton::BS_HOT, |
155 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); | 154 rb.GetBitmapNamed(IDR_CLOSE_BAR_H)); |
156 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 155 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
157 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); | 156 rb.GetBitmapNamed(IDR_CLOSE_BAR_P)); |
158 close_button_->SetTooltipText( | 157 close_button_->SetTooltipText( |
159 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP))); | 158 UTF16ToWide(l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP))); |
160 close_button_->SetAccessibleName( | 159 close_button_->SetAccessibleName( |
161 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE))); | 160 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
162 AddChildView(close_button_); | 161 AddChildView(close_button_); |
163 | 162 |
164 if (kDialog_left == NULL) { | 163 if (kDialog_left == NULL) { |
165 // Background images for the dialog. | 164 // Background images for the dialog. |
166 kDialog_left = rb.GetBitmapNamed(IDR_FIND_DIALOG_LEFT); | 165 kDialog_left = rb.GetBitmapNamed(IDR_FIND_DIALOG_LEFT); |
167 kDialog_middle = rb.GetBitmapNamed(IDR_FIND_DIALOG_MIDDLE); | 166 kDialog_middle = rb.GetBitmapNamed(IDR_FIND_DIALOG_MIDDLE); |
168 kDialog_right = rb.GetBitmapNamed(IDR_FIND_DIALOG_RIGHT); | 167 kDialog_right = rb.GetBitmapNamed(IDR_FIND_DIALOG_RIGHT); |
169 | 168 |
170 // Background images for the Find edit box. | 169 // Background images for the Find edit box. |
171 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); | 170 kBackground = rb.GetBitmapNamed(IDR_FIND_BOX_BACKGROUND); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 553 |
555 void FindBarView::OnThemeChanged() { | 554 void FindBarView::OnThemeChanged() { |
556 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 555 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
557 if (GetThemeProvider()) { | 556 if (GetThemeProvider()) { |
558 close_button_->SetBackground( | 557 close_button_->SetBackground( |
559 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), | 558 GetThemeProvider()->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT), |
560 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 559 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
561 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 560 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
562 } | 561 } |
563 } | 562 } |
OLD | NEW |