summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 19:47:23 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 19:47:23 +0000
commitba96e33fd8a5b9610de51f6d3e15e6c469674dc2 (patch)
treeda17919af6b99801762e4d7618e92e53dc13a9f3 /views
parent44c1d4872df77d6ac3bd064a7634078c443a332f (diff)
downloadchromium_src-ba96e33fd8a5b9610de51f6d3e15e6c469674dc2.zip
chromium_src-ba96e33fd8a5b9610de51f6d3e15e6c469674dc2.tar.gz
chromium_src-ba96e33fd8a5b9610de51f6d3e15e6c469674dc2.tar.bz2
Move text_field.cc and rename the class to Textfield in preparation for porting.
BUG=none TEST=none Review URL: http://codereview.chromium.org/115825 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/message_box_view.cc4
-rw-r--r--views/controls/message_box_view.h6
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc0
-rw-r--r--views/controls/textfield/native_textfield_gtk.h0
-rw-r--r--views/controls/textfield/native_textfield_win.cc0
-rw-r--r--views/controls/textfield/native_textfield_win.h0
-rw-r--r--views/controls/textfield/native_textfield_wrapper.h0
-rw-r--r--views/controls/textfield/textfield.cc (renamed from views/controls/text_field.cc)182
-rw-r--r--views/controls/textfield/textfield.h (renamed from views/controls/text_field.h)31
-rw-r--r--views/focus/focus_manager_unittest.cc46
-rw-r--r--views/view_unittest.cc20
-rw-r--r--views/views.gyp9
12 files changed, 150 insertions, 148 deletions
diff --git a/views/controls/message_box_view.cc b/views/controls/message_box_view.cc
index 785ea42..064f644 100644
--- a/views/controls/message_box_view.cc
+++ b/views/controls/message_box_view.cc
@@ -137,7 +137,7 @@ void MessageBoxView::Init(int dialog_flags,
}
if (dialog_flags & MessageBoxFlags::kFlagHasPromptField) {
- prompt_field_ = new views::TextField;
+ prompt_field_ = new views::Textfield;
prompt_field_->SetText(default_prompt);
}
@@ -169,7 +169,7 @@ void MessageBoxView::ResetLayoutManager() {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::FIXED, message_width_, 0);
- // Column set for prompt textfield, if one has been set.
+ // Column set for prompt Textfield, if one has been set.
const int textfield_column_view_set_id = 1;
if (prompt_field_) {
column_set = layout->AddColumnSet(textfield_column_view_set_id);
diff --git a/views/controls/message_box_view.h b/views/controls/message_box_view.h
index 6356d84..c34e904 100644
--- a/views/controls/message_box_view.h
+++ b/views/controls/message_box_view.h
@@ -10,7 +10,7 @@
#include "base/task.h"
#include "views/controls/image_view.h"
#include "views/controls/label.h"
-#include "views/controls/text_field.h"
+#include "views/controls/textfield/textfield.h"
#include "views/view.h"
namespace views {
@@ -32,7 +32,7 @@ class MessageBoxView : public views::View {
const std::wstring& default_prompt);
// Returns the text box.
- views::TextField* text_box() { return prompt_field_; }
+ views::Textfield* text_box() { return prompt_field_; }
// Returns user entered data in the prompt field.
std::wstring GetInputText();
@@ -75,7 +75,7 @@ class MessageBoxView : public views::View {
views::Label* message_label_;
// Input text field for the message box.
- views::TextField* prompt_field_;
+ views::Textfield* prompt_field_;
// Icon displayed in the upper left corner of the message box.
views::ImageView* icon_;
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/controls/textfield/native_textfield_gtk.cc
diff --git a/views/controls/textfield/native_textfield_gtk.h b/views/controls/textfield/native_textfield_gtk.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/controls/textfield/native_textfield_gtk.h
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/controls/textfield/native_textfield_win.cc
diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/controls/textfield/native_textfield_win.h
diff --git a/views/controls/textfield/native_textfield_wrapper.h b/views/controls/textfield/native_textfield_wrapper.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/views/controls/textfield/native_textfield_wrapper.h
diff --git a/views/controls/text_field.cc b/views/controls/textfield/textfield.cc
index 1d00321..6675ce9 100644
--- a/views/controls/text_field.cc
+++ b/views/controls/textfield/textfield.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "views/controls/text_field.h"
+#include "views/controls/textfield/textfield.h"
#include <atlbase.h>
#include <atlapp.h>
@@ -35,15 +35,15 @@ namespace views {
static const int kDefaultEditStyle = WS_CHILD | WS_VISIBLE;
-class TextField::Edit
- : public CWindowImpl<TextField::Edit, CRichEditCtrl,
+class Textfield::Edit
+ : public CWindowImpl<Textfield::Edit, CRichEditCtrl,
CWinTraits<kDefaultEditStyle> >,
- public CRichEditCommands<TextField::Edit>,
+ public CRichEditCommands<Textfield::Edit>,
public Menu::Delegate {
public:
- DECLARE_WND_CLASS(L"ChromeViewsTextFieldEdit");
+ DECLARE_WND_CLASS(L"ChromeViewsTextfieldEdit");
- Edit(TextField* parent, bool draw_border);
+ Edit(Textfield* parent, bool draw_border);
~Edit();
std::wstring GetText() const;
@@ -186,7 +186,7 @@ class TextField::Edit
static bool did_load_library_;
- TextField* parent_;
+ Textfield* parent_;
// The context menu for the edit.
scoped_ptr<Menu> context_menu_;
@@ -215,7 +215,7 @@ class TextField::Edit
///////////////////////////////////////////////////////////////////////////////
// Helper classes
-TextField::Edit::ScopedFreeze::ScopedFreeze(TextField::Edit* edit,
+Textfield::Edit::ScopedFreeze::ScopedFreeze(Textfield::Edit* edit,
ITextDocument* text_object_model)
: edit_(edit),
text_object_model_(text_object_model) {
@@ -226,7 +226,7 @@ TextField::Edit::ScopedFreeze::ScopedFreeze(TextField::Edit* edit,
}
}
-TextField::Edit::ScopedFreeze::~ScopedFreeze() {
+Textfield::Edit::ScopedFreeze::~ScopedFreeze() {
// Unfreeze the screen.
if (text_object_model_) {
long count;
@@ -242,11 +242,11 @@ TextField::Edit::ScopedFreeze::~ScopedFreeze() {
}
///////////////////////////////////////////////////////////////////////////////
-// TextField::Edit
+// Textfield::Edit
-bool TextField::Edit::did_load_library_ = false;
+bool Textfield::Edit::did_load_library_ = false;
-TextField::Edit::Edit(TextField* parent, bool draw_border)
+Textfield::Edit::Edit(Textfield* parent, bool draw_border)
: parent_(parent),
tracking_double_click_(false),
double_click_time_(0),
@@ -261,13 +261,13 @@ TextField::Edit::Edit(TextField* parent, bool draw_border)
did_load_library_ = !!LoadLibrary(L"riched20.dll");
DWORD style = kDefaultEditStyle;
- if (parent->GetStyle() & TextField::STYLE_PASSWORD)
+ if (parent->GetStyle() & Textfield::STYLE_PASSWORD)
style |= ES_PASSWORD;
if (parent->read_only_)
style |= ES_READONLY;
- if (parent->GetStyle() & TextField::STYLE_MULTILINE)
+ if (parent->GetStyle() & Textfield::STYLE_MULTILINE)
style |= ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL;
else
style |= ES_AUTOHSCROLL;
@@ -277,8 +277,8 @@ TextField::Edit::Edit(TextField* parent, bool draw_border)
RECT r = {0, 0, parent_->width(), parent_->height()};
Create(parent_->GetWidget()->GetNativeView(), r, NULL, style, ex_style);
- if (parent->GetStyle() & TextField::STYLE_LOWERCASE) {
- DCHECK((parent->GetStyle() & TextField::STYLE_PASSWORD) == 0);
+ if (parent->GetStyle() & Textfield::STYLE_LOWERCASE) {
+ DCHECK((parent->GetStyle() & Textfield::STYLE_PASSWORD) == 0);
SetEditStyle(SES_LOWERCASE, SES_LOWERCASE);
}
@@ -302,17 +302,17 @@ TextField::Edit::Edit(TextField* parent, bool draw_border)
l10n_util::GetString(IDS_APP_SELECT_ALL));
}
-TextField::Edit::~Edit() {
+Textfield::Edit::~Edit() {
}
-std::wstring TextField::Edit::GetText() const {
+std::wstring Textfield::Edit::GetText() const {
int len = GetTextLength() + 1;
std::wstring str;
GetWindowText(WriteInto(&str, len), len);
return str;
}
-void TextField::Edit::SetText(const std::wstring& text) {
+void Textfield::Edit::SetText(const std::wstring& text) {
// Adjusting the string direction before setting the text in order to make
// sure both RTL and LTR strings are displayed properly.
std::wstring text_to_set;
@@ -323,14 +323,14 @@ void TextField::Edit::SetText(const std::wstring& text) {
SetWindowText(text_to_set.c_str());
}
-void TextField::Edit::AppendText(const std::wstring& text) {
+void Textfield::Edit::AppendText(const std::wstring& text) {
int text_length = GetWindowTextLength();
::SendMessage(m_hWnd, TBM_SETSEL, true, MAKELPARAM(text_length, text_length));
::SendMessage(m_hWnd, EM_REPLACESEL, false,
reinterpret_cast<LPARAM>(text.c_str()));
}
-std::wstring TextField::Edit::GetSelectedText() const {
+std::wstring Textfield::Edit::GetSelectedText() const {
// Figure out the length of the selection.
long start;
long end;
@@ -343,17 +343,17 @@ std::wstring TextField::Edit::GetSelectedText() const {
return str;
}
-void TextField::Edit::SelectAll() {
+void Textfield::Edit::SelectAll() {
// Select from the end to the front so that the first part of the text is
// always visible.
SetSel(GetTextLength(), 0);
}
-void TextField::Edit::ClearSelection() {
+void Textfield::Edit::ClearSelection() {
SetSel(GetTextLength(), GetTextLength());
}
-void TextField::Edit::RemoveBorder() {
+void Textfield::Edit::RemoveBorder() {
if (!draw_border_)
return;
@@ -363,27 +363,27 @@ void TextField::Edit::RemoveBorder() {
SWP_NOOWNERZORDER | SWP_NOSIZE);
}
-void TextField::Edit::SetEnabled(bool enabled) {
+void Textfield::Edit::SetEnabled(bool enabled) {
SendMessage(parent_->GetNativeComponent(), WM_ENABLE,
static_cast<WPARAM>(enabled), 0);
}
// static
-bool TextField::IsKeystrokeEnter(const Keystroke& key) {
+bool Textfield::IsKeystrokeEnter(const Keystroke& key) {
return key.key == VK_RETURN;
}
// static
-bool TextField::IsKeystrokeEscape(const Keystroke& key) {
+bool Textfield::IsKeystrokeEscape(const Keystroke& key) {
return key.key == VK_ESCAPE;
}
-void TextField::Edit::SetBackgroundColor(COLORREF bg_color) {
+void Textfield::Edit::SetBackgroundColor(COLORREF bg_color) {
CRichEditCtrl::SetBackgroundColor(bg_color);
bg_color_ = bg_color;
}
-bool TextField::Edit::IsCommandEnabled(int id) const {
+bool Textfield::Edit::IsCommandEnabled(int id) const {
switch (id) {
case IDS_APP_UNDO: return !parent_->IsReadOnly() && !!CanUndo();
case IDS_APP_CUT: return !parent_->IsReadOnly() &&
@@ -396,7 +396,7 @@ bool TextField::Edit::IsCommandEnabled(int id) const {
}
}
-void TextField::Edit::ExecuteCommand(int id) {
+void Textfield::Edit::ExecuteCommand(int id) {
ScopedFreeze freeze(this, GetTextObjectModel());
OnBeforePossibleChange();
switch (id) {
@@ -410,11 +410,11 @@ void TextField::Edit::ExecuteCommand(int id) {
OnAfterPossibleChange();
}
-void TextField::Edit::OnChar(TCHAR ch, UINT repeat_count, UINT flags) {
+void Textfield::Edit::OnChar(TCHAR ch, UINT repeat_count, UINT flags) {
HandleKeystroke(GetCurrentMessage()->message, ch, repeat_count, flags);
}
-void TextField::Edit::OnContextMenu(HWND window, const CPoint& point) {
+void Textfield::Edit::OnContextMenu(HWND window, const CPoint& point) {
CPoint p(point);
if (point.x == -1 || point.y == -1) {
GetCaretPos(&p);
@@ -423,7 +423,7 @@ void TextField::Edit::OnContextMenu(HWND window, const CPoint& point) {
context_menu_->RunMenuAt(p.x, p.y);
}
-void TextField::Edit::OnCopy() {
+void Textfield::Edit::OnCopy() {
if (parent_->IsPassword())
return;
@@ -435,7 +435,7 @@ void TextField::Edit::OnCopy() {
}
}
-void TextField::Edit::OnCut() {
+void Textfield::Edit::OnCut() {
if (parent_->IsReadOnly() || parent_->IsPassword())
return;
@@ -446,7 +446,7 @@ void TextField::Edit::OnCut() {
ReplaceSel(L"", true);
}
-LRESULT TextField::Edit::OnImeChar(UINT message, WPARAM wparam, LPARAM lparam) {
+LRESULT Textfield::Edit::OnImeChar(UINT message, WPARAM wparam, LPARAM lparam) {
// http://crbug.com/7707: a rich-edit control may crash when it receives a
// WM_IME_CHAR message while it is processing a WM_IME_COMPOSITION message.
// Since view controls don't need WM_IME_CHAR messages, we prevent WM_IME_CHAR
@@ -455,7 +455,7 @@ LRESULT TextField::Edit::OnImeChar(UINT message, WPARAM wparam, LPARAM lparam) {
return 0;
}
-LRESULT TextField::Edit::OnImeStartComposition(UINT message,
+LRESULT Textfield::Edit::OnImeStartComposition(UINT message,
WPARAM wparam,
LPARAM lparam) {
// Users may press alt+shift or control+shift keys to change their keyboard
@@ -470,7 +470,7 @@ LRESULT TextField::Edit::OnImeStartComposition(UINT message,
return DefWindowProc(message, wparam, lparam);
}
-LRESULT TextField::Edit::OnImeComposition(UINT message,
+LRESULT Textfield::Edit::OnImeComposition(UINT message,
WPARAM wparam,
LPARAM lparam) {
text_before_change_.clear();
@@ -506,7 +506,7 @@ LRESULT TextField::Edit::OnImeComposition(UINT message,
return result;
}
-LRESULT TextField::Edit::OnImeEndComposition(UINT message,
+LRESULT Textfield::Edit::OnImeEndComposition(UINT message,
WPARAM wparam,
LPARAM lparam) {
// Bug 11863: Korean IMEs send a WM_IME_ENDCOMPOSITION message without
@@ -520,7 +520,7 @@ LRESULT TextField::Edit::OnImeEndComposition(UINT message,
return DefWindowProc(message, wparam, lparam);
}
-void TextField::Edit::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) {
+void Textfield::Edit::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) {
// NOTE: Annoyingly, ctrl-alt-<key> generates WM_KEYDOWN rather than
// WM_SYSKEYDOWN, so we need to check (flags & KF_ALTDOWN) in various places
// in this function even with a WM_SYSKEYDOWN handler.
@@ -599,7 +599,7 @@ void TextField::Edit::OnKeyDown(TCHAR key, UINT repeat_count, UINT flags) {
HandleKeystroke(GetCurrentMessage()->message, key, repeat_count, flags);
}
-void TextField::Edit::OnLButtonDblClk(UINT keys, const CPoint& point) {
+void Textfield::Edit::OnLButtonDblClk(UINT keys, const CPoint& point) {
// Save the double click info for later triple-click detection.
tracking_double_click_ = true;
double_click_point_ = point;
@@ -612,7 +612,7 @@ void TextField::Edit::OnLButtonDblClk(UINT keys, const CPoint& point) {
OnAfterPossibleChange();
}
-void TextField::Edit::OnLButtonDown(UINT keys, const CPoint& point) {
+void Textfield::Edit::OnLButtonDown(UINT keys, const CPoint& point) {
// Check for triple click, then reset tracker. Should be safe to subtract
// double_click_time_ from the current message's time even if the timer has
// wrapped in between.
@@ -629,7 +629,7 @@ void TextField::Edit::OnLButtonDown(UINT keys, const CPoint& point) {
OnAfterPossibleChange();
}
-void TextField::Edit::OnLButtonUp(UINT keys, const CPoint& point) {
+void Textfield::Edit::OnLButtonUp(UINT keys, const CPoint& point) {
ScopedFreeze freeze(this, GetTextObjectModel());
OnBeforePossibleChange();
DefWindowProc(WM_LBUTTONUP, keys,
@@ -637,11 +637,11 @@ void TextField::Edit::OnLButtonUp(UINT keys, const CPoint& point) {
OnAfterPossibleChange();
}
-void TextField::Edit::OnMouseLeave() {
+void Textfield::Edit::OnMouseLeave() {
SetContainsMouse(false);
}
-LRESULT TextField::Edit::OnMouseWheel(UINT message,
+LRESULT Textfield::Edit::OnMouseWheel(UINT message,
WPARAM w_param, LPARAM l_param) {
// Reroute the mouse-wheel to the window under the mouse pointer if
// applicable.
@@ -650,7 +650,7 @@ LRESULT TextField::Edit::OnMouseWheel(UINT message,
return DefWindowProc(message, w_param, l_param);;
}
-void TextField::Edit::OnMouseMove(UINT keys, const CPoint& point) {
+void Textfield::Edit::OnMouseMove(UINT keys, const CPoint& point) {
SetContainsMouse(true);
// Clamp the selection to the visible text so the user can't drag to select
// the "phantom newline". In theory we could achieve this by clipping the X
@@ -704,7 +704,7 @@ void TextField::Edit::OnMouseMove(UINT keys, const CPoint& point) {
}
}
-int TextField::Edit::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
+int Textfield::Edit::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
content_insets_.Set(0, 0, 0, 0);
parent_->CalculateInsets(&content_insets_);
if (w_param) {
@@ -724,7 +724,7 @@ int TextField::Edit::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
return 0;
}
-void TextField::Edit::OnNCPaint(HRGN region) {
+void Textfield::Edit::OnNCPaint(HRGN region) {
if (!draw_border_)
return;
@@ -786,7 +786,7 @@ void TextField::Edit::OnNCPaint(HRGN region) {
ReleaseDC(hdc);
}
-void TextField::Edit::OnNonLButtonDown(UINT keys, const CPoint& point) {
+void Textfield::Edit::OnNonLButtonDown(UINT keys, const CPoint& point) {
// Interestingly, the edit doesn't seem to cancel triple clicking when the
// x-buttons (which usually means "thumb buttons") are pressed, so we only
// call this for M and R down.
@@ -794,7 +794,7 @@ void TextField::Edit::OnNonLButtonDown(UINT keys, const CPoint& point) {
SetMsgHandled(false);
}
-void TextField::Edit::OnPaste() {
+void Textfield::Edit::OnPaste() {
if (parent_->IsReadOnly() || !ViewsDelegate::views_delegate)
return;
@@ -816,7 +816,7 @@ void TextField::Edit::OnPaste() {
}
}
-void TextField::Edit::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) {
+void Textfield::Edit::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) {
// Nearly all alt-<xxx> combos result in beeping rather than doing something
// useful, so we discard most. Exceptions:
// * ctrl-alt-<xxx>, which is sometimes important, generates WM_CHAR instead
@@ -828,17 +828,17 @@ void TextField::Edit::OnSysChar(TCHAR ch, UINT repeat_count, UINT flags) {
SetMsgHandled(false);
}
-void TextField::Edit::HandleKeystroke(UINT message,
+void Textfield::Edit::HandleKeystroke(UINT message,
TCHAR key,
UINT repeat_count,
UINT flags) {
ScopedFreeze freeze(this, GetTextObjectModel());
- TextField::Controller* controller = parent_->GetController();
+ Textfield::Controller* controller = parent_->GetController();
bool handled = false;
if (controller) {
handled = controller->HandleKeystroke(parent_,
- TextField::Keystroke(message, key, repeat_count, flags));
+ Textfield::Keystroke(message, key, repeat_count, flags));
}
if (!handled) {
@@ -848,12 +848,12 @@ void TextField::Edit::HandleKeystroke(UINT message,
}
}
-void TextField::Edit::OnBeforePossibleChange() {
+void Textfield::Edit::OnBeforePossibleChange() {
// Record our state.
text_before_change_ = GetText();
}
-void TextField::Edit::OnAfterPossibleChange() {
+void Textfield::Edit::OnAfterPossibleChange() {
// Prevent the user from selecting the "phantom newline" at the end of the
// edit. If they try, we just silently move the end of the selection back to
// the end of the real text.
@@ -886,7 +886,7 @@ void TextField::Edit::OnAfterPossibleChange() {
}
}
-LONG TextField::Edit::ClipXCoordToVisibleText(LONG x,
+LONG Textfield::Edit::ClipXCoordToVisibleText(LONG x,
bool is_triple_click) const {
// Clip the X coordinate to the left edge of the text. Careful:
// PosFromChar(0) may return a negative X coordinate if the beginning of the
@@ -942,7 +942,7 @@ LONG TextField::Edit::ClipXCoordToVisibleText(LONG x,
return is_triple_click ? (right_bound - 1) : right_bound;
}
-void TextField::Edit::SetContainsMouse(bool contains_mouse) {
+void Textfield::Edit::SetContainsMouse(bool contains_mouse) {
if (contains_mouse == contains_mouse_)
return;
@@ -964,7 +964,7 @@ void TextField::Edit::SetContainsMouse(bool contains_mouse) {
RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME);
}
-ITextDocument* TextField::Edit::GetTextObjectModel() const {
+ITextDocument* Textfield::Edit::GetTextObjectModel() const {
if (!text_object_model_) {
CComPtr<IRichEditOle> ole_interface;
ole_interface.Attach(GetOleInterface());
@@ -974,9 +974,9 @@ ITextDocument* TextField::Edit::GetTextObjectModel() const {
}
/////////////////////////////////////////////////////////////////////////////
-// TextField
+// Textfield
-TextField::~TextField() {
+Textfield::~Textfield() {
if (edit_) {
// If the edit hwnd still exists, we need to destroy it explicitly.
if (*edit_)
@@ -985,7 +985,7 @@ TextField::~TextField() {
}
}
-void TextField::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
+void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
Widget* widget;
if (is_add && (widget = GetWidget())) {
@@ -1022,14 +1022,14 @@ void TextField::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
}
}
-void TextField::Layout() {
+void Textfield::Layout() {
if (native_view_) {
native_view_->SetBounds(GetLocalBounds(true));
native_view_->Layout();
}
}
-gfx::Size TextField::GetPreferredSize() {
+gfx::Size Textfield::GetPreferredSize() {
gfx::Insets insets;
CalculateInsets(&insets);
return gfx::Size(font_.GetExpectedTextWidth(default_width_in_chars_) +
@@ -1037,23 +1037,23 @@ gfx::Size TextField::GetPreferredSize() {
num_lines_ * font_.height() + insets.height());
}
-std::wstring TextField::GetText() const {
+std::wstring Textfield::GetText() const {
return text_;
}
-void TextField::SetText(const std::wstring& text) {
+void Textfield::SetText(const std::wstring& text) {
text_ = text;
if (edit_)
edit_->SetText(text);
}
-void TextField::AppendText(const std::wstring& text) {
+void Textfield::AppendText(const std::wstring& text) {
text_ += text;
if (edit_)
edit_->AppendText(text);
}
-void TextField::CalculateInsets(gfx::Insets* insets) {
+void Textfield::CalculateInsets(gfx::Insets* insets) {
DCHECK(insets);
if (!draw_border_)
@@ -1067,32 +1067,32 @@ void TextField::CalculateInsets(gfx::Insets* insets) {
insets->Set(3, 3, 3, 3);
}
-void TextField::SyncText() {
+void Textfield::SyncText() {
if (edit_)
text_ = edit_->GetText();
}
-void TextField::SetController(Controller* controller) {
+void Textfield::SetController(Controller* controller) {
controller_ = controller;
}
-TextField::Controller* TextField::GetController() const {
+Textfield::Controller* Textfield::GetController() const {
return controller_;
}
-bool TextField::IsReadOnly() const {
+bool Textfield::IsReadOnly() const {
return edit_ ? ((edit_->GetStyle() & ES_READONLY) != 0) : read_only_;
}
-bool TextField::IsPassword() const {
- return GetStyle() & TextField::STYLE_PASSWORD;
+bool Textfield::IsPassword() const {
+ return GetStyle() & Textfield::STYLE_PASSWORD;
}
-bool TextField::IsMultiLine() const {
+bool Textfield::IsMultiLine() const {
return (style_ & STYLE_MULTILINE) != 0;
}
-void TextField::SetReadOnly(bool read_only) {
+void Textfield::SetReadOnly(bool read_only) {
read_only_ = read_only;
if (edit_) {
edit_->SetReadOnly(read_only);
@@ -1100,46 +1100,46 @@ void TextField::SetReadOnly(bool read_only) {
}
}
-void TextField::Focus() {
+void Textfield::Focus() {
::SetFocus(native_view_->GetHWND());
}
-void TextField::SelectAll() {
+void Textfield::SelectAll() {
if (edit_)
edit_->SelectAll();
}
-void TextField::ClearSelection() const {
+void Textfield::ClearSelection() const {
if (edit_)
edit_->ClearSelection();
}
-HWND TextField::GetNativeComponent() {
+HWND Textfield::GetNativeComponent() {
return native_view_->GetHWND();
}
-void TextField::SetBackgroundColor(SkColor color) {
+void Textfield::SetBackgroundColor(SkColor color) {
background_color_ = color;
use_default_background_color_ = false;
UpdateEditBackgroundColor();
}
-void TextField::SetDefaultBackgroundColor() {
+void Textfield::SetDefaultBackgroundColor() {
use_default_background_color_ = true;
UpdateEditBackgroundColor();
}
-void TextField::SetFont(const gfx::Font& font) {
+void Textfield::SetFont(const gfx::Font& font) {
font_ = font;
if (edit_)
edit_->SetFont(font.hfont());
}
-gfx::Font TextField::GetFont() const {
+gfx::Font Textfield::GetFont() const {
return font_;
}
-bool TextField::SetHorizontalMargins(int left, int right) {
+bool Textfield::SetHorizontalMargins(int left, int right) {
// SendMessage expects the two values to be packed into one using MAKELONG
// so we truncate to 16 bits if necessary.
return ERROR_SUCCESS == SendMessage(GetNativeComponent(),
@@ -1149,12 +1149,12 @@ bool TextField::SetHorizontalMargins(int left, int right) {
right & 0xFFFF));
}
-void TextField::SetHeightInLines(int num_lines) {
+void Textfield::SetHeightInLines(int num_lines) {
DCHECK(IsMultiLine());
num_lines_ = num_lines;
}
-void TextField::RemoveBorder() {
+void Textfield::RemoveBorder() {
if (!draw_border_)
return;
@@ -1163,20 +1163,20 @@ void TextField::RemoveBorder() {
edit_->RemoveBorder();
}
-void TextField::SetEnabled(bool enabled) {
+void Textfield::SetEnabled(bool enabled) {
View::SetEnabled(enabled);
edit_->SetEnabled(enabled);
}
-bool TextField::IsFocusable() const {
+bool Textfield::IsFocusable() const {
return IsEnabled() && !IsReadOnly();
}
-void TextField::AboutToRequestFocusFromTabTraversal(bool reverse) {
+void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) {
SelectAll();
}
-bool TextField::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
+bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
// TODO(hamaji): Figure out which keyboard combinations we need to add here,
// similar to LocationBarView::SkipDefaultKeyEventProcessing.
if (e.GetCharacter() == VK_BACK)
@@ -1191,7 +1191,7 @@ bool TextField::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
return false;
}
-void TextField::UpdateEditBackgroundColor() {
+void Textfield::UpdateEditBackgroundColor() {
if (!edit_)
return;
diff --git a/views/controls/text_field.h b/views/controls/textfield/textfield.h
index 3c4571a..114dbbf 100644
--- a/views/controls/text_field.h
+++ b/views/controls/textfield/textfield.h
@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// These classes define a text field widget that can be used in the views UI
-// toolkit.
-
-#ifndef VIEWS_CONTROLS_TEXT_FIELD_H_
-#define VIEWS_CONTROLS_TEXT_FIELD_H_
+#ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
+#define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
#include <string>
@@ -20,7 +17,7 @@ namespace views {
class HWNDView;
// This class implements a ChromeView that wraps a native text (edit) field.
-class TextField : public View {
+class Textfield : public View {
public:
// Keystroke provides a platform-dependent way to send keystroke events.
// Cross-platform code can use IsKeystrokeEnter/Escape to check for these
@@ -54,14 +51,14 @@ class TextField : public View {
class Controller {
public:
// This method is called whenever the text in the field changes.
- virtual void ContentsChanged(TextField* sender,
+ virtual void ContentsChanged(Textfield* sender,
const std::wstring& new_contents) = 0;
// This method is called to get notified about keystrokes in the edit.
// This method returns true if the message was handled and should not be
// processed further. If it returns false the processing continues.
- virtual bool HandleKeystroke(TextField* sender,
- const TextField::Keystroke& keystroke) = 0;
+ virtual bool HandleKeystroke(Textfield* sender,
+ const Textfield::Keystroke& keystroke) = 0;
};
enum StyleFlags {
@@ -71,7 +68,7 @@ class TextField : public View {
STYLE_LOWERCASE = 1<<2
};
- TextField()
+ Textfield()
:
#if defined(OS_WIN)
native_view_(NULL),
@@ -86,7 +83,7 @@ class TextField : public View {
num_lines_(1) {
SetFocusable(true);
}
- explicit TextField(StyleFlags style)
+ explicit Textfield(StyleFlags style)
:
#if defined(OS_WIN)
native_view_(NULL),
@@ -101,7 +98,7 @@ class TextField : public View {
num_lines_(1) {
SetFocusable(true);
}
- virtual ~TextField();
+ virtual ~Textfield();
void ViewHierarchyChanged(bool is_add, View* parent, View* child);
@@ -157,7 +154,7 @@ class TextField : public View {
// Set the font.
void SetFont(const gfx::Font& font);
- // Return the font used by this TextField.
+ // Return the font used by this Textfield.
gfx::Font GetFont() const;
// Sets the left and right margin (in pixels) within the text box. On Windows
@@ -220,7 +217,7 @@ class TextField : public View {
gfx::Font font_;
- // NOTE: this is temporary until we rewrite TextField to always work whether
+ // NOTE: this is temporary until we rewrite Textfield to always work whether
// there is an HWND or not.
// Used if the HWND hasn't been created yet.
std::wstring text_;
@@ -238,16 +235,16 @@ class TextField : public View {
bool use_default_background_color_;
- // The number of lines of text this textfield displays at once.
+ // The number of lines of text this Textfield displays at once.
int num_lines_;
protected:
// Calculates the insets for the text field.
void CalculateInsets(gfx::Insets* insets);
- DISALLOW_COPY_AND_ASSIGN(TextField);
+ DISALLOW_COPY_AND_ASSIGN(Textfield);
};
} // namespace views
-#endif // VIEWS_CONTROLS_TEXT_FIELD_H_
+#endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index 7176a0d..64d34c2 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -20,7 +20,7 @@
#include "views/controls/link.h"
#include "views/controls/scroll_view.h"
#include "views/controls/tabbed_pane.h"
-#include "views/controls/text_field.h"
+#include "views/controls/textfield/textfield.h"
#include "views/widget/accelerator_handler.h"
#include "views/widget/root_view.h"
#include "views/widget/widget_win.h"
@@ -39,13 +39,13 @@ static int count = 1;
static const int kTopCheckBoxID = count++; // 1
static const int kLeftContainerID = count++;
static const int kAppleLabelID = count++;
-static const int kAppleTextFieldID = count++;
+static const int kAppleTextfieldID = count++;
static const int kOrangeLabelID = count++; // 5
-static const int kOrangeTextFieldID = count++;
+static const int kOrangeTextfieldID = count++;
static const int kBananaLabelID = count++;
-static const int kBananaTextFieldID = count++;
+static const int kBananaTextfieldID = count++;
static const int kKiwiLabelID = count++;
-static const int kKiwiTextFieldID = count++; // 10
+static const int kKiwiTextfieldID = count++; // 10
static const int kFruitButtonID = count++;
static const int kFruitCheckBoxID = count++;
@@ -80,7 +80,7 @@ static const int kItalicCheckBoxID = count++;
static const int kUnderlinedCheckBoxID = count++;
static const int kSearchContainerID = count++;
-static const int kSearchTextFieldID = count++; // 40
+static const int kSearchTextfieldID = count++; // 40
static const int kSearchButtonID = count++;
static const int kHelpLinkID = count++;
@@ -271,8 +271,8 @@ void TestViewWindow::Init() {
left_container->AddChildView(label);
label->SetBounds(label_x, y, label_width, label_height);
- views::TextField* text_field = new views::TextField();
- text_field->SetID(kAppleTextFieldID);
+ views::Textfield* text_field = new views::Textfield();
+ text_field->SetID(kAppleTextfieldID);
left_container->AddChildView(text_field);
text_field->SetBounds(label_x + label_width + 5, y,
text_field_width, label_height);
@@ -284,8 +284,8 @@ void TestViewWindow::Init() {
left_container->AddChildView(label);
label->SetBounds(label_x, y, label_width, label_height);
- text_field = new views::TextField();
- text_field->SetID(kOrangeTextFieldID);
+ text_field = new views::Textfield();
+ text_field->SetID(kOrangeTextfieldID);
left_container->AddChildView(text_field);
text_field->SetBounds(label_x + label_width + 5, y,
text_field_width, label_height);
@@ -297,8 +297,8 @@ void TestViewWindow::Init() {
left_container->AddChildView(label);
label->SetBounds(label_x, y, label_width, label_height);
- text_field = new views::TextField();
- text_field->SetID(kBananaTextFieldID);
+ text_field = new views::Textfield();
+ text_field->SetID(kBananaTextfieldID);
left_container->AddChildView(text_field);
text_field->SetBounds(label_x + label_width + 5, y,
text_field_width, label_height);
@@ -310,8 +310,8 @@ void TestViewWindow::Init() {
left_container->AddChildView(label);
label->SetBounds(label_x, y, label_width, label_height);
- text_field = new views::TextField();
- text_field->SetID(kKiwiTextFieldID);
+ text_field = new views::Textfield();
+ text_field->SetID(kKiwiTextfieldID);
left_container->AddChildView(text_field);
text_field->SetBounds(label_x + label_width + 5, y,
text_field_width, label_height);
@@ -457,10 +457,10 @@ void TestViewWindow::Init() {
contents = new views::View();
contents->set_background(
views::Background::CreateSolidBackground(SK_ColorWHITE));
- text_field = new views::TextField();
+ text_field = new views::Textfield();
contents->AddChildView(text_field);
text_field->SetBounds(10, 10, 100, 20);
- text_field->SetID(kSearchTextFieldID);
+ text_field->SetID(kSearchTextfieldID);
button = new views::NativeButton(NULL, L"Search");
contents->AddChildView(button);
@@ -534,15 +534,15 @@ void FocusManagerTest::TearDown() {
TEST_F(FocusManagerTest, NormalTraversal) {
- const int kTraversalIDs[] = { kTopCheckBoxID, kAppleTextFieldID,
- kOrangeTextFieldID, kBananaTextFieldID, kKiwiTextFieldID,
+ const int kTraversalIDs[] = { kTopCheckBoxID, kAppleTextfieldID,
+ kOrangeTextfieldID, kBananaTextfieldID, kKiwiTextfieldID,
kFruitButtonID, kFruitCheckBoxID, kAsparagusButtonID, kRosettaLinkID,
kStupeurEtTremblementLinkID,
kDinerGameLinkID, kRidiculeLinkID, kClosetLinkID, kVisitingLinkID,
kAmelieLinkID, kJoyeuxNoelLinkID, kCampingLinkID, kBriceDeNiceLinkID,
kTaxiLinkID, kAsterixLinkID, kOKButtonID, kCancelButtonID, kHelpButtonID,
kStyleContainerID, kBoldCheckBoxID, kItalicCheckBoxID,
- kUnderlinedCheckBoxID, kSearchTextFieldID, kSearchButtonID, kHelpLinkID,
+ kUnderlinedCheckBoxID, kSearchTextfieldID, kSearchButtonID, kHelpLinkID,
kThumbnailContainerID, kThumbnailStarID, kThumbnailSuperStarID };
// Uncomment the following line if you want to test manually the UI of this
@@ -585,16 +585,16 @@ TEST_F(FocusManagerTest, NormalTraversal) {
TEST_F(FocusManagerTest, TraversalWithNonEnabledViews) {
const int kMainContentsDisabledIDs[] = {
- kBananaTextFieldID, kFruitCheckBoxID, kAsparagusButtonID,
+ kBananaTextfieldID, kFruitCheckBoxID, kAsparagusButtonID,
kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID,
kTaxiLinkID, kAsterixLinkID, kHelpButtonID };
const int kStyleContentsDisabledIDs[] = { kBoldCheckBoxID };
- const int kSearchContentsDisabledIDs[] = { kSearchTextFieldID, kHelpLinkID };
+ const int kSearchContentsDisabledIDs[] = { kSearchTextfieldID, kHelpLinkID };
- const int kTraversalIDs[] = { kTopCheckBoxID, kAppleTextFieldID,
- kOrangeTextFieldID, kKiwiTextFieldID, kFruitButtonID, kBroccoliButtonID,
+ const int kTraversalIDs[] = { kTopCheckBoxID, kAppleTextfieldID,
+ kOrangeTextfieldID, kKiwiTextfieldID, kFruitButtonID, kBroccoliButtonID,
kRosettaLinkID, kStupeurEtTremblementLinkID, kDinerGameLinkID,
kRidiculeLinkID, kAmelieLinkID, kJoyeuxNoelLinkID, kCampingLinkID,
kOKButtonID, kCancelButtonID, kStyleContainerID,
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index b5377eb..3e6543d 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -13,7 +13,7 @@
#include "views/controls/button/native_button_win.h"
#endif
#include "views/controls/scroll_view.h"
-#include "views/controls/text_field.h"
+#include "views/controls/textfield/textfield.h"
#include "views/event.h"
#include "views/focus/view_storage.h"
#include "views/view.h"
@@ -593,8 +593,8 @@ TEST_F(ViewTest, HitTestMasks) {
}
#if defined(OS_WIN)
-// Tests that the TextField view respond appropiately to cut/copy/paste.
-TEST_F(ViewTest, TextFieldCutCopyPaste) {
+// Tests that the Textfield view respond appropiately to cut/copy/paste.
+TEST_F(ViewTest, TextfieldCutCopyPaste) {
const std::wstring kNormalText = L"Normal";
const std::wstring kReadOnlyText = L"Read only";
const std::wstring kPasswordText = L"Password! ** Secret stuff **";
@@ -605,10 +605,10 @@ TEST_F(ViewTest, TextFieldCutCopyPaste) {
window->Init(NULL, gfx::Rect(0, 0, 100, 100), true);
RootView* root_view = window->GetRootView();
- TextField* normal = new TextField();
- TextField* read_only = new TextField();
+ Textfield* normal = new Textfield();
+ Textfield* read_only = new Textfield();
read_only->SetReadOnly(true);
- TextField* password = new TextField(TextField::STYLE_PASSWORD);
+ Textfield* password = new Textfield(Textfield::STYLE_PASSWORD);
root_view->AddChildView(normal);
root_view->AddChildView(read_only);
@@ -675,8 +675,8 @@ TEST_F(ViewTest, TextFieldCutCopyPaste) {
//
// Test Paste.
//
- // Note that we use GetWindowText instead of TextField::GetText below as the
- // text in the TextField class is synced to the text of the HWND on
+ // Note that we use GetWindowText instead of Textfield::GetText below as the
+ // text in the Textfield class is synced to the text of the HWND on
// WM_KEYDOWN messages that we are not simulating here.
// Attempting to copy kNormalText in a read-only text-field should fail.
@@ -745,7 +745,7 @@ class TestViewWithControls : public View {
TestViewWithControls() {
button_ = new ButtonTest(NULL, L"Button");
checkbox_ = new CheckboxTest(L"My checkbox");
- text_field_ = new TextField();
+ text_field_ = new Textfield();
AddChildView(button_);
AddChildView(checkbox_);
AddChildView(text_field_);
@@ -753,7 +753,7 @@ class TestViewWithControls : public View {
ButtonTest* button_;
CheckboxTest* checkbox_;
- TextField* text_field_;
+ Textfield* text_field_;
};
class SimpleWindowDelegate : public WindowDelegate {
diff --git a/views/views.gyp b/views/views.gyp
index f6b49ed..9c86b89 100644
--- a/views/views.gyp
+++ b/views/views.gyp
@@ -135,8 +135,13 @@
'controls/table/group_table_view.h',
'controls/table/table_view.cc',
'controls/table/table_view.h',
- 'controls/text_field.cc',
- 'controls/text_field.h',
+ 'controls/textfield/textfield.cc',
+ 'controls/textfield/textfield.h',
+ 'controls/textfield/native_textfield_gtk.cc',
+ 'controls/textfield/native_textfield_gtk.h',
+ 'controls/textfield/native_textfield_win.cc',
+ 'controls/textfield/native_textfield_win.h',
+ 'controls/textfield/native_textfield_wrapper.h',
'controls/throbber.cc',
'controls/throbber.h',
'controls/tree/tree_view.cc',