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 | |
a2e4f780 |
19 | #if defined(__APPLE__) |
20 | #import <TargetConditionals.h> |
21 | #endif |
22 | |
23 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
24 | #ifdef __OBJC__ |
25 | @class UIView; |
26 | @class UIWindow; |
27 | #else |
28 | struct UIView; |
29 | struct UIWindow; |
30 | #endif |
4fe56619 |
31 | #else |
a2e4f780 |
32 | #ifdef __OBJC__ |
33 | @class NSView; |
34 | @class NSWindow; |
35 | #else |
36 | struct NSView; |
37 | struct NSWindow; |
38 | #endif |
4fe56619 |
39 | #endif |
40 | |
41 | #include <Aspect_Window.hxx> |
42 | |
43 | #include <Standard.hxx> |
ec357c5c |
44 | #include <Standard_Type.hxx> |
4fe56619 |
45 | |
46 | #include <Aspect_FillMethod.hxx> |
47 | #include <Aspect_GradientFillMethod.hxx> |
48 | #include <Aspect_Handle.hxx> |
49 | #include <Aspect_TypeOfResize.hxx> |
50 | #include <Quantity_NameOfColor.hxx> |
51 | #include <Quantity_Parameter.hxx> |
52 | #include <Quantity_Ratio.hxx> |
53 | |
54 | class Aspect_WindowDefinitionError; |
55 | class Aspect_WindowError; |
56 | class Aspect_Background; |
57 | class Quantity_Color; |
58 | class Aspect_GradientBackground; |
59 | |
60 | //! This class defines Cocoa window |
61 | class Cocoa_Window : public Aspect_Window |
62 | { |
63 | |
64 | public: |
65 | |
66 | //! Creates a NSWindow and NSView defined by his position and size in pixels |
67 | Standard_EXPORT Cocoa_Window (const Standard_CString theTitle, |
68 | const Standard_Integer thePxLeft, |
69 | const Standard_Integer thePxTop, |
70 | const Standard_Integer thePxWidth, |
71 | const Standard_Integer thePxHeight); |
72 | |
a2e4f780 |
73 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
74 | //! Creates a wrapper over existing UIView handle |
75 | Standard_EXPORT Cocoa_Window (UIView* theViewUI); |
76 | #else |
4fe56619 |
77 | //! Creates a wrapper over existing NSView handle |
78 | Standard_EXPORT Cocoa_Window (NSView* theViewNS); |
a2e4f780 |
79 | #endif |
4fe56619 |
80 | |
e6f550da |
81 | //! Destroys the Window and all resourses attached to it |
82 | Standard_EXPORT ~Cocoa_Window(); |
4fe56619 |
83 | |
4fe56619 |
84 | //! Opens the window <me> |
b6bf4ec1 |
85 | Standard_EXPORT virtual void Map() const Standard_OVERRIDE; |
4fe56619 |
86 | |
87 | //! Closes the window <me> |
b6bf4ec1 |
88 | Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE; |
4fe56619 |
89 | |
90 | //! Applies the resizing to the window <me> |
b6bf4ec1 |
91 | Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE; |
4fe56619 |
92 | |
93 | //! Apply the mapping change to the window <me> |
b6bf4ec1 |
94 | Standard_EXPORT virtual Standard_Boolean DoMapping() const Standard_OVERRIDE; |
4fe56619 |
95 | |
4fe56619 |
96 | //! Returns True if the window <me> is opened |
b6bf4ec1 |
97 | Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE; |
4fe56619 |
98 | |
99 | //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions |
b6bf4ec1 |
100 | Standard_EXPORT virtual Quantity_Ratio Ratio() const Standard_OVERRIDE; |
4fe56619 |
101 | |
4fe56619 |
102 | //! Returns The Window POSITION in PIXEL |
103 | Standard_EXPORT virtual void Position (Standard_Integer& X1, |
104 | Standard_Integer& Y1, |
105 | Standard_Integer& X2, |
b6bf4ec1 |
106 | Standard_Integer& Y2) const Standard_OVERRIDE; |
4fe56619 |
107 | |
4fe56619 |
108 | //! Returns The Window SIZE in PIXEL |
109 | Standard_EXPORT virtual void Size (Standard_Integer& theWidth, |
b6bf4ec1 |
110 | Standard_Integer& theHeight) const Standard_OVERRIDE; |
4fe56619 |
111 | |
a2e4f780 |
112 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
113 | //! @return associated UIView |
114 | UIView* HView() const { return myHView; } |
115 | |
116 | //! Setup new UIView. |
117 | Standard_EXPORT void SetHView (UIView* theView); |
118 | #else |
4fe56619 |
119 | //! @return associated NSView |
a2e4f780 |
120 | NSView* HView() const { return myHView; } |
4fe56619 |
121 | |
122 | //! Setup new NSView. |
123 | Standard_EXPORT void SetHView (NSView* theView); |
a2e4f780 |
124 | #endif |
4fe56619 |
125 | |
25b97fac |
126 | //! @return native Window handle |
b6bf4ec1 |
127 | virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE |
25b97fac |
128 | { |
129 | return (Aspect_Drawable )HView(); |
130 | } |
131 | |
132 | //! @return parent of native Window handle |
b6bf4ec1 |
133 | virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE |
25b97fac |
134 | { |
135 | return 0; |
136 | } |
137 | |
b6bf4ec1 |
138 | //! Returns nothing on OS X |
139 | virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; } |
140 | |
4fe56619 |
141 | protected: |
142 | |
a2e4f780 |
143 | #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE |
144 | UIView* myHView; |
145 | #else |
4fe56619 |
146 | NSWindow* myHWindow; |
147 | NSView* myHView; |
a2e4f780 |
148 | #endif |
4fe56619 |
149 | Standard_Integer myXLeft; |
150 | Standard_Integer myYTop; |
151 | Standard_Integer myXRight; |
152 | Standard_Integer myYBottom; |
153 | |
154 | public: |
155 | |
f5f4ebd0 |
156 | DEFINE_STANDARD_RTTIEXT(Cocoa_Window,Aspect_Window) |
4fe56619 |
157 | |
158 | }; |
159 | |
160 | DEFINE_STANDARD_HANDLE(Cocoa_Window, Aspect_Window) |
161 | |
162 | #endif // _Cocoa_Window_H__ |