1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Aspect_Window_HeaderFile
17 #define _Aspect_Window_HeaderFile
19 #include <Aspect_Background.hxx>
20 #include <Aspect_GradientBackground.hxx>
21 #include <Aspect_FBConfig.hxx>
22 #include <Aspect_FillMethod.hxx>
23 #include <Quantity_Color.hxx>
24 #include <Aspect_GradientFillMethod.hxx>
25 #include <Aspect_TypeOfResize.hxx>
26 #include <Aspect_Drawable.hxx>
27 #include <Graphic3d_Vec2.hxx>
28 #include <Standard.hxx>
29 #include <Standard_Transient.hxx>
30 #include <Standard_Type.hxx>
31 #include <TCollection_AsciiString.hxx>
33 class Aspect_DisplayConnection;
35 DEFINE_STANDARD_HANDLE(Aspect_Window, Standard_Transient)
38 class Aspect_Window : public Standard_Transient
40 DEFINE_STANDARD_RTTIEXT(Aspect_Window, Standard_Transient)
43 //! Modifies the window background.
44 Standard_EXPORT void SetBackground (const Aspect_Background& ABack);
46 //! Modifies the window background.
47 Standard_EXPORT void SetBackground (const Quantity_Color& color);
49 //! Modifies the window gradient background.
50 Standard_EXPORT void SetBackground (const Aspect_GradientBackground& ABackground);
52 //! Modifies the window gradient background.
53 Standard_EXPORT void SetBackground (const Quantity_Color& theFirstColor, const Quantity_Color& theSecondColor, const Aspect_GradientFillMethod theFillMethod);
55 //! Opens the window <me>.
56 Standard_EXPORT virtual void Map() const = 0;
58 //! Closes the window <me>.
59 Standard_EXPORT virtual void Unmap() const = 0;
61 //! Apply the resizing to the window <me>.
62 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
64 //! Apply the mapping change to the window <me>.
65 //! and returns TRUE if the window is mapped at screen.
66 Standard_EXPORT virtual Standard_Boolean DoMapping() const = 0;
68 //! Returns the window background.
69 Standard_EXPORT Aspect_Background Background() const;
71 //! Returns the current image background fill mode.
72 Standard_EXPORT Aspect_FillMethod BackgroundFillMethod() const;
74 //! Returns the window gradient background.
75 Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
77 //! Returns True if the window <me> is opened
78 //! and False if the window is closed.
79 Standard_EXPORT virtual Standard_Boolean IsMapped() const = 0;
81 //! Returns True if the window <me> is virtual
82 Standard_EXPORT Standard_Boolean IsVirtual() const;
84 //! Setup the virtual state
85 Standard_EXPORT void SetVirtual (const Standard_Boolean theVirtual);
87 //! Returns The Window RATIO equal to the physical
88 //! WIDTH/HEIGHT dimensions
89 Standard_EXPORT virtual Standard_Real Ratio() const = 0;
91 //! Returns The Window POSITION in PIXEL
92 Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const = 0;
94 //! Returns The Window SIZE in PIXEL
95 Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const = 0;
97 //! Returns native Window handle (HWND on Windows, Window with Xlib, and so on)
98 Standard_EXPORT virtual Aspect_Drawable NativeHandle() const = 0;
100 //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
101 Standard_EXPORT virtual Aspect_Drawable NativeParentHandle() const = 0;
103 //! Returns native Window FB config (GLXFBConfig on Xlib)
104 Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
106 //! Returns connection to Display or NULL.
107 const Handle(Aspect_DisplayConnection)& DisplayConnection() const { return myDisplay; }
109 //! Sets window title.
110 virtual void SetTitle (const TCollection_AsciiString& theTitle) { (void )theTitle; }
112 //! Invalidate entire window content.
114 //! Implementation is expected to allow calling this method from non-GUI thread,
115 //! e.g. by queuing exposure event into window message queue or in other thread-safe manner.
117 //! Optional display argument should be passed when called from non-GUI thread
118 //! on platforms implementing thread-unsafe connections to display.
119 //! NULL can be passed instead otherwise.
120 virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp) { (void )theDisp; }
124 //! Return device pixel ratio (logical to backing store scale factor).
125 virtual Standard_Real DevicePixelRatio() const { return 1.0; }
127 //! Convert point from logical units into backing store units.
128 virtual Graphic3d_Vec2d ConvertPointToBacking (const Graphic3d_Vec2d& thePnt) const
130 return thePnt * DevicePixelRatio();
133 //! Convert point from backing store units to logical units.
134 virtual Graphic3d_Vec2d ConvertPointFromBacking (const Graphic3d_Vec2d& thePnt) const
136 return thePnt / DevicePixelRatio();
141 //! Dumps the content of me into the stream
142 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
146 //! Initializes the data of a Window.
147 Standard_EXPORT Aspect_Window();
151 Handle(Aspect_DisplayConnection) myDisplay; //!< Display connection
152 Aspect_Background MyBackground;
153 Aspect_GradientBackground MyGradientBackground;
154 Aspect_FillMethod MyBackgroundFillMethod;
155 Standard_Boolean MyIsVirtual;
159 #endif // _Aspect_Window_HeaderFile