|
Ocean
|
This class is the base class for all windows. More...
#include <Window.h>
Public Types | |
| enum | MouseButton { BUTTON_NONE = 0 , BUTTON_LEFT = 1 , BUTTON_MIDDLE = 2 , BUTTON_RIGHT = 4 } |
| Definition of several mouse buttons. More... | |
| using | Files = std::vector< std::wstring > |
| Definition of a vector holding files. | |
Public Member Functions | |
| virtual bool | initialize (const HICON icon=nullptr, const std::string &windowClass="window") |
| Initializes the window. | |
| bool | initialize (const HINSTANCE applicationInstance, const int iconId, const std::string &windowClass="window") |
| Initializes the window. | |
| virtual void | show () |
| Shows the window. | |
| virtual void | hide () |
| Hides the window. | |
| virtual void | update () |
| Updates the window. | |
| virtual void | repaint (const bool eraseBackground=false) |
| Repaints the window. | |
| bool | move (const int x, const int y) |
| Moves the window. | |
| bool | resize (const unsigned int width, const unsigned int height) |
| Resizes the window. | |
| HINSTANCE | applicationInstance () const |
| Returns the application instance the window belongs to. | |
| const std::wstring & | name () const |
| Returns the name of this window. | |
| HWND | handle () const |
| Returns the handle of this window. | |
| HWND | parentHandle () const |
| Returns the handle of a possible parent window. | |
| HDC | dc () const |
| Returns the device context of this window. | |
| unsigned int | width () const |
| Returns the width of the entire window. | |
| unsigned int | height () const |
| Returns the height of the window. | |
| unsigned int | clientWidth () const |
| Returns the width of the client window. | |
| unsigned int | clientHeight () const |
| Returns the height of the client window. | |
| bool | setParent (const HWND parent) |
| Sets the parent window handle. | |
| void | setText (const std::wstring &text) |
| Sets or changes the text of this windows. | |
| void | setEnableDropAndDrop (const bool state=true) |
| Enables or disables drag&drop support for files. | |
Protected Types | |
| using | ClassMap = std::unordered_map< std::wstring, unsigned int > |
| Map mapping class names to an reference counter. | |
Protected Member Functions | |
| Window (HINSTANCE applicationInstance, const std::wstring &name, const HWND parent=nullptr, const bool isChild=false) | |
| Creates a new window. | |
| virtual | ~Window () |
| Destructs a window. | |
| virtual bool | registerWindowClass (const HICON icon=nullptr) |
| Registers a new windows class for the application window. | |
| virtual bool | createWindow () |
| Creates the window itself using the registered window class. | |
| virtual void | modifyWindowClass (WNDCLASSW &windowClass) |
| Allows the modification of the window class before registration. | |
| virtual void | modifyWindowStyle (DWORD &windowStyle, int &windowLeft, int &windowTop, int &windowWidth, int &windowHeight) |
| Allows the modification of the window style before creation. | |
| virtual void | onInitialized () |
| Event function if the windows has been initialized successfully. | |
| virtual void | onActivate (const bool active) |
| Event function for an activate event. | |
| virtual void | onPaint () |
| Event function to repaint the window. | |
| virtual void | onIdle () |
| Function called by the windows message loop if the process is idling. | |
| virtual void | onShow (const bool visible) |
| Function for a show event. | |
| virtual void | onDestroy () |
| Function for a destroy event. | |
| virtual void | onResize (const unsigned int clientWidth, const unsigned int clientHeight) |
| Function for window resize event. | |
| virtual void | onKeyDown (const int key) |
| Function for keyboard button down events. | |
| virtual void | onMouseDoubleClick (const MouseButton button, const int x, const int y) |
| Function for mouse double click events. | |
| virtual void | onMouseDown (const MouseButton button, const int x, const int y) |
| Function for mouse button down events. | |
| virtual void | onMouseMove (const MouseButton buttons, const int x, const int y) |
| Function for mouse move event. | |
| virtual void | onKeyUp (const int key) |
| Function for keyboard button up events. | |
| virtual void | onMouseUp (const MouseButton button, const int x, const int y) |
| Function for mouse button up events. | |
| virtual void | onMouseWheel (const MouseButton buttons, const int wheel, const int x, const int y) |
| Functions for mouse wheel events. | |
| virtual void | onMinimize () |
| Functions for window minimize event. | |
| virtual void | onDragAndDrop (const Files &files) |
| Event functions for drag&drop events for files. | |
Static Protected Member Functions | |
| static LRESULT CALLBACK | windowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| Window message / event procedure. | |
| static ClassMap & | classMap () |
| Returns the class map for all windows. | |
| static Lock & | classMapLock () |
| Returns the lock of the window class map. | |
Protected Attributes | |
| HWND | parentHandle_ = nullptr |
| Window handle of a possible parent window, making this window to a child window. | |
| std::wstring | className_ |
| Window class name. | |
| HINSTANCE | applicationInstance_ = nullptr |
| Application instance. | |
| std::wstring | name_ |
| Name of the window. | |
| HWND | handle_ = nullptr |
| Window handle. | |
| HDC | dc_ = nullptr |
| Window device context. | |
| bool | isChild_ = false |
| True, if the window is a child window. | |
This class is the base class for all windows.
|
protected |
Map mapping class names to an reference counter.
| using Ocean::Platform::Win::Window::Files = std::vector<std::wstring> |
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.