| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
| 10 #include "ui/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 listener_(NULL), | 242 listener_(NULL), |
| 243 selected_index_(model_->GetDefaultIndex()), | 243 selected_index_(model_->GetDefaultIndex()), |
| 244 invalid_(false), | 244 invalid_(false), |
| 245 disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 245 disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 246 IDR_MENU_DROPARROW).ToImageSkia()), | 246 IDR_MENU_DROPARROW).ToImageSkia()), |
| 247 dropdown_open_(false), | 247 dropdown_open_(false), |
| 248 text_button_(new TransparentButton(this)), | 248 text_button_(new TransparentButton(this)), |
| 249 arrow_button_(new TransparentButton(this)) { | 249 arrow_button_(new TransparentButton(this)) { |
| 250 model_->AddObserver(this); | 250 model_->AddObserver(this); |
| 251 UpdateFromModel(); | 251 UpdateFromModel(); |
| 252 set_focusable(true); | 252 SetFocusable(true); |
| 253 UpdateBorder(); | 253 UpdateBorder(); |
| 254 | 254 |
| 255 // Initialize the button images. | 255 // Initialize the button images. |
| 256 Button::ButtonState button_states[] = { | 256 Button::ButtonState button_states[] = { |
| 257 Button::STATE_DISABLED, | 257 Button::STATE_DISABLED, |
| 258 Button::STATE_NORMAL, | 258 Button::STATE_NORMAL, |
| 259 Button::STATE_HOVERED, | 259 Button::STATE_HOVERED, |
| 260 Button::STATE_PRESSED, | 260 Button::STATE_PRESSED, |
| 261 }; | 261 }; |
| 262 for (int i = 0; i < 2; i++) { | 262 for (int i = 0; i < 2; i++) { |
| 263 for (size_t state_index = 0; state_index < arraysize(button_states); | 263 for (size_t state_index = 0; state_index < arraysize(button_states); |
| 264 state_index++) { | 264 state_index++) { |
| 265 Button::ButtonState state = button_states[state_index]; | 265 Button::ButtonState state = button_states[state_index]; |
| 266 size_t num; | 266 size_t num; |
| 267 bool focused = !!i; | 267 bool focused = !!i; |
| 268 const int* ids = GetBodyButtonImageIds(focused, state, &num); | 268 const int* ids = GetBodyButtonImageIds(focused, state, &num); |
| 269 body_button_painters_[focused][state].reset( | 269 body_button_painters_[focused][state].reset( |
| 270 Painter::CreateImageGridPainter(ids)); | 270 Painter::CreateImageGridPainter(ids)); |
| 271 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state); | 271 menu_button_images_[focused][state] = GetMenuButtonImages(focused, state); |
| 272 } | 272 } |
| 273 } | 273 } |
| 274 | 274 |
| 275 text_button_->SetVisible(true); | 275 text_button_->SetVisible(true); |
| 276 arrow_button_->SetVisible(true); | 276 arrow_button_->SetVisible(true); |
| 277 text_button_->set_focusable(false); | 277 text_button_->SetFocusable(false); |
| 278 arrow_button_->set_focusable(false); | 278 arrow_button_->SetFocusable(false); |
| 279 AddChildView(text_button_); | 279 AddChildView(text_button_); |
| 280 AddChildView(arrow_button_); | 280 AddChildView(arrow_button_); |
| 281 } | 281 } |
| 282 | 282 |
| 283 Combobox::~Combobox() { | 283 Combobox::~Combobox() { |
| 284 model_->RemoveObserver(this); | 284 model_->RemoveObserver(this); |
| 285 } | 285 } |
| 286 | 286 |
| 287 // static | 287 // static |
| 288 const gfx::Font& Combobox::GetFont() { | 288 const gfx::Font& Combobox::GetFont() { |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 810 |
| 811 void Combobox::HandleClickEvent() { | 811 void Combobox::HandleClickEvent() { |
| 812 if (style_ != STYLE_NOTIFY_ON_CLICK) | 812 if (style_ != STYLE_NOTIFY_ON_CLICK) |
| 813 return; | 813 return; |
| 814 | 814 |
| 815 if (listener_) | 815 if (listener_) |
| 816 listener_->OnComboboxTextButtonClicked(this); | 816 listener_->OnComboboxTextButtonClicked(this); |
| 817 } | 817 } |
| 818 | 818 |
| 819 } // namespace views | 819 } // namespace views |
| OLD | NEW |