Skip to content

Commit

Permalink
Support wide window titles
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Aug 4, 2024
1 parent 9270120 commit 84c3a7e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/html_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ namespace momo
{
}

html_ui::html_ui(const std::wstring& title, const size_t width, const size_t height)
: window_(std::make_unique<html_window>(title, static_cast<int>(width), static_cast<int>(height)))
{
}

html_ui::~html_ui() = default;
html_ui::html_ui(html_ui&&) noexcept = default;
html_ui& html_ui::operator=(html_ui&&) noexcept = default;
Expand Down
10 changes: 10 additions & 0 deletions src/html_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ namespace momo
{
}

html_window::html_window(const std::wstring& title, const int width, const int height, const long flags)
: window_(title, width, height,
[this](window*, const UINT message, const WPARAM w_param,
const LPARAM l_param) -> std::optional<LRESULT>
{
return this->processor(message, w_param, l_param);
}, flags)
{
}

window& html_window::get_window()
{
return this->window_;
Expand Down
3 changes: 3 additions & 0 deletions src/html_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace momo
html_window(const std::string& title, int width, int height,
long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX)));

html_window(const std::wstring& title, int width, int height,
long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX)));

~html_window() = default;

window& get_window();
Expand Down
10 changes: 9 additions & 1 deletion src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ namespace momo
}

window::window(const std::string& title, const int width, const int height,
std::function<std::optional<LRESULT>(window*, UINT, WPARAM, LPARAM)> callback,
const long flags)
: window(convert_utf8_to_wide(title), width, height,std::move(callback), flags)
{

}

window::window(const std::wstring& title, const int width, const int height,
std::function<std::optional<LRESULT>(window*, UINT, WPARAM, LPARAM)> callback,
const long flags)
: callback_(std::move(callback))
Expand All @@ -65,7 +73,7 @@ namespace momo

++window_count;

this->handle_ = CreateWindowExW(NULL, this->wc_.lpszClassName, convert_utf8_to_wide(title).data(), flags, x, y,
this->handle_ = CreateWindowExW(NULL, this->wc_.lpszClassName, title.data(), flags, x, y,
width, height, nullptr, nullptr, this->wc_.hInstance, this);

constexpr BOOL value = TRUE;
Expand Down
4 changes: 4 additions & 0 deletions src/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ namespace momo
std::function<std::optional<LRESULT>(window*, UINT, WPARAM, LPARAM)> callback,
long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX)));

window(const std::wstring& title, int width, int height,
std::function<std::optional<LRESULT>(window*, UINT, WPARAM, LPARAM)> callback,
long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX)));

virtual ~window();

void close();
Expand Down

0 comments on commit 84c3a7e

Please sign in to comment.