Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:22

0001 // Created on: 2012-11-12
0002 // Created by: Kirill GAVRILOV
0003 // Copyright (c) 2012-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef Cocoa_Window_HeaderFile
0017 #define Cocoa_Window_HeaderFile
0018 
0019 #if defined(__APPLE__)
0020   #import <TargetConditionals.h>
0021 #endif
0022 
0023 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0024   #ifdef __OBJC__
0025     @class UIView;
0026     @class UIWindow;
0027   #else
0028     struct UIView;
0029     struct UIWindow;
0030   #endif
0031 #else
0032   #ifdef __OBJC__
0033     @class NSView;
0034     @class NSWindow;
0035   #else
0036     struct NSView;
0037     struct NSWindow;
0038   #endif
0039 #endif
0040 
0041 #include <Aspect_Window.hxx>
0042 
0043 #include <Standard.hxx>
0044 #include <Standard_Type.hxx>
0045 
0046 #include <Aspect_FillMethod.hxx>
0047 #include <Aspect_GradientFillMethod.hxx>
0048 #include <Aspect_Handle.hxx>
0049 #include <Aspect_TypeOfResize.hxx>
0050 #include <Aspect_VKey.hxx>
0051 #include <Quantity_NameOfColor.hxx>
0052 
0053 class Aspect_WindowDefinitionError;
0054 class Aspect_WindowError;
0055 class Aspect_Background;
0056 class Quantity_Color;
0057 class Aspect_GradientBackground;
0058 
0059 //! This class defines Cocoa window
0060 class Cocoa_Window : public Aspect_Window
0061 {
0062 public:
0063 
0064   //! Convert Carbon virtual key into Aspect_VKey.
0065   Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (Standard_Integer theKey);
0066 
0067 public:
0068 
0069   //! Creates a NSWindow and NSView defined by his position and size in pixels
0070   Standard_EXPORT Cocoa_Window (const Standard_CString theTitle,
0071                                 const Standard_Integer thePxLeft,
0072                                 const Standard_Integer thePxTop,
0073                                 const Standard_Integer thePxWidth,
0074                                 const Standard_Integer thePxHeight);
0075 
0076 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0077   //! Creates a wrapper over existing UIView handle
0078   Standard_EXPORT Cocoa_Window (UIView* theViewUI);
0079 #else
0080   //! Creates a wrapper over existing NSView handle
0081   Standard_EXPORT Cocoa_Window (NSView* theViewNS);
0082 #endif
0083 
0084   //! Destroys the Window and all resourses attached to it
0085   Standard_EXPORT ~Cocoa_Window();
0086 
0087   //! Opens the window <me>
0088   Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
0089 
0090   //! Closes the window <me>
0091   Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
0092 
0093   //! Applies the resizing to the window <me>
0094   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
0095 
0096   //! Apply the mapping change to the window <me>
0097   Standard_EXPORT virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
0098 
0099   //! Returns True if the window <me> is opened
0100   Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
0101 
0102   //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
0103   Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
0104 
0105   //! Returns The Window POSITION in PIXEL
0106   Standard_EXPORT virtual void Position (Standard_Integer& X1,
0107                                          Standard_Integer& Y1,
0108                                          Standard_Integer& X2,
0109                                          Standard_Integer& Y2) const Standard_OVERRIDE;
0110 
0111   //! Returns The Window SIZE in PIXEL
0112   Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
0113                                      Standard_Integer& theHeight) const Standard_OVERRIDE;
0114 
0115 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0116   //! @return associated UIView
0117   UIView* HView() const { return myHView; }
0118 
0119   //! Setup new UIView.
0120   Standard_EXPORT void SetHView (UIView* theView);
0121 #else
0122   //! @return associated NSView
0123   NSView* HView() const { return myHView; }
0124 
0125   //! Setup new NSView.
0126   Standard_EXPORT void SetHView (NSView* theView);
0127 #endif
0128 
0129   //! @return native Window handle
0130   virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
0131   {
0132     return (Aspect_Drawable )HView();
0133   }
0134 
0135   //! @return parent of native Window handle
0136   virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE
0137   {
0138     return 0;
0139   }
0140 
0141   //! Returns nothing on OS X
0142   virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
0143 
0144   //! Sets window title.
0145   Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
0146 
0147   //! Invalidate entire window content by setting NSView::setNeedsDisplay property.
0148   //! Call will be implicitly redirected to the main thread when called from non-GUI thread.
0149   Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp = NULL) Standard_OVERRIDE;
0150 
0151 protected:
0152 
0153 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0154   UIView*          myHView;
0155 #else
0156   NSWindow*        myHWindow;
0157   NSView*          myHView;
0158 #endif
0159   Standard_Integer myXLeft;
0160   Standard_Integer myYTop;
0161   Standard_Integer myXRight;
0162   Standard_Integer myYBottom;
0163 
0164 public:
0165 
0166   DEFINE_STANDARD_RTTIEXT(Cocoa_Window,Aspect_Window)
0167 
0168 };
0169 
0170 DEFINE_STANDARD_HANDLE(Cocoa_Window, Aspect_Window)
0171 
0172 #endif // _Cocoa_Window_H__