EHS/include/ehs/io/Window_W32.h

126 lines
3.4 KiB
C
Raw Permalink Normal View History

2024-02-05 22:25:30 -08:00
#pragma once
#include "ehs/EHS.h"
#include "ehs/Array.h"
#include "ehs/Str.h"
#include "ehs/Vec4.h"
#include "BaseWindow.h"
#include "HID/InputHandler.h"
#define WM_HIDE (WM_APP + 1)
#define WM_SHOW (WM_APP + 2)
#define WM_HIDE_CURSOR (WM_APP + 3)
#define WM_SHOW_CURSOR (WM_APP + 4)
namespace ehs
{
2024-07-24 01:36:20 -07:00
class EHS_LIB_IO Window : public BaseWindow
2024-02-05 22:25:30 -08:00
{
private:
UInt_32 owner;
HINSTANCE instance;
HWND hdl;
static Array<Window*> windows;
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
public:
2024-02-05 23:55:53 -08:00
~Window() override;
2024-02-05 22:25:30 -08:00
Window();
Window(const Window &win);
Window& operator=(const Window &win);
2024-02-05 23:55:53 -08:00
bool Poll() override;
2024-02-05 22:25:30 -08:00
///Creates the native window.
2024-02-05 23:55:53 -08:00
void Create_32(const Str_32& title, const Vec2_s32& pos, Vec2_u32 scale) override;
2024-02-05 22:25:30 -08:00
///Creates the native window.
2024-02-05 23:55:53 -08:00
void Create_16(const Str_16& title, const Vec2_s32& pos, Vec2_u32 scale) override;
2024-02-05 22:25:30 -08:00
///Creates the native window.
2024-02-05 23:55:53 -08:00
void Create_8(const Str_8& title, const Vec2_s32& pos, Vec2_u32 scale) override;
2024-02-05 22:25:30 -08:00
///Uses an already existing window to render an overlay.
void Use(HWND windowHdl);
///Closes the window.
2024-02-05 23:55:53 -08:00
void Close() override;
2024-02-05 22:25:30 -08:00
///Shows the window.
void Show() override;
///Hides the window.
void Hide() override;
void SetTitle_32(const Str_32& title) override;
2024-02-05 23:55:53 -08:00
Str_32 GetTitle_32() const override;
2024-02-05 22:25:30 -08:00
void SetTitle_16(const Str_16& title) override;
2024-02-05 23:55:53 -08:00
Str_16 GetTitle_16() const override;
2024-02-05 22:25:30 -08:00
void SetTitle_8(const Str_8& title) override;
2024-02-05 23:55:53 -08:00
Str_8 GetTitle_8() const override;
2024-02-05 22:25:30 -08:00
void SetIcon(const Str_8& filePath);
/// Gets the windows native handle for the operating system or other native tasks.
/// @returns The window's native handle.
HWND GetHdl() const;
/// Retrieves the first window handle that has been created using this library.
/// @returns The window's native handle.
static HWND GetAvailableHdl();
HINSTANCE GetInst() const;
/// Toggles whether the window updates and renders.
/// @param [in] toggle The new status.
void ToggleEnabled(bool toggle);
/// Checks whether the window updates and renders.
/// @returns The current status.
bool IsEnabled();
/// Sets the windows position on the desktop.
/// @param [in] x The x axis in pixels.
/// @param [in] y The y axis in pixels.
2024-02-05 23:55:53 -08:00
void SetPos(const Vec2_s32& newPos) override;
2024-02-05 22:25:30 -08:00
/// Gets the windows current position on the desktop.
/// @returns The current value.
2024-02-05 23:55:53 -08:00
Vec2_s32 GetPos() const override;
2024-02-05 22:25:30 -08:00
virtual void OnResized(const Vec2<UInt_32>& newSize);
/// Sets the windows scale which includes the border.
/// @param [in] w The width in pixels.
/// @param [in] h The height in pixels.
2024-02-05 23:55:53 -08:00
void SetScale(const Vec2_u32& newScale) override;
2024-02-05 22:25:30 -08:00
/// Gets the windows current scale.
/// @returns The current value.
2024-02-05 23:55:53 -08:00
Vec2_u32 GetScale() const override;
2024-02-05 22:25:30 -08:00
void ShowCursor(bool toggle) override;
2024-02-05 23:55:53 -08:00
void ConstrainCursor(bool toggle) override;
Serializer<UInt_64> GetClipboard() override;
void SetClipboard(Serializer<UInt_64> data) override;
void SetCursorImg(CursorImg img) override;
2024-02-05 22:25:30 -08:00
protected:
2024-02-05 23:55:53 -08:00
void SendMsg(UINT msg, WPARAM wParam, LPARAM lParam);
2024-02-05 22:25:30 -08:00
};
}