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