Ocean
WxScopedParentWindow.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_WXWIDGETS_WX_SCOPED_PARENT_WINDOW_H
9 #define META_OCEAN_PLATFORM_WXWIDGETS_WX_SCOPED_PARENT_WINDOW_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Platform
17 {
18 
19 namespace WxWidgets
20 {
21 
22 /**
23  * This class implements a parent window taking on an already existing window handle as long as the instance of the scoped window exists.
24  * @ingroup platformwxwidgets
25  */
26 class OCEAN_PLATFORM_WXWIDGETS_EXPORT WxScopedParentWindow
27 {
28  public:
29 
30  /**
31  * Creates a new scoped window.
32  */
34 
35  /**
36  * Creates a new scoped window.
37  * @param handle The handle of an already existing window which will be taken over as long as the scoped window exists, may be nullptr which is then equivalent to the default constructor
38  */
39  explicit WxScopedParentWindow(OCEAN_WXWIDGETS_HANDLE handle);
40 
41  /**
42  * Move constructor.
43  * @param window Window to move
44  */
46 
47  /**
48  * Destructs a scoped window object and gives the external window handle back.
49  */
51 
52  /**
53  * Explicitly releases the internal window and gives the external window handle back.
54  * Use this function to release the internal handle before the scope finishes.
55  */
56  void release();
57 
58  /**
59  * Move operator.
60  * @param window Window to move
61  * @return Reference to this object
62  */
64 
65  /**
66  * Dereferencing operator providing access to the internal window object.
67  * Beware: Ensure that this object has not been released before!
68  * @return The internal window object
69  * @see release().
70  */
71  wxWindow& operator*() const;
72 
73  protected:
74 
75  /**
76  * Disabled copy constructor.
77  */
79 
80  /**
81  * Disabled assign operator.
82  * @return Reference to this object
83  */
85 
86  protected:
87 
88  /// True, if the internal window is associated.
89  bool assocated_ = false;
90 
91  /// The internal window object.
92  wxWindow* window_ = nullptr;
93 };
94 
95 }
96 
97 }
98 
99 }
100 
101 #endif // META_OCEAN_PLATFORM_WXWIDGETS_WX_SCOPED_PARENT_WINDOW_H
This class implements a parent window taking on an already existing window handle as long as the inst...
Definition: WxScopedParentWindow.h:27
WxScopedParentWindow & operator=(WxScopedParentWindow &&window) noexcept
Move operator.
WxScopedParentWindow()
Creates a new scoped window.
WxScopedParentWindow(OCEAN_WXWIDGETS_HANDLE handle)
Creates a new scoped window.
WxScopedParentWindow(WxScopedParentWindow &&window) noexcept
Move constructor.
~WxScopedParentWindow()
Destructs a scoped window object and gives the external window handle back.
wxWindow & operator*() const
Dereferencing operator providing access to the internal window object.
WxScopedParentWindow & operator=(const WxScopedParentWindow &)=delete
Disabled assign operator.
WxScopedParentWindow(const WxScopedParentWindow &)=delete
Disabled copy constructor.
void release()
Explicitly releases the internal window and gives the external window handle back.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15