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

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

Issue 7069022: Adds a basic NativeWindowViews. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « views/examples/native_window_views_example.h ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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/native_window_views_example.h"
6
7 #include "ui/gfx/canvas.h"
8 #include "views/examples/example_base.h"
9 #include "views/controls/button/text_button.h"
10 #include "views/controls/label.h"
11 #include "views/layout/grid_layout.h"
12 #include "views/view.h"
13 #include "views/window/native_window_views.h"
14 #include "views/window/window.h"
15 #include "views/window/window_delegate.h"
16
17 namespace examples {
18
19 class WindowContentView : public views::View,
20 public views::WindowDelegate,
21 public views::ButtonListener {
22 public:
23 WindowContentView()
24 : ALLOW_THIS_IN_INITIALIZER_LIST(
25 button_(new views::TextButton(this, L"Click me!"))),
26 label_(new views::Label(L"Some label")) {
27 views::GridLayout* layout = new views::GridLayout(this);
28 views::ColumnSet* columns = layout->AddColumnSet(0);
29 columns->AddColumn(views::GridLayout::FILL,
30 views::GridLayout::FILL,
31 1,
32 views::GridLayout::USE_PREF,
33 0,
34 0);
35 SetLayoutManager(layout);
36 layout->StartRow(0, 0);
37 layout->AddView(button_);
38 layout->StartRow(1, 0);
39 layout->AddView(label_);
40 }
41 virtual ~WindowContentView() {}
42
43 // Overridden from views::View:
44 virtual void OnPaint(gfx::Canvas* canvas) {
45 canvas->FillRectInt(SK_ColorWHITE, 0, 0, width(), height());
46 }
47
48 // Overridden from views::WindowDelegate:
49 virtual std::wstring GetWindowTitle() const {
50 return L"Example NativeWindowViews";
51 }
52 virtual View* GetContentsView() {
53 return this;
54 }
55
56 // Overridden from views::ButtonListener:
57 virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
58 if (sender == button_)
59 label_->SetText(L"Button Clicked!");
60 }
61
62 private:
63 views::TextButton* button_;
64 views::Label* label_;
65
66 DISALLOW_COPY_AND_ASSIGN(WindowContentView);
67 };
68
69 NativeWindowViewsExample::NativeWindowViewsExample(ExamplesMain* main)
70 : ExampleBase(main) {
71 }
72
73 NativeWindowViewsExample::~NativeWindowViewsExample() {
74 }
75
76 std::wstring NativeWindowViewsExample::GetExampleTitle() {
77 return L"NativeWindowViews";
78 }
79
80 void NativeWindowViewsExample::CreateExampleView(views::View* container) {
81 views::Window* window = new views::Window;
82 views::NativeWindowViews* nwv =
83 new views::NativeWindowViews(container, window);
84 views::Window::InitParams params(new WindowContentView);
85 params.native_window = nwv;
86 params.widget_init_params.bounds = gfx::Rect(20, 20, 600, 300);
87 window->InitWindow(params);
88 window->Show();
89 }
90
91 } // namespace examples
OLDNEW
« no previous file with comments | « views/examples/native_window_views_example.h ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698