0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / WNT / WNT_Window.hxx
CommitLineData
42cf5bc1 1// Created on: 1996-01-26
2// Created by: PLOTNIKOV Eugeny
3// Copyright (c) 1996-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _WNT_Window_HeaderFile
18#define _WNT_Window_HeaderFile
19
49582f9d 20#include <Aspect_Window.hxx>
42cf5bc1 21
1ce0716b 22#if defined(_WIN32) && !defined(OCCT_UWP)
23
49582f9d 24#include <Aspect_Drawable.hxx>
25#include <Aspect_VKey.hxx>
42cf5bc1 26#include <Aspect_Handle.hxx>
49582f9d 27#include <Standard_Type.hxx>
42cf5bc1 28#include <WNT_Dword.hxx>
42cf5bc1 29
49582f9d 30class WNT_WClass;
42cf5bc1 31
42cf5bc1 32DEFINE_STANDARD_HANDLE(WNT_Window, Aspect_Window)
33
34//! This class defines Windows NT window
35class WNT_Window : public Aspect_Window
36{
49582f9d 37public:
38
39 //! Convert WInAPI virtual key (VK_ enumeration) into Aspect_VKey.
40 Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (Standard_Integer theKey);
41
42 //! Convert WPARAM from mouse event to key flags.
43 Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsFromEvent (WPARAM theKeys);
44
45 //! Convert WPARAM from mouse event to mouse buttons bitmask.
46 Standard_EXPORT static Aspect_VKeyMouse MouseButtonsFromEvent (WPARAM theKeys);
47
48 //! Use GetAsyncKeyState() to fetch actual mouse key flags regardless of event loop.
49 Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsAsync();
50
51 //! Use GetAsyncKeyState() to fetch actual mouse buttons state regardless of event loop.
52 Standard_EXPORT static Aspect_VKeyMouse MouseButtonsAsync();
42cf5bc1 53
54public:
55
42cf5bc1 56 //! Creates a Window defined by his position and size
57 //! in pixles from the Parent Window.
58 //! Trigger: Raises WindowDefinitionError if the Position out of the
59 //! Screen Space or the window creation failed.
60 Standard_EXPORT WNT_Window(const Standard_CString theTitle, const Handle(WNT_WClass)& theClass, const WNT_Dword& theStyle, const Standard_Integer thePxLeft, const Standard_Integer thePxTop, const Standard_Integer thePxWidth, const Standard_Integer thePxHeight, const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY, const Aspect_Handle theParent = 0, const Aspect_Handle theMenu = 0, const Standard_Address theClientStruct = 0);
61
62 //! Creates a Window based on the existing window handle.
63 //! This handle equals ( aPart1 << 16 ) + aPart2.
64 Standard_EXPORT WNT_Window(const Aspect_Handle aHandle, const Quantity_NameOfColor aBackColor = Quantity_NOC_MATRAGRAY);
65
e6f550da 66 //! Destroys the Window and all resourses attached to it.
67 Standard_EXPORT ~WNT_Window();
42cf5bc1 68
69 //! Sets cursor <aCursor> for ENTIRE WINDOW CLASS to which
70 //! the Window belongs.
71 Standard_EXPORT void SetCursor (const Aspect_Handle aCursor) const;
72
73 //! Opens the window <me>.
b6bf4ec1 74 Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
42cf5bc1 75
76 //! Opens a window <me> according to <aMapMode>.
77 //! This method is specific to Windows NT.
78 //! <aMapMode> can be one of SW_xxx constants defined
79 //! in <windows.h>. See documentation.
80 Standard_EXPORT void Map (const Standard_Integer aMapMode) const;
81
82 //! Closes the window <me>.
b6bf4ec1 83 Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
42cf5bc1 84
85 //! Applies the resizing to the window <me>.
1a5007a9 86 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;
42cf5bc1 87
88 //! Apply the mapping change to the window <me>
89 //! and returns TRUE if the window is mapped at screen.
b6bf4ec1 90 virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
42cf5bc1 91
92 //! Changes variables due to window position.
93 Standard_EXPORT void SetPos (const Standard_Integer X, const Standard_Integer Y, const Standard_Integer X1, const Standard_Integer Y1);
94
95 //! Returns True if the window <me> is opened
96 //! and False if the window is closed.
b6bf4ec1 97 Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
42cf5bc1 98
99 //! Returns The Window RATIO equal to the physical
100 //! WIDTH/HEIGHT dimensions.
ee2be2a8 101 Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
42cf5bc1 102
103 //! Returns The Window POSITION in PIXEL
b6bf4ec1 104 Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const Standard_OVERRIDE;
42cf5bc1 105
106 //! Returns The Window SIZE in PIXEL
b6bf4ec1 107 Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const Standard_OVERRIDE;
42cf5bc1 108
109 //! Returns the Windows NT handle of the created window <me>.
b6bf4ec1 110 Aspect_Handle HWindow() const;
42cf5bc1 111
112 //! Returns the Windows NT handle parent of the created window <me>.
b6bf4ec1 113 Aspect_Handle HParentWindow() const;
42cf5bc1 114
115 //! Returns native Window handle (HWND)
b6bf4ec1 116 virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE;
42cf5bc1 117
118 //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
b6bf4ec1 119 virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE;
42cf5bc1 120
b6bf4ec1 121 //! Returns nothing on Windows
122 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
42cf5bc1 123
49582f9d 124 //! Sets window title.
125 Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
126
8693dfd0 127 //! Invalidate entire window content by calling InvalidateRect() WinAPI function, resulting in WM_PAINT event put into window message loop.
128 //! Method can be called from non-window thread, and system will also automatically aggregate multiple events into single one.
129 Standard_EXPORT virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp = NULL) Standard_OVERRIDE;
130
d6fbb2ab 131 //! Raw input flags.
132 enum RawInputMask
133 {
134 RawInputMask_Mouse = 0x01, //!< HID_USAGE_GENERIC_MOUSE
135 RawInputMask_SpaceMouse = 0x02, //!< HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER
136 };
137
138 //! RegisterRawInputDevices() wrapper.
139 //! @param theRawDeviceMask [in] mask of RawInputMask flags
140 //! @return number of actually registered device types
141 Standard_EXPORT int RegisterRawInputDevices (unsigned int theRawDeviceMask);
142
92efcf78 143 DEFINE_STANDARD_RTTIEXT(WNT_Window,Aspect_Window)
42cf5bc1 144
145protected:
146
42cf5bc1 147 Standard_Integer aXLeft;
148 Standard_Integer aYTop;
149 Standard_Integer aXRight;
150 Standard_Integer aYBottom;
151 Handle(WNT_WClass) myWClass;
152 Aspect_Handle myHWindow;
153 Aspect_Handle myHParentWindow;
154 Standard_Boolean myIsForeign;
155
42cf5bc1 156};
157
42cf5bc1 158#include <WNT_Window.lxx>
159
1ce0716b 160#endif // _WIN32
42cf5bc1 161#endif // _WNT_Window_HeaderFile