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