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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _WNT_Window_HeaderFile
18 #define _WNT_Window_HeaderFile
20 #include <Aspect_Window.hxx>
22 #if defined(_WIN32) && !defined(OCCT_UWP)
24 #include <Aspect_Drawable.hxx>
25 #include <Aspect_VKey.hxx>
26 #include <Aspect_Handle.hxx>
27 #include <Standard_Type.hxx>
28 #include <WNT_Dword.hxx>
32 DEFINE_STANDARD_HANDLE(WNT_Window, Aspect_Window)
34 //! This class defines Windows NT window
35 class WNT_Window : public Aspect_Window
39 //! Convert WInAPI virtual key (VK_ enumeration) into Aspect_VKey.
40 Standard_EXPORT static Aspect_VKey VirtualKeyFromNative (Standard_Integer theKey);
42 //! Convert WPARAM from mouse event to key flags.
43 Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsFromEvent (WPARAM theKeys);
45 //! Convert WPARAM from mouse event to mouse buttons bitmask.
46 Standard_EXPORT static Aspect_VKeyMouse MouseButtonsFromEvent (WPARAM theKeys);
48 //! Use GetAsyncKeyState() to fetch actual mouse key flags regardless of event loop.
49 Standard_EXPORT static Aspect_VKeyFlags MouseKeyFlagsAsync();
51 //! Use GetAsyncKeyState() to fetch actual mouse buttons state regardless of event loop.
52 Standard_EXPORT static Aspect_VKeyMouse MouseButtonsAsync();
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);
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);
66 //! Destroys the Window and all resourses attached to it.
67 Standard_EXPORT ~WNT_Window();
69 //! Sets cursor <aCursor> for ENTIRE WINDOW CLASS to which
70 //! the Window belongs.
71 Standard_EXPORT void SetCursor (const Aspect_Handle aCursor) const;
73 //! Opens the window <me>.
74 Standard_EXPORT virtual void Map() const Standard_OVERRIDE;
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;
82 //! Closes the window <me>.
83 Standard_EXPORT virtual void Unmap() const Standard_OVERRIDE;
85 //! Applies the resizing to the window <me>.
86 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() const Standard_OVERRIDE;
88 //! Apply the mapping change to the window <me>
89 //! and returns TRUE if the window is mapped at screen.
90 virtual Standard_Boolean DoMapping() const Standard_OVERRIDE;
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);
95 //! Returns True if the window <me> is opened
96 //! and False if the window is closed.
97 Standard_EXPORT virtual Standard_Boolean IsMapped() const Standard_OVERRIDE;
99 //! Returns The Window RATIO equal to the physical
100 //! WIDTH/HEIGHT dimensions.
101 Standard_EXPORT virtual Standard_Real Ratio() const Standard_OVERRIDE;
103 //! Returns The Window POSITION in PIXEL
104 Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const Standard_OVERRIDE;
106 //! Returns The Window SIZE in PIXEL
107 Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const Standard_OVERRIDE;
109 //! Returns the Windows NT handle of the created window <me>.
110 Aspect_Handle HWindow() const;
112 //! Returns the Windows NT handle parent of the created window <me>.
113 Aspect_Handle HParentWindow() const;
115 //! Returns native Window handle (HWND)
116 virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE;
118 //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
119 virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE;
121 //! Returns nothing on Windows
122 virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }
124 //! Sets window title.
125 Standard_EXPORT virtual void SetTitle (const TCollection_AsciiString& theTitle) Standard_OVERRIDE;
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;
131 DEFINE_STANDARD_RTTIEXT(WNT_Window,Aspect_Window)
135 Standard_Integer aXLeft;
136 Standard_Integer aYTop;
137 Standard_Integer aXRight;
138 Standard_Integer aYBottom;
139 Handle(WNT_WClass) myWClass;
140 Aspect_Handle myHWindow;
141 Aspect_Handle myHParentWindow;
142 Standard_Boolean myIsForeign;
146 #include <WNT_Window.lxx>
149 #endif // _WNT_Window_HeaderFile