Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-30 09:02:43

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
0021 //! creation) 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   //! Empty constructor.
0029   //! Note that window is considered "mapped" by default.
0030   Standard_EXPORT Aspect_NeutralWindow();
0031 
0032   //! Return native handle of this drawable.
0033   Aspect_Drawable NativeHandle() const override { return myHandle; }
0034 
0035   //! Return native handle of the parent drawable.
0036   Aspect_Drawable NativeParentHandle() const override { return myParentHandle; }
0037 
0038   //! Return FBConfig.
0039   Aspect_FBConfig NativeFBConfig() const override { return myFBConfig; }
0040 
0041   //! Set native handle.
0042   //! @return true if definition has been changed
0043   bool SetNativeHandle(Aspect_Drawable theWindow)
0044   {
0045     return SetNativeHandles(theWindow, 0, nullptr);
0046   }
0047 
0048   //! Set native handles.
0049   //! @return true if definition has been changed
0050   Standard_EXPORT bool SetNativeHandles(Aspect_Drawable theWindow,
0051                                         Aspect_Drawable theParentWindow,
0052                                         Aspect_FBConfig theFbConfig);
0053 
0054   //! Return true if window is not hidden.
0055   bool IsMapped() const override { return myIsMapped; }
0056 
0057   //! Change window mapped flag to TRUE.
0058   void Map() const override { myIsMapped = true; }
0059 
0060   //! Change window mapped flag to FALSE.
0061   void Unmap() const override { myIsMapped = false; }
0062 
0063   //! Resize window - do nothing.
0064   Aspect_TypeOfResize DoResize() override { return Aspect_TOR_UNKNOWN; }
0065 
0066   //! Map window - do nothing.
0067   bool DoMapping() const override { return true; }
0068 
0069   //! Returns window ratio equal to the physical width/height dimensions.
0070   double Ratio() const override
0071   {
0072     return (myWidth != 0 && myHeight != 0) ? double(myWidth) / double(myHeight) : 1.0;
0073   }
0074 
0075   //! Return the window position.
0076   void Position(int& theX1, int& theY1, int& theX2, int& theY2) const override
0077   {
0078     theX1 = myPosX;
0079     theX2 = myPosX + myWidth;
0080     theY1 = myPosY;
0081     theY2 = myPosY + myHeight;
0082   }
0083 
0084   //! Set the window position.
0085   //! @return true if position has been changed
0086   Standard_EXPORT bool SetPosition(int theX1, int theY1);
0087 
0088   //! Set the window position.
0089   //! @return true if position has been changed
0090   Standard_EXPORT bool SetPosition(int theX1, int theY1, int theX2, int theY2);
0091 
0092   //! Return the window size.
0093   void Size(int& theWidth, int& theHeight) const override
0094   {
0095     theWidth  = myWidth;
0096     theHeight = myHeight;
0097   }
0098 
0099   //! Set the window size.
0100   //! @return true if size has been changed
0101   Standard_EXPORT bool SetSize(const int theWidth, const int theHeight);
0102 
0103 protected:
0104   Aspect_Drawable myHandle;
0105   Aspect_Drawable myParentHandle;
0106   Aspect_FBConfig myFBConfig;
0107   int             myPosX;
0108   int             myPosY;
0109   int             myWidth;
0110   int             myHeight;
0111   mutable bool    myIsMapped;
0112 };
0113 
0114 #endif // _Aspect_NeutralWindow_HeaderFile