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__
27 #include <Aspect_Window.hxx>
29 #include <Standard.hxx>
30 #include <Standard_DefineHandle.hxx>
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>
40 class Aspect_WindowDefinitionError;
41 class Aspect_WindowError;
42 class Aspect_Background;
44 class Aspect_GradientBackground;
46 //! This class defines Cocoa window
47 class Cocoa_Window : public Aspect_Window
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);
59 //! Creates a wrapper over existing NSView handle
60 Standard_EXPORT Cocoa_Window (NSView* theViewNS);
62 //! Destroies the Window and all resourses attached to it
63 Standard_EXPORT virtual void Destroy();
70 //! Opens the window <me>
71 Standard_EXPORT virtual void Map() const;
73 //! Closes the window <me>
74 Standard_EXPORT virtual void Unmap() const;
76 //! Applies the resizing to the window <me>
77 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const;
79 //! Apply the mapping change to the window <me>
80 Standard_EXPORT virtual Standard_Boolean DoMapping() const;
82 //! Returns True if the window <me> is opened
83 Standard_EXPORT virtual Standard_Boolean IsMapped() const;
85 //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
86 Standard_EXPORT virtual Quantity_Ratio Ratio() const;
88 //! Returns The Window POSITION in PIXEL
89 Standard_EXPORT virtual void Position (Standard_Integer& X1,
92 Standard_Integer& Y2) const;
94 //! Returns The Window SIZE in PIXEL
95 Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
96 Standard_Integer& theHeight) const;
98 //! @return associated NSView
99 Standard_EXPORT NSView* HView() const;
101 //! Setup new NSView.
102 Standard_EXPORT void SetHView (NSView* theView);
104 //! @return native Window handle
105 virtual Aspect_Drawable NativeHandle() const
107 return (Aspect_Drawable )HView();
110 //! @return parent of native Window handle
111 virtual Aspect_Drawable NativeParentHandle() const
120 Standard_Integer myXLeft;
121 Standard_Integer myYTop;
122 Standard_Integer myXRight;
123 Standard_Integer myYBottom;
127 DEFINE_STANDARD_RTTI(Cocoa_Window)
131 DEFINE_STANDARD_HANDLE(Cocoa_Window, Aspect_Window)
133 #endif // _Cocoa_Window_H__