Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/updater/win32_progress_callback.h
7437 views
1
// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
6
#include "updater_progress_callback.h"
7
8
#include "common/windows_headers.h"
9
10
class Win32ProgressCallback final : public UpdaterProgressCallback
11
{
12
public:
13
Win32ProgressCallback(HWND parent_hwnd = nullptr);
14
~Win32ProgressCallback() override;
15
16
void PushState() override;
17
void PopState() override;
18
19
void SetCancellable(bool cancellable) override;
20
void SetTitle(const std::string_view title) override;
21
void SetStatusText(const std::string_view text) override;
22
void SetProgressRange(u32 range) override;
23
void SetProgressValue(u32 value) override;
24
25
void DisplayError(const std::string_view message) override;
26
void DisplayWarning(const std::string_view message) override;
27
void DisplayInformation(const std::string_view message) override;
28
void DisplayDebugMessage(const std::string_view message) override;
29
30
void ModalError(const std::string_view message) override;
31
bool ModalConfirmation(const std::string_view message) override;
32
void ModalInformation(const std::string_view message) override;
33
34
private:
35
enum : int
36
{
37
WINDOW_MARGIN = 10,
38
STATUS_TEXT_HEIGHT = 16,
39
PROGRESS_BAR_HEIGHT = 20,
40
LIST_BOX_HEIGHT = 170,
41
CONTROL_SPACING = 10,
42
WINDOW_WIDTH = 600,
43
WINDOW_HEIGHT = WINDOW_MARGIN * 2 + STATUS_TEXT_HEIGHT + CONTROL_SPACING + PROGRESS_BAR_HEIGHT + CONTROL_SPACING +
44
LIST_BOX_HEIGHT,
45
};
46
47
bool Create();
48
void Destroy();
49
void Redraw(bool force);
50
void PumpMessages();
51
52
static LRESULT CALLBACK WndProcThunk(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
53
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
54
55
int Scale(int value) const;
56
57
HWND m_parent_hwnd = nullptr;
58
HWND m_window_hwnd = nullptr;
59
HWND m_text_hwnd = nullptr;
60
HWND m_progress_hwnd = nullptr;
61
HWND m_list_box_hwnd = nullptr;
62
63
HFONT m_font = nullptr;
64
UINT m_dpi = 96;
65
66
int m_last_progress_percent = -1;
67
};
68
69