0022590: Migration to FreeImage - revision of Xw and WNT packages
[occt.git] / src / Xw / Xw_Window.hxx
1 // Created on: 2013-04-06
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2013 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 65 (the "License") You may not use the content of this file
7 // except in compliance with the License Please obtain a copy of the License
8 // at http://wwwopencascadeorg and read it completely before using this file
9 //
10 // The Initial Developer of the Original Code is Open CASCADE SAS, having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License
19
20 #ifndef _Xw_Window_H__
21 #define _Xw_Window_H__
22
23 #if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
24
25 #include <Aspect_Window.hxx>
26
27 #include <Aspect_DisplayConnection.hxx>
28 #include <Aspect_FillMethod.hxx>
29 #include <Aspect_GradientFillMethod.hxx>
30 #include <Aspect_Handle.hxx>
31 #include <Aspect_TypeOfResize.hxx>
32 #include <Standard.hxx>
33 #include <Standard_DefineHandle.hxx>
34 #include <Quantity_NameOfColor.hxx>
35 #include <Quantity_Parameter.hxx>
36 #include <Quantity_Ratio.hxx>
37
38 class Aspect_WindowDefinitionError;
39 class Aspect_WindowError;
40 class Aspect_Background;
41 class Quantity_Color;
42 class Aspect_GradientBackground;
43
44 //! This class defines XLib window intended for creation of OpenGL context.
45 class Xw_Window : public Aspect_Window
46 {
47
48 public:
49
50   //! Creates a XLib window defined by his position and size in pixels.
51   //! Throws exception if window can not be created or Display do not support GLX extension.
52   Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
53                              const Standard_CString theTitle,
54                              const Standard_Integer thePxLeft,
55                              const Standard_Integer thePxTop,
56                              const Standard_Integer thePxWidth,
57                              const Standard_Integer thePxHeight);
58
59   //! Creates a wrapper over existing Window handle
60   Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
61                              const Window theXWin);
62
63   //! Destroies the Window and all resourses attached to it
64   Standard_EXPORT virtual void Destroy();
65
66   ~Xw_Window()
67   {
68     Destroy();
69   }
70
71   //! Opens the window <me>
72   Standard_EXPORT virtual void Map() const;
73
74   //! Closes the window <me>
75   Standard_EXPORT virtual void Unmap() const;
76
77   //! Applies the resizing to the window <me>
78   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
79
80   //! Apply the mapping change to the window <me>
81   Standard_EXPORT virtual Standard_Boolean DoMapping() const;
82
83   //! Returns True if the window <me> is opened
84   Standard_EXPORT virtual Standard_Boolean IsMapped() const;
85
86   //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
87   Standard_EXPORT virtual Quantity_Ratio Ratio() const;
88
89   //! Returns The Window POSITION in PIXEL
90   Standard_EXPORT virtual void Position (Standard_Integer& X1,
91                                          Standard_Integer& Y1,
92                                          Standard_Integer& X2,
93                                          Standard_Integer& Y2) const;
94
95   //! Returns The Window SIZE in PIXEL
96   Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
97                                      Standard_Integer& theHeight) const;
98
99   //! @return native Window handle
100   Standard_EXPORT Window XWindow() const;
101
102   //! @return connection to X Display
103   Standard_EXPORT const Handle(Aspect_DisplayConnection)& DisplayConnection() const;
104
105 protected:
106
107   Handle(Aspect_DisplayConnection) myDisplay; //!< X Display connection
108   Window           myXWindow;  //!< XLib window handle
109   Standard_Integer myXLeft;    //!< left   position in pixels
110   Standard_Integer myYTop;     //!< top    position in pixels
111   Standard_Integer myXRight;   //!< right  position in pixels
112   Standard_Integer myYBottom;  //!< bottom position in pixels
113   Standard_Boolean myIsOwnWin; //!< flag to indicate own window handle (to be deallocated on destruction)
114
115 public:
116
117   DEFINE_STANDARD_RTTI(Xw_Window)
118
119 };
120
121 DEFINE_STANDARD_HANDLE(Xw_Window, Aspect_Window)
122
123 #endif //  Win32 or Mac OS X
124 #endif // _Xw_Window_H__