| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // fit the entire size of the RootView. The RootView takes ownership of this | 213 // fit the entire size of the RootView. The RootView takes ownership of this |
| 214 // View, unless it is set as not being parent-owned. | 214 // View, unless it is set as not being parent-owned. |
| 215 void SetContentsView(View* view); | 215 void SetContentsView(View* view); |
| 216 | 216 |
| 217 // Returns the bounds of the Widget in screen coordinates. | 217 // Returns the bounds of the Widget in screen coordinates. |
| 218 gfx::Rect GetWindowScreenBounds() const; | 218 gfx::Rect GetWindowScreenBounds() const; |
| 219 | 219 |
| 220 // Returns the bounds of the Widget's client area in screen coordinates. | 220 // Returns the bounds of the Widget's client area in screen coordinates. |
| 221 gfx::Rect GetClientAreaScreenBounds() const; | 221 gfx::Rect GetClientAreaScreenBounds() const; |
| 222 | 222 |
| 223 // Retrieves the restored bounds for the window. |
| 224 gfx::Rect GetRestoredBounds() const; |
| 225 |
| 223 // Sizes and/or places the widget to the specified bounds, size or position. | 226 // Sizes and/or places the widget to the specified bounds, size or position. |
| 224 void SetBounds(const gfx::Rect& bounds); | 227 void SetBounds(const gfx::Rect& bounds); |
| 225 void SetSize(const gfx::Size& size); | 228 void SetSize(const gfx::Size& size); |
| 226 | 229 |
| 227 // Like SetBounds(), but ensures the Widget is fully visible within the bounds | 230 // Like SetBounds(), but ensures the Widget is fully visible within the bounds |
| 228 // of its parent. If the Widget has no parent, it is centered within the | 231 // of its parent. If the Widget has no parent, it is centered within the |
| 229 // bounds of its screen if it is visible, or |other_widget|'s screen if it is | 232 // bounds of its screen if it is visible, or |other_widget|'s screen if it is |
| 230 // not. | 233 // not. |
| 231 void SetBoundsConstrained(const gfx::Rect& bounds, | 234 void SetBoundsConstrained(const gfx::Rect& bounds, |
| 232 Widget* other_widget); | 235 Widget* other_widget); |
| 233 | 236 |
| 234 // Places the widget in front of the specified widget in z-order. | 237 // Places the widget in front of the specified widget in z-order. |
| 235 void MoveAboveWidget(Widget* widget); | 238 void MoveAboveWidget(Widget* widget); |
| 236 void MoveAbove(gfx::NativeView native_view); | 239 void MoveAbove(gfx::NativeView native_view); |
| 237 | 240 |
| 238 // Sets a shape on the widget. This takes ownership of shape. | 241 // Sets a shape on the widget. This takes ownership of shape. |
| 239 void SetShape(gfx::NativeRegion shape); | 242 void SetShape(gfx::NativeRegion shape); |
| 240 | 243 |
| 241 // Hides the widget then closes it after a return to the message loop. | 244 // Hides the widget then closes it after a return to the message loop. |
| 242 virtual void Close(); | 245 virtual void Close(); |
| 243 | 246 |
| 244 // TODO(beng): Move off public API. | 247 // TODO(beng): Move off public API. |
| 245 // Closes the widget immediately. Compare to |Close|. This will destroy the | 248 // Closes the widget immediately. Compare to |Close|. This will destroy the |
| 246 // window handle associated with this Widget, so should not be called from | 249 // window handle associated with this Widget, so should not be called from |
| 247 // any code that expects it to be valid beyond this call. | 250 // any code that expects it to be valid beyond this call. |
| 248 void CloseNow(); | 251 void CloseNow(); |
| 249 | 252 |
| 253 // Toggles the enable state for the Close button (and the Close menu item in |
| 254 // the system menu). |
| 255 void EnableClose(bool enable); |
| 256 |
| 250 // Shows or hides the widget, without changing activation state. | 257 // Shows or hides the widget, without changing activation state. |
| 251 virtual void Show(); | 258 virtual void Show(); |
| 252 void Hide(); | 259 void Hide(); |
| 253 | 260 |
| 261 // Like Show(), but does not activate the window. |
| 262 void ShowInactive(); |
| 263 |
| 254 // Activates the widget, assuming it already exists and is visible. | 264 // Activates the widget, assuming it already exists and is visible. |
| 255 void Activate(); | 265 void Activate(); |
| 256 | 266 |
| 257 // Deactivates the widget, making the next window in the Z order the active | 267 // Deactivates the widget, making the next window in the Z order the active |
| 258 // window. | 268 // window. |
| 259 void Deactivate(); | 269 void Deactivate(); |
| 260 | 270 |
| 261 // Returns whether the Widget is the currently active window. | 271 // Returns whether the Widget is the currently active window. |
| 262 virtual bool IsActive() const; | 272 virtual bool IsActive() const; |
| 263 | 273 |
| 274 // Prevents the window from being rendered as deactivated the next time it is. |
| 275 // This state is reset automatically as soon as the window becomes activated |
| 276 // again. There is no ability to control the state through this API as this |
| 277 // leads to sync problems. |
| 278 void DisableInactiveRendering(); |
| 279 |
| 264 // Sets the widget to be on top of all other widgets in the windowing system. | 280 // Sets the widget to be on top of all other widgets in the windowing system. |
| 265 void SetAlwaysOnTop(bool on_top); | 281 void SetAlwaysOnTop(bool on_top); |
| 266 | 282 |
| 267 // Maximizes/minimizes/restores the window. | 283 // Maximizes/minimizes/restores the window. |
| 268 void Maximize(); | 284 void Maximize(); |
| 269 void Minimize(); | 285 void Minimize(); |
| 270 void Restore(); | 286 void Restore(); |
| 271 | 287 |
| 272 // Whether or not the window is maximized or minimized. | 288 // Whether or not the window is maximized or minimized. |
| 273 virtual bool IsMaximized() const; | 289 virtual bool IsMaximized() const; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Sets the currently visible cursor. If |cursor| is NULL, the cursor used | 358 // Sets the currently visible cursor. If |cursor| is NULL, the cursor used |
| 343 // before the current is restored. | 359 // before the current is restored. |
| 344 void SetCursor(gfx::NativeCursor cursor); | 360 void SetCursor(gfx::NativeCursor cursor); |
| 345 | 361 |
| 346 // Resets the last move flag so that we can go around the optimization | 362 // Resets the last move flag so that we can go around the optimization |
| 347 // that disregards duplicate mouse moves when ending animation requires | 363 // that disregards duplicate mouse moves when ending animation requires |
| 348 // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation | 364 // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation |
| 349 // to cause the close button to highlight. | 365 // to cause the close button to highlight. |
| 350 void ResetLastMouseMoveFlag(); | 366 void ResetLastMouseMoveFlag(); |
| 351 | 367 |
| 368 // Tell the window to update its title from the delegate. |
| 369 void UpdateWindowTitle(); |
| 370 |
| 371 // Tell the window to update its icon from the delegate. |
| 372 void UpdateWindowIcon(); |
| 373 |
| 352 // Retrieves the focus traversable for this widget. | 374 // Retrieves the focus traversable for this widget. |
| 353 FocusTraversable* GetFocusTraversable(); | 375 FocusTraversable* GetFocusTraversable(); |
| 354 | 376 |
| 355 // Notifies the view hierarchy contained in this widget that theme resources | 377 // Notifies the view hierarchy contained in this widget that theme resources |
| 356 // changed. | 378 // changed. |
| 357 void ThemeChanged(); | 379 void ThemeChanged(); |
| 358 | 380 |
| 359 // Notifies the view hierarchy contained in this widget that locale resources | 381 // Notifies the view hierarchy contained in this widget that locale resources |
| 360 // changed. | 382 // changed. |
| 361 void LocaleChanged(); | 383 void LocaleChanged(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // native accessibility event and the duplicate event would cause | 433 // native accessibility event and the duplicate event would cause |
| 412 // problems. | 434 // problems. |
| 413 void NotifyAccessibilityEvent( | 435 void NotifyAccessibilityEvent( |
| 414 View* view, | 436 View* view, |
| 415 ui::AccessibilityTypes::Event event_type, | 437 ui::AccessibilityTypes::Event event_type, |
| 416 bool send_native_event); | 438 bool send_native_event); |
| 417 | 439 |
| 418 const NativeWidget* native_widget() const { return native_widget_; } | 440 const NativeWidget* native_widget() const { return native_widget_; } |
| 419 NativeWidget* native_widget() { return native_widget_; } | 441 NativeWidget* native_widget() { return native_widget_; } |
| 420 | 442 |
| 443 // TODO(beng): remove once Window is folded in. |
| 444 virtual Window* AsWindow(); |
| 445 virtual const Window* AsWindow() const; |
| 446 |
| 421 // Overridden from NativeWidgetDelegate: | 447 // Overridden from NativeWidgetDelegate: |
| 448 virtual bool CanActivate() const OVERRIDE; |
| 449 virtual bool IsInactiveRenderingDisabled() const OVERRIDE; |
| 450 virtual void EnableInactiveRendering() OVERRIDE; |
| 451 virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; |
| 422 virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE; | 452 virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE; |
| 423 virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE; | 453 virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE; |
| 424 virtual void OnNativeWidgetCreated() OVERRIDE; | 454 virtual void OnNativeWidgetCreated() OVERRIDE; |
| 455 virtual void OnNativeWidgetDestroying() OVERRIDE; |
| 425 virtual void OnNativeWidgetDestroyed() OVERRIDE; | 456 virtual void OnNativeWidgetDestroyed() OVERRIDE; |
| 426 virtual void OnSizeChanged(const gfx::Size& new_size) OVERRIDE; | 457 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 458 virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) OVERRIDE; |
| 459 virtual void OnNativeWidgetBeginUserBoundsChange() OVERRIDE; |
| 460 virtual void OnNativeWidgetEndUserBoundsChange() OVERRIDE; |
| 427 virtual bool HasFocusManager() const OVERRIDE; | 461 virtual bool HasFocusManager() const OVERRIDE; |
| 428 virtual bool OnNativeWidgetPaintAccelerated( | 462 virtual bool OnNativeWidgetPaintAccelerated( |
| 429 const gfx::Rect& dirty_region) OVERRIDE; | 463 const gfx::Rect& dirty_region) OVERRIDE; |
| 430 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE; | 464 virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE; |
| 465 virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE; |
| 431 virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE; | 466 virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE; |
| 432 virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE; | 467 virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE; |
| 433 virtual void OnMouseCaptureLost() OVERRIDE; | 468 virtual void OnMouseCaptureLost() OVERRIDE; |
| 469 virtual bool ExecuteCommand(int command_id) OVERRIDE; |
| 434 virtual Widget* AsWidget() OVERRIDE; | 470 virtual Widget* AsWidget() OVERRIDE; |
| 435 virtual const Widget* AsWidget() const OVERRIDE; | 471 virtual const Widget* AsWidget() const OVERRIDE; |
| 436 | 472 |
| 437 // Overridden from FocusTraversable: | 473 // Overridden from FocusTraversable: |
| 438 virtual FocusSearch* GetFocusSearch() OVERRIDE; | 474 virtual FocusSearch* GetFocusSearch() OVERRIDE; |
| 439 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; | 475 virtual FocusTraversable* GetFocusTraversableParent() OVERRIDE; |
| 440 virtual View* GetFocusTraversableParentView() OVERRIDE; | 476 virtual View* GetFocusTraversableParentView() OVERRIDE; |
| 441 | 477 |
| 442 protected: | 478 protected: |
| 443 // TODO(beng): Remove NativeWidgetGtk's dependence on the mouse state flags. | 479 // TODO(beng): Remove NativeWidgetGtk's dependence on the mouse state flags. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 469 bool last_mouse_event_was_move_; | 505 bool last_mouse_event_was_move_; |
| 470 gfx::Point last_mouse_event_position_; | 506 gfx::Point last_mouse_event_position_; |
| 471 | 507 |
| 472 private: | 508 private: |
| 473 // Try to create a compositor if one hasn't been created yet. | 509 // Try to create a compositor if one hasn't been created yet. |
| 474 void EnsureCompositor(); | 510 void EnsureCompositor(); |
| 475 | 511 |
| 476 // Returns whether capture should be released on mouse release. | 512 // Returns whether capture should be released on mouse release. |
| 477 virtual bool ShouldReleaseCaptureOnMouseReleased() const; | 513 virtual bool ShouldReleaseCaptureOnMouseReleased() const; |
| 478 | 514 |
| 515 // Persists the window's restored position and maximized state using the |
| 516 // window delegate. |
| 517 void SaveWindowPosition(); |
| 518 |
| 479 NativeWidget* native_widget_; | 519 NativeWidget* native_widget_; |
| 480 | 520 |
| 481 InitParams::Type type_; | |
| 482 | |
| 483 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is | 521 // Non-owned pointer to the Widget's delegate. May be NULL if no delegate is |
| 484 // being used. | 522 // being used. |
| 485 WidgetDelegate* widget_delegate_; | 523 WidgetDelegate* widget_delegate_; |
| 486 | 524 |
| 487 // The root of the View hierarchy attached to this window. | 525 // The root of the View hierarchy attached to this window. |
| 488 // WARNING: see warning in tooltip_manager_ for ordering dependencies with | 526 // WARNING: see warning in tooltip_manager_ for ordering dependencies with |
| 489 // this and tooltip_manager_. | 527 // this and tooltip_manager_. |
| 490 scoped_ptr<internal::RootView> root_view_; | 528 scoped_ptr<internal::RootView> root_view_; |
| 491 | 529 |
| 492 // The View that provides the non-client area of the window (title bar, | 530 // The View that provides the non-client area of the window (title bar, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 514 // See class documentation for Widget above for a note about ownership. | 552 // See class documentation for Widget above for a note about ownership. |
| 515 InitParams::Ownership ownership_; | 553 InitParams::Ownership ownership_; |
| 516 | 554 |
| 517 // See set_is_secondary_widget(). | 555 // See set_is_secondary_widget(). |
| 518 bool is_secondary_widget_; | 556 bool is_secondary_widget_; |
| 519 | 557 |
| 520 // The current frame type in use by this window. Defaults to | 558 // The current frame type in use by this window. Defaults to |
| 521 // FRAME_TYPE_DEFAULT. | 559 // FRAME_TYPE_DEFAULT. |
| 522 FrameType frame_type_; | 560 FrameType frame_type_; |
| 523 | 561 |
| 562 // True when the window should be rendered as active, regardless of whether |
| 563 // or not it actually is. |
| 564 bool disable_inactive_rendering_; |
| 565 |
| 566 // Set to true if the widget is in the process of closing. |
| 567 bool widget_closed_; |
| 568 |
| 524 DISALLOW_COPY_AND_ASSIGN(Widget); | 569 DISALLOW_COPY_AND_ASSIGN(Widget); |
| 525 }; | 570 }; |
| 526 | 571 |
| 527 } // namespace views | 572 } // namespace views |
| 528 | 573 |
| 529 #endif // VIEWS_WIDGET_WIDGET_H_ | 574 #endif // VIEWS_WIDGET_WIDGET_H_ |
| OLD | NEW |