Increment OCCT version up to 7.4.0
[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
d8d01f6e 19#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) && !defined(__ANDROID__) && !defined(__QNX__)
ed97f43c 20
21#include <Aspect_Window.hxx>
22
49582f9d 23#include <Aspect_VKey.hxx>
ed97f43c 24#include <Aspect_DisplayConnection.hxx>
25#include <Aspect_FillMethod.hxx>
26#include <Aspect_GradientFillMethod.hxx>
27#include <Aspect_Handle.hxx>
28#include <Aspect_TypeOfResize.hxx>
29#include <Standard.hxx>
ec357c5c 30#include <Standard_Type.hxx>
ed97f43c 31#include <Quantity_NameOfColor.hxx>
ed97f43c 32
33class Aspect_WindowDefinitionError;
34class Aspect_WindowError;
35class Aspect_Background;
36class Quantity_Color;
37class Aspect_GradientBackground;
38
39//! This class defines XLib window intended for creation of OpenGL context.
40class Xw_Window : public Aspect_Window
41{
49582f9d 42public:
43
44 //! Convert X11 virtual key (KeySym) into Aspect_VKey.
45 Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (unsigned long theKey);
ed97f43c 46
47public:
48
49 //! Creates a XLib window defined by his position and size in pixels.
50 //! Throws exception if window can not be created or Display do not support GLX extension.
51 Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
52 const Standard_CString theTitle,
53 const Standard_Integer thePxLeft,
54 const Standard_Integer thePxTop,
55 const Standard_Integer thePxWidth,
b6bf4ec1 56 const Standard_Integer thePxHeight,
57 const Aspect_FBConfig theFBConfig = NULL);
ed97f43c 58
59 //! Creates a wrapper over existing Window handle
60 Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
b6bf4ec1 61 const Window theXWin,
62 const Aspect_FBConfig theFBConfig = NULL);
ed97f43c 63
e6f550da 64 //! Destroys the Window and all resourses attached to it
65 Standard_EXPORT ~Xw_Window();
ed97f43c 66
67 //! Opens the window <me>
b6bf4ec1 68 Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
ed97f43c 69
70 //! Closes the window <me>
b6bf4ec1 71 Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
ed97f43c 72
73 //! Applies the resizing to the window <me>
b6bf4ec1 74 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
ed97f43c 75
76 //! Apply the mapping change to the window <me>
b6bf4ec1 77 Standard_EXPORT virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
ed97f43c 78
79 //! Returns True if the window <me> is opened
b6bf4ec1 80 Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
ed97f43c 81
82 //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
ee2be2a8 83 Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
ed97f43c 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,
b6bf4ec1 89 Standard_Integer& Y2) const Standard_OVERRIDE;
ed97f43c 90
91 //! Returns The Window SIZE in PIXEL
92 Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
b6bf4ec1 93 Standard_Integer& theHeight) const Standard_OVERRIDE;
ed97f43c 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
b6bf4ec1 102 virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
25b97fac 103 {
104 return (Aspect_Drawable )XWindow();
105 }
106
107 //! @return parent of native Window handle
b6bf4ec1 108 virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE
25b97fac 109 {
110 return 0;
111 }
112
b6bf4ec1 113 //! @return native Window FB config (GLXFBConfig on Xlib)
114 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE
115 {
116 return myFBConfig;
117 }
118
49582f9d 119 //! Sets window title.
120 Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
121
8693dfd0 122 //! Invalidate entire window content through generation of Expose event.
123 //! This method does not aggregate multiple calls into single event - dedicated event will be sent on each call.
124 //! When NULL display connection is specified, the connection specified on window creation will be used.
125 //! Sending exposure messages from non-window thread would require dedicated display connection opened specifically
126 //! for this working thread to avoid race conditions, since Xlib display connection is not thread-safe by default.
127 Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp) Standard_OVERRIDE;
128
ed97f43c 129protected:
130
131 Handle(Aspect_DisplayConnection) myDisplay; //!< X Display connection
132 Window myXWindow; //!< XLib window handle
b6bf4ec1 133 Aspect_FBConfig myFBConfig; //!< GLXFBConfig
ed97f43c 134 Standard_Integer myXLeft; //!< left position in pixels
135 Standard_Integer myYTop; //!< top position in pixels
136 Standard_Integer myXRight; //!< right position in pixels
137 Standard_Integer myYBottom; //!< bottom position in pixels
138 Standard_Boolean myIsOwnWin; //!< flag to indicate own window handle (to be deallocated on destruction)
139
140public:
141
92efcf78 142 DEFINE_STANDARD_RTTIEXT(Xw_Window,Aspect_Window)
ed97f43c 143
144};
145
146DEFINE_STANDARD_HANDLE(Xw_Window, Aspect_Window)
147
148#endif // Win32 or Mac OS X
149#endif // _Xw_Window_H__