Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1996-01-26
0002 // Created by: PLOTNIKOV Eugeny
0003 // Copyright (c) 1996-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _WNT_Window_HeaderFile
0018 #define _WNT_Window_HeaderFile
0019 
0020 #include <Aspect_Window.hxx>
0021 
0022 #if defined(_WIN32) && !defined(OCCT_UWP)
0023 
0024 #include <Aspect_Drawable.hxx>
0025 #include <Aspect_VKey.hxx>
0026 #include <Aspect_Handle.hxx>
0027 #include <WNT_Dword.hxx>
0028 
0029 class Aspect_WindowInputListener;
0030 class WNT_WClass;
0031 typedef struct tagMSG MSG;
0032 
0033 DEFINE_STANDARD_HANDLE(WNT_Window, Aspect_Window)
0034 
0035 //! This class defines Windows NT window
0036 class WNT_Window : public Aspect_Window
0037 {
0038   DEFINE_STANDARD_RTTIEXT(WNT_Window, Aspect_Window)
0039 public:
0040 
0041   //! Convert WInAPI virtual key (VK_ enumeration) into Aspect_VKey.
0042   Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (Standard_Integer theKey);
0043 
0044   //! Convert WPARAM from mouse event to key flags.
0045   Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsFromEvent (WPARAM theKeys);
0046 
0047   //! Convert WPARAM from mouse event to mouse buttons bitmask.
0048   Standard_EXPORT static Aspect_VKeyMouse MouseButtonsFromEvent (WPARAM theKeys);
0049 
0050   //! Use GetAsyncKeyState() to fetch actual mouse key flags regardless of event loop.
0051   Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsAsync();
0052 
0053   //! Use GetAsyncKeyState() to fetch actual mouse buttons state regardless of event loop.
0054   Standard_EXPORT static Aspect_VKeyMouse MouseButtonsAsync();
0055 
0056 public:
0057 
0058   //! Creates a Window defined by his position and size in pixels from the Parent Window.
0059   //! Trigger: Raises WindowDefinitionError if the Position out of the Screen Space or the window creation failed.
0060   Standard_EXPORT WNT_Window (const Standard_CString theTitle,
0061                               const Handle(WNT_WClass)& theClass,
0062                               const WNT_Dword& theStyle,
0063                               const Standard_Integer thePxLeft,  const Standard_Integer thePxTop,
0064                               const Standard_Integer thePxWidth, const Standard_Integer thePxHeight,
0065                               const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY,
0066                               const Aspect_Handle theParent = 0,
0067                               const Aspect_Handle theMenu = 0,
0068                               const Standard_Address theClientStruct = 0);
0069 
0070   //! Creates a Window based on the existing window handle.
0071   Standard_EXPORT WNT_Window (const Aspect_Handle theHandle,
0072                               const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY);
0073 
0074   //! Destroys the Window and all resources attached to it.
0075   Standard_EXPORT virtual ~WNT_Window();
0076 
0077   //! Sets cursor for ENTIRE WINDOW CLASS to which the Window belongs.
0078   Standard_EXPORT void SetCursor (const Aspect_Handle theCursor) const;
0079 
0080   //! Opens the window <me>.
0081   Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
0082   
0083   //! Opens a window according to the map mode.
0084   //! This method is specific to Windows NT.
0085   //! @param theMapMode [in] can be one of SW_xxx constants defined in <windows.h>
0086   Standard_EXPORT void Map (const Standard_Integer theMapMode) const;
0087 
0088   //! Closes the window <me>.
0089   Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
0090   
0091   //! Applies the resizing to the window <me>.
0092   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
0093   
0094   //! Does nothing on Windows.
0095   virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }
0096 
0097   //! Changes variables due to window position.
0098   Standard_EXPORT void SetPos (const Standard_Integer X, const Standard_Integer Y, const Standard_Integer X1, const Standard_Integer Y1);
0099   
0100   //! Returns True if the window <me> is opened
0101   //! and False if the window is closed.
0102   Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
0103   
0104   //! Returns The Window RATIO equal to the physical
0105   //! WIDTH/HEIGHT dimensions.
0106   Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
0107   
0108   //! Returns The Window POSITION in PIXEL
0109   Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const Standard_OVERRIDE;
0110   
0111   //! Returns The Window SIZE in PIXEL
0112   Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const Standard_OVERRIDE;
0113   
0114   //! Returns native Window handle (HWND)
0115   virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE { return (Aspect_Drawable )myHWindow; }
0116   
0117   //! Returns parent of native Window handle (HWND on Windows).
0118   virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE { return (Aspect_Drawable )myHParentWindow; }
0119 
0120   //! Returns nothing on Windows
0121   virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
0122 
0123   //! Sets window title.
0124   Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
0125 
0126   //! Invalidate entire window content by calling InvalidateRect() WinAPI function, resulting in WM_PAINT event put into window message loop.
0127   //! Method can be called from non-window thread, and system will also automatically aggregate multiple events into single one.
0128   Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp = Handle(Aspect_DisplayConnection)()) Standard_OVERRIDE;
0129 
0130 public:
0131 
0132   //! Returns the Windows NT handle of the created window <me>.
0133   Aspect_Handle HWindow() const { return myHWindow; }
0134 
0135   //! Returns the Windows NT handle parent of the created window <me>.
0136   Aspect_Handle HParentWindow() const { return myHParentWindow; }
0137 
0138   //! Raw input flags.
0139   enum RawInputMask
0140   {
0141     RawInputMask_Mouse      = 0x01, //!< HID_USAGE_GENERIC_MOUSE
0142     RawInputMask_SpaceMouse = 0x02, //!< HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER
0143   };
0144 
0145   //! RegisterRawInputDevices() wrapper.
0146   //! @param theRawDeviceMask [in] mask of RawInputMask flags
0147   //! @return number of actually registered device types
0148   Standard_EXPORT int RegisterRawInputDevices (unsigned int theRawDeviceMask);
0149 
0150   //! Process a single window message.
0151   //! @param theListener [in][out] listener to redirect message
0152   //! @param theMsg [in][out] message to process
0153   //! @return TRUE if message has been processed
0154   Standard_EXPORT virtual bool ProcessMessage (Aspect_WindowInputListener& theListener,
0155                                                MSG& theMsg);
0156 
0157 private:
0158 
0159   class TouchInputHelper;
0160 
0161 protected:
0162 
0163   Handle(WNT_WClass) myWClass;
0164   Handle(TouchInputHelper) myTouchInputHelper;
0165   Aspect_Handle    myHWindow;
0166   Aspect_Handle    myHParentWindow;
0167   Standard_Integer myXLeft;
0168   Standard_Integer myYTop;
0169   Standard_Integer myXRight;
0170   Standard_Integer myYBottom;
0171   Standard_Boolean myIsForeign;
0172 
0173 };
0174 
0175 #endif // _WIN32
0176 #endif // _WNT_Window_HeaderFile