| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <gdk/gdkkeysyms.h> | 5 #include <gdk/gdkkeysyms.h> |
| 6 #include <gtk/gtk.h> | 6 #include <gtk/gtk.h> |
| 7 | 7 |
| 8 #include "views/controls/textfield/native_textfield_gtk.h" | 8 #include "views/controls/textfield/native_textfield_gtk.h" |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 !textfield_->IsPassword()); | 250 !textfield_->IsPassword()); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 void NativeTextfieldGtk::UpdateEnabled() { | 254 void NativeTextfieldGtk::UpdateEnabled() { |
| 255 if (!native_view()) | 255 if (!native_view()) |
| 256 return; | 256 return; |
| 257 SetEnabled(textfield_->IsEnabled()); | 257 SetEnabled(textfield_->IsEnabled()); |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool NativeTextfieldGtk::IsPassword() { | |
| 261 return textfield_->IsPassword(); | |
| 262 } | |
| 263 | |
| 264 gfx::Insets NativeTextfieldGtk::CalculateInsets() { | 260 gfx::Insets NativeTextfieldGtk::CalculateInsets() { |
| 265 if (!native_view()) | 261 if (!native_view()) |
| 266 return gfx::Insets(); | 262 return gfx::Insets(); |
| 267 | 263 |
| 268 GtkWidget* widget = native_view(); | 264 GtkWidget* widget = native_view(); |
| 269 gfx::Insets insets; | 265 gfx::Insets insets; |
| 270 | 266 |
| 271 if (textfield_->IsMultiLine()) { | 267 if (textfield_->IsMultiLine()) { |
| 272 insets += GetTextViewInnerBorder(GTK_TEXT_VIEW(widget)); | 268 insets += GetTextViewInnerBorder(GTK_TEXT_VIEW(widget)); |
| 273 } else { | 269 } else { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 318 |
| 323 if (!textfield_->IsMultiLine()) { | 319 if (!textfield_->IsMultiLine()) { |
| 324 gfx::Insets insets = GetEntryInnerBorder(GTK_ENTRY(native_view())); | 320 gfx::Insets insets = GetEntryInnerBorder(GTK_ENTRY(native_view())); |
| 325 GtkBorder border = {insets.left(), insets.right(), top, bottom}; | 321 GtkBorder border = {insets.left(), insets.right(), top, bottom}; |
| 326 gtk_entry_set_inner_border(GTK_ENTRY(native_view()), &border); | 322 gtk_entry_set_inner_border(GTK_ENTRY(native_view()), &border); |
| 327 } else { | 323 } else { |
| 328 NOTIMPLEMENTED(); | 324 NOTIMPLEMENTED(); |
| 329 } | 325 } |
| 330 } | 326 } |
| 331 | 327 |
| 332 void NativeTextfieldGtk::SetFocus() { | 328 bool NativeTextfieldGtk::SetFocus() { |
| 333 Focus(); | 329 Focus(); |
| 330 return true; |
| 334 } | 331 } |
| 335 | 332 |
| 336 View* NativeTextfieldGtk::GetView() { | 333 View* NativeTextfieldGtk::GetView() { |
| 337 return this; | 334 return this; |
| 338 } | 335 } |
| 339 | 336 |
| 340 gfx::NativeView NativeTextfieldGtk::GetTestingHandle() const { | 337 gfx::NativeView NativeTextfieldGtk::GetTestingHandle() const { |
| 341 return native_view(); | 338 return native_view(); |
| 342 } | 339 } |
| 343 | 340 |
| 344 bool NativeTextfieldGtk::IsIMEComposing() const { | 341 bool NativeTextfieldGtk::IsIMEComposing() const { |
| 345 return false; | 342 return false; |
| 346 } | 343 } |
| 347 | 344 |
| 345 bool NativeTextfieldGtk::HandleKeyPressed(const views::KeyEvent& e) { |
| 346 return false; |
| 347 } |
| 348 |
| 349 bool NativeTextfieldGtk::HandleKeyReleased(const views::KeyEvent& e) { |
| 350 return false; |
| 351 } |
| 352 |
| 353 void NativeTextfieldGtk::HandleWillGainFocus() { |
| 354 } |
| 355 |
| 356 void NativeTextfieldGtk::HandleDidGainFocus() { |
| 357 } |
| 358 |
| 359 void NativeTextfieldGtk::HandleWillLoseFocus() { |
| 360 } |
| 361 |
| 348 // static | 362 // static |
| 349 gboolean NativeTextfieldGtk::OnKeyPressEventHandler( | 363 gboolean NativeTextfieldGtk::OnKeyPressEventHandler( |
| 350 GtkWidget* widget, | 364 GtkWidget* widget, |
| 351 GdkEventKey* event, | 365 GdkEventKey* event, |
| 352 NativeTextfieldGtk* textfield) { | 366 NativeTextfieldGtk* textfield) { |
| 353 return textfield->OnKeyPressEvent(event); | 367 return textfield->OnKeyPressEvent(event); |
| 354 } | 368 } |
| 355 | 369 |
| 356 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { | 370 gboolean NativeTextfieldGtk::OnKeyPressEvent(GdkEventKey* event) { |
| 357 Textfield::Controller* controller = textfield_->GetController(); | 371 Textfield::Controller* controller = textfield_->GetController(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 g_signal_connect(widget, "changed", | 451 g_signal_connect(widget, "changed", |
| 438 G_CALLBACK(OnChangedHandler), this); | 452 G_CALLBACK(OnChangedHandler), this); |
| 439 } | 453 } |
| 440 g_signal_connect_after(widget, "key-press-event", | 454 g_signal_connect_after(widget, "key-press-event", |
| 441 G_CALLBACK(OnKeyPressEventHandler), this); | 455 G_CALLBACK(OnKeyPressEventHandler), this); |
| 442 // In order to properly trigger Accelerators bound to VKEY_RETURN, we need to | 456 // In order to properly trigger Accelerators bound to VKEY_RETURN, we need to |
| 443 // send an event when the widget gets the activate signal. | 457 // send an event when the widget gets the activate signal. |
| 444 g_signal_connect(widget, "activate", G_CALLBACK(OnActivateHandler), this); | 458 g_signal_connect(widget, "activate", G_CALLBACK(OnActivateHandler), this); |
| 445 } | 459 } |
| 446 | 460 |
| 461 bool NativeTextfieldGtk::IsPassword() { |
| 462 return textfield_->IsPassword(); |
| 463 } |
| 464 |
| 447 } // namespace views | 465 } // namespace views |
| OLD | NEW |