Nebula
Loading...
Searching...
No Matches
Win32::Win32DisplayDevice Class Reference

#include <win32displaydevice.h>

Detailed Description

Win32 implementation of DisplayDevice class.

Manages the application window.

(C) 2006 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file

Inherits Base::DisplayDeviceBase.

Public Member Functions

 Win32DisplayDevice ()
 constructor
 
virtual ~Win32DisplayDevice ()
 destructor
 
virtual bool Open ()
 open the display
 
virtual void Close ()
 close the display
 
virtual void Reopen ()
 reopens the display
 
virtual void ProcessWindowMessages ()
 process window system messages, call this method once per frame
 
virtual void PostEvent (const Win32::Win32Event &winEvent)
 posts an event sent from an external source (useful for embedded windows)
 
HWND GetHwnd () const
 get the application window HWND
 
- Public Member Functions inherited from Base::DisplayDeviceBase
 DisplayDeviceBase ()
 constructor
 
virtual ~DisplayDeviceBase ()
 destructor
 
bool Open ()
 open the display
 
void Close ()
 close the display
 
bool IsOpen () const
 return true if display is currently open
 
void ProcessWindowMessages ()
 process window system messages, call this method once per frame
 
void Reopen ()
 reopens the display device which enables switching from display modes
 
void SetVerticalSyncEnabled (bool b)
 set if vertical sync should be used
 
const bool IsVerticalSyncEnabled () const
 get if vertical sync is enabled
 
bool AdapterExists (CoreGraphics::Adapter::Code adapter)
 return true if adapter exists
 
Util::Array< CoreGraphics::DisplayModeGetAvailableDisplayModes (CoreGraphics::Adapter::Code adapter, CoreGraphics::PixelFormat::Code pixelFormat)
 get available display modes on given adapter
 
bool SupportsDisplayMode (CoreGraphics::Adapter::Code adapter, const CoreGraphics::DisplayMode &requestedMode)
 return true if a given display mode is supported
 
CoreGraphics::DisplayMode GetCurrentAdapterDisplayMode (CoreGraphics::Adapter::Code adapter)
 get current adapter display mode (i.e. the desktop display mode)
 
CoreGraphics::AdapterInfo GetAdapterInfo (CoreGraphics::Adapter::Code adapter)
 get general info about display adapter
 
void SetAdapter (CoreGraphics::Adapter::Code a)
 set display adapter (make sure adapter exists!)
 
CoreGraphics::Adapter::Code GetAdapter () const
 get display adapter
 
const bool IsFullscreen () const
 get if a window is running in full screen
 
void AttachEventHandler (const Ptr< CoreGraphics::DisplayEventHandler > &h)
 attach a display event handler
 
void RemoveEventHandler (const Ptr< CoreGraphics::DisplayEventHandler > &h)
 remove a display event handler
 
CoreGraphics::WindowId SetupWindow (const Util::String &title, const Util::String &icon, const CoreGraphics::DisplayMode &displayMode, const CoreGraphics::AntiAliasQuality::Code aa=CoreGraphics::AntiAliasQuality::None)
 create a new window
 
CoreGraphics::WindowId EmbedWindow (const Util::Blob &windowData)
 create a window from one created by another window system
 
CoreGraphics::WindowId GetMainWindow () const
 get the 'main' window, if none exists, returns NULL
 
const CoreGraphics::WindowId GetCurrentWindow () const
 get the current window
 
const CoreGraphics::WindowId GetWindow (IndexT index) const
 get window using index, where 0 is the default window
 
const Util::Array< CoreGraphics::WindowId > & GetWindows () const
 get all windows as an array
 
void MakeWindowCurrent (const CoreGraphics::WindowId id)
 make ID the current one
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Protected Types

enum  { AccelToggleFullscreen = 1001 }
 

Protected Member Functions

virtual bool WindowOpen ()
 open the application window
 
virtual void CloseWindow ()
 close the application window
 
virtual bool EmbedWindow ()
 opens the window embedded
 
virtual void OnMinimized ()
 called on WM_SIZE when window is minimized
 
virtual void OnRestored ()
 called on WM_SIZE when window is restored
 
virtual bool OnSetCursor ()
 called on WM_SETCURSOR
 
virtual void OnPaint ()
 called on WM_PAINT
 
virtual void OnSetFocus ()
 called on WM_SETFOCUS
 
virtual void OnKillFocus ()
 called on WM_KILLFOCUS
 
virtual void OnCloseRequested ()
 called on WM_CLOSE to request if window should be closed
 
virtual void OnToggleFullscreenWindowed ()
 called when Alt-Enter is pressed
 
virtual void OnResize (WORD width, WORD height)
 called when WM_SIZE gets propagated
 
virtual void OnKeyDown (LPARAM lParam, WPARAM wParam)
 called on WM_KEYDOWN
 
virtual void OnKeyUp (LPARAM lParam, WPARAM wParam)
 called on WM_KEYUP
 
virtual void OnChar (WPARAM wParam)
 called on WM_CHAR
 
virtual void OnMouseButton (UINT uMsg, LPARAM lParam)
 called on mouse button event
 
virtual void OnMouseMove (LPARAM lParam)
 called on WM_MOUSEMOVE
 
virtual void OnMouseWheel (WPARAM wParam)
 called on WM_MOUSEWHEEL
 
Input::Key::Code TranslateKeyCode (LPARAM lParam, WPARAM wParam) const
 translate a Windows virtual key code into a Nebula key code
 
virtual CoreGraphics::DisplayMode ComputeAdjustedWindowRect ()
 adjust window size taking client area into account
 
Math::float2 ComputeAbsMousePos (LPARAM lParam) const
 compute absolute mouse position from lParam
 
Math::float2 ComputeNormMousePos (const Math::float2 &absMousePos) const
 compute normalized mouse position from absolute mouse pos
 
- Protected Member Functions inherited from Base::DisplayDeviceBase
bool NotifyEventHandlers (const CoreGraphics::DisplayEvent &e)
 notify event handlers about an event
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Static Protected Member Functions

static LRESULT CALLBACK WinProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 the WinProc
 

Protected Attributes

HINSTANCE hInst
 
HWND hWnd
 
HWND parentHwnd
 
HACCEL hAccel
 
DWORD windowedStyle
 
DWORD fullscreenStyle
 
DWORD childWindowStyle
 
- Protected Attributes inherited from Base::DisplayDeviceBase
CoreGraphics::Adapter::Code adapter
 
bool verticalSync
 
bool isOpen
 
bool isFullscreen
 
Util::Array< Ptr< CoreGraphics::DisplayEventHandler > > eventHandlers
 
CoreGraphics::WindowId currentWindow
 
Util::Array< CoreGraphics::WindowIdwindows
 

Private Member Functions

 __DeclareClass (Win32DisplayDevice)
 
 __DeclareSingleton (Win32DisplayDevice)
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
AccelToggleFullscreen 

Constructor & Destructor Documentation

◆ Win32DisplayDevice()

Win32::Win32DisplayDevice::Win32DisplayDevice ( )

constructor

◆ ~Win32DisplayDevice()

Win32::Win32DisplayDevice::~Win32DisplayDevice ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Win32::Win32DisplayDevice::__DeclareClass ( Win32DisplayDevice )
private

◆ __DeclareSingleton()

Win32::Win32DisplayDevice::__DeclareSingleton ( Win32DisplayDevice )
private

◆ Close()

void Win32::Win32DisplayDevice::Close ( )
virtual

close the display

◆ CloseWindow()

void Win32::Win32DisplayDevice::CloseWindow ( )
protectedvirtual

close the application window

Close the application window.

◆ ComputeAbsMousePos()

float2 Win32::Win32DisplayDevice::ComputeAbsMousePos ( LPARAM lParam) const
protected

compute absolute mouse position from lParam

◆ ComputeAdjustedWindowRect()

DisplayMode Win32::Win32DisplayDevice::ComputeAdjustedWindowRect ( )
protectedvirtual

adjust window size taking client area into account

This will return an adjusted window size which takes the client area of the window into account.

This is only relevant for windowed mode.

◆ ComputeNormMousePos()

float2 Win32::Win32DisplayDevice::ComputeNormMousePos ( const Math::float2 & absMousePos) const
protected

compute normalized mouse position from absolute mouse pos

◆ EmbedWindow()

bool Win32::Win32DisplayDevice::EmbedWindow ( )
protectedvirtual

opens the window embedded

◆ GetHwnd()

HWND Win32::Win32DisplayDevice::GetHwnd ( ) const
inline

get the application window HWND

◆ OnChar()

void Win32::Win32DisplayDevice::OnChar ( WPARAM wParam)
protectedvirtual

called on WM_CHAR

◆ OnCloseRequested()

void Win32::Win32DisplayDevice::OnCloseRequested ( )
protectedvirtual

called on WM_CLOSE to request if window should be closed

◆ OnKeyDown()

void Win32::Win32DisplayDevice::OnKeyDown ( LPARAM lParam,
WPARAM wParam )
protectedvirtual

called on WM_KEYDOWN

◆ OnKeyUp()

void Win32::Win32DisplayDevice::OnKeyUp ( LPARAM lParam,
WPARAM wParam )
protectedvirtual

called on WM_KEYUP

◆ OnKillFocus()

void Win32::Win32DisplayDevice::OnKillFocus ( )
protectedvirtual

called on WM_KILLFOCUS

◆ OnMinimized()

void Win32::Win32DisplayDevice::OnMinimized ( )
protectedvirtual

called on WM_SIZE when window is minimized

◆ OnMouseButton()

void Win32::Win32DisplayDevice::OnMouseButton ( UINT uMsg,
LPARAM lParam )
protectedvirtual

called on mouse button event

◆ OnMouseMove()

void Win32::Win32DisplayDevice::OnMouseMove ( LPARAM lParam)
protectedvirtual

called on WM_MOUSEMOVE

◆ OnMouseWheel()

void Win32::Win32DisplayDevice::OnMouseWheel ( WPARAM wParam)
protectedvirtual

called on WM_MOUSEWHEEL

◆ OnPaint()

void Win32::Win32DisplayDevice::OnPaint ( )
protectedvirtual

called on WM_PAINT

◆ OnResize()

void Win32::Win32DisplayDevice::OnResize ( WORD width,
WORD height )
protectedvirtual

called when WM_SIZE gets propagated

◆ OnRestored()

void Win32::Win32DisplayDevice::OnRestored ( )
protectedvirtual

called on WM_SIZE when window is restored

◆ OnSetCursor()

bool Win32::Win32DisplayDevice::OnSetCursor ( )
protectedvirtual

called on WM_SETCURSOR

◆ OnSetFocus()

void Win32::Win32DisplayDevice::OnSetFocus ( )
protectedvirtual

called on WM_SETFOCUS

◆ OnToggleFullscreenWindowed()

void Win32::Win32DisplayDevice::OnToggleFullscreenWindowed ( )
protectedvirtual

called when Alt-Enter is pressed

◆ Open()

bool Win32::Win32DisplayDevice::Open ( )
virtual

open the display

◆ PostEvent()

void Win32::Win32DisplayDevice::PostEvent ( const Win32::Win32Event & winEvent)
virtual

posts an event sent from an external source (useful for embedded windows)

◆ ProcessWindowMessages()

void Win32::Win32DisplayDevice::ProcessWindowMessages ( )
virtual

process window system messages, call this method once per frame

Polls for and processes window messages.

Call this message once per frame in your render loop. If the user clicks the window close button, or hits Alt-F4, a CloseRequested input event will be sent.

◆ Reopen()

void Win32::Win32DisplayDevice::Reopen ( )
virtual

reopens the display

◆ TranslateKeyCode()

Input::Key::Code Win32::Win32DisplayDevice::TranslateKeyCode ( LPARAM lParam,
WPARAM wParam ) const
protected

translate a Windows virtual key code into a Nebula key code

Helper method which translates a Win32 virtual key code into a Nebula key code.

◆ WindowOpen()

virtual bool Win32::Win32DisplayDevice::WindowOpen ( )
protectedvirtual

open the application window

◆ WinProc()

LRESULT CALLBACK Win32::Win32DisplayDevice::WinProc ( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
staticprotected

the WinProc

The Nebula WinProc.

Member Data Documentation

◆ childWindowStyle

DWORD Win32::Win32DisplayDevice::childWindowStyle
protected

◆ fullscreenStyle

DWORD Win32::Win32DisplayDevice::fullscreenStyle
protected

◆ hAccel

HACCEL Win32::Win32DisplayDevice::hAccel
protected

◆ hInst

HINSTANCE Win32::Win32DisplayDevice::hInst
protected

◆ hWnd

HWND Win32::Win32DisplayDevice::hWnd
protected

◆ parentHwnd

HWND Win32::Win32DisplayDevice::parentHwnd
protected

◆ windowedStyle

DWORD Win32::Win32DisplayDevice::windowedStyle
protected

The documentation for this class was generated from the following files: