1 // Created on: 2012-11-12
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Cocoa_Window_H__
17 #define _Cocoa_Window_H__
19 #if defined(__APPLE__)
20 #import <TargetConditionals.h>
23 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
41 #include <Aspect_Window.hxx>
43 #include <Standard.hxx>
44 #include <Standard_Type.hxx>
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>
54 class Aspect_WindowDefinitionError;
55 class Aspect_WindowError;
56 class Aspect_Background;
58 class Aspect_GradientBackground;
60 //! This class defines Cocoa window
61 class Cocoa_Window : public Aspect_Window
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);
73 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
74 //! Creates a wrapper over existing UIView handle
75 Standard_EXPORT Cocoa_Window (UIView* theViewUI);
77 //! Creates a wrapper over existing NSView handle
78 Standard_EXPORT Cocoa_Window (NSView* theViewNS);
81 //! Destroys the Window and all resourses attached to it
82 Standard_EXPORT ~Cocoa_Window();
84 //! Opens the window <me>
85 Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
87 //! Closes the window <me>
88 Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
90 //! Applies the resizing to the window <me>
91 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
93 //! Apply the mapping change to the window <me>
94 Standard_EXPORT virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
96 //! Returns True if the window <me> is opened
97 Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
99 //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
100 Standard_EXPORT virtual Quantity_Ratio Ratio() const Standard_OVERRIDE;
102 //! Returns The Window POSITION in PIXEL
103 Standard_EXPORT virtual void Position (Standard_Integer& X1,
104 Standard_Integer& Y1,
105 Standard_Integer& X2,
106 Standard_Integer& Y2) const Standard_OVERRIDE;
108 //! Returns The Window SIZE in PIXEL
109 Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
110 Standard_Integer& theHeight) const Standard_OVERRIDE;
112 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
113 //! @return associated UIView
114 UIView* HView() const { return myHView; }
116 //! Setup new UIView.
117 Standard_EXPORT void SetHView (UIView* theView);
119 //! @return associated NSView
120 NSView* HView() const { return myHView; }
122 //! Setup new NSView.
123 Standard_EXPORT void SetHView (NSView* theView);
126 //! @return native Window handle
127 virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
129 return (Aspect_Drawable )HView();
132 //! @return parent of native Window handle
133 virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE
138 //! Returns nothing on OS X
139 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
143 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
149 Standard_Integer myXLeft;
150 Standard_Integer myYTop;
151 Standard_Integer myXRight;
152 Standard_Integer myYBottom;
156 DEFINE_STANDARD_RTTIEXT(Cocoa_Window,Aspect_Window)
160 DEFINE_STANDARD_HANDLE(Cocoa_Window, Aspect_Window)
162 #endif // _Cocoa_Window_H__