0025147: Visualization, TKOpenGl - support EGL as alternative to GLX
[occt.git] / src / Cocoa / Cocoa_Window.hxx
CommitLineData
6aca4d39 1// Created on: 2012-11-12
4fe56619 2// Created by: Kirill GAVRILOV
6aca4d39 3// Copyright (c) 2012-2014 OPEN CASCADE SAS
4fe56619 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
4fe56619 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.
4fe56619 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
4fe56619 15
16#ifndef _Cocoa_Window_H__
17#define _Cocoa_Window_H__
18
19#ifdef __OBJC__
20 @class NSView;
21 @class NSWindow;
22#else
23 struct NSView;
24 struct NSWindow;
25#endif
26
27#include <Aspect_Window.hxx>
28
29#include <Standard.hxx>
30#include <Standard_DefineHandle.hxx>
31
32#include <Aspect_FillMethod.hxx>
33#include <Aspect_GradientFillMethod.hxx>
34#include <Aspect_Handle.hxx>
35#include <Aspect_TypeOfResize.hxx>
36#include <Quantity_NameOfColor.hxx>
37#include <Quantity_Parameter.hxx>
38#include <Quantity_Ratio.hxx>
39
40class Aspect_WindowDefinitionError;
41class Aspect_WindowError;
42class Aspect_Background;
43class Quantity_Color;
44class Aspect_GradientBackground;
45
46//! This class defines Cocoa window
47class Cocoa_Window : public Aspect_Window
48{
49
50public:
51
52 //! Creates a NSWindow and NSView defined by his position and size in pixels
53 Standard_EXPORT Cocoa_Window (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 NSView handle
60 Standard_EXPORT Cocoa_Window (NSView* theViewNS);
61
62 //! Destroies the Window and all resourses attached to it
63 Standard_EXPORT virtual void Destroy();
64
65 ~Cocoa_Window()
66 {
67 Destroy();
68 }
69
4fe56619 70 //! Opens the window <me>
71 Standard_EXPORT virtual void Map() const;
72
73 //! Closes the window <me>
74 Standard_EXPORT virtual void Unmap() const;
75
76 //! Applies the resizing to the window <me>
77 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
78
79 //! Apply the mapping change to the window <me>
80 Standard_EXPORT virtual Standard_Boolean DoMapping() const;
81
4fe56619 82 //! Returns True if the window <me> is opened
83 Standard_EXPORT virtual Standard_Boolean IsMapped() const;
84
85 //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
86 Standard_EXPORT virtual Quantity_Ratio Ratio() const;
87
4fe56619 88 //! Returns The Window POSITION in PIXEL
89 Standard_EXPORT virtual void Position (Standard_Integer& X1,
90 Standard_Integer& Y1,
91 Standard_Integer& X2,
92 Standard_Integer& Y2) const;
93
4fe56619 94 //! Returns The Window SIZE in PIXEL
95 Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
96 Standard_Integer& theHeight) const;
97
4fe56619 98 //! @return associated NSView
99 Standard_EXPORT NSView* HView() const;
100
101 //! Setup new NSView.
102 Standard_EXPORT void SetHView (NSView* theView);
103
25b97fac 104 //! @return native Window handle
105 virtual Aspect_Drawable NativeHandle() const
106 {
107 return (Aspect_Drawable )HView();
108 }
109
110 //! @return parent of native Window handle
111 virtual Aspect_Drawable NativeParentHandle() const
112 {
113 return 0;
114 }
115
4fe56619 116protected:
117
118 NSWindow* myHWindow;
119 NSView* myHView;
120 Standard_Integer myXLeft;
121 Standard_Integer myYTop;
122 Standard_Integer myXRight;
123 Standard_Integer myYBottom;
124
125public:
126
127 DEFINE_STANDARD_RTTI(Cocoa_Window)
128
129};
130
131DEFINE_STANDARD_HANDLE(Cocoa_Window, Aspect_Window)
132
133#endif // _Cocoa_Window_H__