LaunchAPPLServer: a touch of color

This commit is contained in:
Wolfgang Thaller 2018-05-17 00:38:55 +02:00
parent 7f1eb5692c
commit e39e0a09c5
5 changed files with 75 additions and 21 deletions

View File

@ -82,6 +82,8 @@ bool portsAvailable[] = { false, false, false, false };
#else
bool portsAvailable[] = { true, true, false, false };
#endif
Boolean hasIconUtils = true;
Boolean hasColorQD = true;
struct Prefs
{
@ -132,7 +134,9 @@ void ShowAboutBox()
return;
}
WindowRef w = GetNewWindow(128, NULL, (WindowPtr) -1);
WindowRef w = hasColorQD ?
GetNewCWindow(128, NULL, (WindowPtr) -1)
: GetNewWindow(128, NULL, (WindowPtr) -1);
aboutWindow = w;
#if TARGET_API_MAC_CARBON
Rect screenBounds = (*GetMainDevice())->gdRect;
@ -155,12 +159,24 @@ void UpdateAboutWindow()
SetPortWindowPort(aboutWindow);
BeginUpdate(aboutWindow);
Rect portRect;
GetWindowPortBounds(aboutWindow,&portRect);
EraseRect(&portRect);
Rect r;
GetWindowPortBounds(aboutWindow,&r);
EraseRect(&r);
SetRect(&r, portRect.right/2 - 16, 10, portRect.right/2 + 16, 42);
InsetRect(&r, 10,10);
if(hasIconUtils)
PlotIconID(&r, kAlignAbsoluteCenter, kTransformNone, 128);
else
PlotIcon(&r, GetResource('ICN#', 128));
r = portRect;
r.left += 10;
r.top += 52;
r.bottom -= 10;
r.right -= 10;
Handle h = GetResource('TEXT', 128);
HLock(h);
TETextBox(*h, GetHandleSize(h), &r, teJustLeft);
@ -643,6 +659,9 @@ int main()
Boolean hasWaitNextEvent = false;
Boolean hasGestalt = false;
Boolean hasAppleEvents = false;
hasIconUtils = false;
hasColorQD = false;
if (is128KROM)
{
UniversalProcPtr trapUnimpl = GetToolTrapAddress(_Unimplemented);
@ -659,6 +678,12 @@ int main()
long response = 0;
OSErr err = Gestalt(gestaltAppleEventsAttr, &response);
hasAppleEvents = err == noErr && response != 0;
err = Gestalt(gestaltIconUtilitiesAttr, &response);
hasIconUtils = err == noErr && response != 0;
err = Gestalt(gestaltQuickdrawVersion, &response);
hasColorQD = err == noErr && response != 0;
}
}
#else

View File

@ -94,10 +94,10 @@ data 'TEXT' (128, purgeable) {
};
resource 'WIND' (128, "About") {
{0, 0, 200, 320}, noGrowDocProc;
{0, 0, 242, 320}, noGrowDocProc;
invisible;
goAway;
0, "About LaunchAPPLShell";
0, "About LaunchAPPLServer";
noAutoCenter;
};

View File

@ -166,3 +166,23 @@ resource 'ics4' (128, purgeable) {
$"0000 FF00 FCCC CCCF 0000 0000 0FEF FEF0"
};
data 'ppat' (128) {
$"0001 0000 001C 0000 004E 0000 0000 FFFF"
$"0000 0000 8822 8822 8822 8822 0000 0000"
$"8001 0000 0000 0008 0008 0000 0000 0000"
$"0000 0048 0000 0048 0000 0000 0001 0001"
$"0001 0000 0000 0000 0056 0000 0000 0000"
$"0000 0000 0000 0000 0000 0000 0000 0000"
$"CCCC CCCC FFFF"
};
data 'ppat' (129) {
$"0001 0000 001C 0000 004E 0000 0000 FFFF"
$"0000 0000 77DD 77DD 77DD 77DD 0000 0000"
$"8001 0000 0000 0008 0008 0000 0000 0000"
$"0000 0048 0000 0048 0000 0000 0001 0001"
$"0001 0000 0000 0000 0056 0000 0000 0000"
$"0000 0000 0000 0000 0000 0000 0000 0000"
$"4444 4444 4444"
};

View File

@ -7,6 +7,8 @@ const short tableTop = 50;
const short tableLineHeight = 20;
const short tableBaseline = 15;
extern Boolean hasColorQD;
enum class StatusDisplay::Stat : short
{
heapSize,
@ -20,7 +22,9 @@ enum class StatusDisplay::Stat : short
StatusDisplay::StatusDisplay()
{
statusWindow = GetNewWindow(129, NULL, (WindowPtr) -1);
statusWindow = hasColorQD ?
GetNewCWindow(129, NULL, (WindowPtr) -1)
: GetNewWindow(129, NULL, (WindowPtr) -1);
#if TARGET_API_MAC_CARBON
Rect bounds;
@ -78,6 +82,12 @@ StatusDisplay::StatusDisplay()
DiffRgn(background, tmp, background);
}
DisposeRgn(tmp);
if(hasColorQD)
{
progressBg = GetPixPat(128);
progressFg = GetPixPat(129);
}
}
StatusDisplay::~StatusDisplay()
@ -116,11 +126,7 @@ void StatusDisplay::DrawValue(Stat stat, long val)
void StatusDisplay::Update()
{
#if TARGET_API_MAC_CARBON
SetPortWindowPort(statusWindow);
#else
SetPort(statusWindow);
#endif
BeginUpdate(statusWindow);
EraseRgn(background);
@ -140,19 +146,20 @@ void StatusDisplay::Update()
progressRect.left+1 + (progressRect.right-progressRect.left-2) * progressDone / progressTotal,
progressRect.bottom-1);
#if TARGET_API_MAC_CARBON
Pattern fg, bg;
GetQDGlobalsDarkGray(&fg);
GetQDGlobalsLightGray(&bg);
#else
const Pattern& fg = qd.dkGray;
const Pattern& bg = qd.ltGray;
#if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
if(!hasColorQD)
FillRect(&r, &qd.dkGray);
else
#endif
FillRect(&r, &fg);
FillCRect(&r, progressFg);
r.left = r.right;
r.right = progressRect.right - 1;
FillRect(&r, &bg);
#if TARGET_CPU_68K && !TARGET_RT_MAC_CFM
if(!hasColorQD)
FillRect(&r, &qd.ltGray);
else
#endif
FillCRect(&r, progressBg);
}
else
EraseRect(&progressRect);

View File

@ -33,6 +33,8 @@ class StatusDisplay
Rect valueRects[nValues];
short columnWidths[6];
PixPatHandle progressBg, progressFg;
enum class Stat : short;
void DrawValue(Stat stat, ConstStr255Param str);