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/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "ui/base/models/combobox_model.h" | 10 #include "ui/base/models/combobox_model.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 label->SetBounds(label_x, y, label_width, label_height); | 348 label->SetBounds(label_x, y, label_width, label_height); |
349 | 349 |
350 text_field = new Textfield(); | 350 text_field = new Textfield(); |
351 text_field->set_id(kKiwiTextfieldID); | 351 text_field->set_id(kKiwiTextfieldID); |
352 left_container_->AddChildView(text_field); | 352 left_container_->AddChildView(text_field); |
353 text_field->SetBounds(label_x + label_width + 5, y, | 353 text_field->SetBounds(label_x + label_width + 5, y, |
354 text_field_width, label_height); | 354 text_field_width, label_height); |
355 | 355 |
356 y += label_height + gap_between_labels; | 356 y += label_height + gap_between_labels; |
357 | 357 |
358 LabelButton* button = new LabelButton(NULL, ASCIIToUTF16("Click me")); | 358 LabelButton* button = new LabelButton(nullptr); |
359 button->SetStyle(Button::STYLE_BUTTON); | 359 button->InitAsButton(ASCIIToUTF16("Click me")); |
360 button->SetBounds(label_x, y + 10, 80, 30); | 360 button->SetBounds(label_x, y + 10, 80, 30); |
361 button->set_id(kFruitButtonID); | 361 button->set_id(kFruitButtonID); |
362 left_container_->AddChildView(button); | 362 left_container_->AddChildView(button); |
363 y += 40; | 363 y += 40; |
364 | 364 |
365 cb = new Checkbox(ASCIIToUTF16("This is another check box")); | 365 cb = new Checkbox(ASCIIToUTF16("This is another check box")); |
366 cb->SetBounds(label_x + label_width + 5, y, 180, 20); | 366 cb->SetBounds(label_x + label_width + 5, y, 180, 20); |
367 cb->set_id(kFruitCheckBoxID); | 367 cb->set_id(kFruitCheckBoxID); |
368 left_container_->AddChildView(cb); | 368 left_container_->AddChildView(cb); |
369 y += 20; | 369 y += 20; |
370 | 370 |
371 Combobox* combobox = new Combobox(&combobox_model_); | 371 Combobox* combobox = new Combobox(&combobox_model_); |
372 combobox->SetBounds(label_x + label_width + 5, y, 150, 30); | 372 combobox->SetBounds(label_x + label_width + 5, y, 150, 30); |
373 combobox->set_id(kComboboxID); | 373 combobox->set_id(kComboboxID); |
374 left_container_->AddChildView(combobox); | 374 left_container_->AddChildView(combobox); |
375 | 375 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 Link* link = new Link(ASCIIToUTF16(kTitles[i])); | 444 Link* link = new Link(ASCIIToUTF16(kTitles[i])); |
445 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 445 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
446 link->set_id(kIDs[i]); | 446 link->set_id(kIDs[i]); |
447 scroll_content->AddChildView(link); | 447 scroll_content->AddChildView(link); |
448 link->SetBounds(5, y, 300, 15); | 448 link->SetBounds(5, y, 300, 15); |
449 y += 15; | 449 y += 15; |
450 } | 450 } |
451 | 451 |
452 y = 250; | 452 y = 250; |
453 int width = 60; | 453 int width = 60; |
454 button = new LabelButton(NULL, ASCIIToUTF16("OK")); | 454 button = new LabelButton(nullptr); |
455 button->SetStyle(Button::STYLE_BUTTON); | 455 button->InitAsButton(ASCIIToUTF16("OK")); |
456 button->set_id(kOKButtonID); | 456 button->set_id(kOKButtonID); |
457 button->SetIsDefault(true); | 457 button->SetIsDefault(true); |
458 | 458 |
459 GetContentsView()->AddChildView(button); | 459 GetContentsView()->AddChildView(button); |
460 button->SetBounds(150, y, width, 30); | 460 button->SetBounds(150, y, width, 30); |
461 | 461 |
462 button = new LabelButton(NULL, ASCIIToUTF16("Cancel")); | 462 button = new LabelButton(nullptr); |
463 button->SetStyle(Button::STYLE_BUTTON); | 463 button->InitAsButton(ASCIIToUTF16("Cancel")); |
464 button->set_id(kCancelButtonID); | 464 button->set_id(kCancelButtonID); |
465 GetContentsView()->AddChildView(button); | 465 GetContentsView()->AddChildView(button); |
466 button->SetBounds(220, y, width, 30); | 466 button->SetBounds(220, y, width, 30); |
467 | 467 |
468 button = new LabelButton(NULL, ASCIIToUTF16("Help")); | 468 button = new LabelButton(nullptr); |
469 button->SetStyle(Button::STYLE_BUTTON); | 469 button->InitAsButton(ASCIIToUTF16("Help")); |
470 button->set_id(kHelpButtonID); | 470 button->set_id(kHelpButtonID); |
471 GetContentsView()->AddChildView(button); | 471 GetContentsView()->AddChildView(button); |
472 button->SetBounds(290, y, width, 30); | 472 button->SetBounds(290, y, width, 30); |
473 | 473 |
474 y += 40; | 474 y += 40; |
475 | 475 |
476 View* contents = NULL; | 476 View* contents = NULL; |
477 Link* link = NULL; | 477 Link* link = NULL; |
478 | 478 |
479 // Left bottom box with style checkboxes. | 479 // Left bottom box with style checkboxes. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 style_tab_->AddTab(ASCIIToUTF16("Other"), new View()); | 512 style_tab_->AddTab(ASCIIToUTF16("Other"), new View()); |
513 | 513 |
514 // Right bottom box with search. | 514 // Right bottom box with search. |
515 contents = new View(); | 515 contents = new View(); |
516 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); | 516 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); |
517 text_field = new Textfield(); | 517 text_field = new Textfield(); |
518 contents->AddChildView(text_field); | 518 contents->AddChildView(text_field); |
519 text_field->SetBounds(10, 10, 100, 20); | 519 text_field->SetBounds(10, 10, 100, 20); |
520 text_field->set_id(kSearchTextfieldID); | 520 text_field->set_id(kSearchTextfieldID); |
521 | 521 |
522 button = new LabelButton(NULL, ASCIIToUTF16("Search")); | 522 button = new LabelButton(nullptr); |
523 button->SetStyle(Button::STYLE_BUTTON); | 523 button->InitAsButton(ASCIIToUTF16("Search")); |
524 contents->AddChildView(button); | 524 contents->AddChildView(button); |
525 button->SetBounds(112, 5, 60, 30); | 525 button->SetBounds(112, 5, 60, 30); |
526 button->set_id(kSearchButtonID); | 526 button->set_id(kSearchButtonID); |
527 | 527 |
528 link = new Link(ASCIIToUTF16("Help")); | 528 link = new Link(ASCIIToUTF16("Help")); |
529 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 529 link->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
530 link->set_id(kHelpLinkID); | 530 link->set_id(kHelpLinkID); |
531 contents->AddChildView(link); | 531 contents->AddChildView(link); |
532 link->SetBounds(175, 10, 30, 20); | 532 link->SetBounds(175, 10, 30, 20); |
533 | 533 |
534 search_border_view_ = new BorderView(contents); | 534 search_border_view_ = new BorderView(contents); |
535 search_border_view_->set_id(kSearchContainerID); | 535 search_border_view_->set_id(kSearchContainerID); |
536 | 536 |
537 GetContentsView()->AddChildView(search_border_view_); | 537 GetContentsView()->AddChildView(search_border_view_); |
538 search_border_view_->SetBounds(300, y, 240, 50); | 538 search_border_view_->SetBounds(300, y, 240, 50); |
539 | 539 |
540 y += 60; | 540 y += 60; |
541 | 541 |
542 contents = new View(); | 542 contents = new View(); |
543 contents->SetFocusable(true); | 543 contents->SetFocusable(true); |
544 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); | 544 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); |
545 contents->set_id(kThumbnailContainerID); | 545 contents->set_id(kThumbnailContainerID); |
546 button = new LabelButton(NULL, ASCIIToUTF16("Star")); | 546 button = new LabelButton(nullptr); |
547 button->SetStyle(Button::STYLE_BUTTON); | 547 button->InitAsButton(ASCIIToUTF16("Star")); |
548 contents->AddChildView(button); | 548 contents->AddChildView(button); |
549 button->SetBounds(5, 5, 50, 30); | 549 button->SetBounds(5, 5, 50, 30); |
550 button->set_id(kThumbnailStarID); | 550 button->set_id(kThumbnailStarID); |
551 button = new LabelButton(NULL, ASCIIToUTF16("SuperStar")); | 551 button = new LabelButton(nullptr); |
552 button->SetStyle(Button::STYLE_BUTTON); | 552 button->InitAsButton(ASCIIToUTF16("SuperStar")); |
553 contents->AddChildView(button); | 553 contents->AddChildView(button); |
554 button->SetBounds(60, 5, 100, 30); | 554 button->SetBounds(60, 5, 100, 30); |
555 button->set_id(kThumbnailSuperStarID); | 555 button->set_id(kThumbnailSuperStarID); |
556 | 556 |
557 GetContentsView()->AddChildView(contents); | 557 GetContentsView()->AddChildView(contents); |
558 contents->SetBounds(250, y, 200, 50); | 558 contents->SetBounds(250, y, 200, 50); |
559 // We can only call RadioButton::SetChecked() on the radio-button is part of | 559 // We can only call RadioButton::SetChecked() on the radio-button is part of |
560 // the view hierarchy. | 560 // the view hierarchy. |
561 radio_button_to_check->SetChecked(true); | 561 radio_button_to_check->SetChecked(true); |
562 } | 562 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 GetFocusManager()->AdvanceFocus(false); | 843 GetFocusManager()->AdvanceFocus(false); |
844 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 844 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
845 | 845 |
846 // Advance backwards from the root node. | 846 // Advance backwards from the root node. |
847 GetFocusManager()->ClearFocus(); | 847 GetFocusManager()->ClearFocus(); |
848 GetFocusManager()->AdvanceFocus(true); | 848 GetFocusManager()->AdvanceFocus(true); |
849 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); | 849 EXPECT_FALSE(GetFocusManager()->GetFocusedView()); |
850 } | 850 } |
851 | 851 |
852 } // namespace views | 852 } // namespace views |
OLD | NEW |