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

Side by Side Diff: views/controls/textfield/textfield.cc

Issue 6628037: views: Moves TextfieldController/TextRange into their own headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a typo Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/controls/textfield/textfield.h" 5 #include "views/controls/textfield/textfield.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #endif 9 #endif
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "ui/base/keycodes/keyboard_codes.h" 15 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "ui/gfx/insets.h" 16 #include "ui/gfx/insets.h"
17 #include "views/controls/native/native_view_host.h" 17 #include "views/controls/native/native_view_host.h"
18 #include "views/controls/textfield/native_textfield_wrapper.h" 18 #include "views/controls/textfield/native_textfield_wrapper.h"
19 #include "views/controls/textfield/text_range.h"
20 #include "views/controls/textfield/textfield_controller.h"
19 #include "views/widget/widget.h" 21 #include "views/widget/widget.h"
20 22
21 #if defined(OS_LINUX) 23 #if defined(OS_LINUX)
22 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h" 24 #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
23 #elif defined(OS_WIN) 25 #elif defined(OS_WIN)
24 #include "base/win/win_util.h" 26 #include "base/win/win_util.h"
25 // TODO(beng): this should be removed when the OS_WIN hack from 27 // TODO(beng): this should be removed when the OS_WIN hack from
26 // ViewHierarchyChanged is removed. 28 // ViewHierarchyChanged is removed.
29 #include "views/controls/textfield/native_textfield_views.h"
27 #include "views/controls/textfield/native_textfield_win.h" 30 #include "views/controls/textfield/native_textfield_win.h"
28 #include "views/controls/textfield/native_textfield_views.h"
29 #include "views/events/event_utils_win.h" 31 #include "views/events/event_utils_win.h"
30 #endif 32 #endif
31 33
32 namespace views { 34 namespace views {
33 35
34 // static 36 // static
35 const char Textfield::kViewClassName[] = "views/Textfield"; 37 const char Textfield::kViewClassName[] = "views/Textfield";
36 38
37 ///////////////////////////////////////////////////////////////////////////// 39 /////////////////////////////////////////////////////////////////////////////
38 // TextRange
39
40 TextRange::TextRange(size_t start, size_t end)
41 : start_(start),
42 end_(end) {
43 }
44
45 size_t TextRange::GetMin() const {
46 return std::min(start_, end_);
47 }
48
49 size_t TextRange::GetMax() const {
50 return std::max(start_, end_);
51 }
52
53 void TextRange::SetRange(size_t start, size_t end) {
54 start_ = start;
55 end_ = end;
56 }
57
58 /////////////////////////////////////////////////////////////////////////////
59 // Textfield 40 // Textfield
60 41
61 Textfield::Textfield() 42 Textfield::Textfield()
62 : native_wrapper_(NULL), 43 : native_wrapper_(NULL),
63 controller_(NULL), 44 controller_(NULL),
64 style_(STYLE_DEFAULT), 45 style_(STYLE_DEFAULT),
65 read_only_(false), 46 read_only_(false),
66 default_width_in_chars_(0), 47 default_width_in_chars_(0),
67 draw_border_(true), 48 draw_border_(true),
68 text_color_(SK_ColorBLACK), 49 text_color_(SK_ColorBLACK),
(...skipping 21 matching lines...) Expand all
90 num_lines_(1), 71 num_lines_(1),
91 initialized_(false), 72 initialized_(false),
92 horizontal_margins_were_set_(false), 73 horizontal_margins_were_set_(false),
93 vertical_margins_were_set_(false) { 74 vertical_margins_were_set_(false) {
94 SetFocusable(true); 75 SetFocusable(true);
95 } 76 }
96 77
97 Textfield::~Textfield() { 78 Textfield::~Textfield() {
98 } 79 }
99 80
100 void Textfield::SetController(Controller* controller) { 81 void Textfield::SetController(TextfieldController* controller) {
101 controller_ = controller; 82 controller_ = controller;
102 } 83 }
103 84
104 Textfield::Controller* Textfield::GetController() const { 85 TextfieldController* Textfield::GetController() const {
105 return controller_; 86 return controller_;
106 } 87 }
107 88
108 void Textfield::SetReadOnly(bool read_only) { 89 void Textfield::SetReadOnly(bool read_only) {
109 read_only_ = read_only; 90 read_only_ = read_only;
110 if (native_wrapper_) { 91 if (native_wrapper_) {
111 native_wrapper_->UpdateReadOnly(); 92 native_wrapper_->UpdateReadOnly();
112 native_wrapper_->UpdateTextColor(); 93 native_wrapper_->UpdateTextColor();
113 native_wrapper_->UpdateBackgroundColor(); 94 native_wrapper_->UpdateBackgroundColor();
114 } 95 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 396 }
416 #endif 397 #endif
417 } 398 }
418 } 399 }
419 400
420 std::string Textfield::GetClassName() const { 401 std::string Textfield::GetClassName() const {
421 return kViewClassName; 402 return kViewClassName;
422 } 403 }
423 404
424 } // namespace views 405 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698