File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,13 @@ class example_application : public webframe::application
8989 router->set_default (&_archive_handler);
9090 router->add_route (" /greetingIPC" , &_greeting_ipc_handler);
9191 }
92+
93+ void launch_desktop (webframe::desktop_context *context)
94+ {
95+ webframe::window *win = context->create_window (nullptr , 800 , 600 );
96+ win->set_title (" WebFrame Example" );
97+ win->load_path (" index.html" );
98+ }
9299private:
93100 archive_handler _archive_handler;
94101 greeting_ipc_handler _greeting_ipc_handler;
Original file line number Diff line number Diff line change 1919#ifndef WEBFRAME_CONFIG_HPP
2020#define WEBFRAME_CONFIG_HPP
2121
22+ #include < list>
2223#include < optional>
2324#include < string>
2425
@@ -38,12 +39,16 @@ namespace webframe
3839 void set_dark_mode (bool dark_mode);
3940 void set_default_window_size (int width, int height);
4041
42+ void set_icon (const std::string& path);
43+ void set_icons (const std::initializer_list<std::string>& paths);
44+
4145 bool get_dark_mode (bool &dark_mode) const ;
4246 std::pair<int , int > get_default_window_size () const ;
4347
4448 private:
4549 std::optional<bool > _force_dark_mode;
4650 std::pair<int , int > _default_window_size = {800 , 600 };
51+ std::list<std::string> _icon_paths;
4752 };
4853
4954 class server_config
Original file line number Diff line number Diff line change 2626 */
2727
2828#include < csignal>
29+
30+ #include < initializer_list>
2931#include < string>
3032
3133namespace webframe
3234{
3335 class window
3436 {
3537 public:
38+ virtual void set_title (const std::string& title) = 0;
3639 virtual void load_url (const std::string& url) = 0;
3740 virtual void load_path (const std::string& path) = 0;
3841 virtual std::string get_id () const = 0;
@@ -43,9 +46,11 @@ namespace webframe
4346 public:
4447 desktop_context () = default ;
4548 ~desktop_context () = default ;
49+
4650 virtual window* create_window (window *parent, int width = -1 , int height = -1 );
4751 virtual window* find_window (const std::string& id);
4852 virtual void destroy_window (window* handle);
53+
4954 virtual std::string get_exe_path () const ;
5055 };
5156
Original file line number Diff line number Diff line change @@ -17,14 +17,24 @@ namespace webframe
1717 return result;
1818 }
1919
20+ void desktop_config::set_default_window_size (int width, int height)
21+ {
22+ _default_window_size = {width, height};
23+ }
24+
2025 std::pair<int , int > desktop_config::get_default_window_size () const
2126 {
2227 return _default_window_size;
2328 }
2429
25- void desktop_config::set_default_window_size ( int width, int height )
30+ void desktop_config::set_icon ( const std::string &path )
2631 {
27- _default_window_size = {width, height};
32+ _icon_paths.push_back (path);
33+ }
34+
35+ void desktop_config::set_icons (const std::initializer_list<std::string> &paths)
36+ {
37+ _icon_paths.insert (_icon_paths.end (), paths);
2838 }
2939
3040 void server_config::set_host (const std::string &host)
Original file line number Diff line number Diff line change @@ -10,12 +10,15 @@ namespace webframe::desktop
1010 public:
1111 window (wxFrame *frame, wxSharedPtr<wxWebViewHandler> webview_handler);
1212 ~window () = default ;
13+
1314 void load_path (const std::string &path) override ;
1415 void load_url (const std::string &url) override ;
15- std::string get_id () const override ;
1616
17+ std::string get_id () const override ;
1718 wxFrame *get_frame () const ;
1819
20+ void set_title (const std::string &title) override ;
21+
1922 private:
2023 std::unique_ptr<wxFrame> _frame;
2124 wxWebView *_webview;
Original file line number Diff line number Diff line change @@ -50,4 +50,10 @@ namespace webframe::desktop
5050 {
5151 return _frame.get ();
5252 }
53+
54+ void window::set_title (const std::string &title)
55+ {
56+ wxString wx_title = wxString (title.c_str ());
57+ _frame->SetTitle (wx_title);
58+ }
5359}
You can’t perform that action at this time.
0 commit comments