0024947: Redesign OCCT legacy type system
[occt.git] / src / Xw / Xw_Window.hxx
CommitLineData
ed97f43c 1// Created on: 2013-04-06
2// Created by: Kirill Gavrilov
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
ed97f43c 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
ed97f43c 6//
d5f74e42 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
973c2be1 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.
ed97f43c 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
ed97f43c 15
16#ifndef _Xw_Window_H__
17#define _Xw_Window_H__
18
0304f711 19#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__)
ed97f43c 20
21#include <Aspect_Window.hxx>
22
23#include <Aspect_DisplayConnection.hxx>
24#include <Aspect_FillMethod.hxx>
25#include <Aspect_GradientFillMethod.hxx>
26#include <Aspect_Handle.hxx>
27#include <Aspect_TypeOfResize.hxx>
28#include <Standard.hxx>
29#include <Standard_DefineHandle.hxx>
30#include <Quantity_NameOfColor.hxx>
31#include <Quantity_Parameter.hxx>
32#include <Quantity_Ratio.hxx>
33
34class Aspect_WindowDefinitionError;
35class Aspect_WindowError;
36class Aspect_Background;
37class Quantity_Color;
38class Aspect_GradientBackground;
39
40//! This class defines XLib window intended for creation of OpenGL context.
41class Xw_Window : public Aspect_Window
42{
43
44public:
45
46 //! Creates a XLib window defined by his position and size in pixels.
47 //! Throws exception if window can not be created or Display do not support GLX extension.
48 Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
49 const Standard_CString theTitle,
50 const Standard_Integer thePxLeft,
51 const Standard_Integer thePxTop,
52 const Standard_Integer thePxWidth,
53 const Standard_Integer thePxHeight);
54
55 //! Creates a wrapper over existing Window handle
56 Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
57 const Window theXWin);
58
59 //! Destroies the Window and all resourses attached to it
60 Standard_EXPORT virtual void Destroy();
61
62 ~Xw_Window()
63 {
64 Destroy();
65 }
66
67 //! Opens the window <me>
68 Standard_EXPORT virtual void Map() const;
69
70 //! Closes the window <me>
71 Standard_EXPORT virtual void Unmap() const;
72
73 //! Applies the resizing to the window <me>
74 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
75
76 //! Apply the mapping change to the window <me>
77 Standard_EXPORT virtual Standard_Boolean DoMapping() const;
78
79 //! Returns True if the window <me> is opened
80 Standard_EXPORT virtual Standard_Boolean IsMapped() const;
81
82 //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
83 Standard_EXPORT virtual Quantity_Ratio Ratio() const;
84
85 //! Returns The Window POSITION in PIXEL
86 Standard_EXPORT virtual void Position (Standard_Integer& X1,
87 Standard_Integer& Y1,
88 Standard_Integer& X2,
89 Standard_Integer& Y2) const;
90
91 //! Returns The Window SIZE in PIXEL
92 Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
93 Standard_Integer& theHeight) const;
94
95 //! @return native Window handle
96 Standard_EXPORT Window XWindow() const;
97
98 //! @return connection to X Display
99 Standard_EXPORT const Handle(Aspect_DisplayConnection)& DisplayConnection() const;
100
25b97fac 101 //! @return native Window handle
102 virtual Aspect_Drawable NativeHandle() const
103 {
104 return (Aspect_Drawable )XWindow();
105 }
106
107 //! @return parent of native Window handle
108 virtual Aspect_Drawable NativeParentHandle() const
109 {
110 return 0;
111 }
112
ed97f43c 113protected:
114
115 Handle(Aspect_DisplayConnection) myDisplay; //!< X Display connection
116 Window myXWindow; //!< XLib window handle
117 Standard_Integer myXLeft; //!< left position in pixels
118 Standard_Integer myYTop; //!< top position in pixels
119 Standard_Integer myXRight; //!< right position in pixels
120 Standard_Integer myYBottom; //!< bottom position in pixels
121 Standard_Boolean myIsOwnWin; //!< flag to indicate own window handle (to be deallocated on destruction)
122
123public:
124
125 DEFINE_STANDARD_RTTI(Xw_Window)
126
127};
128
129DEFINE_STANDARD_HANDLE(Xw_Window, Aspect_Window)
130
131#endif // Win32 or Mac OS X
132#endif // _Xw_Window_H__