Ocean
|
This class is the base class for all windows. More...
Public Types | |
enum | MouseButton { BUTTON_NONE = 0 , BUTTON_LEFT = 1 , BUTTON_MIDDLE = 2 , BUTTON_RIGHT = 4 } |
Definition of several mouse buttons. More... | |
typedef std::vector< std::wstring > | Files |
Definition of a vector holding files. More... | |
Public Member Functions | |
virtual bool | initialize (const HICON icon=nullptr, const std::string &windowClass="window") |
Initializes the window. More... | |
bool | initialize (const HINSTANCE applicationInstance, const int iconId, const std::string &windowClass="window") |
Initializes the window. More... | |
virtual void | show () |
Shows the window. More... | |
virtual void | hide () |
Hides the window. More... | |
virtual void | update () |
Updates the window. More... | |
virtual void | repaint (const bool eraseBackground=false) |
Repaints the window. More... | |
bool | move (const int x, const int y) |
Moves the window. More... | |
bool | resize (const unsigned int width, const unsigned int height) |
Resizes the window. More... | |
HINSTANCE | applicationInstance () const |
Returns the application instance the window belongs to. More... | |
const std::wstring & | name () const |
Returns the name of this window. More... | |
HWND | handle () const |
Returns the handle of this window. More... | |
HWND | parentHandle () const |
Returns the handle of a possible parent window. More... | |
HDC | dc () const |
Returns the device context of this window. More... | |
unsigned int | width () const |
Returns the width of the entire window. More... | |
unsigned int | height () const |
Returns the height of the window. More... | |
unsigned int | clientWidth () const |
Returns the width of the client window. More... | |
unsigned int | clientHeight () const |
Returns the height of the client window. More... | |
bool | setParent (const HWND parent) |
Sets the parent window handle. More... | |
void | setText (const std::wstring &text) |
Sets or changes the text of this windows. More... | |
void | setEnableDropAndDrop (const bool state=true) |
Enables or disables drag&drop support for files. More... | |
Protected Types | |
typedef std::unordered_map< std::wstring, unsigned int > | ClassMap |
Map mapping class names to an reference counter. More... | |
Protected Member Functions | |
Window (HINSTANCE applicationInstance, const std::wstring &name, const HWND parent=nullptr, const bool isChild=false) | |
Creates a new window. More... | |
virtual | ~Window () |
Destructs a window. More... | |
virtual bool | registerWindowClass (const HICON icon=nullptr) |
Registers a new windows class for the application window. More... | |
virtual bool | createWindow () |
Creates the window itself using the registered window class. More... | |
virtual void | modifyWindowClass (WNDCLASSW &windowClass) |
Allows the modification of the window class before registration. More... | |
virtual void | modifyWindowStyle (DWORD &windowStyle, int &windowLeft, int &windowTop, int &windowWidth, int &windowHeight) |
Allows the modification of the window style before creation. More... | |
virtual void | onInitialized () |
Event function if the windows has been initialized successfully. More... | |
virtual void | onActivate (const bool active) |
Event function for an activate event. More... | |
virtual void | onPaint () |
Event function to repaint the window. More... | |
virtual void | onIdle () |
Function called by the windows message loop if the process is idling. More... | |
virtual void | onShow (const bool visible) |
Function for a show event. More... | |
virtual void | onDestroy () |
Function for a destroy event. More... | |
virtual void | onResize (const unsigned int clientWidth, const unsigned int clientHeight) |
Function for window resize event. More... | |
virtual void | onKeyDown (const int key) |
Function for keyboard button down events. More... | |
virtual void | onMouseDoubleClick (const MouseButton button, const int x, const int y) |
Function for mouse double click events. More... | |
virtual void | onMouseDown (const MouseButton button, const int x, const int y) |
Function for mouse button down events. More... | |
virtual void | onMouseMove (const MouseButton buttons, const int x, const int y) |
Function for mouse move event. More... | |
virtual void | onKeyUp (const int key) |
Function for keyboard button up events. More... | |
virtual void | onMouseUp (const MouseButton button, const int x, const int y) |
Function for mouse button up events. More... | |
virtual void | onMouseWheel (const MouseButton buttons, const int wheel, const int x, const int y) |
Functions for mouse wheel events. More... | |
virtual void | onMinimize () |
Functions for window minimize event. More... | |
virtual void | onDragAndDrop (const Files &files) |
Event functions for drag&drop events for files. More... | |
Static Protected Member Functions | |
static LRESULT CALLBACK | windowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Window message / event procedure. More... | |
static ClassMap & | classMap () |
Returns the class map for all windows. More... | |
static Lock & | classMapLock () |
Returns the lock of the window class map. More... | |
Protected Attributes | |
HWND | parentHandle_ = nullptr |
Window handle of a possible parent window, making this window to a child window. More... | |
std::wstring | className_ |
Window class name. More... | |
HINSTANCE | applicationInstance_ = nullptr |
Application instance. More... | |
std::wstring | name_ |
Name of the window. More... | |
HWND | handle_ = nullptr |
Window handle. More... | |
HDC | dc_ = nullptr |
Window device context. More... | |
bool | isChild_ = false |
True, if the window is a child window. More... | |
This class is the base class for all windows.
|
protected |
Map mapping class names to an reference counter.
typedef std::vector<std::wstring> Ocean::Platform::Win::Window::Files |
Definition of a vector holding files.
|
protected |
Creates a new window.
Beware: If a derived window class will use a different window class as the default one you have to change the window class name in the constructor.
applicationInstance | The instance of the application, must be valid |
name | The name of the application window |
parent | Possible parent window making this window to a child window |
isChild | True, if the window is intended to be a child window |
|
protectedvirtual |
Destructs a window.
|
inline |
Returns the application instance the window belongs to.
|
staticprotected |
Returns the class map for all windows.
|
staticprotected |
Returns the lock of the window class map.
unsigned int Ocean::Platform::Win::Window::clientHeight | ( | ) | const |
Returns the height of the client window.
unsigned int Ocean::Platform::Win::Window::clientWidth | ( | ) | const |
Returns the width of the client window.
|
protectedvirtual |
Creates the window itself using the registered window class.
Reimplemented in Ocean::Platform::Win::TextWindow.
|
inline |
Returns the device context of this window.
|
inline |
Returns the handle of this window.
unsigned int Ocean::Platform::Win::Window::height | ( | ) | const |
Returns the height of the window.
|
virtual |
Hides the window.
|
virtual |
Initializes the window.
icon | The optional handle of the icon to be used, nullptr to use default icon |
windowClass | The name of the window class |
|
inline |
Initializes the window.
applicationInstance | The instance of the application, must be valid |
iconId | The id of the icon as specified in the resources, with range [0, infinity) |
windowClass | The name of the window class |
|
protectedvirtual |
Allows the modification of the window class before registration.
Overload this function to change the window type.
However do not change the class name.
windowClass | Window class to modify |
Reimplemented in Ocean::Platform::Win::BitmapWindow.
|
protectedvirtual |
Allows the modification of the window style before creation.
Overload this function to change the window style.
windowStyle | Window style to modify |
windowLeft | Left position of the window |
windowTop | Top position of the window |
windowWidth | Width of the window |
windowHeight | Height of the window |
bool Ocean::Platform::Win::Window::move | ( | const int | x, |
const int | y | ||
) |
Moves the window.
x | The new horizontal position |
y | The new vertical position |
|
inline |
Returns the name of this window.
|
protectedvirtual |
Event function for an activate event.
active | True, if the window is activated, false if the window is inactivated |
|
protectedvirtual |
Function for a destroy event.
Reimplemented in Ocean::Platform::Win::ApplicationWindow.
|
protectedvirtual |
Event functions for drag&drop events for files.
files | The files which have been dropped |
|
protectedvirtual |
Function called by the windows message loop if the process is idling.
|
protectedvirtual |
Event function if the windows has been initialized successfully.
Reimplemented in Ocean::Platform::GL::Win::WindowContext.
|
protectedvirtual |
Function for keyboard button down events.
key | Specifies the key button |
|
protectedvirtual |
Function for keyboard button up events.
key | Specifies the key button |
|
protectedvirtual |
Functions for window minimize event.
|
protectedvirtual |
Function for mouse double click events.
button | Specifies the mouse button |
x | Specifies the x position of the cursor |
y | Specifies the y position of the cursor |
Reimplemented in Ocean::Platform::Win::BitmapWindow.
|
protectedvirtual |
Function for mouse button down events.
button | Specifies the mouse button |
x | Specifies the x position of the cursor |
y | Specifies the y position of the cursor |
|
protectedvirtual |
Function for mouse move event.
buttons | Holds all pushed mouse buttons |
x | Specifies the x position of the cursor |
y | Specifies the y position of the cursor |
|
protectedvirtual |
Function for mouse button up events.
button | Specifies the mouse button |
x | Specifies the x position of the cursor |
y | Specifies the y position of the cursor |
|
protectedvirtual |
Functions for mouse wheel events.
buttons | Holds all pushed mouse buttons |
wheel | Specifies the wheel delta value |
x | Specifies the x position of the cursor |
y | Specifies the y position of the cursor |
|
protectedvirtual |
Event function to repaint the window.
Reimplemented in Ocean::Platform::Win::BitmapWindow.
|
protectedvirtual |
Function for window resize event.
clientWidth | New client width |
clientHeight | New client height |
Reimplemented in Ocean::Platform::Win::BitmapWindow.
|
protectedvirtual |
Function for a show event.
visible | True, if the window is being shown, false if the window is being hidden |
|
inline |
Returns the handle of a possible parent window.
|
protectedvirtual |
Registers a new windows class for the application window.
icon | The optional handle of the icon to be used, nullptr to use default icon |
|
virtual |
Repaints the window.
eraseBackground | True, to erase the background |
bool Ocean::Platform::Win::Window::resize | ( | const unsigned int | width, |
const unsigned int | height | ||
) |
Resizes the window.
width | New window width |
height | New window height |
void Ocean::Platform::Win::Window::setEnableDropAndDrop | ( | const bool | state = true | ) |
Enables or disables drag&drop support for files.
state | True, to enable support for drag&drop of file for this window; False, to disable drag&drop. |
bool Ocean::Platform::Win::Window::setParent | ( | const HWND | parent | ) |
Sets the parent window handle.
void Ocean::Platform::Win::Window::setText | ( | const std::wstring & | text | ) |
Sets or changes the text of this windows.
text | The text to be set |
|
virtual |
Shows the window.
|
virtual |
Updates the window.
unsigned int Ocean::Platform::Win::Window::width | ( | ) | const |
Returns the width of the entire window.
|
staticprotected |
|
protected |
Application instance.
|
protected |
Window class name.
|
protected |
Window device context.
|
protected |
Window handle.
|
protected |
True, if the window is a child window.
|
protected |
Name of the window.
|
protected |
Window handle of a possible parent window, making this window to a child window.