Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:58

0001 // Copyright (c) 2016 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Aspect_NeutralWindow_HeaderFile
0015 #define _Aspect_NeutralWindow_HeaderFile
0016 
0017 #include <Aspect_Window.hxx>
0018 
0019 //! Defines a platform-neutral window.
0020 //! This class is intended to be used in context when window management (including OpenGL context creation)
0021 //! is performed on application side (e.g. using external framework).
0022 //!
0023 //! Window properties should be managed by application and assigned to this class as properties.
0024 class Aspect_NeutralWindow : public Aspect_Window
0025 {
0026   DEFINE_STANDARD_RTTIEXT(Aspect_NeutralWindow, Aspect_Window)
0027 public:
0028 
0029   //! Empty constructor.
0030   //! Note that window is considered "mapped" by default.
0031   Standard_EXPORT Aspect_NeutralWindow();
0032 
0033   //! Return native handle of this drawable.
0034   virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return myHandle; }
0035 
0036   //! Return native handle of the parent drawable.
0037   virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return myParentHandle; }
0038 
0039   //! Return FBConfig.
0040   virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return myFBConfig; }
0041 
0042   //! Set native handle.
0043   //! @return true if definition has been changed
0044   Standard_Boolean SetNativeHandle (Aspect_Drawable theWindow) { return SetNativeHandles (theWindow, 0, 0); }
0045 
0046   //! Set native handles.
0047   //! @return true if definition has been changed
0048   Standard_EXPORT Standard_Boolean SetNativeHandles (Aspect_Drawable theWindow,
0049                                                      Aspect_Drawable theParentWindow,
0050                                                      Aspect_FBConfig theFbConfig);
0051 
0052   //! Return true if window is not hidden.
0053   virtual Standard_Boolean IsMapped() const Standard_OVERRIDE { return myIsMapped; }
0054 
0055   //! Change window mapped flag to TRUE.
0056   virtual void Map()   const Standard_OVERRIDE { myIsMapped = Standard_True; }
0057 
0058   //! Change window mapped flag to FALSE.
0059   virtual void Unmap() const Standard_OVERRIDE { myIsMapped = Standard_False; }
0060 
0061   //! Resize window - do nothing.
0062   virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE { return Aspect_TOR_UNKNOWN; }
0063 
0064   //! Map window - do nothing.
0065   virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
0066 
0067   //! Returns window ratio equal to the physical width/height dimensions.
0068   virtual Standard_Real Ratio() const Standard_OVERRIDE
0069   {
0070     return (myWidth != 0 && myHeight != 0)
0071          ? Standard_Real(myWidth) / Standard_Real(myHeight)
0072          : 1.0;
0073   }
0074 
0075   //! Return the window position.
0076   virtual void Position (Standard_Integer& theX1, Standard_Integer& theY1,
0077                          Standard_Integer& theX2, Standard_Integer& theY2) const Standard_OVERRIDE
0078   {
0079     theX1 = myPosX;
0080     theX2 = myPosX + myWidth;
0081     theY1 = myPosY;
0082     theY2 = myPosY + myHeight;
0083   }
0084 
0085   //! Set the window position.
0086   //! @return true if position has been changed
0087   Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1,
0088                                                 Standard_Integer theY1);
0089 
0090   //! Set the window position.
0091   //! @return true if position has been changed
0092   Standard_EXPORT Standard_Boolean SetPosition (Standard_Integer theX1, Standard_Integer theY1,
0093                                                 Standard_Integer theX2, Standard_Integer theY2);
0094 
0095   //! Return the window size.
0096   virtual void Size (Standard_Integer& theWidth,
0097                      Standard_Integer& theHeight) const Standard_OVERRIDE
0098   {
0099     theWidth  = myWidth;
0100     theHeight = myHeight;
0101   }
0102 
0103   //! Set the window size.
0104   //! @return true if size has been changed
0105   Standard_EXPORT Standard_Boolean SetSize (const Standard_Integer theWidth,
0106                                             const Standard_Integer theHeight);
0107 
0108 protected:
0109 
0110   Aspect_Drawable  myHandle;
0111   Aspect_Drawable  myParentHandle;
0112   Aspect_FBConfig  myFBConfig;
0113   Standard_Integer myPosX;
0114   Standard_Integer myPosY;
0115   Standard_Integer myWidth;
0116   Standard_Integer myHeight;
0117   mutable Standard_Boolean myIsMapped;
0118 
0119 };
0120 
0121 DEFINE_STANDARD_HANDLE(Aspect_NeutralWindow, Aspect_Window)
0122 
0123 #endif // _Aspect_NeutralWindow_HeaderFile