diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 01:15:18 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 01:15:18 +0000 |
commit | fe00335bb1d7dab7143a3f77cac9526d53f08c7a (patch) | |
tree | 02f9a379a10865c2b8762f663552588ab3816979 /views/examples/button_example.h | |
parent | 5b69e884ffd49dd64835a87d95b282377d6ad1c3 (diff) | |
download | chromium_src-fe00335bb1d7dab7143a3f77cac9526d53f08c7a.zip chromium_src-fe00335bb1d7dab7143a3f77cac9526d53f08c7a.tar.gz chromium_src-fe00335bb1d7dab7143a3f77cac9526d53f08c7a.tar.bz2 |
View examples:
I'm planning to move these to unit_test using Jay's testing framework,
but let's check in it first, and then I will refactor and move them to unittest.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/examples/button_example.h')
-rw-r--r-- | views/examples/button_example.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/views/examples/button_example.h b/views/examples/button_example.h new file mode 100644 index 0000000..ef93376 --- /dev/null +++ b/views/examples/button_example.h @@ -0,0 +1,42 @@ +// 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. + +#ifndef VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ +#define VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ + +#include "base/string_util.h" +#include "views/controls/button/text_button.h" +#include "views/controls/tabbed_pane/tabbed_pane.h" +#include "views/examples/example_base.h" + +namespace examples { + +// ButtonExample simply counts the number of clicks. +class ButtonExample : protected ExampleBase, private views::ButtonListener { + public: + ButtonExample(views::TabbedPane* tabbed_pane, views::Label* message) + : ExampleBase(message), + count_(0) { + views::TextButton* button = new views::TextButton(this, L"Button"); + tabbed_pane->AddTab(L"Text Button", button); + } + + virtual ~ButtonExample() {} + + private: + // ButtonListner implementation. + virtual void ButtonPressed(views::Button* sender, const views::Event& event) { + PrintStatus(L"Pressed! count:%d", ++count_); + } + + // The number of times the button is pressed. + int count_; + + DISALLOW_COPY_AND_ASSIGN(ButtonExample); +}; + +} // namespace examples + +#endif // VIEWS_EXAMPLES_BUTTON_EXAMPLE_H_ + |