1 // =================================
 2 // Copyright (c) 2022 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 using System;
 7 using System.Collections;
 8 
 9 namespace System.Screen
10 {
11     public class WindowManager
12     {
13         public nothrow WindowManager() : nextWindowHandle(0)
14         {
15         }
16         public void AddWindow(Control* window)
17         {
18             window->SetHandle(nextWindowHandle++);
19             windowMap[window->Handle()] = window;
20         }
21         public Control* GetWindow(int windowHandle) const
22         {
23             Map<intControl*>.ConstIterator it = windowMap.CFind(windowHandle);
24             if (it != windowMap.CEnd())
25             {
26                 Control* control = it->second;
27                 return control;
28             }
29             else
30             {
31                 return null;
32             }
33         }
34         public void RemoveWindow(Control* window)
35         {
36             windowMap.Remove(window->Handle());
37         }
38         private int nextWindowHandle;
39         private Map<intControl*> windowMap;
40     }
41 }