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

Side by Side Diff: chrome/browser/ui/gtk/find_bar_gtk.h

Issue 7063003: Make FindBar obey dialog bounds for GTK. Will fix other platforms in separate patches. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 virtual bool IsFindBarVisible(); 58 virtual bool IsFindBarVisible();
59 virtual void RestoreSavedFocus(); 59 virtual void RestoreSavedFocus();
60 virtual FindBarTesting* GetFindBarTesting(); 60 virtual FindBarTesting* GetFindBarTesting();
61 61
62 // Methods from FindBarTesting. 62 // Methods from FindBarTesting.
63 virtual bool GetFindBarWindowInfo(gfx::Point* position, 63 virtual bool GetFindBarWindowInfo(gfx::Point* position,
64 bool* fully_visible); 64 bool* fully_visible);
65 virtual string16 GetFindText(); 65 virtual string16 GetFindText();
66 virtual string16 GetFindSelectedText(); 66 virtual string16 GetFindSelectedText();
67 virtual string16 GetMatchCountText(); 67 virtual string16 GetMatchCountText();
68 virtual int GetWidth();
68 69
69 // Overridden from NotificationObserver: 70 // Overridden from NotificationObserver:
70 virtual void Observe(NotificationType type, 71 virtual void Observe(NotificationType type,
71 const NotificationSource& source, 72 const NotificationSource& source,
72 const NotificationDetails& details); 73 const NotificationDetails& details);
73 74
74 private: 75 private:
75 void InitWidgets(); 76 void InitWidgets();
76 77
77 // Store the currently focused widget if it is not in the find bar. 78 // Store the currently focused widget if it is not in the find bar.
78 // This should always be called before we claim focus. 79 // This should always be called before we claim focus.
79 void StoreOutsideFocus(); 80 void StoreOutsideFocus();
80 81
81 // For certain keystrokes, such as up or down, we want to forward the event 82 // For certain keystrokes, such as up or down, we want to forward the event
82 // to the renderer rather than handling it ourselves. Returns true if the 83 // to the renderer rather than handling it ourselves. Returns true if the
83 // key event was forwarded. 84 // key event was forwarded.
84 // See similar function in FindBarWin. 85 // See similar function in FindBarWin.
85 bool MaybeForwardKeyEventToRenderer(GdkEventKey* event); 86 bool MaybeForwardKeyEventToRenderer(GdkEventKey* event);
86 87
87 // Searches for another occurrence of the entry text, moving forward if 88 // Searches for another occurrence of the entry text, moving forward if
88 // |forward_search| is true. 89 // |forward_search| is true.
89 void FindEntryTextInContents(bool forward_search); 90 void FindEntryTextInContents(bool forward_search);
90 91
91 void UpdateMatchLabelAppearance(bool failure); 92 void UpdateMatchLabelAppearance(bool failure);
92 93
93 // Asynchronously repositions the dialog. 94 // Asynchronously repositions the dialog.
94 void Reposition(); 95 void Reposition();
95 96
97 // Returns the bounds of the dialog that contains the find bar.
98 gfx::Rect GetDialogBounds();
99
96 // Returns the rectangle representing where to position the find bar. If 100 // Returns the rectangle representing where to position the find bar. If
97 // |avoid_overlapping_rect| is specified, the return value will be a rectangle 101 // |avoid_overlapping_rect| is specified, the return value will be a rectangle
98 // located immediately to the left of |avoid_overlapping_rect|, as long as 102 // located immediately to the left of |avoid_overlapping_rect|, as long as
99 // there is enough room for the dialog to draw within the bounds. If not, the 103 // there is enough room for the dialog to draw within the bounds. If not, the
100 // dialog position returned will overlap |avoid_overlapping_rect|. 104 // dialog position returned will overlap |avoid_overlapping_rect|.
101 // Note: |avoid_overlapping_rect| is expected to use coordinates relative to 105 // Note: |avoid_overlapping_rect| is expected to use coordinates relative to
102 // the top of the page area, (it will be converted to coordinates relative to 106 // the top of the page area, (it will be converted to coordinates relative to
103 // the top of the browser window, when comparing against the dialog 107 // the top of the browser window, when comparing against the dialog
104 // coordinates). The returned value is relative to the browser window. 108 // coordinates). The returned value is relative to the browser window.
105 gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect); 109 gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect);
106 110
107 // Adjust the text alignment according to the text direction of the widget 111 // Adjust the text alignment according to the text direction of the widget
108 // and |text_entry_|'s content, to make sure the real text alignment is 112 // and |text_entry_|'s content, to make sure the real text alignment is
109 // always in sync with the UI language direction. 113 // always in sync with the UI language direction.
110 void AdjustTextAlignment(); 114 void AdjustTextAlignment();
111 115
112 // Get the position of the findbar within the floating container. 116 // Get the position of the findbar within the floating container.
113 gfx::Point GetPosition(); 117 gfx::Point GetPosition();
114 118
115 static void OnParentSet(GtkWidget* widget, GtkObject* old_parent, 119 static void OnParentSet(GtkWidget* widget, GtkObject* old_parent,
116 FindBarGtk* find_bar); 120 FindBarGtk* find_bar);
117 121
122 static void OnContentSizeAllocate(GtkWidget* content_hbox,
123 GtkAllocation* allocation,
124 FindBarGtk* find_bar);
125
118 static void OnSetFloatingPosition(GtkFloatingContainer* floating_container, 126 static void OnSetFloatingPosition(GtkFloatingContainer* floating_container,
119 GtkAllocation* allocation, 127 GtkAllocation* allocation,
120 FindBarGtk* find_bar); 128 FindBarGtk* find_bar);
121 129
122 // Callback when the entry text changes. 130 // Callback when the entry text changes.
123 static gboolean OnChanged(GtkWindow* window, FindBarGtk* find_bar); 131 static gboolean OnChanged(GtkWindow* window, FindBarGtk* find_bar);
124 132
125 static gboolean OnKeyPressEvent(GtkWidget* widget, GdkEventKey* event, 133 static gboolean OnKeyPressEvent(GtkWidget* widget, GdkEventKey* event,
126 FindBarGtk* find_bar); 134 FindBarGtk* find_bar);
127 static gboolean OnKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event, 135 static gboolean OnKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // The selection rect we are currently showing. We cache it to avoid covering 240 // The selection rect we are currently showing. We cache it to avoid covering
233 // it up. 241 // it up.
234 gfx::Rect selection_rect_; 242 gfx::Rect selection_rect_;
235 243
236 NotificationRegistrar registrar_; 244 NotificationRegistrar registrar_;
237 245
238 DISALLOW_COPY_AND_ASSIGN(FindBarGtk); 246 DISALLOW_COPY_AND_ASSIGN(FindBarGtk);
239 }; 247 };
240 248
241 #endif // CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_ 249 #endif // CHROME_BROWSER_UI_GTK_FIND_BAR_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698