Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class example_application : public webframe::application
router->set_default(&_archive_handler);
router->add_route("/greetingIPC", &_greeting_ipc_handler);
}

void launch_desktop(webframe::desktop_context *context)
{
webframe::window *win = context->create_window(nullptr, 800, 600);
win->set_title("WebFrame Example");
win->load_path("index.html");
}
private:
archive_handler _archive_handler;
greeting_ipc_handler _greeting_ipc_handler;
Expand Down
5 changes: 5 additions & 0 deletions include/webframe/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef WEBFRAME_CONFIG_HPP
#define WEBFRAME_CONFIG_HPP

#include <list>
#include <optional>
#include <string>

Expand All @@ -38,12 +39,16 @@ namespace webframe
void set_dark_mode(bool dark_mode);
void set_default_window_size(int width, int height);

void set_icon(const std::string& path);
void set_icons(const std::initializer_list<std::string>& paths);

bool get_dark_mode(bool &dark_mode) const;
std::pair<int, int> get_default_window_size() const;

private:
std::optional<bool> _force_dark_mode;
std::pair<int, int> _default_window_size = {800, 600};
std::list<std::string> _icon_paths;
};

class server_config
Expand Down
5 changes: 5 additions & 0 deletions include/webframe/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
*/

#include <csignal>

#include <initializer_list>
#include <string>

namespace webframe
{
class window
{
public:
virtual void set_title(const std::string& title) = 0;
virtual void load_url(const std::string& url) = 0;
virtual void load_path(const std::string& path) = 0;
virtual std::string get_id() const = 0;
Expand All @@ -43,9 +46,11 @@ namespace webframe
public:
desktop_context() = default;
~desktop_context() = default;

virtual window* create_window(window *parent, int width = -1, int height = -1);
virtual window* find_window(const std::string& id);
virtual void destroy_window(window* handle);

virtual std::string get_exe_path() const;
};

Expand Down
14 changes: 12 additions & 2 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ namespace webframe
return result;
}

void desktop_config::set_default_window_size(int width, int height)
{
_default_window_size = {width, height};
}

std::pair<int, int> desktop_config::get_default_window_size() const
{
return _default_window_size;
}

void desktop_config::set_default_window_size(int width, int height)
void desktop_config::set_icon(const std::string &path)
{
_default_window_size = {width, height};
_icon_paths.push_back(path);
}

void desktop_config::set_icons(const std::initializer_list<std::string> &paths)
{
_icon_paths.insert(_icon_paths.end(), paths);
}

void server_config::set_host(const std::string &host)
Expand Down
5 changes: 4 additions & 1 deletion src/runtimes/desktop/include/desktop/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ namespace webframe::desktop
public:
window(wxFrame *frame, wxSharedPtr<wxWebViewHandler> webview_handler);
~window() = default;

void load_path(const std::string &path) override;
void load_url(const std::string &url) override;
std::string get_id() const override;

std::string get_id() const override;
wxFrame *get_frame() const;

void set_title(const std::string &title) override;

private:
std::unique_ptr<wxFrame> _frame;
wxWebView *_webview;
Expand Down
6 changes: 6 additions & 0 deletions src/runtimes/desktop/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ namespace webframe::desktop
{
return _frame.get();
}

void window::set_title(const std::string &title)
{
wxString wx_title = wxString(title.c_str());
_frame->SetTitle(wx_title);
}
}
Loading