11#include < iostream>
22#include " nativeapi.h"
33
4+ using nativeapi::AppRunner;
5+ using nativeapi::Tray;
6+ using nativeapi::TrayManager;
47using nativeapi::Window;
58using nativeapi::WindowManager;
9+ using nativeapi::WindowOptions;
610
711int main () {
8- WindowManager windowManager = WindowManager ();
12+ WindowManager window_manager = WindowManager ();
913
10- // Get primary display information
11- std::shared_ptr<Window> currentWindowPtr = windowManager.GetCurrent ();
12- if (currentWindowPtr != nullptr ) {
13- Window& currentWindow = *currentWindowPtr;
14- std::cout << " Current Window Information:" << std::endl;
15- std::cout << " ID: " << currentWindow.id << std::endl;
14+ // Create a new window with options
15+ WindowOptions options;
16+ options.title = " My Window" ;
17+ options.size .width = 800 ;
18+ options.size .height = 600 ;
19+ std::shared_ptr<Window> window_ptr = window_manager.Create (options);
20+ if (window_ptr != nullptr ) {
21+ Window& window = *window_ptr;
22+ std::cout << " New Window Information:" << std::endl;
23+ std::cout << " ID: " << window.id << std::endl;
1624 std::cout << std::endl;
25+ window.Show ();
26+ window.Focus ();
1727 }
1828
19- // Get all windows
20- std::vector<std::shared_ptr<Window>> windowList = (windowManager. GetAll ());
21- std::cout << " \n All Windows Information: " << std::endl ;
22- for ( size_t i = 0 ; i < windowList. size (); i++ ) {
23- const Window& window = *windowList[i] ;
24- std::cout << " Window " << (i + 1 ) << " : " << std::endl ;
25- std::cout << " ID: " << window .id << std::endl;
26- auto windowSize = window. GetSize () ;
27- std::cout << " Size: " << windowSize. width << " x " << windowSize. height
28- << std::endl;
29+ TrayManager trayManager = TrayManager ();
30+
31+ std::shared_ptr<Tray> newTrayPtr = trayManager. Create () ;
32+ if (newTrayPtr != nullptr ) {
33+ Tray& newTray = *newTrayPtr ;
34+ newTray. SetTitle ( " Hello, World! " ) ;
35+ std::cout << " Tray ID: " << newTray .id << std::endl;
36+ std::cout << " Tray Title: " << newTray. GetTitle () << std::endl ;
37+ } else {
38+ std::cerr << " Failed to create tray. " << std::endl;
2939 }
40+
41+ AppRunner runner;
42+ runner.Run (window_ptr);
43+
3044 return 0 ;
31- }
45+ }
0 commit comments