| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_H_ |
| 6 #define VIEWS_WIDGET_WIDGET_H_ | 6 #define VIEWS_WIDGET_WIDGET_H_ |
| 7 | 7 |
| 8 #include "app/gfx/native_widget_types.h" | 8 #include "app/gfx/native_widget_types.h" |
| 9 | 9 |
| 10 class ThemeProvider; | 10 class ThemeProvider; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // | 36 // |
| 37 // The Widget is responsible for handling various system events and forwarding | 37 // The Widget is responsible for handling various system events and forwarding |
| 38 // them to the appropriate view. | 38 // them to the appropriate view. |
| 39 // | 39 // |
| 40 ///////////////////////////////////////////////////////////////////////////// | 40 ///////////////////////////////////////////////////////////////////////////// |
| 41 | 41 |
| 42 class Widget { | 42 class Widget { |
| 43 public: | 43 public: |
| 44 virtual ~Widget() { } | 44 virtual ~Widget() { } |
| 45 | 45 |
| 46 // Creates a transparent popup widget specific to the current platform useful | 46 enum TransparencyParam { |
| 47 // for transient status notifications. | 47 Transparent, |
| 48 static Widget* CreateTransparentPopupWidget(bool delete_on_destroy); | 48 NotTransparent |
| 49 }; |
| 50 |
| 51 enum EventsParam { |
| 52 AcceptEvents, |
| 53 NotAcceptEvents |
| 54 }; |
| 55 |
| 56 enum DeleteParam { |
| 57 DeleteOnDestroy, |
| 58 NotDeleteOnDestroy |
| 59 }; |
| 60 |
| 61 // Creates a transient popup widget specific to the current platform. |
| 62 static Widget* CreatePopupWidget(TransparencyParam transparent, |
| 63 EventsParam accept_events, |
| 64 DeleteParam delete_on_destroy); |
| 49 | 65 |
| 50 // Initialize the Widget with a parent and an initial desired size. | 66 // Initialize the Widget with a parent and an initial desired size. |
| 51 // |contents_view| is the view that will be the single child of RootView | 67 // |contents_view| is the view that will be the single child of RootView |
| 52 // within this Widget. As contents_view is inserted into RootView's tree, | 68 // within this Widget. As contents_view is inserted into RootView's tree, |
| 53 // RootView assumes ownership of this view and cleaning it up. If you remove | 69 // RootView assumes ownership of this view and cleaning it up. If you remove |
| 54 // this view, you are responsible for its destruction. If this value is NULL, | 70 // this view, you are responsible for its destruction. If this value is NULL, |
| 55 // the caller is responsible for populating the RootView, and sizing its | 71 // the caller is responsible for populating the RootView, and sizing its |
| 56 // contents as the window is sized. | 72 // contents as the window is sized. |
| 57 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0; | 73 virtual void Init(gfx::NativeView parent, const gfx::Rect& bounds) = 0; |
| 58 | 74 |
| 59 // Sets the specified view as the contents of this Widget. There can only | 75 // Sets the specified view as the contents of this Widget. There can only |
| 60 // be one contnets view child of this Widget's RootView. This view is sized to | 76 // be one contents view child of this Widget's RootView. This view is sized to |
| 61 // fit the entire size of the RootView. The RootView takes ownership of this | 77 // fit the entire size of the RootView. The RootView takes ownership of this |
| 62 // View, unless it is set as not being parent-owned. | 78 // View, unless it is set as not being parent-owned. |
| 63 virtual void SetContentsView(View* view) = 0; | 79 virtual void SetContentsView(View* view) = 0; |
| 64 | 80 |
| 65 // Returns the bounds of this Widget in the screen coordinate system. | 81 // Returns the bounds of this Widget in the screen coordinate system. |
| 66 // If the receiving Widget is a frame which is larger than its client area, | 82 // If the receiving Widget is a frame which is larger than its client area, |
| 67 // this method returns the client area if including_frame is false and the | 83 // this method returns the client area if including_frame is false and the |
| 68 // frame bounds otherwise. If the receiving Widget is not a frame, | 84 // frame bounds otherwise. If the receiving Widget is not a frame, |
| 69 // including_frame is ignored. | 85 // including_frame is ignored. |
| 70 virtual void GetBounds(gfx::Rect* out, bool including_frame) const = 0; | 86 virtual void GetBounds(gfx::Rect* out, bool including_frame) const = 0; |
| 71 | 87 |
| 72 // Sizes and/or places the widget to the specified bounds, size or position. | 88 // Sizes and/or places the widget to the specified bounds, size or position. |
| 73 virtual void SetBounds(const gfx::Rect& bounds) = 0; | 89 virtual void SetBounds(const gfx::Rect& bounds) = 0; |
| 74 | 90 |
| 91 // Places the widget in front of the specified widget in z-order. |
| 92 virtual void MoveAbove(Widget* widget) = 0; |
| 93 |
| 75 // Sets a shape on the widget. | 94 // Sets a shape on the widget. |
| 76 virtual void SetShape(const gfx::Path& shape) = 0; | 95 virtual void SetShape(const gfx::Path& shape) = 0; |
| 77 | 96 |
| 78 // Hides the widget then closes it after a return to the message loop. | 97 // Hides the widget then closes it after a return to the message loop. |
| 79 virtual void Close() = 0; | 98 virtual void Close() = 0; |
| 80 | 99 |
| 81 // Closes the widget immediately. Compare to |Close|. This will destroy the | 100 // Closes the widget immediately. Compare to |Close|. This will destroy the |
| 82 // window handle associated with this Widget, so should not be called from | 101 // window handle associated with this Widget, so should not be called from |
| 83 // any code that expects it to be valid beyond this call. | 102 // any code that expects it to be valid beyond this call. |
| 84 virtual void CloseNow() = 0; | 103 virtual void CloseNow() = 0; |
| 85 | 104 |
| 86 // Shows or hides the widget, without changing activation state. | 105 // Shows or hides the widget, without changing activation state. |
| 87 virtual void Show() = 0; | 106 virtual void Show() = 0; |
| 88 virtual void Hide() = 0; | 107 virtual void Hide() = 0; |
| 89 | 108 |
| 90 // Returns the gfx::NativeView associated with this Widget. | 109 // Returns the gfx::NativeView associated with this Widget. |
| 91 virtual gfx::NativeView GetNativeView() const = 0; | 110 virtual gfx::NativeView GetNativeView() const = 0; |
| 92 | 111 |
| 93 // Forces a paint of a specified rectangle immediately. | 112 // Forces a paint of a specified rectangle immediately. |
| 94 virtual void PaintNow(const gfx::Rect& update_rect) = 0; | 113 virtual void PaintNow(const gfx::Rect& update_rect) = 0; |
| 95 | 114 |
| 96 // Sets the opacity of the widget. This may allow widgets behind the widget | 115 // Sets the opacity of the widget. This may allow widgets behind the widget |
| 97 // in the Z-order to become visible, depending on the capabilities of the | 116 // in the Z-order to become visible, depending on the capabilities of the |
| 98 // underlying windowing system. Note that the caller must then schedule a | 117 // underlying windowing system. Note that the caller must then schedule a |
| 99 // repaint to allow this change to take effect. | 118 // repaint to allow this change to take effect. |
| 100 virtual void SetOpacity(unsigned char opacity) = 0; | 119 virtual void SetOpacity(unsigned char opacity) = 0; |
| 101 | 120 |
| 121 // Sets the widget to be on top of all other widgets in the windowing system. |
| 122 virtual void SetAlwaysOnTop(bool on_top) = 0; |
| 123 |
| 102 // Returns the RootView contained by this Widget. | 124 // Returns the RootView contained by this Widget. |
| 103 virtual RootView* GetRootView() = 0; | 125 virtual RootView* GetRootView() = 0; |
| 104 | 126 |
| 105 // Returns the Widget associated with the root ancestor. | 127 // Returns the Widget associated with the root ancestor. |
| 106 virtual Widget* GetRootWidget() const = 0; | 128 virtual Widget* GetRootWidget() const = 0; |
| 107 | 129 |
| 108 // Returns whether the Widget is visible to the user. | 130 // Returns whether the Widget is visible to the user. |
| 109 virtual bool IsVisible() const = 0; | 131 virtual bool IsVisible() const = 0; |
| 110 | 132 |
| 111 // Returns whether the Widget is the currently active window. | 133 // Returns whether the Widget is the currently active window. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 virtual FocusManager* GetFocusManager() { return NULL; } | 167 virtual FocusManager* GetFocusManager() { return NULL; } |
| 146 | 168 |
| 147 // Forwarded from the RootView so that the widget can do any cleanup. | 169 // Forwarded from the RootView so that the widget can do any cleanup. |
| 148 virtual void ViewHierarchyChanged(bool is_add, View *parent, | 170 virtual void ViewHierarchyChanged(bool is_add, View *parent, |
| 149 View *child) = 0; | 171 View *child) = 0; |
| 150 }; | 172 }; |
| 151 | 173 |
| 152 } // namespace views | 174 } // namespace views |
| 153 | 175 |
| 154 #endif // VIEWS_WIDGET_WIDGET_H_ | 176 #endif // VIEWS_WIDGET_WIDGET_H_ |
| OLD | NEW |