@marcos_feitoza/personal-finance-frontend-core-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.circleci/config.yml +23 -0
  2. package/.metadata +45 -0
  3. package/CHANGELOG.md +26 -0
  4. package/README.md +16 -0
  5. package/analysis_options.yaml +28 -0
  6. package/android/app/build.gradle.kts +44 -0
  7. package/android/app/src/debug/AndroidManifest.xml +7 -0
  8. package/android/app/src/main/AndroidManifest.xml +45 -0
  9. package/android/app/src/main/kotlin/com/example/personal_finance_frontend_core_ui/MainActivity.kt +5 -0
  10. package/android/app/src/main/res/drawable/launch_background.xml +12 -0
  11. package/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
  12. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  13. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  14. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  15. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  16. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  17. package/android/app/src/main/res/values/styles.xml +18 -0
  18. package/android/app/src/main/res/values-night/styles.xml +18 -0
  19. package/android/app/src/profile/AndroidManifest.xml +7 -0
  20. package/android/build.gradle.kts +21 -0
  21. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  22. package/android/gradle.properties +3 -0
  23. package/android/settings.gradle.kts +25 -0
  24. package/ios/Flutter/AppFrameworkInfo.plist +26 -0
  25. package/ios/Flutter/Debug.xcconfig +1 -0
  26. package/ios/Flutter/Release.xcconfig +1 -0
  27. package/ios/Runner/AppDelegate.swift +13 -0
  28. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
  29. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
  30. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
  31. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
  32. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
  33. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
  34. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
  35. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
  36. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
  37. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
  38. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
  39. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
  40. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
  41. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
  42. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
  43. package/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
  44. package/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
  45. package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
  46. package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
  47. package/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
  48. package/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
  49. package/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
  50. package/ios/Runner/Base.lproj/Main.storyboard +26 -0
  51. package/ios/Runner/Info.plist +49 -0
  52. package/ios/Runner/Runner-Bridging-Header.h +1 -0
  53. package/ios/Runner.xcodeproj/project.pbxproj +619 -0
  54. package/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  55. package/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  56. package/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  57. package/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +101 -0
  58. package/ios/Runner.xcworkspace/contents.xcworkspacedata +7 -0
  59. package/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  60. package/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  61. package/ios/RunnerTests/RunnerTests.swift +12 -0
  62. package/lib/main.dart +122 -0
  63. package/lib/personal_finance_frontend_core_ui.dart +1 -0
  64. package/lib/utils/currency_input_formatter.dart +49 -0
  65. package/lib/utils/currency_utils.dart +14 -0
  66. package/lib/utils/theme_notifier.dart +33 -0
  67. package/lib/widgets/app_widgets.dart +405 -0
  68. package/lib/widgets/crypto_trade_form.dart +357 -0
  69. package/lib/widgets/dividend_log_form.dart +151 -0
  70. package/lib/widgets/edit_transaction_dialog.dart +112 -0
  71. package/lib/widgets/expense_form.dart +238 -0
  72. package/lib/widgets/investment_form.dart +223 -0
  73. package/lib/widgets/rrsp_contribution_form.dart +157 -0
  74. package/lib/widgets/salary_form.dart +152 -0
  75. package/lib/widgets/trade_form.dart +374 -0
  76. package/lib/widgets/user_profile_avatar.dart +60 -0
  77. package/linux/CMakeLists.txt +128 -0
  78. package/linux/flutter/CMakeLists.txt +88 -0
  79. package/linux/flutter/generated_plugin_registrant.cc +11 -0
  80. package/linux/flutter/generated_plugin_registrant.h +15 -0
  81. package/linux/flutter/generated_plugins.cmake +23 -0
  82. package/linux/runner/CMakeLists.txt +26 -0
  83. package/linux/runner/main.cc +6 -0
  84. package/linux/runner/my_application.cc +130 -0
  85. package/linux/runner/my_application.h +18 -0
  86. package/macos/Flutter/Flutter-Debug.xcconfig +1 -0
  87. package/macos/Flutter/Flutter-Release.xcconfig +1 -0
  88. package/macos/Flutter/GeneratedPluginRegistrant.swift +10 -0
  89. package/macos/Runner/AppDelegate.swift +13 -0
  90. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
  91. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
  92. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
  93. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
  94. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
  95. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
  96. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
  97. package/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
  98. package/macos/Runner/Base.lproj/MainMenu.xib +343 -0
  99. package/macos/Runner/Configs/AppInfo.xcconfig +14 -0
  100. package/macos/Runner/Configs/Debug.xcconfig +2 -0
  101. package/macos/Runner/Configs/Release.xcconfig +2 -0
  102. package/macos/Runner/Configs/Warnings.xcconfig +13 -0
  103. package/macos/Runner/DebugProfile.entitlements +12 -0
  104. package/macos/Runner/Info.plist +32 -0
  105. package/macos/Runner/MainFlutterWindow.swift +15 -0
  106. package/macos/Runner/Release.entitlements +8 -0
  107. package/macos/Runner.xcodeproj/project.pbxproj +705 -0
  108. package/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  109. package/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +99 -0
  110. package/macos/Runner.xcworkspace/contents.xcworkspacedata +7 -0
  111. package/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  112. package/macos/RunnerTests/RunnerTests.swift +12 -0
  113. package/package.json +29 -0
  114. package/pubspec.yaml +94 -0
  115. package/test/widget_test.dart +30 -0
  116. package/web/favicon.png +0 -0
  117. package/web/icons/Icon-192.png +0 -0
  118. package/web/icons/Icon-512.png +0 -0
  119. package/web/icons/Icon-maskable-192.png +0 -0
  120. package/web/icons/Icon-maskable-512.png +0 -0
  121. package/web/index.html +38 -0
  122. package/web/manifest.json +35 -0
  123. package/windows/CMakeLists.txt +108 -0
  124. package/windows/flutter/CMakeLists.txt +109 -0
  125. package/windows/flutter/generated_plugin_registrant.cc +11 -0
  126. package/windows/flutter/generated_plugin_registrant.h +15 -0
  127. package/windows/flutter/generated_plugins.cmake +23 -0
  128. package/windows/runner/CMakeLists.txt +40 -0
  129. package/windows/runner/Runner.rc +121 -0
  130. package/windows/runner/flutter_window.cpp +71 -0
  131. package/windows/runner/flutter_window.h +33 -0
  132. package/windows/runner/main.cpp +43 -0
  133. package/windows/runner/resource.h +16 -0
  134. package/windows/runner/resources/app_icon.ico +0 -0
  135. package/windows/runner/runner.exe.manifest +14 -0
  136. package/windows/runner/utils.cpp +65 -0
  137. package/windows/runner/utils.h +19 -0
  138. package/windows/runner/win32_window.cpp +288 -0
  139. package/windows/runner/win32_window.h +102 -0
@@ -0,0 +1,288 @@
1
+ #include "win32_window.h"
2
+
3
+ #include <dwmapi.h>
4
+ #include <flutter_windows.h>
5
+
6
+ #include "resource.h"
7
+
8
+ namespace {
9
+
10
+ /// Window attribute that enables dark mode window decorations.
11
+ ///
12
+ /// Redefined in case the developer's machine has a Windows SDK older than
13
+ /// version 10.0.22000.0.
14
+ /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
15
+ #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
16
+ #define DWMWA_USE_IMMERSIVE_DARK_MODE 20
17
+ #endif
18
+
19
+ constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW";
20
+
21
+ /// Registry key for app theme preference.
22
+ ///
23
+ /// A value of 0 indicates apps should use dark mode. A non-zero or missing
24
+ /// value indicates apps should use light mode.
25
+ constexpr const wchar_t kGetPreferredBrightnessRegKey[] =
26
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
27
+ constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme";
28
+
29
+ // The number of Win32Window objects that currently exist.
30
+ static int g_active_window_count = 0;
31
+
32
+ using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd);
33
+
34
+ // Scale helper to convert logical scaler values to physical using passed in
35
+ // scale factor
36
+ int Scale(int source, double scale_factor) {
37
+ return static_cast<int>(source * scale_factor);
38
+ }
39
+
40
+ // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module.
41
+ // This API is only needed for PerMonitor V1 awareness mode.
42
+ void EnableFullDpiSupportIfAvailable(HWND hwnd) {
43
+ HMODULE user32_module = LoadLibraryA("User32.dll");
44
+ if (!user32_module) {
45
+ return;
46
+ }
47
+ auto enable_non_client_dpi_scaling =
48
+ reinterpret_cast<EnableNonClientDpiScaling*>(
49
+ GetProcAddress(user32_module, "EnableNonClientDpiScaling"));
50
+ if (enable_non_client_dpi_scaling != nullptr) {
51
+ enable_non_client_dpi_scaling(hwnd);
52
+ }
53
+ FreeLibrary(user32_module);
54
+ }
55
+
56
+ } // namespace
57
+
58
+ // Manages the Win32Window's window class registration.
59
+ class WindowClassRegistrar {
60
+ public:
61
+ ~WindowClassRegistrar() = default;
62
+
63
+ // Returns the singleton registrar instance.
64
+ static WindowClassRegistrar* GetInstance() {
65
+ if (!instance_) {
66
+ instance_ = new WindowClassRegistrar();
67
+ }
68
+ return instance_;
69
+ }
70
+
71
+ // Returns the name of the window class, registering the class if it hasn't
72
+ // previously been registered.
73
+ const wchar_t* GetWindowClass();
74
+
75
+ // Unregisters the window class. Should only be called if there are no
76
+ // instances of the window.
77
+ void UnregisterWindowClass();
78
+
79
+ private:
80
+ WindowClassRegistrar() = default;
81
+
82
+ static WindowClassRegistrar* instance_;
83
+
84
+ bool class_registered_ = false;
85
+ };
86
+
87
+ WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
88
+
89
+ const wchar_t* WindowClassRegistrar::GetWindowClass() {
90
+ if (!class_registered_) {
91
+ WNDCLASS window_class{};
92
+ window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
93
+ window_class.lpszClassName = kWindowClassName;
94
+ window_class.style = CS_HREDRAW | CS_VREDRAW;
95
+ window_class.cbClsExtra = 0;
96
+ window_class.cbWndExtra = 0;
97
+ window_class.hInstance = GetModuleHandle(nullptr);
98
+ window_class.hIcon =
99
+ LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON));
100
+ window_class.hbrBackground = 0;
101
+ window_class.lpszMenuName = nullptr;
102
+ window_class.lpfnWndProc = Win32Window::WndProc;
103
+ RegisterClass(&window_class);
104
+ class_registered_ = true;
105
+ }
106
+ return kWindowClassName;
107
+ }
108
+
109
+ void WindowClassRegistrar::UnregisterWindowClass() {
110
+ UnregisterClass(kWindowClassName, nullptr);
111
+ class_registered_ = false;
112
+ }
113
+
114
+ Win32Window::Win32Window() {
115
+ ++g_active_window_count;
116
+ }
117
+
118
+ Win32Window::~Win32Window() {
119
+ --g_active_window_count;
120
+ Destroy();
121
+ }
122
+
123
+ bool Win32Window::Create(const std::wstring& title,
124
+ const Point& origin,
125
+ const Size& size) {
126
+ Destroy();
127
+
128
+ const wchar_t* window_class =
129
+ WindowClassRegistrar::GetInstance()->GetWindowClass();
130
+
131
+ const POINT target_point = {static_cast<LONG>(origin.x),
132
+ static_cast<LONG>(origin.y)};
133
+ HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
134
+ UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
135
+ double scale_factor = dpi / 96.0;
136
+
137
+ HWND window = CreateWindow(
138
+ window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
139
+ Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
140
+ Scale(size.width, scale_factor), Scale(size.height, scale_factor),
141
+ nullptr, nullptr, GetModuleHandle(nullptr), this);
142
+
143
+ if (!window) {
144
+ return false;
145
+ }
146
+
147
+ UpdateTheme(window);
148
+
149
+ return OnCreate();
150
+ }
151
+
152
+ bool Win32Window::Show() {
153
+ return ShowWindow(window_handle_, SW_SHOWNORMAL);
154
+ }
155
+
156
+ // static
157
+ LRESULT CALLBACK Win32Window::WndProc(HWND const window,
158
+ UINT const message,
159
+ WPARAM const wparam,
160
+ LPARAM const lparam) noexcept {
161
+ if (message == WM_NCCREATE) {
162
+ auto window_struct = reinterpret_cast<CREATESTRUCT*>(lparam);
163
+ SetWindowLongPtr(window, GWLP_USERDATA,
164
+ reinterpret_cast<LONG_PTR>(window_struct->lpCreateParams));
165
+
166
+ auto that = static_cast<Win32Window*>(window_struct->lpCreateParams);
167
+ EnableFullDpiSupportIfAvailable(window);
168
+ that->window_handle_ = window;
169
+ } else if (Win32Window* that = GetThisFromHandle(window)) {
170
+ return that->MessageHandler(window, message, wparam, lparam);
171
+ }
172
+
173
+ return DefWindowProc(window, message, wparam, lparam);
174
+ }
175
+
176
+ LRESULT
177
+ Win32Window::MessageHandler(HWND hwnd,
178
+ UINT const message,
179
+ WPARAM const wparam,
180
+ LPARAM const lparam) noexcept {
181
+ switch (message) {
182
+ case WM_DESTROY:
183
+ window_handle_ = nullptr;
184
+ Destroy();
185
+ if (quit_on_close_) {
186
+ PostQuitMessage(0);
187
+ }
188
+ return 0;
189
+
190
+ case WM_DPICHANGED: {
191
+ auto newRectSize = reinterpret_cast<RECT*>(lparam);
192
+ LONG newWidth = newRectSize->right - newRectSize->left;
193
+ LONG newHeight = newRectSize->bottom - newRectSize->top;
194
+
195
+ SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth,
196
+ newHeight, SWP_NOZORDER | SWP_NOACTIVATE);
197
+
198
+ return 0;
199
+ }
200
+ case WM_SIZE: {
201
+ RECT rect = GetClientArea();
202
+ if (child_content_ != nullptr) {
203
+ // Size and position the child window.
204
+ MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left,
205
+ rect.bottom - rect.top, TRUE);
206
+ }
207
+ return 0;
208
+ }
209
+
210
+ case WM_ACTIVATE:
211
+ if (child_content_ != nullptr) {
212
+ SetFocus(child_content_);
213
+ }
214
+ return 0;
215
+
216
+ case WM_DWMCOLORIZATIONCOLORCHANGED:
217
+ UpdateTheme(hwnd);
218
+ return 0;
219
+ }
220
+
221
+ return DefWindowProc(window_handle_, message, wparam, lparam);
222
+ }
223
+
224
+ void Win32Window::Destroy() {
225
+ OnDestroy();
226
+
227
+ if (window_handle_) {
228
+ DestroyWindow(window_handle_);
229
+ window_handle_ = nullptr;
230
+ }
231
+ if (g_active_window_count == 0) {
232
+ WindowClassRegistrar::GetInstance()->UnregisterWindowClass();
233
+ }
234
+ }
235
+
236
+ Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept {
237
+ return reinterpret_cast<Win32Window*>(
238
+ GetWindowLongPtr(window, GWLP_USERDATA));
239
+ }
240
+
241
+ void Win32Window::SetChildContent(HWND content) {
242
+ child_content_ = content;
243
+ SetParent(content, window_handle_);
244
+ RECT frame = GetClientArea();
245
+
246
+ MoveWindow(content, frame.left, frame.top, frame.right - frame.left,
247
+ frame.bottom - frame.top, true);
248
+
249
+ SetFocus(child_content_);
250
+ }
251
+
252
+ RECT Win32Window::GetClientArea() {
253
+ RECT frame;
254
+ GetClientRect(window_handle_, &frame);
255
+ return frame;
256
+ }
257
+
258
+ HWND Win32Window::GetHandle() {
259
+ return window_handle_;
260
+ }
261
+
262
+ void Win32Window::SetQuitOnClose(bool quit_on_close) {
263
+ quit_on_close_ = quit_on_close;
264
+ }
265
+
266
+ bool Win32Window::OnCreate() {
267
+ // No-op; provided for subclasses.
268
+ return true;
269
+ }
270
+
271
+ void Win32Window::OnDestroy() {
272
+ // No-op; provided for subclasses.
273
+ }
274
+
275
+ void Win32Window::UpdateTheme(HWND const window) {
276
+ DWORD light_mode;
277
+ DWORD light_mode_size = sizeof(light_mode);
278
+ LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey,
279
+ kGetPreferredBrightnessRegValue,
280
+ RRF_RT_REG_DWORD, nullptr, &light_mode,
281
+ &light_mode_size);
282
+
283
+ if (result == ERROR_SUCCESS) {
284
+ BOOL enable_dark_mode = light_mode == 0;
285
+ DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE,
286
+ &enable_dark_mode, sizeof(enable_dark_mode));
287
+ }
288
+ }
@@ -0,0 +1,102 @@
1
+ #ifndef RUNNER_WIN32_WINDOW_H_
2
+ #define RUNNER_WIN32_WINDOW_H_
3
+
4
+ #include <windows.h>
5
+
6
+ #include <functional>
7
+ #include <memory>
8
+ #include <string>
9
+
10
+ // A class abstraction for a high DPI-aware Win32 Window. Intended to be
11
+ // inherited from by classes that wish to specialize with custom
12
+ // rendering and input handling
13
+ class Win32Window {
14
+ public:
15
+ struct Point {
16
+ unsigned int x;
17
+ unsigned int y;
18
+ Point(unsigned int x, unsigned int y) : x(x), y(y) {}
19
+ };
20
+
21
+ struct Size {
22
+ unsigned int width;
23
+ unsigned int height;
24
+ Size(unsigned int width, unsigned int height)
25
+ : width(width), height(height) {}
26
+ };
27
+
28
+ Win32Window();
29
+ virtual ~Win32Window();
30
+
31
+ // Creates a win32 window with |title| that is positioned and sized using
32
+ // |origin| and |size|. New windows are created on the default monitor. Window
33
+ // sizes are specified to the OS in physical pixels, hence to ensure a
34
+ // consistent size this function will scale the inputted width and height as
35
+ // as appropriate for the default monitor. The window is invisible until
36
+ // |Show| is called. Returns true if the window was created successfully.
37
+ bool Create(const std::wstring& title, const Point& origin, const Size& size);
38
+
39
+ // Show the current window. Returns true if the window was successfully shown.
40
+ bool Show();
41
+
42
+ // Release OS resources associated with window.
43
+ void Destroy();
44
+
45
+ // Inserts |content| into the window tree.
46
+ void SetChildContent(HWND content);
47
+
48
+ // Returns the backing Window handle to enable clients to set icon and other
49
+ // window properties. Returns nullptr if the window has been destroyed.
50
+ HWND GetHandle();
51
+
52
+ // If true, closing this window will quit the application.
53
+ void SetQuitOnClose(bool quit_on_close);
54
+
55
+ // Return a RECT representing the bounds of the current client area.
56
+ RECT GetClientArea();
57
+
58
+ protected:
59
+ // Processes and route salient window messages for mouse handling,
60
+ // size change and DPI. Delegates handling of these to member overloads that
61
+ // inheriting classes can handle.
62
+ virtual LRESULT MessageHandler(HWND window,
63
+ UINT const message,
64
+ WPARAM const wparam,
65
+ LPARAM const lparam) noexcept;
66
+
67
+ // Called when CreateAndShow is called, allowing subclass window-related
68
+ // setup. Subclasses should return false if setup fails.
69
+ virtual bool OnCreate();
70
+
71
+ // Called when Destroy is called.
72
+ virtual void OnDestroy();
73
+
74
+ private:
75
+ friend class WindowClassRegistrar;
76
+
77
+ // OS callback called by message pump. Handles the WM_NCCREATE message which
78
+ // is passed when the non-client area is being created and enables automatic
79
+ // non-client DPI scaling so that the non-client area automatically
80
+ // responds to changes in DPI. All other messages are handled by
81
+ // MessageHandler.
82
+ static LRESULT CALLBACK WndProc(HWND const window,
83
+ UINT const message,
84
+ WPARAM const wparam,
85
+ LPARAM const lparam) noexcept;
86
+
87
+ // Retrieves a class instance pointer for |window|
88
+ static Win32Window* GetThisFromHandle(HWND const window) noexcept;
89
+
90
+ // Update the window frame's theme to match the system theme.
91
+ static void UpdateTheme(HWND const window);
92
+
93
+ bool quit_on_close_ = false;
94
+
95
+ // window handle for top level window.
96
+ HWND window_handle_ = nullptr;
97
+
98
+ // window handle for hosted content.
99
+ HWND child_content_ = nullptr;
100
+ };
101
+
102
+ #endif // RUNNER_WIN32_WINDOW_H_