| OLD | NEW |
| 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 VIEWS_WIDGET_WIDGET_H_ | 5 #ifndef VIEWS_WIDGET_WIDGET_H_ |
| 6 #define VIEWS_WIDGET_WIDGET_H_ | 6 #define VIEWS_WIDGET_WIDGET_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/base/accessibility/accessibility_types.h" | 13 #include "ui/base/accessibility/accessibility_types.h" |
| 14 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "views/focus/focus_manager.h" | 16 #include "views/focus/focus_manager.h" |
| 17 #include "views/widget/native_widget_delegate.h" | 17 #include "views/widget/native_widget_delegate.h" |
| 18 | 18 |
| 19 #if defined(OS_WIN) |
| 20 // Windows headers define macros for these function names which screw with us. |
| 21 #if defined(IsMaximized) |
| 22 #undef IsMaximized |
| 23 #endif |
| 24 #if defined(IsMinimized) |
| 25 #undef IsMinimized |
| 26 #endif |
| 27 #endif |
| 28 |
| 19 namespace gfx { | 29 namespace gfx { |
| 20 class Canvas; | 30 class Canvas; |
| 21 class Path; | 31 class Path; |
| 22 class Point; | 32 class Point; |
| 23 class Rect; | 33 class Rect; |
| 24 } | 34 } |
| 25 | 35 |
| 26 namespace ui { | 36 namespace ui { |
| 27 class Accelerator; | 37 class Accelerator; |
| 28 class Compositor; | 38 class Compositor; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Hides the widget then closes it after a return to the message loop. | 223 // Hides the widget then closes it after a return to the message loop. |
| 214 virtual void Close(); | 224 virtual void Close(); |
| 215 | 225 |
| 216 // TODO(beng): Move off public API. | 226 // TODO(beng): Move off public API. |
| 217 // Closes the widget immediately. Compare to |Close|. This will destroy the | 227 // Closes the widget immediately. Compare to |Close|. This will destroy the |
| 218 // window handle associated with this Widget, so should not be called from | 228 // window handle associated with this Widget, so should not be called from |
| 219 // any code that expects it to be valid beyond this call. | 229 // any code that expects it to be valid beyond this call. |
| 220 void CloseNow(); | 230 void CloseNow(); |
| 221 | 231 |
| 222 // Shows or hides the widget, without changing activation state. | 232 // Shows or hides the widget, without changing activation state. |
| 223 void Show(); | 233 virtual void Show(); |
| 224 void Hide(); | 234 void Hide(); |
| 225 | 235 |
| 236 // Activates the widget, assuming it already exists and is visible. |
| 237 void Activate(); |
| 238 |
| 239 // Deactivates the widget, making the next window in the Z order the active |
| 240 // window. |
| 241 void Deactivate(); |
| 242 |
| 243 // Returns whether the Widget is the currently active window. |
| 244 virtual bool IsActive() const; |
| 245 |
| 246 // Sets the widget to be on top of all other widgets in the windowing system. |
| 247 void SetAlwaysOnTop(bool on_top); |
| 248 |
| 249 // Maximizes/minimizes/restores the window. |
| 250 void Maximize(); |
| 251 void Minimize(); |
| 252 void Restore(); |
| 253 |
| 254 // Whether or not the window is maximized or minimized. |
| 255 virtual bool IsMaximized() const; |
| 256 bool IsMinimized() const; |
| 257 |
| 226 // Sets the opacity of the widget. This may allow widgets behind the widget | 258 // Sets the opacity of the widget. This may allow widgets behind the widget |
| 227 // in the Z-order to become visible, depending on the capabilities of the | 259 // in the Z-order to become visible, depending on the capabilities of the |
| 228 // underlying windowing system. Note that the caller must then schedule a | 260 // underlying windowing system. Note that the caller must then schedule a |
| 229 // repaint to allow this change to take effect. | 261 // repaint to allow this change to take effect. |
| 230 void SetOpacity(unsigned char opacity); | 262 void SetOpacity(unsigned char opacity); |
| 231 | 263 |
| 232 // Sets the widget to be on top of all other widgets in the windowing system. | |
| 233 void SetAlwaysOnTop(bool on_top); | |
| 234 | |
| 235 // Returns the View at the root of the View hierarchy contained by this | 264 // Returns the View at the root of the View hierarchy contained by this |
| 236 // Widget. | 265 // Widget. |
| 237 View* GetRootView(); | 266 View* GetRootView(); |
| 238 | 267 |
| 239 // A secondary widget is one that is automatically closed (via Close()) when | 268 // A secondary widget is one that is automatically closed (via Close()) when |
| 240 // all non-secondary widgets are closed. | 269 // all non-secondary widgets are closed. |
| 241 // Default is true. | 270 // Default is true. |
| 242 // TODO(beng): This is an ugly API, should be handled implicitly via | 271 // TODO(beng): This is an ugly API, should be handled implicitly via |
| 243 // transience. | 272 // transience. |
| 244 void set_is_secondary_widget(bool is_secondary_widget) { | 273 void set_is_secondary_widget(bool is_secondary_widget) { |
| 245 is_secondary_widget_ = is_secondary_widget; | 274 is_secondary_widget_ = is_secondary_widget; |
| 246 } | 275 } |
| 247 bool is_secondary_widget() const { return is_secondary_widget_; } | 276 bool is_secondary_widget() const { return is_secondary_widget_; } |
| 248 | 277 |
| 249 // Returns whether the Widget is visible to the user. | 278 // Returns whether the Widget is visible to the user. |
| 250 bool IsVisible() const; | 279 virtual bool IsVisible() const; |
| 251 | |
| 252 // Returns whether the Widget is the currently active window. | |
| 253 bool IsActive() const; | |
| 254 | 280 |
| 255 // Returns whether the Widget is customized for accessibility. | 281 // Returns whether the Widget is customized for accessibility. |
| 256 bool IsAccessibleWidget() const; | 282 bool IsAccessibleWidget() const; |
| 257 | 283 |
| 258 // Returns the ThemeProvider that provides theme resources for this Widget. | 284 // Returns the ThemeProvider that provides theme resources for this Widget. |
| 259 virtual ThemeProvider* GetThemeProvider() const; | 285 virtual ThemeProvider* GetThemeProvider() const; |
| 260 | 286 |
| 261 // Returns the FocusManager for this widget. | 287 // Returns the FocusManager for this widget. |
| 262 // Note that all widgets in a widget hierarchy share the same focus manager. | 288 // Note that all widgets in a widget hierarchy share the same focus manager. |
| 263 // TODO(beng): remove virtual. | 289 // TODO(beng): remove virtual. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 443 |
| 418 // See set_is_secondary_widget(). | 444 // See set_is_secondary_widget(). |
| 419 bool is_secondary_widget_; | 445 bool is_secondary_widget_; |
| 420 | 446 |
| 421 DISALLOW_COPY_AND_ASSIGN(Widget); | 447 DISALLOW_COPY_AND_ASSIGN(Widget); |
| 422 }; | 448 }; |
| 423 | 449 |
| 424 } // namespace views | 450 } // namespace views |
| 425 | 451 |
| 426 #endif // VIEWS_WIDGET_WIDGET_H_ | 452 #endif // VIEWS_WIDGET_WIDGET_H_ |
| OLD | NEW |