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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_GTK_AUTOFILL_AUTOFILL_POPUP_VIEW_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_AUTOFILL_AUTOFILL_POPUP_VIEW_GTK_H_ 7 8 #include <pango/pango.h> 9 #include <vector> 10 11 #include "base/compiler_specific.h" 12 #include "base/strings/string16.h" 13 #include "chrome/browser/ui/autofill/autofill_popup_view.h" 14 #include "ui/base/glib/glib_integers.h" 15 #include "ui/base/gtk/gtk_signal.h" 16 #include "ui/base/gtk/gtk_signal_registrar.h" 17 #include "ui/gfx/font.h" 18 19 class Profile; 20 21 namespace content { 22 class RenderViewHost; 23 } 24 25 namespace gfx { 26 class Rect; 27 } 28 29 typedef struct _GdkEventButton GdkEventButton; 30 typedef struct _GdkEventConfigure GdkEventConfigure; 31 typedef struct _GdkEventCrossing GdkEventCrossing; 32 typedef struct _GdkEventExpose GdkEventExpose; 33 typedef struct _GdkEventKey GdkEventKey; 34 typedef struct _GdkEventMotion GdkEventMotion; 35 typedef struct _GdkColor GdkColor; 36 typedef struct _GtkWidget GtkWidget; 37 38 namespace autofill { 39 40 class AutofillPopupController; 41 42 // Gtk implementation for AutofillPopupView interface. 43 class AutofillPopupViewGtk : public AutofillPopupView { 44 public: 45 explicit AutofillPopupViewGtk(AutofillPopupController* controller); 46 47 private: 48 virtual ~AutofillPopupViewGtk(); 49 50 // AutofillPopupView implementation. 51 virtual void Hide() OVERRIDE; 52 virtual void Show() OVERRIDE; 53 virtual void InvalidateRow(size_t row) OVERRIDE; 54 virtual void UpdateBoundsAndRedrawPopup() OVERRIDE; 55 56 CHROMEGTK_CALLBACK_1(AutofillPopupViewGtk, gboolean, HandleConfigure, 57 GdkEventConfigure*); 58 CHROMEGTK_CALLBACK_1(AutofillPopupViewGtk, gboolean, HandleButtonRelease, 59 GdkEventButton*); 60 CHROMEGTK_CALLBACK_1(AutofillPopupViewGtk, gboolean, HandleExpose, 61 GdkEventExpose*); 62 CHROMEGTK_CALLBACK_1(AutofillPopupViewGtk, gboolean, HandleLeave, 63 GdkEventCrossing*) 64 CHROMEGTK_CALLBACK_1(AutofillPopupViewGtk, gboolean, HandleMotion, 65 GdkEventMotion*); 66 67 // Set up the pango layout to display the autofill results. 68 void SetUpLayout(); 69 70 // Set up the pango layout to print the given text and have it's width match 71 // the text's (this gives us better control when placing the text box). 72 void SetLayoutText(const base::string16& text, 73 const gfx::Font& font, 74 const GdkColor text_color); 75 76 // Draw the separator as the given |separator_rect|. 77 void DrawSeparator(cairo_t* cairo_context, const gfx::Rect& separator_rect); 78 79 // Draw the given autofill entry in |entry_rect|. 80 void DrawAutofillEntry(cairo_t* cairo_context, 81 size_t index, 82 const gfx::Rect& entry_rect); 83 84 // Set the initial bounds of the popup to show, including the placement 85 // of it. 86 void SetInitialBounds(); 87 88 AutofillPopupController* controller_; // Weak reference. 89 90 ui::GtkSignalRegistrar signals_; 91 92 GtkWidget* window_; // Strong reference. 93 PangoLayout* layout_; // Strong reference. 94 95 DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewGtk); 96 }; 97 98 } // namespace autofill 99 100 #endif // CHROME_BROWSER_UI_GTK_AUTOFILL_AUTOFILL_POPUP_VIEW_GTK_H_ 101