1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "views/examples/examples_main.h"
#include "app/app_paths.h"
#include "app/resource_bundle.h"
#include "base/at_exit.h"
#include "base/i18n/icu_util.h"
#include "base/process_util.h"
#include "views/controls/label.h"
#include "views/controls/button/text_button.h"
#include "views/examples/button_example.h"
#include "views/examples/combobox_example.h"
#include "views/examples/message_box_example.h"
#include "views/examples/radio_button_example.h"
#include "views/examples/scroll_view_example.h"
#include "views/examples/tabbed_pane_example.h"
#include "views/examples/textfield_example.h"
#include "views/focus/accelerator_handler.h"
#include "views/grid_layout.h"
#include "views/window/window.h"
namespace examples {
views::View* ExamplesMain::GetContentsView() {
return contents_;
}
void ExamplesMain::SetStatus(const std::wstring& status) {
status_label_->SetText(status);
}
void ExamplesMain::Run() {
base::EnableTerminationOnHeapCorruption();
// The exit manager is in charge of calling the dtors of singleton objects.
base::AtExitManager exit_manager;
app::RegisterPathProvider();
icu_util::Initialize();
// This requires chrome to be built first right now.
// TODO(oshima): fix build to include resource file.
ResourceBundle::InitSharedInstance(L"en-US");
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
// Creates a window with the tabbed pane for each examples, and
// a label to print messages from each examples.
DCHECK(contents_ == NULL) << "Run called more than once.";
contents_ = new views::View();
contents_->set_background(views::Background::CreateStandardPanelBackground());
views::GridLayout* layout = new views::GridLayout(contents_);
contents_->SetLayoutManager(layout);
views::ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0, 0);
views::TabbedPane* tabbed_pane = new views::TabbedPane();
status_label_ = new views::Label();
layout->StartRow(1, 0);
layout->AddView(tabbed_pane);
layout->StartRow(0 /* no expand */, 0);
layout->AddView(status_label_);
views::Window* window =
views::Window::CreateChromeWindow(NULL, gfx::Rect(0, 0, 600, 300), this);
examples::TextfieldExample textfield_example(this);
tabbed_pane->AddTab(textfield_example.GetExampleTitle(),
textfield_example.GetExampleView());
examples::ButtonExample button_example(this);
tabbed_pane->AddTab(button_example.GetExampleTitle(),
button_example.GetExampleView());
examples::ComboboxExample combobox_example(this);
tabbed_pane->AddTab(combobox_example.GetExampleTitle(),
combobox_example.GetExampleView());
examples::TabbedPaneExample tabbed_pane_example(this);
tabbed_pane->AddTab(tabbed_pane_example.GetExampleTitle(),
tabbed_pane_example.GetExampleView());
examples::MessageBoxExample message_box_example(this);
tabbed_pane->AddTab(message_box_example.GetExampleTitle(),
message_box_example.GetExampleView());
examples::RadioButtonExample radio_button_example(this);
tabbed_pane->AddTab(radio_button_example.GetExampleTitle(),
radio_button_example.GetExampleView());
examples::ScrollViewExample scroll_view_example(this);
tabbed_pane->AddTab(scroll_view_example.GetExampleTitle(),
scroll_view_example.GetExampleView());
window->Show();
views::AcceleratorHandler accelerator_handler;
MessageLoopForUI::current()->Run(&accelerator_handler);
}
} // examples namespace
int main(int argc, char** argv) {
#if defined(OS_WIN)
OleInitialize(NULL);
#elif defined(OS_LINUX)
// Initializes gtk stuff.
g_thread_init(NULL);
g_type_init();
gtk_init(&argc, &argv);
#endif
CommandLine::Init(argc, argv);
examples::ExamplesMain main;
main.Run();
#if defined(OS_WIN)
OleUninitialize();
#endif
return 0;
}
|