Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Win32Window.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Win32_Window_INCLUDE_ONCE
33 #define Win32_Window_INCLUDE_ONCE
34 
36 #include <vlWin32/Win32Context.hpp>
37 #include <map>
38 
39 namespace vlWin32
40 {
41 //-----------------------------------------------------------------------------
43  VLWIN32_EXPORT void peekMessage(MSG& msg);
45 //-----------------------------------------------------------------------------
46 // Win32Window
47 //-----------------------------------------------------------------------------
52  {
53  public:
54  static LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
55 
56  public:
57  Win32Window();
58  ~Win32Window();
59 
62  bool initWin32GLWindow(HWND parent, HGLRC share_context, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x=0, int y=0, int width=640, int height=480);
63 
65  void destroyWin32GLWindow();
66 
67  HWND hwnd() const { return mHWND; }
68 
70  DWORD style() const { return mStyle; }
71 
73  void setStyle(DWORD style) { mStyle = style; }
74 
76  DWORD exStyle() const { return mStyle; }
77 
79  void setExStyle(DWORD ex_style) { mStyle = ex_style; }
80 
82  const wchar_t* windowClassName() const { return mWindowClassName; }
83 
85  void setWindowClassName(const wchar_t* name) { mWindowClassName = name; }
86 
87  protected:
89  HWND mHWND;
90  DWORD mStyle;
91  DWORD mExStyle;
92  const wchar_t* mWindowClassName;
93 
94  // *** static members start here ***
95 
96  public:
98  static Win32Window* getWindow(HWND hWnd);
99  static const std::map< HWND, Win32Window* >& winMap() { return mWinMap; }
100 
101  protected:
102  static std::map< HWND, Win32Window* > mWinMap;
103  };
104 //-----------------------------------------------------------------------------
105  VLWIN32_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short& unicode_out, vl::EKey& key_out);
106 //-----------------------------------------------------------------------------
107 }
108 
109 #endif
VLWIN32_EXPORT void peekMessage(MSG &msg)
The Win32Window class is a Win32Context that can be used as a top or child window.
Definition: Win32Window.hpp:51
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
const wchar_t * windowClassName() const
Specifies the value given to the lpClassName parameter passed to CreateWindowEx.
Definition: Win32Window.hpp:82
void setExStyle(DWORD ex_style)
The dwStyle parameter passed to the Win32 function CreateWindowEx.
Definition: Win32Window.hpp:79
The OpenGLContextFormat class encapsulates the settings of an OpenGL rendering context.
VLWIN32_EXPORT int messageLoop()
DWORD exStyle() const
The dwStyle parameter passed to the Win32 function CreateWindowEx.
Definition: Win32Window.hpp:76
VLWIN32_EXPORT void dispatchUpdate()
void setStyle(DWORD style)
The dwExStyle parameter passed to the Win32 function CreateWindowEx.
Definition: Win32Window.hpp:73
const wchar_t * mWindowClassName
Definition: Win32Window.hpp:92
void setWindowClassName(const wchar_t *name)
Specifies the value given to the lpClassName parameter passed to CreateWindowEx.
Definition: Win32Window.hpp:85
DWORD style() const
The dwExStyle parameter passed to the Win32 function CreateWindowEx.
Definition: Win32Window.hpp:70
The Win32Context class implements an OpenGLContext using the Win32 API.
static std::map< HWND, Win32Window *> mWinMap
VLWIN32_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short &unicode_out, vl::EKey &key_out)
static const std::map< HWND, Win32Window *> & winMap()
Definition: Win32Window.hpp:99
The Win32 bindings namespace.