From e39e0a09c5e1d75131d827bc1b3524d45020115b Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 17 May 2018 00:38:55 +0200 Subject: [PATCH] LaunchAPPLServer: a touch of color --- LaunchAPPL/Server/LaunchAPPLServer.cc | 33 +++++++++++++++++++++--- LaunchAPPL/Server/LaunchAPPLServer.r | 4 +-- LaunchAPPL/Server/LauncherIcon.r | 20 +++++++++++++++ LaunchAPPL/Server/StatusDisplay.cc | 37 ++++++++++++++++----------- LaunchAPPL/Server/StatusDisplay.h | 2 ++ 5 files changed, 75 insertions(+), 21 deletions(-) diff --git a/LaunchAPPL/Server/LaunchAPPLServer.cc b/LaunchAPPL/Server/LaunchAPPLServer.cc index 99b4a7790c..73a568f42e 100644 --- a/LaunchAPPL/Server/LaunchAPPLServer.cc +++ b/LaunchAPPL/Server/LaunchAPPLServer.cc @@ -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 diff --git a/LaunchAPPL/Server/LaunchAPPLServer.r b/LaunchAPPL/Server/LaunchAPPLServer.r index 26b8446a0e..34a2b659d7 100644 --- a/LaunchAPPL/Server/LaunchAPPLServer.r +++ b/LaunchAPPL/Server/LaunchAPPLServer.r @@ -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; }; diff --git a/LaunchAPPL/Server/LauncherIcon.r b/LaunchAPPL/Server/LauncherIcon.r index a1c45eea86..4fc1f9e3df 100644 --- a/LaunchAPPL/Server/LauncherIcon.r +++ b/LaunchAPPL/Server/LauncherIcon.r @@ -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" +}; + diff --git a/LaunchAPPL/Server/StatusDisplay.cc b/LaunchAPPL/Server/StatusDisplay.cc index 4c1933f6d1..b3b1acf299 100644 --- a/LaunchAPPL/Server/StatusDisplay.cc +++ b/LaunchAPPL/Server/StatusDisplay.cc @@ -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); diff --git a/LaunchAPPL/Server/StatusDisplay.h b/LaunchAPPL/Server/StatusDisplay.h index 7f0559faae..c6b05d1372 100644 --- a/LaunchAPPL/Server/StatusDisplay.h +++ b/LaunchAPPL/Server/StatusDisplay.h @@ -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);