OLD | NEW |
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 "ui/views/controls/textfield/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 bool NativeTextfieldViews::OnKeyReleased(const KeyEvent& event) { | 138 bool NativeTextfieldViews::OnKeyReleased(const KeyEvent& event) { |
139 NOTREACHED(); | 139 NOTREACHED(); |
140 return false; | 140 return false; |
141 } | 141 } |
142 | 142 |
143 bool NativeTextfieldViews::GetDropFormats( | 143 bool NativeTextfieldViews::GetDropFormats( |
144 int* formats, | 144 int* formats, |
145 std::set<OSExchangeData::CustomFormat>* custom_formats) { | 145 std::set<OSExchangeData::CustomFormat>* custom_formats) { |
146 if (!textfield_->IsEnabled() || textfield_->read_only()) | 146 if (!textfield_->enabled() || textfield_->read_only()) |
147 return false; | 147 return false; |
148 // TODO(msw): Can we support URL, FILENAME, etc.? | 148 // TODO(msw): Can we support URL, FILENAME, etc.? |
149 *formats = ui::OSExchangeData::STRING; | 149 *formats = ui::OSExchangeData::STRING; |
150 return true; | 150 return true; |
151 } | 151 } |
152 | 152 |
153 bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) { | 153 bool NativeTextfieldViews::CanDrop(const OSExchangeData& data) { |
154 return textfield_->IsEnabled() && !textfield_->read_only() && | 154 return textfield_->enabled() && !textfield_->read_only() && data.HasString(); |
155 data.HasString(); | |
156 } | 155 } |
157 | 156 |
158 int NativeTextfieldViews::OnDragUpdated(const DropTargetEvent& event) { | 157 int NativeTextfieldViews::OnDragUpdated(const DropTargetEvent& event) { |
159 DCHECK(CanDrop(event.data())); | 158 DCHECK(CanDrop(event.data())); |
160 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); | 159 bool in_selection = GetRenderText()->IsPointInSelection(event.location()); |
161 is_drop_cursor_visible_ = !in_selection; | 160 is_drop_cursor_visible_ = !in_selection; |
162 // TODO(msw): Pan over text when the user drags to the visible text edge. | 161 // TODO(msw): Pan over text when the user drags to the visible text edge. |
163 OnCaretBoundsChanged(); | 162 OnCaretBoundsChanged(); |
164 SchedulePaint(); | 163 SchedulePaint(); |
165 | 164 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, | 291 void NativeTextfieldViews::WriteDragDataForView(views::View* sender, |
293 const gfx::Point& press_pt, | 292 const gfx::Point& press_pt, |
294 OSExchangeData* data) { | 293 OSExchangeData* data) { |
295 DCHECK_NE(ui::DragDropTypes::DRAG_NONE, | 294 DCHECK_NE(ui::DragDropTypes::DRAG_NONE, |
296 GetDragOperationsForView(sender, press_pt)); | 295 GetDragOperationsForView(sender, press_pt)); |
297 data->SetString(GetSelectedText()); | 296 data->SetString(GetSelectedText()); |
298 } | 297 } |
299 | 298 |
300 int NativeTextfieldViews::GetDragOperationsForView(views::View* sender, | 299 int NativeTextfieldViews::GetDragOperationsForView(views::View* sender, |
301 const gfx::Point& p) { | 300 const gfx::Point& p) { |
302 if (!textfield_->IsEnabled() || !GetRenderText()->IsPointInSelection(p)) | 301 if (!textfield_->enabled() || !GetRenderText()->IsPointInSelection(p)) |
303 return ui::DragDropTypes::DRAG_NONE; | 302 return ui::DragDropTypes::DRAG_NONE; |
304 if (sender == this && !textfield_->read_only()) | 303 if (sender == this && !textfield_->read_only()) |
305 return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY; | 304 return ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY; |
306 return ui::DragDropTypes::DRAG_COPY; | 305 return ui::DragDropTypes::DRAG_COPY; |
307 } | 306 } |
308 | 307 |
309 bool NativeTextfieldViews::CanStartDragForView(View* sender, | 308 bool NativeTextfieldViews::CanStartDragForView(View* sender, |
310 const gfx::Point& press_pt, | 309 const gfx::Point& press_pt, |
311 const gfx::Point& p) { | 310 const gfx::Point& p) { |
312 return GetRenderText()->IsPointInSelection(press_pt); | 311 return GetRenderText()->IsPointInSelection(press_pt); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 399 } |
401 | 400 |
402 void NativeTextfieldViews::UpdateIsPassword() { | 401 void NativeTextfieldViews::UpdateIsPassword() { |
403 model_->set_is_password(textfield_->IsPassword()); | 402 model_->set_is_password(textfield_->IsPassword()); |
404 OnCaretBoundsChanged(); | 403 OnCaretBoundsChanged(); |
405 SchedulePaint(); | 404 SchedulePaint(); |
406 OnTextInputTypeChanged(); | 405 OnTextInputTypeChanged(); |
407 } | 406 } |
408 | 407 |
409 void NativeTextfieldViews::UpdateEnabled() { | 408 void NativeTextfieldViews::UpdateEnabled() { |
410 SetEnabled(textfield_->IsEnabled()); | 409 SetEnabled(textfield_->enabled()); |
411 SchedulePaint(); | 410 SchedulePaint(); |
412 OnTextInputTypeChanged(); | 411 OnTextInputTypeChanged(); |
413 } | 412 } |
414 | 413 |
415 gfx::Insets NativeTextfieldViews::CalculateInsets() { | 414 gfx::Insets NativeTextfieldViews::CalculateInsets() { |
416 return GetInsets(); | 415 return GetInsets(); |
417 } | 416 } |
418 | 417 |
419 void NativeTextfieldViews::UpdateHorizontalMargins() { | 418 void NativeTextfieldViews::UpdateHorizontalMargins() { |
420 int left, right; | 419 int left, right; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 | 1088 |
1090 #if defined(USE_AURA) | 1089 #if defined(USE_AURA) |
1091 // static | 1090 // static |
1092 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 1091 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
1093 Textfield* field) { | 1092 Textfield* field) { |
1094 return new NativeTextfieldViews(field); | 1093 return new NativeTextfieldViews(field); |
1095 } | 1094 } |
1096 #endif | 1095 #endif |
1097 | 1096 |
1098 } // namespace views | 1097 } // namespace views |
OLD | NEW |