Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/views/controls/combobox/combobox.cc

Issue 141523005: Combobox: Rename styles to STYLE_NORMAL and STYLE_ACTION and modify behaviors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix for Windows Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | ui/views/controls/combobox/combobox_listener.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
9 #include "grit/ui_resources.h" 11 #include "grit/ui_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 12 #include "ui/base/accessibility/accessible_view_state.h"
11 #include "ui/base/models/combobox_model.h" 13 #include "ui/base/models/combobox_model.h"
12 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/events/event.h" 15 #include "ui/events/event.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 16 #include "ui/events/keycodes/keyboard_codes.h"
15 #include "ui/gfx/animation/throb_animation.h" 17 #include "ui/gfx/animation/throb_animation.h"
16 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } // namespace 214 } // namespace
213 215
214 // static 216 // static
215 const char Combobox::kViewClassName[] = "views/Combobox"; 217 const char Combobox::kViewClassName[] = "views/Combobox";
216 218
217 //////////////////////////////////////////////////////////////////////////////// 219 ////////////////////////////////////////////////////////////////////////////////
218 // Combobox, public: 220 // Combobox, public:
219 221
220 Combobox::Combobox(ui::ComboboxModel* model) 222 Combobox::Combobox(ui::ComboboxModel* model)
221 : model_(model), 223 : model_(model),
222 style_(STYLE_SHOW_DROP_DOWN_ON_CLICK), 224 style_(STYLE_NORMAL),
223 listener_(NULL), 225 listener_(NULL),
224 selected_index_(model_->GetDefaultIndex()), 226 selected_index_(model_->GetDefaultIndex()),
225 invalid_(false), 227 invalid_(false),
226 disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed( 228 disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
227 IDR_MENU_DROPARROW).ToImageSkia()), 229 IDR_MENU_DROPARROW).ToImageSkia()),
228 dropdown_open_(false), 230 dropdown_open_(false),
229 text_button_(new TransparentButton(this)), 231 text_button_(new TransparentButton(this)),
230 arrow_button_(new TransparentButton(this)) { 232 arrow_button_(new TransparentButton(this)),
233 weak_ptr_factory_(this) {
231 model_->AddObserver(this); 234 model_->AddObserver(this);
232 UpdateFromModel(); 235 UpdateFromModel();
233 SetFocusable(true); 236 SetFocusable(true);
234 UpdateBorder(); 237 UpdateBorder();
235 238
236 // Initialize the button images. 239 // Initialize the button images.
237 Button::ButtonState button_states[] = { 240 Button::ButtonState button_states[] = {
238 Button::STATE_DISABLED, 241 Button::STATE_DISABLED,
239 Button::STATE_NORMAL, 242 Button::STATE_NORMAL,
240 Button::STATE_HOVERED, 243 Button::STATE_HOVERED,
(...skipping 28 matching lines...) Expand all
269 const gfx::FontList& Combobox::GetFontList() { 272 const gfx::FontList& Combobox::GetFontList() {
270 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 273 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
271 return rb.GetFontList(ui::ResourceBundle::BaseFont); 274 return rb.GetFontList(ui::ResourceBundle::BaseFont);
272 } 275 }
273 276
274 void Combobox::SetStyle(Style style) { 277 void Combobox::SetStyle(Style style) {
275 if (style_ == style) 278 if (style_ == style)
276 return; 279 return;
277 280
278 style_ = style; 281 style_ = style;
282 if (style_ == STYLE_ACTION)
283 selected_index_ = 0;
279 284
280 UpdateBorder(); 285 UpdateBorder();
286 UpdateFromModel();
281 PreferredSizeChanged(); 287 PreferredSizeChanged();
282 } 288 }
283 289
284 void Combobox::ModelChanged() { 290 void Combobox::ModelChanged() {
285 selected_index_ = std::min(0, model_->GetItemCount()); 291 selected_index_ = std::min(0, model_->GetItemCount());
286 UpdateFromModel(); 292 UpdateFromModel();
287 PreferredSizeChanged(); 293 PreferredSizeChanged();
288 } 294 }
289 295
290 void Combobox::SetSelectedIndex(int index) { 296 void Combobox::SetSelectedIndex(int index) {
297 if (style_ == STYLE_ACTION)
298 return;
299
291 selected_index_ = index; 300 selected_index_ = index;
292 SchedulePaint(); 301 SchedulePaint();
293 } 302 }
294 303
295 bool Combobox::SelectValue(const base::string16& value) { 304 bool Combobox::SelectValue(const base::string16& value) {
305 if (style_ == STYLE_ACTION)
306 return false;
307
296 for (int i = 0; i < model()->GetItemCount(); ++i) { 308 for (int i = 0; i < model()->GetItemCount(); ++i) {
297 if (value == model()->GetItemAt(i)) { 309 if (value == model()->GetItemAt(i)) {
298 SetSelectedIndex(i); 310 SetSelectedIndex(i);
299 return true; 311 return true;
300 } 312 }
301 } 313 }
302 return false; 314 return false;
303 } 315 }
304 316
305 void Combobox::SetAccessibleName(const base::string16& name) { 317 void Combobox::SetAccessibleName(const base::string16& name) {
(...skipping 17 matching lines...) Expand all
323 } 335 }
324 336
325 void Combobox::Layout() { 337 void Combobox::Layout() {
326 PrefixDelegate::Layout(); 338 PrefixDelegate::Layout();
327 339
328 gfx::Insets insets = GetInsets(); 340 gfx::Insets insets = GetInsets();
329 int text_button_width = 0; 341 int text_button_width = 0;
330 int arrow_button_width = 0; 342 int arrow_button_width = 0;
331 343
332 switch (style_) { 344 switch (style_) {
333 case STYLE_SHOW_DROP_DOWN_ON_CLICK: { 345 case STYLE_NORMAL: {
334 arrow_button_width = width(); 346 arrow_button_width = width();
335 break; 347 break;
336 } 348 }
337 case STYLE_NOTIFY_ON_CLICK: { 349 case STYLE_ACTION: {
338 arrow_button_width = GetDisclosureArrowLeftPadding() + 350 arrow_button_width = GetDisclosureArrowLeftPadding() +
339 disclosure_arrow_->width() + GetDisclosureArrowRightPadding(); 351 disclosure_arrow_->width() + GetDisclosureArrowRightPadding();
340 text_button_width = width() - arrow_button_width; 352 text_button_width = width() - arrow_button_width;
341 break; 353 break;
342 } 354 }
343 } 355 }
344 356
345 int arrow_button_x = std::max(0, text_button_width); 357 int arrow_button_x = std::max(0, text_button_width);
346 text_button_->SetBounds(0, 0, std::max(0, text_button_width), height()); 358 text_button_->SetBounds(0, 0, std::max(0, text_button_width), height());
347 arrow_button_->SetBounds(arrow_button_x, 0, arrow_button_width, height()); 359 arrow_button_->SetBounds(arrow_button_x, 0, arrow_button_width, height());
348 } 360 }
349 361
350 bool Combobox::IsItemChecked(int id) const { 362 bool Combobox::IsItemChecked(int id) const {
351 return false; 363 return false;
352 } 364 }
353 365
354 bool Combobox::IsCommandEnabled(int id) const { 366 bool Combobox::IsCommandEnabled(int id) const {
355 return model()->IsItemEnabledAt(MenuCommandToIndex(id)); 367 return model()->IsItemEnabledAt(MenuCommandToIndex(id));
356 } 368 }
357 369
358 void Combobox::ExecuteCommand(int id) { 370 void Combobox::ExecuteCommand(int id) {
359 selected_index_ = MenuCommandToIndex(id); 371 selected_index_ = MenuCommandToIndex(id);
360 OnSelectionChanged(); 372 OnPerformAction();
361 } 373 }
362 374
363 bool Combobox::GetAccelerator(int id, ui::Accelerator* accel) { 375 bool Combobox::GetAccelerator(int id, ui::Accelerator* accel) {
364 return false; 376 return false;
365 } 377 }
366 378
367 int Combobox::GetRowCount() { 379 int Combobox::GetRowCount() {
368 return model()->GetItemCount(); 380 return model()->GetItemCount();
369 } 381 }
370 382
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 new_index = GetAdjacentIndex(model(), 1, -1); 461 new_index = GetAdjacentIndex(model(), 1, -1);
450 break; 462 break;
451 463
452 // Move to the previous item if any. 464 // Move to the previous item if any.
453 case ui::VKEY_UP: 465 case ui::VKEY_UP:
454 new_index = GetAdjacentIndex(model(), -1, selected_index_); 466 new_index = GetAdjacentIndex(model(), -1, selected_index_);
455 break; 467 break;
456 468
457 // Click the button only when the button style mode. 469 // Click the button only when the button style mode.
458 case ui::VKEY_SPACE: 470 case ui::VKEY_SPACE:
459 if (style_ == STYLE_NOTIFY_ON_CLICK) { 471 if (style_ == STYLE_ACTION) {
460 // When pressing space, the click event will be raised after the key is 472 // When pressing space, the click event will be raised after the key is
461 // released. 473 // released.
462 text_button_->SetState(Button::STATE_PRESSED); 474 text_button_->SetState(Button::STATE_PRESSED);
463 } else { 475 } else {
464 return false; 476 return false;
465 } 477 }
466 break; 478 break;
467 479
468 // Click the button only when the button style mode. 480 // Click the button only when the button style mode.
469 case ui::VKEY_RETURN: 481 case ui::VKEY_RETURN:
470 if (style_ != STYLE_NOTIFY_ON_CLICK) 482 if (style_ != STYLE_ACTION)
471 return false; 483 return false;
472 HandleClickEvent(); 484 OnPerformAction();
473 break; 485 break;
474 486
475 default: 487 default:
476 return false; 488 return false;
477 } 489 }
478 490
479 if (show_menu) { 491 if (show_menu) {
480 UpdateFromModel(); 492 UpdateFromModel();
481 ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD); 493 ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD);
482 } else if (new_index != selected_index_ && new_index != kNoSelection) { 494 } else if (new_index != selected_index_ && new_index != kNoSelection &&
495 style_ != STYLE_ACTION) {
483 DCHECK(!model()->IsItemSeparatorAt(new_index)); 496 DCHECK(!model()->IsItemSeparatorAt(new_index));
484 selected_index_ = new_index; 497 selected_index_ = new_index;
485 OnSelectionChanged(); 498 OnPerformAction();
486 } 499 }
487 500
488 return true; 501 return true;
489 } 502 }
490 503
491 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { 504 bool Combobox::OnKeyReleased(const ui::KeyEvent& e) {
492 if (style_ != STYLE_NOTIFY_ON_CLICK) 505 if (style_ != STYLE_ACTION)
493 return false; // crbug.com/127520 506 return false; // crbug.com/127520
494 507
495 if (e.key_code() == ui::VKEY_SPACE) 508 if (e.key_code() == ui::VKEY_SPACE && style_ == STYLE_ACTION)
496 HandleClickEvent(); 509 OnPerformAction();
497 510
498 return false; 511 return false;
499 } 512 }
500 513
501 void Combobox::OnPaint(gfx::Canvas* canvas) { 514 void Combobox::OnPaint(gfx::Canvas* canvas) {
502 switch (style_) { 515 switch (style_) {
503 case STYLE_SHOW_DROP_DOWN_ON_CLICK: { 516 case STYLE_NORMAL: {
504 OnPaintBackground(canvas); 517 OnPaintBackground(canvas);
505 PaintText(canvas); 518 PaintText(canvas);
506 OnPaintBorder(canvas); 519 OnPaintBorder(canvas);
507 break; 520 break;
508 } 521 }
509 case STYLE_NOTIFY_ON_CLICK: { 522 case STYLE_ACTION: {
510 PaintButtons(canvas); 523 PaintButtons(canvas);
511 PaintText(canvas); 524 PaintText(canvas);
512 break; 525 break;
513 } 526 }
514 } 527 }
515 } 528 }
516 529
517 void Combobox::OnFocus() { 530 void Combobox::OnFocus() {
518 GetInputMethod()->OnFocus(); 531 GetInputMethod()->OnFocus();
519 View::OnFocus(); 532 View::OnFocus();
(...skipping 19 matching lines...) Expand all
539 552
540 void Combobox::OnComboboxModelChanged(ui::ComboboxModel* model) { 553 void Combobox::OnComboboxModelChanged(ui::ComboboxModel* model) {
541 DCHECK_EQ(model, model_); 554 DCHECK_EQ(model, model_);
542 ModelChanged(); 555 ModelChanged();
543 } 556 }
544 557
545 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) { 558 void Combobox::ButtonPressed(Button* sender, const ui::Event& event) {
546 RequestFocus(); 559 RequestFocus();
547 560
548 if (sender == text_button_) { 561 if (sender == text_button_) {
549 HandleClickEvent(); 562 OnPerformAction();
550 } else { 563 } else {
551 DCHECK_EQ(arrow_button_, sender); 564 DCHECK_EQ(arrow_button_, sender);
552 // TODO(hajimehoshi): Fix the problem that the arrow button blinks when 565 // TODO(hajimehoshi): Fix the problem that the arrow button blinks when
553 // cliking this while the dropdown menu is opened. 566 // cliking this while the dropdown menu is opened.
554 const base::TimeDelta delta = base::Time::Now() - closed_time_; 567 const base::TimeDelta delta = base::Time::Now() - closed_time_;
555 if (delta.InMilliseconds() <= kMinimumMsBetweenButtonClicks) 568 if (delta.InMilliseconds() <= kMinimumMsBetweenButtonClicks)
556 return; 569 return;
557 570
558 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE; 571 ui::MenuSourceType source_type = ui::MENU_SOURCE_MOUSE;
559 if (event.IsKeyEvent()) 572 if (event.IsKeyEvent())
560 source_type = ui::MENU_SOURCE_KEYBOARD; 573 source_type = ui::MENU_SOURCE_KEYBOARD;
561 else if (event.IsGestureEvent() || event.IsTouchEvent()) 574 else if (event.IsGestureEvent() || event.IsTouchEvent())
562 source_type = ui::MENU_SOURCE_TOUCH; 575 source_type = ui::MENU_SOURCE_TOUCH;
563 ShowDropDownMenu(source_type); 576 ShowDropDownMenu(source_type);
564 } 577 }
565 } 578 }
566 579
567 void Combobox::UpdateFromModel() { 580 void Combobox::UpdateFromModel() {
568 int max_width = 0;
569 const gfx::FontList& font_list = Combobox::GetFontList(); 581 const gfx::FontList& font_list = Combobox::GetFontList();
570 582
571 MenuItemView* menu = new MenuItemView(this); 583 MenuItemView* menu = new MenuItemView(this);
572 // MenuRunner owns |menu|. 584 // MenuRunner owns |menu|.
573 dropdown_list_menu_runner_.reset(new MenuRunner(menu)); 585 dropdown_list_menu_runner_.reset(new MenuRunner(menu));
574 586
575 int num_items = model()->GetItemCount(); 587 int num_items = model()->GetItemCount();
588 int width = 0;
576 for (int i = 0; i < num_items; ++i) { 589 for (int i = 0; i < num_items; ++i) {
577 if (model()->IsItemSeparatorAt(i)) { 590 if (model()->IsItemSeparatorAt(i)) {
578 menu->AppendSeparator(); 591 menu->AppendSeparator();
579 continue; 592 continue;
580 } 593 }
581 594
582 base::string16 text = model()->GetItemAt(i); 595 base::string16 text = model()->GetItemAt(i);
583 596
584 // Inserting the Unicode formatting characters if necessary so that the 597 // Inserting the Unicode formatting characters if necessary so that the
585 // text is displayed correctly in right-to-left UIs. 598 // text is displayed correctly in right-to-left UIs.
586 base::i18n::AdjustStringForLocaleDirection(&text); 599 base::i18n::AdjustStringForLocaleDirection(&text);
587 600
588 menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL); 601 menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL);
589 max_width = std::max(max_width, gfx::GetStringWidth(text, font_list)); 602
603 if (style_ != STYLE_ACTION || i == selected_index_)
604 width = std::max(width, gfx::GetStringWidth(text, font_list));
590 } 605 }
591 606
592 content_size_.SetSize(max_width, font_list.GetHeight()); 607 content_size_.SetSize(width, font_list.GetHeight());
593 } 608 }
594 609
595 void Combobox::UpdateBorder() { 610 void Combobox::UpdateBorder() {
596 scoped_ptr<FocusableBorder> border(new FocusableBorder()); 611 scoped_ptr<FocusableBorder> border(new FocusableBorder());
597 if (style_ == STYLE_NOTIFY_ON_CLICK) 612 if (style_ == STYLE_ACTION)
598 border->SetInsets(8, 13, 8, 13); 613 border->SetInsets(8, 13, 8, 13);
599 if (invalid_) 614 if (invalid_)
600 border->SetColor(kWarningColor); 615 border->SetColor(kWarningColor);
601 SetBorder(border.PassAs<Border>()); 616 SetBorder(border.PassAs<Border>());
602 } 617 }
603 618
604 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const { 619 void Combobox::AdjustBoundsForRTLUI(gfx::Rect* rect) const {
605 rect->set_x(GetMirroredXForRect(*rect)); 620 rect->set_x(GetMirroredXForRect(*rect));
606 } 621 }
607 622
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 gfx::Rect arrow_bounds(arrow_x, 654 gfx::Rect arrow_bounds(arrow_x,
640 height() / 2 - disclosure_arrow_->height() / 2, 655 height() / 2 - disclosure_arrow_->height() / 2,
641 disclosure_arrow_->width(), 656 disclosure_arrow_->width(),
642 disclosure_arrow_->height()); 657 disclosure_arrow_->height());
643 AdjustBoundsForRTLUI(&arrow_bounds); 658 AdjustBoundsForRTLUI(&arrow_bounds);
644 659
645 canvas->DrawImageInt(*disclosure_arrow_, arrow_bounds.x(), arrow_bounds.y()); 660 canvas->DrawImageInt(*disclosure_arrow_, arrow_bounds.x(), arrow_bounds.y());
646 } 661 }
647 662
648 void Combobox::PaintButtons(gfx::Canvas* canvas) { 663 void Combobox::PaintButtons(gfx::Canvas* canvas) {
649 DCHECK(style_ == STYLE_NOTIFY_ON_CLICK); 664 DCHECK(style_ == STYLE_ACTION);
650 665
651 gfx::ScopedCanvas scoped_canvas(canvas); 666 gfx::ScopedCanvas scoped_canvas(canvas);
652 if (base::i18n::IsRTL()) { 667 if (base::i18n::IsRTL()) {
653 canvas->Translate(gfx::Vector2d(width(), 0)); 668 canvas->Translate(gfx::Vector2d(width(), 0));
654 canvas->Scale(-1, 1); 669 canvas->Scale(-1, 1);
655 } 670 }
656 671
657 bool focused = HasFocus(); 672 bool focused = HasFocus();
658 const std::vector<const gfx::ImageSkia*>& arrow_button_images = 673 const std::vector<const gfx::ImageSkia*>& arrow_button_images =
659 menu_button_images_[focused][ 674 menu_button_images_[focused][
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 if (arrow_button_) 758 if (arrow_button_)
744 arrow_button_->SetState(original_state); 759 arrow_button_->SetState(original_state);
745 closed_time_ = base::Time::Now(); 760 closed_time_ = base::Time::Now();
746 761
747 // Need to explicitly clear mouse handler so that events get sent 762 // Need to explicitly clear mouse handler so that events get sent
748 // properly after the menu finishes running. If we don't do this, then 763 // properly after the menu finishes running. If we don't do this, then
749 // the first click to other parts of the UI is eaten. 764 // the first click to other parts of the UI is eaten.
750 SetMouseHandler(NULL); 765 SetMouseHandler(NULL);
751 } 766 }
752 767
753 void Combobox::OnSelectionChanged() { 768 void Combobox::OnPerformAction() {
754 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_VALUE_CHANGED, false); 769 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_VALUE_CHANGED, false);
755 SchedulePaint(); 770 SchedulePaint();
771
772 // This combobox may be deleted by the listener.
773 base::WeakPtr<Combobox> weak_ptr = weak_ptr_factory_.GetWeakPtr();
756 if (listener_) 774 if (listener_)
757 listener_->OnSelectedIndexChanged(this); 775 listener_->OnPerformAction(this);
758 // |this| may now be deleted. 776
777 if (weak_ptr && style_ == STYLE_ACTION)
778 selected_index_ = 0;
759 } 779 }
760 780
761 int Combobox::MenuCommandToIndex(int menu_command_id) const { 781 int Combobox::MenuCommandToIndex(int menu_command_id) const {
762 // (note that the id received is offset by kFirstMenuItemId) 782 // (note that the id received is offset by kFirstMenuItemId)
763 // Revert menu ID offset to map back to combobox model. 783 // Revert menu ID offset to map back to combobox model.
764 int index = menu_command_id - kFirstMenuItemId; 784 int index = menu_command_id - kFirstMenuItemId;
765 DCHECK_LT(index, model()->GetItemCount()); 785 DCHECK_LT(index, model()->GetItemCount());
766 return index; 786 return index;
767 } 787 }
768 788
769 int Combobox::GetDisclosureArrowLeftPadding() const { 789 int Combobox::GetDisclosureArrowLeftPadding() const {
770 switch (style_) { 790 switch (style_) {
771 case STYLE_SHOW_DROP_DOWN_ON_CLICK: 791 case STYLE_NORMAL:
772 return kDisclosureArrowLeftPadding; 792 return kDisclosureArrowLeftPadding;
773 case STYLE_NOTIFY_ON_CLICK: 793 case STYLE_ACTION:
774 return kDisclosureArrowButtonLeftPadding; 794 return kDisclosureArrowButtonLeftPadding;
775 } 795 }
776 NOTREACHED(); 796 NOTREACHED();
777 return 0; 797 return 0;
778 } 798 }
779 799
780 int Combobox::GetDisclosureArrowRightPadding() const { 800 int Combobox::GetDisclosureArrowRightPadding() const {
781 switch (style_) { 801 switch (style_) {
782 case STYLE_SHOW_DROP_DOWN_ON_CLICK: 802 case STYLE_NORMAL:
783 return kDisclosureArrowRightPadding; 803 return kDisclosureArrowRightPadding;
784 case STYLE_NOTIFY_ON_CLICK: 804 case STYLE_ACTION:
785 return kDisclosureArrowButtonRightPadding; 805 return kDisclosureArrowButtonRightPadding;
786 } 806 }
787 NOTREACHED(); 807 NOTREACHED();
788 return 0; 808 return 0;
789 } 809 }
790 810
791 void Combobox::HandleClickEvent() {
792 if (style_ != STYLE_NOTIFY_ON_CLICK)
793 return;
794
795 if (listener_)
796 listener_->OnComboboxTextButtonClicked(this);
797 }
798
799 } // namespace views 811 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/combobox/combobox.h ('k') | ui/views/controls/combobox/combobox_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698