Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:37

0001 // Created on: 2013-04-06
0002 // Created by: Kirill Gavrilov
0003 // Copyright (c) 2013-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 Xw_Window_HeaderFile
0017 #define Xw_Window_HeaderFile
0018 
0019 #include <Aspect_Window.hxx>
0020 
0021 #include <Aspect_VKey.hxx>
0022 
0023 class Aspect_DisplayConnection;
0024 class Aspect_WindowInputListener;
0025 
0026 typedef union _XEvent XEvent;
0027 
0028 //! This class defines XLib window intended for creation of OpenGL context.
0029 class Xw_Window : public Aspect_Window
0030 {
0031   DEFINE_STANDARD_RTTIEXT(Xw_Window, Aspect_Window)
0032 public:
0033 
0034   //! Convert X11 virtual key (KeySym) into Aspect_VKey.
0035   Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (unsigned long theKey);
0036 
0037 public:
0038 
0039   //! Creates a XLib window defined by his position and size in pixels.
0040   //! Throws exception if window can not be created or Display do not support GLX extension.
0041   Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
0042                              const Standard_CString theTitle,
0043                              const Standard_Integer thePxLeft,
0044                              const Standard_Integer thePxTop,
0045                              const Standard_Integer thePxWidth,
0046                              const Standard_Integer thePxHeight);
0047 
0048   //! Creates a wrapper over existing Window handle
0049   Standard_EXPORT Xw_Window (const Handle(Aspect_DisplayConnection)& theXDisplay,
0050                              const Aspect_Drawable theXWin,
0051                              const Aspect_FBConfig theFBConfig = NULL);
0052 
0053   //! Destroys the Window and all resources attached to it
0054   Standard_EXPORT ~Xw_Window();
0055 
0056   //! Opens the window <me>
0057   Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
0058 
0059   //! Closes the window <me>
0060   Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
0061 
0062   //! Applies the resizing to the window <me>
0063   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
0064 
0065   //! Apply the mapping change to the window <me>
0066   virtual Standard_Boolean DoMapping() const Standard_OVERRIDE
0067   {
0068     return Standard_True; // IsMapped()
0069   }
0070 
0071   //! Returns True if the window <me> is opened
0072   Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
0073 
0074   //! Returns The Window RATIO equal to the physical WIDTH/HEIGHT dimensions
0075   Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
0076 
0077   //! Returns The Window POSITION in PIXEL
0078   Standard_EXPORT virtual void Position (Standard_Integer& X1,
0079                                          Standard_Integer& Y1,
0080                                          Standard_Integer& X2,
0081                                          Standard_Integer& Y2) const Standard_OVERRIDE;
0082 
0083   //! Returns The Window SIZE in PIXEL
0084   Standard_EXPORT virtual void Size (Standard_Integer& theWidth,
0085                                      Standard_Integer& theHeight) const Standard_OVERRIDE;
0086 
0087   //! @return native Window handle
0088   Aspect_Drawable XWindow() const { return myXWindow; }
0089 
0090   //! @return native Window handle
0091   virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
0092   {
0093     return myXWindow;
0094   }
0095 
0096   //! @return parent of native Window handle
0097   virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE
0098   {
0099     return 0;
0100   }
0101 
0102   //! @return native Window FB config (GLXFBConfig on Xlib)
0103   virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE
0104   {
0105     return myFBConfig;
0106   }
0107 
0108   //! Sets window title.
0109   Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
0110 
0111   //! Invalidate entire window content through generation of Expose event.
0112   //! This method does not aggregate multiple calls into single event - dedicated event will be sent on each call.
0113   //! When NULL display connection is specified, the connection specified on window creation will be used.
0114   //! Sending exposure messages from non-window thread would require dedicated display connection opened specifically
0115   //! for this working thread to avoid race conditions, since Xlib display connection is not thread-safe by default.
0116   Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp) Standard_OVERRIDE;
0117 
0118   //! Process a single window message.
0119   //! @param theListener [in][out] listener to redirect message
0120   //! @param theMsg [in][out] message to process
0121   //! @return TRUE if message has been processed
0122   Standard_EXPORT virtual bool ProcessMessage (Aspect_WindowInputListener& theListener,
0123                                                XEvent& theMsg);
0124 
0125 protected:
0126 
0127   Aspect_Drawable  myXWindow;  //!< XLib window handle
0128   Aspect_FBConfig  myFBConfig; //!< GLXFBConfig
0129   Standard_Integer myXLeft;    //!< left   position in pixels
0130   Standard_Integer myYTop;     //!< top    position in pixels
0131   Standard_Integer myXRight;   //!< right  position in pixels
0132   Standard_Integer myYBottom;  //!< bottom position in pixels
0133   Standard_Boolean myIsOwnWin; //!< flag to indicate own window handle (to be deallocated on destruction)
0134 
0135 };
0136 
0137 DEFINE_STANDARD_HANDLE(Xw_Window, Aspect_Window)
0138 
0139 #endif // _Xw_Window_H__