Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:19:14

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 //! This class defines Windows NT window
0034 class WNT_Window : public Aspect_Window
0035 {
0036   DEFINE_STANDARD_RTTIEXT(WNT_Window, Aspect_Window)
0037 public:
0038   //! Convert WInAPI virtual key (VK_ enumeration) into Aspect_VKey.
0039   Standard_EXPORT static Aspect_VKey VirtualKeyFromNative(int theKey);
0040 
0041   //! Convert WPARAM from mouse event to key flags.
0042   Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsFromEvent(WPARAM theKeys);
0043 
0044   //! Convert WPARAM from mouse event to mouse buttons bitmask.
0045   Standard_EXPORT static Aspect_VKeyMouse MouseButtonsFromEvent(WPARAM theKeys);
0046 
0047   //! Use GetAsyncKeyState() to fetch actual mouse key flags regardless of event loop.
0048   Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsAsync();
0049 
0050   //! Use GetAsyncKeyState() to fetch actual mouse buttons state regardless of event loop.
0051   Standard_EXPORT static Aspect_VKeyMouse MouseButtonsAsync();
0052 
0053 public:
0054   //! Creates a Window defined by his position and size in pixels from the Parent Window.
0055   //! Trigger: Raises WindowDefinitionError if the Position out of the Screen Space or the window
0056   //! creation failed.
0057   Standard_EXPORT WNT_Window(const char* const              theTitle,
0058                              const occ::handle<WNT_WClass>& theClass,
0059                              const WNT_Dword&               theStyle,
0060                              const int                      thePxLeft,
0061                              const int                      thePxTop,
0062                              const int                      thePxWidth,
0063                              const int                      thePxHeight,
0064                              const Quantity_NameOfColor     theBackColor = Quantity_NOC_MATRAGRAY,
0065                              const Aspect_Handle            theParent    = 0,
0066                              const Aspect_Handle            theMenu      = 0,
0067                              void* const                    theClientStruct = 0);
0068 
0069   //! Creates a Window based on the existing window handle.
0070   Standard_EXPORT WNT_Window(const Aspect_Handle        theHandle,
0071                              const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY);
0072 
0073   //! Destroys the Window and all resources attached to it.
0074   Standard_EXPORT virtual ~WNT_Window();
0075 
0076   //! Sets cursor for ENTIRE WINDOW CLASS to which the Window belongs.
0077   Standard_EXPORT void SetCursor(const Aspect_Handle theCursor) const;
0078 
0079   //! Opens the window <me>.
0080   Standard_EXPORT virtual void Map() const override;
0081 
0082   //! Opens a window according to the map mode.
0083   //! This method is specific to Windows NT.
0084   //! @param[in] theMapMode  can be one of SW_xxx constants defined in <windows.h>
0085   Standard_EXPORT void Map(const int theMapMode) const;
0086 
0087   //! Closes the window <me>.
0088   Standard_EXPORT virtual void Unmap() const override;
0089 
0090   //! Applies the resizing to the window <me>.
0091   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() override;
0092 
0093   //! Does nothing on Windows.
0094   virtual bool DoMapping() const override { return true; }
0095 
0096   //! Changes variables due to window position.
0097   Standard_EXPORT void SetPos(const int X, const int Y, const int X1, const int Y1);
0098 
0099   //! Returns True if the window <me> is opened
0100   //! and False if the window is closed.
0101   Standard_EXPORT virtual bool IsMapped() const override;
0102 
0103   //! Returns The Window RATIO equal to the physical
0104   //! WIDTH/HEIGHT dimensions.
0105   Standard_EXPORT virtual double Ratio() const override;
0106 
0107   //! Returns The Window POSITION in PIXEL
0108   Standard_EXPORT virtual void Position(int& X1, int& Y1, int& X2, int& Y2) const override;
0109 
0110   //! Returns The Window SIZE in PIXEL
0111   Standard_EXPORT virtual void Size(int& Width, int& Height) const override;
0112 
0113   //! Returns native Window handle (HWND)
0114   virtual Aspect_Drawable NativeHandle() const override { return (Aspect_Drawable)myHWindow; }
0115 
0116   //! Returns parent of native Window handle (HWND on Windows).
0117   virtual Aspect_Drawable NativeParentHandle() const override
0118   {
0119     return (Aspect_Drawable)myHParentWindow;
0120   }
0121 
0122   //! Returns nothing on Windows
0123   virtual Aspect_FBConfig NativeFBConfig() const override { return NULL; }
0124 
0125   //! Sets window title.
0126   Standard_EXPORT virtual void SetTitle(const TCollection_AsciiString& theTitle) override;
0127 
0128   //! Invalidate entire window content by calling InvalidateRect() WinAPI function, resulting in
0129   //! WM_PAINT event put into window message loop. Method can be called from non-window thread, and
0130   //! system will also automatically aggregate multiple events into single one.
0131   Standard_EXPORT virtual void InvalidateContent(
0132     const occ::handle<Aspect_DisplayConnection>& theDisp =
0133       occ::handle<Aspect_DisplayConnection>()) override;
0134 
0135 public:
0136   //! Returns the Windows NT handle of the created window <me>.
0137   Aspect_Handle HWindow() const { return myHWindow; }
0138 
0139   //! Returns the Windows NT handle parent of the created window <me>.
0140   Aspect_Handle HParentWindow() const { return myHParentWindow; }
0141 
0142   //! Raw input flags.
0143   enum RawInputMask
0144   {
0145     RawInputMask_Mouse      = 0x01, //!< HID_USAGE_GENERIC_MOUSE
0146     RawInputMask_SpaceMouse = 0x02, //!< HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER
0147   };
0148 
0149   //! RegisterRawInputDevices() wrapper.
0150   //! @param[in] theRawDeviceMask  mask of RawInputMask flags
0151   //! @return number of actually registered device types
0152   Standard_EXPORT int RegisterRawInputDevices(unsigned int theRawDeviceMask);
0153 
0154   //! Process a single window message.
0155   //! @param[in][out] theListener  listener to redirect message
0156   //! @param[in][out] theMsg  message to process
0157   //! @return TRUE if message has been processed
0158   Standard_EXPORT virtual bool ProcessMessage(Aspect_WindowInputListener& theListener, MSG& theMsg);
0159 
0160 private:
0161   class TouchInputHelper;
0162 
0163 protected:
0164   occ::handle<WNT_WClass>       myWClass;
0165   occ::handle<TouchInputHelper> myTouchInputHelper;
0166   Aspect_Handle                 myHWindow;
0167   Aspect_Handle                 myHParentWindow;
0168   int                           myXLeft;
0169   int                           myYTop;
0170   int                           myXRight;
0171   int                           myYBottom;
0172   bool                          myIsForeign;
0173 };
0174 
0175 #endif // _WIN32
0176 #endif // _WNT_Window_HeaderFile