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

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

Issue 9117012: Rename visual style "password" to "obscured" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 8 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_win.h" 5 #include "ui/views/controls/textfield/native_textfield_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 contains_mouse_(false), 93 contains_mouse_(false),
94 ime_discard_composition_(false), 94 ime_discard_composition_(false),
95 ime_composition_start_(0), 95 ime_composition_start_(0),
96 ime_composition_length_(0), 96 ime_composition_length_(0),
97 container_view_(new NativeViewHost), 97 container_view_(new NativeViewHost),
98 bg_color_(0) { 98 bg_color_(0) {
99 if (!did_load_library_) 99 if (!did_load_library_)
100 did_load_library_ = !!LoadLibrary(L"riched20.dll"); 100 did_load_library_ = !!LoadLibrary(L"riched20.dll");
101 101
102 DWORD style = kDefaultEditStyle | ES_AUTOHSCROLL; 102 DWORD style = kDefaultEditStyle | ES_AUTOHSCROLL;
103 if (textfield_->style() & Textfield::STYLE_PASSWORD) 103 if (textfield_->style() & Textfield::STYLE_OBSCURED)
104 style |= ES_PASSWORD; 104 style |= ES_PASSWORD;
105 105
106 if (textfield_->read_only()) 106 if (textfield_->read_only())
107 style |= ES_READONLY; 107 style |= ES_READONLY;
108 108
109 // Make sure we apply RTL related extended window styles if necessary. 109 // Make sure we apply RTL related extended window styles if necessary.
110 DWORD ex_style = l10n_util::GetExtendedStyles(); 110 DWORD ex_style = l10n_util::GetExtendedStyles();
111 111
112 RECT r = {0, 0, textfield_->width(), textfield_->height()}; 112 RECT r = {0, 0, textfield_->width(), textfield_->height()};
113 Create(textfield_->GetWidget()->GetNativeView(), r, NULL, style, ex_style); 113 Create(textfield_->GetWidget()->GetNativeView(), r, NULL, style, ex_style);
114 114
115 if (textfield_->style() & Textfield::STYLE_LOWERCASE) { 115 if (textfield_->style() & Textfield::STYLE_LOWERCASE) {
116 DCHECK((textfield_->style() & Textfield::STYLE_PASSWORD) == 0); 116 DCHECK((textfield_->style() & Textfield::STYLE_OBSCURED) == 0);
117 SetEditStyle(SES_LOWERCASE, SES_LOWERCASE); 117 SetEditStyle(SES_LOWERCASE, SES_LOWERCASE);
118 } 118 }
119 119
120 // Set up the text_object_model_. 120 // Set up the text_object_model_.
121 base::win::ScopedComPtr<IRichEditOle, &IID_IRichEditOle> ole_interface; 121 base::win::ScopedComPtr<IRichEditOle, &IID_IRichEditOle> ole_interface;
122 ole_interface.Attach(GetOleInterface()); 122 ole_interface.Attach(GetOleInterface());
123 if (ole_interface) 123 if (ole_interface)
124 text_object_model_.QueryFrom(ole_interface); 124 text_object_model_.QueryFrom(ole_interface);
125 125
126 InitializeAccessibilityInfo(); 126 InitializeAccessibilityInfo();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 254
255 void NativeTextfieldWin::UpdateFont() { 255 void NativeTextfieldWin::UpdateFont() {
256 SendMessage(m_hWnd, WM_SETFONT, 256 SendMessage(m_hWnd, WM_SETFONT,
257 reinterpret_cast<WPARAM>(textfield_->font().GetNativeFont()), 257 reinterpret_cast<WPARAM>(textfield_->font().GetNativeFont()),
258 TRUE); 258 TRUE);
259 // Setting the font blows away any text color we've set, so reset it. 259 // Setting the font blows away any text color we've set, so reset it.
260 UpdateTextColor(); 260 UpdateTextColor();
261 } 261 }
262 262
263 void NativeTextfieldWin::UpdateIsPassword() { 263 void NativeTextfieldWin::UpdateIsObscured() {
264 // TODO: Need to implement for Windows. 264 // TODO: Need to implement for Windows.
265 UpdateAccessibleState(STATE_SYSTEM_PROTECTED, textfield_->IsPassword()); 265 UpdateAccessibleState(STATE_SYSTEM_PROTECTED, textfield_->IsObscured());
266 } 266 }
267 267
268 void NativeTextfieldWin::UpdateEnabled() { 268 void NativeTextfieldWin::UpdateEnabled() {
269 SendMessage(m_hWnd, WM_ENABLE, textfield_->enabled(), 0); 269 SendMessage(m_hWnd, WM_ENABLE, textfield_->enabled(), 0);
270 UpdateAccessibleState(STATE_SYSTEM_UNAVAILABLE, !textfield_->enabled()); 270 UpdateAccessibleState(STATE_SYSTEM_UNAVAILABLE, !textfield_->enabled());
271 } 271 }
272 272
273 gfx::Insets NativeTextfieldWin::CalculateInsets() { 273 gfx::Insets NativeTextfieldWin::CalculateInsets() {
274 // NOTE: One would think GetThemeMargins would return the insets we should 274 // NOTE: One would think GetThemeMargins would return the insets we should
275 // use, but it doesn't. The margins returned by GetThemeMargins are always 275 // use, but it doesn't. The margins returned by GetThemeMargins are always
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // NativeTextfieldWin, ui::SimpleMenuModel::Delegate implementation: 392 // NativeTextfieldWin, ui::SimpleMenuModel::Delegate implementation:
393 393
394 bool NativeTextfieldWin::IsCommandIdChecked(int command_id) const { 394 bool NativeTextfieldWin::IsCommandIdChecked(int command_id) const {
395 return false; 395 return false;
396 } 396 }
397 397
398 bool NativeTextfieldWin::IsCommandIdEnabled(int command_id) const { 398 bool NativeTextfieldWin::IsCommandIdEnabled(int command_id) const {
399 switch (command_id) { 399 switch (command_id) {
400 case IDS_APP_UNDO: return !textfield_->read_only() && !!CanUndo(); 400 case IDS_APP_UNDO: return !textfield_->read_only() && !!CanUndo();
401 case IDS_APP_CUT: return !textfield_->read_only() && 401 case IDS_APP_CUT: return !textfield_->read_only() &&
402 !textfield_->IsPassword() && !!CanCut(); 402 !textfield_->IsObscured() && !!CanCut();
403 case IDS_APP_COPY: return !!CanCopy() && !textfield_->IsPassword(); 403 case IDS_APP_COPY: return !!CanCopy() && !textfield_->IsObscured();
404 case IDS_APP_PASTE: return !textfield_->read_only() && !!CanPaste(); 404 case IDS_APP_PASTE: return !textfield_->read_only() && !!CanPaste();
405 case IDS_APP_SELECT_ALL: return !!CanSelectAll(); 405 case IDS_APP_SELECT_ALL: return !!CanSelectAll();
406 default: NOTREACHED(); 406 default: NOTREACHED();
407 return false; 407 return false;
408 } 408 }
409 } 409 }
410 410
411 bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id, 411 bool NativeTextfieldWin::GetAcceleratorForCommandId(int command_id,
412 ui::Accelerator* accelerator) { 412 ui::Accelerator* accelerator) {
413 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators 413 // The standard Ctrl-X, Ctrl-V and Ctrl-C are not defined as accelerators
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 POINT p(point); 519 POINT p(point);
520 if (point.x == -1 || point.y == -1) { 520 if (point.x == -1 || point.y == -1) {
521 GetCaretPos(&p); 521 GetCaretPos(&p);
522 MapWindowPoints(HWND_DESKTOP, &p, 1); 522 MapWindowPoints(HWND_DESKTOP, &p, 1);
523 } 523 }
524 BuildContextMenu(); 524 BuildContextMenu();
525 context_menu_->RunContextMenuAt(gfx::Point(p)); 525 context_menu_->RunContextMenuAt(gfx::Point(p));
526 } 526 }
527 527
528 void NativeTextfieldWin::OnCopy() { 528 void NativeTextfieldWin::OnCopy() {
529 if (textfield_->IsPassword()) 529 if (textfield_->IsObscured())
530 return; 530 return;
531 531
532 const string16 text(GetSelectedText()); 532 const string16 text(GetSelectedText());
533 if (!text.empty() && ViewsDelegate::views_delegate) { 533 if (!text.empty() && ViewsDelegate::views_delegate) {
534 ui::ScopedClipboardWriter scw( 534 ui::ScopedClipboardWriter scw(
535 ViewsDelegate::views_delegate->GetClipboard()); 535 ViewsDelegate::views_delegate->GetClipboard());
536 scw.WriteText(text); 536 scw.WriteText(text);
537 } 537 }
538 } 538 }
539 539
540 void NativeTextfieldWin::OnCut() { 540 void NativeTextfieldWin::OnCut() {
541 if (textfield_->read_only() || textfield_->IsPassword()) 541 if (textfield_->read_only() || textfield_->IsObscured())
542 return; 542 return;
543 543
544 OnCopy(); 544 OnCopy();
545 545
546 // This replace selection will have no effect (even on the undo stack) if the 546 // This replace selection will have no effect (even on the undo stack) if the
547 // current selection is empty. 547 // current selection is empty.
548 ReplaceSel(L"", true); 548 ReplaceSel(L"", true);
549 } 549 }
550 550
551 LRESULT NativeTextfieldWin::OnImeChar(UINT message, 551 LRESULT NativeTextfieldWin::OnImeChar(UINT message,
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1157
1158 // static 1158 // static
1159 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 1159 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
1160 Textfield* field) { 1160 Textfield* field) {
1161 if (views::Widget::IsPureViews()) 1161 if (views::Widget::IsPureViews())
1162 return new NativeTextfieldViews(field); 1162 return new NativeTextfieldViews(field);
1163 return new NativeTextfieldWin(field); 1163 return new NativeTextfieldWin(field);
1164 } 1164 }
1165 1165
1166 } // namespace views 1166 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.h ('k') | ui/views/controls/textfield/native_textfield_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698