2019-01-23 18:41:12 +00:00
|
|
|
/*
|
|
|
|
Copyright 2019 Wolfgang Thaller.
|
|
|
|
|
|
|
|
This file is part of Retro68.
|
|
|
|
|
|
|
|
Retro68 is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Retro68 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Retro68. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-05-06 16:49:43 +00:00
|
|
|
#include <MacTypes.h>
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <TextUtils.h>
|
|
|
|
|
2018-05-19 12:55:27 +00:00
|
|
|
#include "Window.h"
|
2019-01-08 23:31:32 +00:00
|
|
|
#ifdef DEBUG_CONSOLE
|
|
|
|
#include <retro/Console.h>
|
|
|
|
#endif
|
2018-05-19 12:55:27 +00:00
|
|
|
|
2018-05-06 16:49:43 +00:00
|
|
|
enum class AppStatus
|
|
|
|
{
|
|
|
|
empty = 0,
|
2018-05-08 00:37:25 +00:00
|
|
|
readyModem = 1,
|
|
|
|
readyPrinter,
|
2019-01-08 23:15:44 +00:00
|
|
|
readyMacTCP,
|
|
|
|
readyOpenTpt,
|
2019-01-23 18:41:12 +00:00
|
|
|
readySharedFiles,
|
2018-05-08 00:37:25 +00:00
|
|
|
downloading,
|
|
|
|
upgrading,
|
|
|
|
running,
|
|
|
|
uploading
|
2018-05-06 16:49:43 +00:00
|
|
|
};
|
|
|
|
|
2018-05-19 12:55:27 +00:00
|
|
|
class StatusDisplay : public Window
|
2018-05-06 16:49:43 +00:00
|
|
|
{
|
|
|
|
WindowPtr statusWindow;
|
|
|
|
Str255 statusString = "\p";
|
|
|
|
AppStatus status = AppStatus::empty;
|
|
|
|
int progressDone, progressTotal = 0;
|
|
|
|
long freeMem;
|
2018-05-07 20:39:24 +00:00
|
|
|
long startTime;
|
|
|
|
long speed = -1;
|
|
|
|
long timeRemaining = -1;
|
2018-05-08 00:15:05 +00:00
|
|
|
int errorCount = -1;
|
2018-05-06 16:49:43 +00:00
|
|
|
|
|
|
|
RgnHandle background;
|
|
|
|
Rect statusRect;
|
|
|
|
Rect progressRect;
|
2018-05-07 20:39:24 +00:00
|
|
|
|
|
|
|
static const int nValues = 7;
|
|
|
|
Rect valueRects[nValues];
|
|
|
|
short columnWidths[6];
|
|
|
|
|
2018-05-16 22:38:55 +00:00
|
|
|
PixPatHandle progressBg, progressFg;
|
|
|
|
|
2019-01-08 23:31:32 +00:00
|
|
|
#ifdef DEBUG_CONSOLE
|
|
|
|
Rect consoleRect;
|
|
|
|
retro::Console console;
|
|
|
|
#endif
|
|
|
|
|
2018-05-07 20:39:24 +00:00
|
|
|
enum class Stat : short;
|
|
|
|
|
|
|
|
void DrawValue(Stat stat, ConstStr255Param str);
|
|
|
|
void DrawValue(Stat stat, long val);
|
2018-05-14 21:58:11 +00:00
|
|
|
void Inval(const Rect& r);
|
2018-05-07 20:39:24 +00:00
|
|
|
|
2018-05-06 16:49:43 +00:00
|
|
|
public:
|
|
|
|
StatusDisplay();
|
|
|
|
~StatusDisplay();
|
|
|
|
|
|
|
|
WindowPtr GetWindow() { return statusWindow; }
|
2018-05-19 12:55:27 +00:00
|
|
|
virtual void Update() override;
|
2018-05-06 16:49:43 +00:00
|
|
|
|
|
|
|
void Idle();
|
|
|
|
|
|
|
|
void SetStatus(AppStatus s);
|
|
|
|
void SetProgress(int done = 0, int total = 0);
|
|
|
|
void SetStatus(AppStatus stat, int done, int total);
|
2018-05-07 20:39:24 +00:00
|
|
|
void SetErrorCount(int errorCount);
|
2018-05-06 16:49:43 +00:00
|
|
|
};
|