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

Side by Side Diff: views/examples/message_box_example.cc

Issue 8555013: views: Move examples/ directory to ui/views/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « views/examples/message_box_example.h ('k') | views/examples/native_theme_button_example.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "views/examples/message_box_example.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "views/controls/message_box_view.h"
9 #include "views/layout/grid_layout.h"
10 #include "views/view.h"
11
12 namespace examples {
13
14 MessageBoxExample::MessageBoxExample(ExamplesMain* main)
15 : ExampleBase(main, "Message Box View") {
16 }
17
18 MessageBoxExample::~MessageBoxExample() {
19 }
20
21 void MessageBoxExample::CreateExampleView(views::View* container) {
22 message_box_view_ = new views::MessageBoxView(
23 0,
24 ASCIIToUTF16("Message Box Message"),
25 ASCIIToUTF16("Default Prompt"));
26 status_ = new views::TextButton(this, ASCIIToUTF16("Show Status"));
27 toggle_ = new views::TextButton(this, ASCIIToUTF16("Toggle Checkbox"));
28
29 views::GridLayout* layout = new views::GridLayout(container);
30 container->SetLayoutManager(layout);
31
32 message_box_view_->SetCheckBoxLabel(ASCIIToUTF16("Check Box"));
33
34 const int message_box_column = 0;
35 views::ColumnSet* column_set = layout->AddColumnSet(message_box_column);
36 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
37 views::GridLayout::USE_PREF, 0, 0);
38 layout->StartRow(1 /* expand */, message_box_column);
39 layout->AddView(message_box_view_);
40
41 const int button_column = 1;
42 column_set = layout->AddColumnSet(button_column);
43 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
44 0.5f, views::GridLayout::USE_PREF, 0, 0);
45 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
46 0.5f, views::GridLayout::USE_PREF, 0, 0);
47
48 layout->StartRow(0 /* no expand */, button_column);
49
50 layout->AddView(status_);
51 layout->AddView(toggle_);
52 }
53
54 void MessageBoxExample::ButtonPressed(views::Button* sender,
55 const views::Event& event) {
56 if (sender == status_) {
57 message_box_view_->SetCheckBoxLabel(
58 ASCIIToUTF16(BoolToOnOff(message_box_view_->IsCheckBoxSelected())));
59 PrintStatus(message_box_view_->IsCheckBoxSelected() ?
60 "Check Box Selected" : "Check Box Not Selected");
61 } else if (sender == toggle_) {
62 message_box_view_->SetCheckBoxSelected(
63 !message_box_view_->IsCheckBoxSelected());
64 }
65 }
66
67 } // namespace examples
OLDNEW
« no previous file with comments | « views/examples/message_box_example.h ('k') | views/examples/native_theme_button_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698