1 // Copyright (c) 2016 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Aspect_NeutralWindow_HeaderFile
15 #define _Aspect_NeutralWindow_HeaderFile
17 #include <Aspect_Window.hxx>
19 //! Defines a platform-neutral window.
20 //! This class is intended to be used in context when window management (including OpenGL context creation)
21 //! is performed on application side (e.g. using external framework).
23 //! Window properties should be managed by application and assigned to this class as properties.
24 class Aspect_NeutralWindow : public Aspect_Window
26 DEFINE_STANDARD_RTTIEXT(Aspect_NeutralWindow, Aspect_Window)
29 //! Empty constructor.
30 //! Note that window is considered "mapped" by default.
31 Standard_EXPORT Aspect_NeutralWindow();
33 //! Return native handle of this drawable.
34 virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return myHandle; }
36 //! Return native handle of the parent drawable.
37 virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return myParentHandle; }
40 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return myFBConfig; }
42 //! Set native handle.
43 //! @return true if definition has been changed
44 Standard_Boolean SetNativeHandle (Aspect_Drawable theWindow) { return SetNativeHandles (theWindow, 0, 0); }
46 //! Set native handles.
47 //! @return true if definition has been changed
48 Standard_EXPORT Standard_Boolean SetNativeHandles (Aspect_Drawable theWindow,
49 Aspect_Drawable theParentWindow,
50 Aspect_FBConfig theFbConfig);
52 //! Return true if window is not hidden.
53 virtual Standard_Boolean IsMapped() const Standard_OVERRIDE { return myIsMapped; }
55 //! Change window mapped flag to TRUE.
56 virtual void Map() const Standard_OVERRIDE { myIsMapped = Standard_True; }
58 //! Change window mapped flag to FALSE.
59 virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; }
61 //! Resize window - do nothing.
62 virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
64 //! Map window - do nothing.
65 virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
67 //! Returns window ratio equal to the physical width/height dimensions.
68 virtual Standard_Real Ratio() const Standard_OVERRIDE
70 return (myWidth != 0 && myHeight != 0)
71 ? Standard_Real(myWidth) / Standard_Real(myHeight)
75 //! Return the window position.
76 virtual void Position (Standard_Integer& theX1, Standard_Integer& theY1,
77 Standard_Integer& theX2, Standard_Integer& theY2) const Standard_OVERRIDE
80 theX2 = myPosX + myWidth;
82 theY2 = myPosY + myHeight;
85 //! Set the window position.
86 //! @return true if position has been changed
87 Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1,
88 Standard_Integer theY1);
90 //! Set the window position.
91 //! @return true if position has been changed
92 Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1, Standard_Integer theY1,
93 Standard_Integer theX2, Standard_Integer theY2);
95 //! Return the window size.
96 virtual void Size (Standard_Integer& theWidth,
97 Standard_Integer& theHeight) const Standard_OVERRIDE
100 theHeight = myHeight;
103 //! Set the window size.
104 //! @return true if size has been changed
105 Standard_EXPORT Standard_Boolean SetSize (const Standard_Integer theWidth,
106 const Standard_Integer theHeight);
110 Aspect_Drawable myHandle;
111 Aspect_Drawable myParentHandle;
112 Aspect_FBConfig myFBConfig;
113 Standard_Integer myPosX;
114 Standard_Integer myPosY;
115 Standard_Integer myWidth;
116 Standard_Integer myHeight;
117 mutable Standard_Boolean myIsMapped;
121 DEFINE_STANDARD_HANDLE(Aspect_NeutralWindow, Aspect_Window)
123 #endif // _Aspect_NeutralWindow_HeaderFile