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

Side by Side Diff: views/examples/textfield_example.h

Issue 270032: Password style support for gtk's textfield impl.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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/examples_main_base.cc ('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:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 #ifndef VIEWS_EXAMPLES_TEXTFIELD_EXAMPLE_H_
6 #define VIEWS_EXAMPLES_TEXTFIELD_EXAMPLE_H_
7
8 #include "base/string_util.h"
9 #include "views/controls/label.h"
10 #include "views/controls/tabbed_pane/tabbed_pane.h"
11 #include "views/controls/textfield/textfield.h"
12 #include "views/examples/example_base.h"
13
14 namespace examples {
15
16 using views::Textfield;
17
18 // TextfieldExample mimics login screen.
19 class TextfieldExample : protected ExampleBase,
20 public Textfield::Controller {
21 public:
22 TextfieldExample(views::TabbedPane* tabbed_pane, views::Label* message)
23 : ExampleBase(message),
24 name_(new Textfield()),
25 password_(new Textfield(Textfield::STYLE_PASSWORD)) {
26 name_->SetController(this);
27 password_->SetController(this);
28
29 views::View* container = new views::View();
30 tabbed_pane->AddTab(L"Textfield", container);
31 views::GridLayout* layout = new views::GridLayout(container);
32 container->SetLayoutManager(layout);
33
34 views::ColumnSet* column_set = layout->AddColumnSet(0);
35 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
36 0.2f, views::GridLayout::USE_PREF, 0, 0);
37 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
38 0.8f, views::GridLayout::USE_PREF, 0, 0);
39 layout->StartRow(0, 0);
40 layout->AddView(new views::Label(L"Name:"));
41 layout->AddView(name_);
42 layout->StartRow(0, 0);
43 layout->AddView(new views::Label(L"Password:"));
44 layout->AddView(password_);
45 }
46
47 virtual ~TextfieldExample() {}
48
49 private:
50 // Textfield::Controller implementations:
51 // This method is called whenever the text in the field changes.
52 virtual void ContentsChanged(Textfield* sender,
53 const string16& new_contents) {
54 if (sender == name_) {
55 PrintStatus(L"Name [%ls]", UTF16ToWideHack(new_contents).c_str());
56 } else if (sender == password_) {
57 PrintStatus(L"Password [%ls]", UTF16ToWideHack(new_contents).c_str());
58 }
59 }
60
61 // Let the control handle keystrokes.
62 virtual bool HandleKeystroke(Textfield* sender,
63 const Textfield::Keystroke& keystroke) {
64 return false;
65 }
66
67 // Textfields for name and password.
68 views::Textfield* name_, *password_;
69
70 DISALLOW_COPY_AND_ASSIGN(TextfieldExample);
71 };
72
73 } // namespace examples
74
75 #endif // VIEWS_EXAMPLES_TEXTFIELD_EXAMPLE_H_
76
OLDNEW
« no previous file with comments | « views/examples/examples_main_base.cc ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698