| 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 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 public: | 87 public: |
| 88 enum FrameType { | 88 enum FrameType { |
| 89 FRAME_TYPE_DEFAULT, // Use whatever the default would be. | 89 FRAME_TYPE_DEFAULT, // Use whatever the default would be. |
| 90 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. | 90 FRAME_TYPE_FORCE_CUSTOM, // Force the custom frame. |
| 91 FRAME_TYPE_FORCE_NATIVE // Force the native frame. | 91 FRAME_TYPE_FORCE_NATIVE // Force the native frame. |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 struct InitParams { | 94 struct InitParams { |
| 95 enum Type { | 95 enum Type { |
| 96 TYPE_WINDOW, // A Window, like a frame window. | 96 TYPE_WINDOW, // A Window, like a frame window. |
| 97 // Widgets of TYPE_WINDOW will have a NonClientView. |
| 97 TYPE_CONTROL, // A control, like a button. | 98 TYPE_CONTROL, // A control, like a button. |
| 98 TYPE_POPUP, // An undecorated Window, with transient properties. | 99 TYPE_POPUP, // An undecorated Window, with transient properties. |
| 99 TYPE_MENU // An undecorated Window, with transient properties | 100 TYPE_MENU // An undecorated Window, with transient properties |
| 100 // specialized to menus. | 101 // specialized to menus. |
| 101 }; | 102 }; |
| 102 enum Ownership { | 103 enum Ownership { |
| 103 // Default. Creator is not responsible for managing the lifetime of the | 104 // Default. Creator is not responsible for managing the lifetime of the |
| 104 // Widget, it is destroyed when the corresponding NativeWidget is | 105 // Widget, it is destroyed when the corresponding NativeWidget is |
| 105 // destroyed. | 106 // destroyed. |
| 106 NATIVE_WIDGET_OWNS_WIDGET, | 107 NATIVE_WIDGET_OWNS_WIDGET, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 gfx::Rect* rect); | 158 gfx::Rect* rect); |
| 158 | 159 |
| 159 // SetPureViews and IsPureViews update and return the state of a global | 160 // SetPureViews and IsPureViews update and return the state of a global |
| 160 // setting that tracks whether to use available pure Views implementations. | 161 // setting that tracks whether to use available pure Views implementations. |
| 161 static void SetPureViews(bool pure); | 162 static void SetPureViews(bool pure); |
| 162 static bool IsPureViews(); | 163 static bool IsPureViews(); |
| 163 | 164 |
| 164 // Passes through to NativeWidget::GetWidgetForNativeView(). | 165 // Passes through to NativeWidget::GetWidgetForNativeView(). |
| 165 static Widget* GetWidgetForNativeView(gfx::NativeView native_view); | 166 static Widget* GetWidgetForNativeView(gfx::NativeView native_view); |
| 166 | 167 |
| 168 |
| 169 // Returns the preferred size of the contents view of this window based on |
| 170 // its localized size data. The width in cols is held in a localized string |
| 171 // resource identified by |col_resource_id|, the height in the same fashion. |
| 172 // TODO(beng): This should eventually live somewhere else, probably closer to |
| 173 // ClientView. |
| 174 static int GetLocalizedContentsWidth(int col_resource_id); |
| 175 static int GetLocalizedContentsHeight(int row_resource_id); |
| 176 static gfx::Size GetLocalizedContentsSize(int col_resource_id, |
| 177 int row_resource_id); |
| 178 |
| 167 void Init(const InitParams& params); | 179 void Init(const InitParams& params); |
| 168 | 180 |
| 169 // Unconverted methods ------------------------------------------------------- | 181 // Unconverted methods ------------------------------------------------------- |
| 170 | 182 |
| 171 // TODO(beng): reorder, they've been converted now. | 183 // TODO(beng): reorder, they've been converted now. |
| 172 | 184 |
| 173 // Returns the gfx::NativeView associated with this Widget. | 185 // Returns the gfx::NativeView associated with this Widget. |
| 174 gfx::NativeView GetNativeView() const; | 186 gfx::NativeView GetNativeView() const; |
| 175 | 187 |
| 176 // Returns the gfx::NativeWindow associated with this Widget. This may return | 188 // Returns the gfx::NativeWindow associated with this Widget. This may return |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 bool send_native_event); | 450 bool send_native_event); |
| 439 | 451 |
| 440 const NativeWidget* native_widget() const { return native_widget_; } | 452 const NativeWidget* native_widget() const { return native_widget_; } |
| 441 NativeWidget* native_widget() { return native_widget_; } | 453 NativeWidget* native_widget() { return native_widget_; } |
| 442 | 454 |
| 443 // TODO(beng): remove once Window is folded in. | 455 // TODO(beng): remove once Window is folded in. |
| 444 virtual Window* AsWindow(); | 456 virtual Window* AsWindow(); |
| 445 virtual const Window* AsWindow() const; | 457 virtual const Window* AsWindow() const; |
| 446 | 458 |
| 447 // Overridden from NativeWidgetDelegate: | 459 // Overridden from NativeWidgetDelegate: |
| 460 virtual bool IsModal() const OVERRIDE; |
| 461 virtual bool IsDialogBox() const OVERRIDE; |
| 448 virtual bool CanActivate() const OVERRIDE; | 462 virtual bool CanActivate() const OVERRIDE; |
| 449 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; | 463 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; |
| 450 virtual void EnableInactiveRendering() OVERRIDE; | 464 virtual void EnableInactiveRendering() OVERRIDE; |
| 451 virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; | 465 virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; |
| 452 virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE; | 466 virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE; |
| 453 virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE; | 467 virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE; |
| 454 virtual void OnNativeWidgetCreated() OVERRIDE; | 468 virtual void OnNativeWidgetCreated(const gfx::Rect& create_bounds) OVERRIDE; |
| 455 virtual void OnNativeWidgetDestroying() OVERRIDE; | 469 virtual void OnNativeWidgetDestroying() OVERRIDE; |
| 456 virtual void OnNativeWidgetDestroyed() OVERRIDE; | 470 virtual void OnNativeWidgetDestroyed() OVERRIDE; |
| 457 virtual gfx::Size GetMinimumSize() OVERRIDE; | 471 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 458 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) OVERRIDE; | 472 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) OVERRIDE; |
| 459 virtual void OnNativeWidgetBeginUserBoundsChange() OVERRIDE; | 473 virtual void OnNativeWidgetBeginUserBoundsChange() OVERRIDE; |
| 460 virtual void OnNativeWidgetEndUserBoundsChange() OVERRIDE; | 474 virtual void OnNativeWidgetEndUserBoundsChange() OVERRIDE; |
| 461 virtual bool HasFocusManager() const OVERRIDE; | 475 virtual bool HasFocusManager() const OVERRIDE; |
| 462 virtual bool OnNativeWidgetPaintAccelerated( | 476 virtual bool OnNativeWidgetPaintAccelerated( |
| 463 const gfx::Rect& dirty_region) OVERRIDE; | 477 const gfx::Rect& dirty_region) OVERRIDE; |
| 464 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE; | 478 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // Try to create a compositor if one hasn't been created yet. | 523 // Try to create a compositor if one hasn't been created yet. |
| 510 void EnsureCompositor(); | 524 void EnsureCompositor(); |
| 511 | 525 |
| 512 // Returns whether capture should be released on mouse release. | 526 // Returns whether capture should be released on mouse release. |
| 513 virtual bool ShouldReleaseCaptureOnMouseReleased() const; | 527 virtual bool ShouldReleaseCaptureOnMouseReleased() const; |
| 514 | 528 |
| 515 // Persists the window's restored position and maximized state using the | 529 // Persists the window's restored position and maximized state using the |
| 516 // window delegate. | 530 // window delegate. |
| 517 void SaveWindowPosition(); | 531 void SaveWindowPosition(); |
| 518 | 532 |
| 533 // Sizes and positions the window just after it is created. |
| 534 void SetInitialBounds(const gfx::Rect& bounds); |
| 535 |
| 519 NativeWidget* native_widget_; | 536 NativeWidget* native_widget_; |
| 520 | 537 |
| 521 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is | 538 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is |
| 522 // being used. | 539 // being used. |
| 523 WidgetDelegate* widget_delegate_; | 540 WidgetDelegate* widget_delegate_; |
| 524 | 541 |
| 525 // The root of the View hierarchy attached to this window. | 542 // The root of the View hierarchy attached to this window. |
| 526 // WARNING: see warning in tooltip_manager_ for ordering dependencies with | 543 // WARNING: see warning in tooltip_manager_ for ordering dependencies with |
| 527 // this and tooltip_manager_. | 544 // this and tooltip_manager_. |
| 528 scoped_ptr<internal::RootView> root_view_; | 545 scoped_ptr<internal::RootView> root_view_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 559 // FRAME_TYPE_DEFAULT. | 576 // FRAME_TYPE_DEFAULT. |
| 560 FrameType frame_type_; | 577 FrameType frame_type_; |
| 561 | 578 |
| 562 // True when the window should be rendered as active, regardless of whether | 579 // True when the window should be rendered as active, regardless of whether |
| 563 // or not it actually is. | 580 // or not it actually is. |
| 564 bool disable_inactive_rendering_; | 581 bool disable_inactive_rendering_; |
| 565 | 582 |
| 566 // Set to true if the widget is in the process of closing. | 583 // Set to true if the widget is in the process of closing. |
| 567 bool widget_closed_; | 584 bool widget_closed_; |
| 568 | 585 |
| 586 // The saved maximized state for this window. See note in SetInitialBounds |
| 587 // that explains why we save this. |
| 588 bool saved_maximized_state_; |
| 589 |
| 590 // The smallest size the window can be. |
| 591 gfx::Size minimum_size_; |
| 592 |
| 569 DISALLOW_COPY_AND_ASSIGN(Widget); | 593 DISALLOW_COPY_AND_ASSIGN(Widget); |
| 570 }; | 594 }; |
| 571 | 595 |
| 572 } // namespace views | 596 } // namespace views |
| 573 | 597 |
| 574 #endif // VIEWS_WIDGET_WIDGET_H_ | 598 #endif // VIEWS_WIDGET_WIDGET_H_ |
| OLD | NEW |