[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 5 | #ifndef UI_BASE_BASE_WINDOW_H_ |
6 | #define UI_BASE_BASE_WINDOW_H_ | ||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 7 | |
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 8 | #include "base/component_export.h" |
Daniel Bratell | 2e13fbc | 2017-12-28 11:08:15 | [diff] [blame] | 9 | #include "build/build_config.h" |
Avi Drissman | 9e653328 | 2019-07-17 17:25:12 | [diff] [blame] | 10 | #include "ui/base/ui_base_types.h" |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 11 | #include "ui/gfx/native_widget_types.h" |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 12 | |
13 | namespace gfx { | ||||
14 | class Rect; | ||||
15 | } | ||||
16 | |||||
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 17 | namespace ui { |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 18 | |
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 19 | // Provides an interface to perform actions on windows, and query window |
20 | // state. | ||||
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 21 | class COMPONENT_EXPORT(UI_BASE) BaseWindow { |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 22 | public: |
23 | // Returns true if the window is currently the active/focused window. | ||||
24 | virtual bool IsActive() const = 0; | ||||
25 | |||||
26 | // Returns true if the window is maximized (aka zoomed). | ||||
27 | virtual bool IsMaximized() const = 0; | ||||
28 | |||||
29 | // Returns true if the window is minimized. | ||||
30 | virtual bool IsMinimized() const = 0; | ||||
31 | |||||
[email protected] | c80ed69 | 2012-04-18 19:51:10 | [diff] [blame] | 32 | // Returns true if the window is full screen. |
33 | virtual bool IsFullscreen() const = 0; | ||||
34 | |||||
[email protected] | b954da47 | 2013-08-27 00:20:17 | [diff] [blame] | 35 | // Returns true if the window is fully restored (not Fullscreen, Maximized, |
36 | // Minimized). | ||||
37 | static bool IsRestored(const BaseWindow& window); | ||||
38 | |||||
Christopher Cameron | 3cf47fe | 2022-03-16 23:40:24 | [diff] [blame] | 39 | // IsFullscreenFakedForTesting is set by tests that are not written robustly |
40 | // to asynchronous transitions to fullscreen (e.g, by using | ||||
41 | // ScopedFakeNSWindowFullscreen on macOS). | ||||
42 | static void SetFullscreenFakedForTesting(bool); | ||||
43 | static bool IsFullscreenFakedForTesting(); | ||||
44 | |||||
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 45 | // Return a platform dependent identifier for this window. |
yoz | f506725 | 2014-11-05 22:10:11 | [diff] [blame] | 46 | virtual gfx::NativeWindow GetNativeWindow() const = 0; |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 47 | |
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 48 | // Returns the nonmaximized bounds of the window (even if the window is |
49 | // currently maximized or minimized) in terms of the screen coordinates. | ||||
50 | virtual gfx::Rect GetRestoredBounds() const = 0; | ||||
51 | |||||
[email protected] | 68eeede | 2013-05-09 06:10:57 | [diff] [blame] | 52 | // Returns the restore state for the window (platform dependent). |
53 | virtual ui::WindowShowState GetRestoredState() const = 0; | ||||
54 | |||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 55 | // Retrieves the window's current bounds, including its window. |
56 | // This will only differ from GetRestoredBounds() for maximized | ||||
57 | // and minimized windows. | ||||
58 | virtual gfx::Rect GetBounds() const = 0; | ||||
59 | |||||
60 | // Shows the window, or activates it if it's already visible. | ||||
61 | virtual void Show() = 0; | ||||
62 | |||||
[email protected] | 7d412f7 | 2012-10-25 04:59:15 | [diff] [blame] | 63 | // Hides the window. |
64 | virtual void Hide() = 0; | ||||
65 | |||||
Elly Fong-Jones | 9421d88 | 2018-03-21 12:19:26 | [diff] [blame] | 66 | // Returns whether the window is visible. |
67 | virtual bool IsVisible() const = 0; | ||||
68 | |||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 69 | // Show the window, but do not activate it. Does nothing if window |
70 | // is already visible. | ||||
71 | virtual void ShowInactive() = 0; | ||||
72 | |||||
73 | // Closes the window as soon as possible. The close action may be delayed | ||||
74 | // if an operation is in progress (e.g. a drag operation). | ||||
75 | virtual void Close() = 0; | ||||
76 | |||||
77 | // Activates (brings to front) the window. Restores the window from minimized | ||||
78 | // state if necessary. | ||||
79 | virtual void Activate() = 0; | ||||
80 | |||||
81 | // Deactivates the window, making the next window in the Z order the active | ||||
82 | // window. | ||||
83 | virtual void Deactivate() = 0; | ||||
84 | |||||
85 | // Maximizes/minimizes/restores the window. | ||||
86 | virtual void Maximize() = 0; | ||||
87 | virtual void Minimize() = 0; | ||||
88 | virtual void Restore() = 0; | ||||
89 | |||||
90 | // Sets the window's size and position to the specified values. | ||||
91 | virtual void SetBounds(const gfx::Rect& bounds) = 0; | ||||
92 | |||||
93 | // Flashes the taskbar item associated with this window. | ||||
94 | // Set |flash| to true to initiate flashing, false to stop flashing. | ||||
95 | virtual void FlashFrame(bool flash) = 0; | ||||
[email protected] | d101b0c | 2012-03-16 00:30:57 | [diff] [blame] | 96 | |
Avi Drissman | 9e653328 | 2019-07-17 17:25:12 | [diff] [blame] | 97 | // Returns the z-order level of the window. |
98 | virtual ZOrderLevel GetZOrderLevel() const = 0; | ||||
[email protected] | 46d4605 | 2013-10-11 11:27:22 | [diff] [blame] | 99 | |
Avi Drissman | 9e653328 | 2019-07-17 17:25:12 | [diff] [blame] | 100 | // Sets the z-order level of the window. |
101 | virtual void SetZOrderLevel(ZOrderLevel order) = 0; | ||||
[email protected] | 41d9faf | 2012-02-28 23:46:02 | [diff] [blame] | 102 | }; |
103 | |||||
[email protected] | 5f39adc | 2013-05-23 11:50:46 | [diff] [blame] | 104 | } // namespace ui |
105 | |||||
106 | #endif // UI_BASE_BASE_WINDOW_H_ |