diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:35:40 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:35:40 +0000 |
commit | 6bc080954611da13cfba38879e96792c079d1a95 (patch) | |
tree | 9cd29e2c9faa988cf6dbcf9024b832776509759d /views | |
parent | 005afbdc6836ecd6b3a09ab76b00221201830210 (diff) | |
download | chromium_src-6bc080954611da13cfba38879e96792c079d1a95.zip chromium_src-6bc080954611da13cfba38879e96792c079d1a95.tar.gz chromium_src-6bc080954611da13cfba38879e96792c079d1a95.tar.bz2 |
Make the views bookmark bubble work on GTK.
The combobox still isn't implemented, but this makes TextBox work, and also
does some changes around the info_bubble to make sure it get created properly.
TEST=none
BUG=none.
Review URL: http://codereview.chromium.org/177026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/label.cc | 5 | ||||
-rw-r--r-- | views/controls/native_control_gtk.cc | 2 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.cc | 73 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.h | 2 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 2 |
5 files changed, 76 insertions, 8 deletions
diff --git a/views/controls/label.cc b/views/controls/label.cc index 5dec56b8..3d2304f 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -101,8 +101,9 @@ int Label::ComputeMultiLineFlags() { return flags; } -void Label::CalculateDrawStringParams( - std::wstring* paint_text, gfx::Rect* text_bounds, int* flags) { +void Label::CalculateDrawStringParams(std::wstring* paint_text, + gfx::Rect* text_bounds, + int* flags) { DCHECK(paint_text && text_bounds && flags); if (url_set_) { diff --git a/views/controls/native_control_gtk.cc b/views/controls/native_control_gtk.cc index 5576f29..656632b 100644 --- a/views/controls/native_control_gtk.cc +++ b/views/controls/native_control_gtk.cc @@ -1,4 +1,4 @@ -// #ifndef CHROME_VIEWS_NATIVE_CONTROL_WIN_H_// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this +// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this // source code is governed by a BSD-style license that can be found in the // LICENSE file. diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc index 87ef0db..82cda2b 100644 --- a/views/controls/textfield/native_textfield_gtk.cc +++ b/views/controls/textfield/native_textfield_gtk.cc @@ -4,13 +4,19 @@ #include "views/controls/textfield/native_textfield_gtk.h" +#include "base/string_util.h" +#include "views/controls/textfield/textfield.h" + namespace views { //////////////////////////////////////////////////////////////////////////////// // NativeTextfieldGtk, public: NativeTextfieldGtk::NativeTextfieldGtk(Textfield* textfield) - : NativeControlGtk() { + : NativeControlGtk(), + textfield_(textfield) { + if (textfield_->style() & Textfield::STYLE_MULTILINE) + NOTIMPLEMENTED(); // We don't support multiline yet. } NativeTextfieldGtk::~NativeTextfieldGtk() { @@ -20,44 +26,91 @@ NativeTextfieldGtk::~NativeTextfieldGtk() { // NativeTextfieldGtk, NativeTextfieldWrapper implementation: std::wstring NativeTextfieldGtk::GetText() const { - return std::wstring(); + if (!native_view()) + return std::wstring(); + return UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(native_view()))); } void NativeTextfieldGtk::UpdateText() { + if (!native_view()) + return; + gtk_entry_set_text(GTK_ENTRY(native_view()), + WideToUTF8(textfield_->text()).c_str()); } void NativeTextfieldGtk::AppendText(const std::wstring& text) { + if (!native_view()) + return; + gtk_entry_append_text(GTK_ENTRY(native_view()), WideToUTF8(text).c_str()); } std::wstring NativeTextfieldGtk::GetSelectedText() const { - return std::wstring(); + if (!native_view()) + return std::wstring(); + + int begin, end; + if (!gtk_editable_get_selection_bounds(GTK_EDITABLE(native_view()), + &begin, &end)) + return std::wstring(); // Nothing selected. + + return UTF8ToWide(std::string( + >k_entry_get_text(GTK_ENTRY(native_view()))[begin], + end - begin)); } void NativeTextfieldGtk::SelectAll() { + if (!native_view()) + return; + // -1 as the end position selects to the end of the text. + gtk_editable_select_region(GTK_EDITABLE(native_view()), + 0, -1); } void NativeTextfieldGtk::ClearSelection() { + if (!native_view()) + return; + gtk_editable_select_region(GTK_EDITABLE(native_view()), 0, 0); } void NativeTextfieldGtk::UpdateBorder() { + if (!native_view()) + return; + NOTIMPLEMENTED(); } void NativeTextfieldGtk::UpdateBackgroundColor() { + if (!native_view()) + return; + NOTIMPLEMENTED(); } void NativeTextfieldGtk::UpdateReadOnly() { + if (!native_view()) + return; + gtk_editable_set_editable(GTK_EDITABLE(native_view()), + textfield_->IsEnabled()); } void NativeTextfieldGtk::UpdateFont() { + if (!native_view()) + return; + NOTIMPLEMENTED(); } void NativeTextfieldGtk::UpdateEnabled() { + if (!native_view()) + return; + NOTIMPLEMENTED(); } void NativeTextfieldGtk::SetHorizontalMargins(int left, int right) { + if (!native_view()) + return; + NOTIMPLEMENTED(); } void NativeTextfieldGtk::SetFocus() { + Focus(); } View* NativeTextfieldGtk::GetView() { @@ -72,7 +125,10 @@ gfx::NativeView NativeTextfieldGtk::GetTestingHandle() const { // NativeTextfieldGtk, NativeControlGtk overrides: void NativeTextfieldGtk::CreateNativeControl() { - // TODO(port): create gtk text field + GtkWidget* widget = gtk_entry_new(); + // TODO(brettw) hook in an observer to get text change events so we can call + // the controller. + NativeControlCreated(widget); } void NativeTextfieldGtk::NativeControlCreated(GtkWidget* widget) { @@ -80,4 +136,13 @@ void NativeTextfieldGtk::NativeControlCreated(GtkWidget* widget) { // TODO(port): post-creation init } +//////////////////////////////////////////////////////////////////////////////// +// NativeTextfieldWrapper, public: + +// static +NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( + Textfield* field) { + return new NativeTextfieldGtk(field); +} + } // namespace views diff --git a/views/controls/textfield/native_textfield_gtk.h b/views/controls/textfield/native_textfield_gtk.h index ce89e55..83013f3 100644 --- a/views/controls/textfield/native_textfield_gtk.h +++ b/views/controls/textfield/native_textfield_gtk.h @@ -38,6 +38,8 @@ class NativeTextfieldGtk : public NativeControlGtk, virtual void NativeControlCreated(GtkWidget* widget); private: + Textfield* textfield_; + DISALLOW_COPY_AND_ASSIGN(NativeTextfieldGtk); }; diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 91b7e5c..bf086ad 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -720,7 +720,7 @@ void WidgetGtk::OnWindowPaint(GtkWidget* widget, GdkEventExpose* event) { // view here as that is done by OnPaint. DCHECK(transparent_); int width, height; - gtk_window_get_size (GTK_WINDOW (widget), &width, &height); + gtk_window_get_size(GTK_WINDOW (widget), &width, &height); cairo_t* cr = gdk_cairo_create(widget->window); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0, 0, 0, 0); |