| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 VIEWS_WIDGET_WIDGET_GTK_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_GTK_H_ |
| 6 #define VIEWS_WIDGET_WIDGET_GTK_H_ | 6 #define VIEWS_WIDGET_WIDGET_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // transparent is done by ConfigureWidgetForTransparentBackground. | 49 // transparent is done by ConfigureWidgetForTransparentBackground. |
| 50 bool MakeTransparent(); | 50 bool MakeTransparent(); |
| 51 bool is_transparent() const { return transparent_; } | 51 bool is_transparent() const { return transparent_; } |
| 52 | 52 |
| 53 // Sets whether or not we are deleted when the widget is destroyed. The | 53 // Sets whether or not we are deleted when the widget is destroyed. The |
| 54 // default is true. | 54 // default is true. |
| 55 void set_delete_on_destroy(bool delete_on_destroy) { | 55 void set_delete_on_destroy(bool delete_on_destroy) { |
| 56 delete_on_destroy_ = delete_on_destroy; | 56 delete_on_destroy_ = delete_on_destroy; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Adds and removes the specified widget as a child of this widget's contents. |
| 60 // These methods make sure to add the widget to the window's contents |
| 61 // container if this widget is a window. |
| 59 void AddChild(GtkWidget* child); | 62 void AddChild(GtkWidget* child); |
| 60 void RemoveChild(GtkWidget* child); | 63 void RemoveChild(GtkWidget* child); |
| 61 | 64 |
| 65 // A safe way to reparent a child widget to this widget. Calls |
| 66 // gtk_widget_reparent which handles refcounting to avoid destroying the |
| 67 // widget when removing it from its old parent. |
| 68 void ReparentChild(GtkWidget* child); |
| 69 |
| 62 // Positions a child GtkWidget at the specified location and bounds. | 70 // Positions a child GtkWidget at the specified location and bounds. |
| 63 void PositionChild(GtkWidget* child, int x, int y, int w, int h); | 71 void PositionChild(GtkWidget* child, int x, int y, int w, int h); |
| 64 | 72 |
| 65 // Parent GtkWidget all children are added to. This is not necessarily | 73 // Parent GtkWidget all children are added to. When this WidgetGtk corresponds |
| 66 // the same as returned by GetNativeView. | 74 // to a top level window, this is the GtkFixed within the GtkWindow, not the |
| 67 GtkWidget* child_widget_parent() const { return child_widget_parent_; } | 75 // GtkWindow itself. For child widgets, this is the same GtkFixed as |
| 76 // |widget_|. |
| 77 GtkWidget* window_contents() const { return window_contents_; } |
| 68 | 78 |
| 69 virtual void SetContentsView(View* view); | 79 virtual void SetContentsView(View* view); |
| 70 | 80 |
| 71 // Overridden from Widget: | 81 // Overridden from Widget: |
| 72 virtual void GetBounds(gfx::Rect* out, bool including_frame) const; | 82 virtual void GetBounds(gfx::Rect* out, bool including_frame) const; |
| 73 virtual void SetBounds(const gfx::Rect& bounds); | 83 virtual void SetBounds(const gfx::Rect& bounds); |
| 74 virtual void SetShape(const gfx::Path& shape); | 84 virtual void SetShape(const gfx::Path& shape); |
| 75 virtual void Close(); | 85 virtual void Close(); |
| 76 virtual void CloseNow(); | 86 virtual void CloseNow(); |
| 77 virtual void Show(); | 87 virtual void Show(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 static gboolean CallVisibilityNotify(GtkWidget* widget, | 177 static gboolean CallVisibilityNotify(GtkWidget* widget, |
| 168 GdkEventVisibility* event); | 178 GdkEventVisibility* event); |
| 169 static gboolean CallGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); | 179 static gboolean CallGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); |
| 170 static void CallGrabNotify(GtkWidget* widget, gboolean was_grabbed); | 180 static void CallGrabNotify(GtkWidget* widget, gboolean was_grabbed); |
| 171 static void CallDestroy(GtkObject* object); | 181 static void CallDestroy(GtkObject* object); |
| 172 | 182 |
| 173 // Returns the first ancestor of |widget| that is a window. | 183 // Returns the first ancestor of |widget| that is a window. |
| 174 static Window* GetWindowImpl(GtkWidget* widget); | 184 static Window* GetWindowImpl(GtkWidget* widget); |
| 175 | 185 |
| 176 // Creates the GtkWidget. | 186 // Creates the GtkWidget. |
| 177 void CreateGtkWidget(); | 187 void CreateGtkWidget(GtkWidget* parent); |
| 188 |
| 189 // Attaches the widget contents to the window's widget. |
| 190 void AttachGtkWidgetToWindow(); |
| 178 | 191 |
| 179 // Invoked from create widget to enable the various bits needed for a | 192 // Invoked from create widget to enable the various bits needed for a |
| 180 // transparent background. This is only invoked if MakeTransparent has been | 193 // transparent background. This is only invoked if MakeTransparent has been |
| 181 // invoked. | 194 // invoked. |
| 182 void ConfigureWidgetForTransparentBackground(); | 195 void ConfigureWidgetForTransparentBackground(); |
| 183 | 196 |
| 184 void HandleGrabBroke(); | 197 void HandleGrabBroke(); |
| 185 | 198 |
| 186 const Type type_; | 199 const Type type_; |
| 187 | 200 |
| 188 // Our native views. If we're a window/popup, then widget_ is the window and | 201 // Our native views. If we're a window/popup, then widget_ is the window and |
| 189 // child_widget_parent_ is a GtkFixed. If we're not a window/popup, then | 202 // window_contents_ is a GtkFixed. If we're not a window/popup, then widget_ |
| 190 // widget_ and child_widget_parent_ are a GtkFixed. | 203 // and window_contents_ point to the same GtkFixed. |
| 191 GtkWidget* widget_; | 204 GtkWidget* widget_; |
| 192 GtkWidget* child_widget_parent_; | 205 GtkWidget* window_contents_; |
| 206 |
| 207 // Child GtkWidgets created with no parent need to be parented to a valid top |
| 208 // level window otherwise Gtk throws a fit. |null_parent_| is an invisible |
| 209 // popup that such GtkWidgets are parented to. |
| 210 static GtkWidget* null_parent_; |
| 193 | 211 |
| 194 // The root of the View hierarchy attached to this window. | 212 // The root of the View hierarchy attached to this window. |
| 195 scoped_ptr<RootView> root_view_; | 213 scoped_ptr<RootView> root_view_; |
| 196 | 214 |
| 197 scoped_ptr<TooltipManagerGtk> tooltip_manager_; | 215 scoped_ptr<TooltipManagerGtk> tooltip_manager_; |
| 198 | 216 |
| 199 // If true, the mouse is currently down. | 217 // If true, the mouse is currently down. |
| 200 bool is_mouse_down_; | 218 bool is_mouse_down_; |
| 201 | 219 |
| 202 // Have we done a mouse grab? | 220 // Have we done a mouse grab? |
| (...skipping 20 matching lines...) Expand all Loading... |
| 223 bool transparent_; | 241 bool transparent_; |
| 224 | 242 |
| 225 scoped_ptr<DefaultThemeProvider> default_theme_provider_; | 243 scoped_ptr<DefaultThemeProvider> default_theme_provider_; |
| 226 | 244 |
| 227 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); | 245 DISALLOW_COPY_AND_ASSIGN(WidgetGtk); |
| 228 }; | 246 }; |
| 229 | 247 |
| 230 } // namespace views | 248 } // namespace views |
| 231 | 249 |
| 232 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ | 250 #endif // VIEWS_WIDGET_WIDGET_GTK_H_ |
| OLD | NEW |