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

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 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
(Empty)
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_OMNIBOX_OMNIBOX_POPUP_VIEW_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_OMNIBOX_OMNIBOX_POPUP_VIEW_GTK_H_
7
8 #include <gtk/gtk.h>
9
10 #include <map>
11 #include <string>
12
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "chrome/browser/autocomplete/autocomplete_match.h"
17 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20 #include "ui/base/gtk/gtk_signal.h"
21 #include "ui/base/window_open_disposition.h"
22 #include "ui/gfx/font.h"
23
24 class AutocompleteResult;
25 class GtkThemeService;
26 class OmniboxEditModel;
27 class OmniboxPopupModel;
28 class OmniboxView;
29 class SkBitmap;
30
31 namespace gfx {
32 class Image;
33 }
34
35 class OmniboxPopupViewGtk : public OmniboxPopupView,
36 public content::NotificationObserver {
37 public:
38 OmniboxPopupViewGtk(const gfx::Font& font,
39 OmniboxView* omnibox_view,
40 OmniboxEditModel* edit_model,
41 GtkWidget* location_bar);
42 virtual ~OmniboxPopupViewGtk();
43
44 // Initializes the view.
45 virtual void Init();
46
47 // Overridden from OmniboxPopupView:
48 virtual bool IsOpen() const OVERRIDE;
49 virtual void InvalidateLine(size_t line) OVERRIDE;
50 virtual void UpdatePopupAppearance() OVERRIDE;
51 virtual gfx::Rect GetTargetBounds() OVERRIDE;
52 virtual void PaintUpdatesNow() OVERRIDE;
53 virtual void OnDragCanceled() OVERRIDE;
54
55 // Overridden from content::NotificationObserver:
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 protected:
61 // Convert a y-coordinate to the closest line / result.
62 size_t LineFromY(int y) const;
63
64 // Return a Rect for the space for a result line. This excludes the border,
65 // but includes the padding. This is the area that is colored for a
66 // selection.
67 gfx::Rect GetRectForLine(size_t line, int width) const;
68
69 // Returns the number of hidden matches at the top of the popup. This is
70 // non-zero when a verbatim match like search-what-you-typed is present but
71 // should not be shown.
72 size_t GetHiddenMatchCount() const;
73
74 // Returns the current autocomplete result.
75 virtual const AutocompleteResult& GetResult() const;
76
77 private:
78 // Be friendly for unit tests.
79 friend class OmniboxPopupViewGtkTest;
80
81 static void SetupLayoutForMatch(
82 PangoLayout* layout,
83 const base::string16& text,
84 const AutocompleteMatch::ACMatchClassifications& classifications,
85 const GdkColor* base_color,
86 const GdkColor* dim_color,
87 const GdkColor* url_color,
88 const std::string& prefix_text);
89
90 virtual void Show(size_t num_results);
91 virtual void Hide();
92
93 // Restack the popup window directly above the browser's toplevel window.
94 void StackWindow();
95
96 // Accept a line of the results, for example, when the user clicks a line.
97 void AcceptLine(size_t line, WindowOpenDisposition disposition);
98
99 // Returns the appropriate icon to display beside |match|.
100 gfx::Image IconForMatch(const AutocompleteMatch& match,
101 bool selected,
102 bool is_selected_keyword);
103
104 // Returns the |index|th element of match, unless we're selected and showing
105 // the associated keyword match.
106 void GetVisibleMatchForInput(size_t index,
107 const AutocompleteMatch** match,
108 bool* is_selected_keyword);
109
110 CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleMotion,
111 GdkEventMotion*);
112
113 CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleButtonPress,
114 GdkEventButton*);
115
116 CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleButtonRelease,
117 GdkEventButton*);
118
119 CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleExpose,
120 GdkEventExpose*);
121
122 scoped_ptr<OmniboxPopupModel> model_;
123 OmniboxView* omnibox_view_;
124 GtkWidget* location_bar_;
125
126 // Our popup window, which is the only widget used, and we paint it on our
127 // own. This widget shouldn't be exposed outside of this class.
128 GtkWidget* window_;
129 // The pango layout object created from the window, cached across exposes.
130 PangoLayout* layout_;
131
132 GtkThemeService* theme_service_;
133 content::NotificationRegistrar registrar_;
134
135 // Font used for suggestions after being derived from the constructor's
136 // |font|.
137 gfx::Font font_;
138
139 // A list of colors which we should use for drawing the popup. These change
140 // between gtk and normal mode.
141 GdkColor border_color_;
142 GdkColor background_color_;
143 GdkColor selected_background_color_;
144 GdkColor hovered_background_color_;
145 GdkColor content_text_color_;
146 GdkColor selected_content_text_color_;
147 GdkColor content_dim_text_color_;
148 GdkColor selected_content_dim_text_color_;
149 GdkColor url_text_color_;
150 GdkColor url_selected_text_color_;
151
152 // If the user cancels a dragging action (i.e. by pressing ESC), we don't have
153 // a convenient way to release mouse capture. Instead we use this flag to
154 // simply ignore all remaining drag events, and the eventual mouse release
155 // event. Since OnDragCanceled() can be called when we're not dragging, this
156 // flag is reset to false on a mouse pressed event, to make sure we don't
157 // erroneously ignore the next drag.
158 bool ignore_mouse_drag_;
159
160 // Whether our popup is currently open / shown, or closed / hidden.
161 bool opened_;
162
163 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupViewGtk);
164 };
165
166 #endif // CHROME_BROWSER_UI_GTK_OMNIBOX_OMNIBOX_POPUP_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698