Path: blob/master/src/updater/cocoa_progress_callback.h
4243 views
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>1// SPDX-License-Identifier: CC-BY-NC-ND-4.023#pragma once45#include "common/progress_callback.h"67#include <AppKit/AppKit.h>8#include <Cocoa/Cocoa.h>910#ifndef __OBJC__11#error This file needs to be compiled with Objective C++.12#endif1314#if __has_feature(objc_arc)15#error ARC should not be enabled.16#endif1718class CocoaProgressCallback final : public ProgressCallback19{20public:21CocoaProgressCallback();22~CocoaProgressCallback();2324void PushState() override;25void PopState() override;2627void SetCancellable(bool cancellable) override;28void SetTitle(const std::string_view title) override;29void SetStatusText(const std::string_view text) override;30void SetProgressRange(u32 range) override;31void SetProgressValue(u32 value) override;3233void DisplayError(const std::string_view message) override;34void DisplayWarning(const std::string_view message) override;35void DisplayInformation(const std::string_view message) override;36void DisplayDebugMessage(const std::string_view message) override;3738void ModalError(const std::string_view message) override;39bool ModalConfirmation(const std::string_view message) override;40void ModalInformation(const std::string_view message) override;4142private:43enum : int44{45WINDOW_WIDTH = 600,46WINDOW_HEIGHT = 300,47WINDOW_MARGIN = 20,48SUBWINDOW_PADDING = 10,49SUBWINDOW_WIDTH = WINDOW_WIDTH - WINDOW_MARGIN - WINDOW_MARGIN,50};5152bool Create();53void Destroy();54void UpdateProgress();55void AppendMessage(const std::string_view message);5657NSWindow* m_window = nil;58NSView* m_view = nil;59NSTextField* m_status = nil;60NSProgressIndicator* m_progress = nil;61NSScrollView* m_text_scroll = nil;62NSTextView* m_text = nil;63};646566