-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.cpp
More file actions
45 lines (40 loc) · 1.54 KB
/
context.cpp
File metadata and controls
45 lines (40 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <desktop.hpp>
namespace webframe::desktop
{
context::context(webframe::desktop_config *config, webframe::router *router) : _webview_handler(wxSharedPtr<wxWebViewHandler>(new webframe::desktop::webview_handler(router)))
{
auto const &[default_width, default_height] = config->get_default_window_size();
_default_width = default_width;
_default_height = default_height;
}
webframe::window *context::create_window(webframe::window *parent, int width, int height)
{
// TODO: do something with window ID to avoid the reinterpret_cast
webframe::desktop::window *parent_window = reinterpret_cast<webframe::desktop::window *>(parent);
wxFrame *frame = new wxFrame(
parent_window ? parent_window->get_frame() : nullptr,
wxID_ANY,
"WebFrame",
wxDefaultPosition,
wxSize(width > 0 ? width : _default_width, height > 0 ? height : _default_height));
return new webframe::desktop::window(frame, _webview_handler);
}
webframe::window *context::find_window(const std::string &id)
{
webframe::window *result(nullptr);
auto it = _windows.find(id);
if (it != _windows.end())
{
result = it->second.get();
}
return result;
}
void context::destroy_window(webframe::window *handle)
{
_windows.erase(handle->get_id());
}
std::string context::get_exe_path() const
{
return wxStandardPaths::Get().GetExecutablePath().ToStdString();
}
}