From 1af5e74aea56b86a11d8e58a0ec25ff31db75c3d Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sat, 4 Dec 2021 17:33:52 -0700 Subject: [PATCH] Added speaker toggle --- mac-cpp-source/Iomega Tester.rsrc.bin | Bin 3456 -> 3968 bytes mac-cpp-source/macos/text_box.cpp | 3 ++ mac-cpp-source/tip/tip.cpp | 32 ++++--------------- mac-cpp-source/tip/tip.h | 8 +++++ mac-cpp-source/tip/tip_main.cpp | 44 ++++++++++++++++++++------ mac-cpp-source/tip/tip_text.cpp | 28 +++++++++++++++- 6 files changed, 79 insertions(+), 36 deletions(-) diff --git a/mac-cpp-source/Iomega Tester.rsrc.bin b/mac-cpp-source/Iomega Tester.rsrc.bin index 8bf07a3ec933f86998abf9798a551dd640943630..609bbe1f49d83d6a52bc409853300f051ee17fbf 100644 GIT binary patch delta 794 zcmY*XL2DE-6n>d8Zr$$eEC^NF!VYV}f?zKTdJrkat|+=lQB?3Iq802#@Y2I%`wJ?) zcoFyRLB+!AZA85lnE?-8hAyR)Vg>h51_B-9m&9pphU9zid*6F6$wZ8a`tsd#)vfgF z#d~Qo_nL^F%v@;;;QwQ(GrpjGhUr}uiFi;*gB-kY7^Sui?TohUV& zhzTa#sMPm2>YL%V>f`&Z`eDDm?QfPgT*OgBPk(>~Bh3wX^|eSFNgBlzlULiL*ds4t zKoC()fqg*9C$=|;A&YAHAWqXfVLCv5t`m^&CnkX?Pjvwh>ub6o2-~P=eE3JZ;^Xe| zQK-h*!pe!t)NMxJ=I=jk;yr8uPXYhTv@c!5qZoO3bN&Xf(VClW5o2es&$e&DZ{b)~ zROn(7bd_%rd}vymHC@r$wYGB}{0nOzxd6UP9jz}f r!v1A>K5gn4e)zL1R=@w_zd*BU^}`|R3|YQ>+UT)|lis7}XKH@|OE~ve delta 277 zcmZpWZ;+l4Y0mTQ?oqp#yJv2iF)%RXI(hmv0BK~<)Y#7n;xhsC@JpNkKW z{*)e)833gJxdpkpF)%W6`MUar0!>$9Xkg$2iZ5VZWR}Cw2xKuZ+yJr*7@8QQf$Uez zi%eZ6XYwid02w+A4gdc$FtBlem4VreCO~luh&Yo4LY&10Xov?yoYeuS<_45~gn5z4 JmdQW)$^qiiM(F?m diff --git a/mac-cpp-source/macos/text_box.cpp b/mac-cpp-source/macos/text_box.cpp index 53686d9..a5df93d 100644 --- a/mac-cpp-source/macos/text_box.cpp +++ b/mac-cpp-source/macos/text_box.cpp @@ -130,6 +130,9 @@ bool TBMouseDown( TBHandle tb, Point where, WindowPtr whichWindow ) { HLock( (Handle) tb ); TBRec &my = **tb; + // Return if hidden + if((*my.scroll)->contrlVis == 0) return 0; + ControlHandle whichCntl; short partCode = FindControl(where, whichWindow, &whichCntl); if (partCode) { diff --git a/mac-cpp-source/tip/tip.cpp b/mac-cpp-source/tip/tip.cpp index f1eb586..f0dfea7 100644 --- a/mac-cpp-source/tip/tip.cpp +++ b/mac-cpp-source/tip/tip.cpp @@ -8,17 +8,6 @@ #include "tip.h" -// ----------------------- Test Monitor Panel Definitions ------------------- -#define SET_RECT(LEFT, TOP, RIGHT, BOTTOM) {TOP, LEFT, BOTTOM, RIGHT} - -Rect CS_Stat = SET_RECT(114, 8, 242, 28); -Rect TP_Perc = SET_RECT( 12, 56, 409, 72); -Rect SS_Jaz = SET_RECT( 12, 94, 409, 126); -Rect SS_Sid0 = SET_RECT( 12, 94, 409, 110); -Rect TL_Sect = SET_RECT( 75, 154, 203, 170); -Rect ES_Read = SET_RECT(346, 154, 409, 170); -Rect SE_Rect = SET_RECT(222, 154, 255, 221); - /******************************************************************************* * WinMain * @@ -110,18 +99,6 @@ void WndProc(long iMessage, uint16_t wParam) { } } -BtnList tipBtns[] = { - {IDB_BACK, szBack, 157, 301, 80, 24}, - {IDB_NEXT, szNext, 236, 301, 80, 24}, - {IDB_QUIT, szQuit, 402, 301, 45, 24}, - // For Mac TIP only - {IDB_TEST, szPressToStart, 157, 301, 150, 24}, - {IDB_EXPL, "Explain", 330, 301, 60, 24}, - {IDB_OKAY, "Okay", 380, 301, 65, 24}, - {IDB_READ, "Open in SimpleText...", 210, 301, 160, 24}, - {0, 0, 0, 0, 0, 0} -}; - /******************************************************************************* * SUNKEN FIELDS *******************************************************************************/ @@ -369,7 +346,10 @@ void TestMonitorWndProc() { PaintTextArray(TestGrayText, GRAY_COLOR); PaintTestPhase(); - // TODO: paint the little speaker icon + // paint the little speaker icon + Rect theRect; + SetRect(&theRect, 232, 191, 232+16, 191+16); + PlotIconID(&theRect, atTopLeft, 0, 129); } /******************************************************************************* @@ -436,5 +416,7 @@ void AllowProgramExit() { *******************************************************************************/ void ErrorSound() { - SysBeep(10); + if(SendMessage(hSoundCheckbox, BM_GETCHECK) == BST_CHECKED) { + SysBeep(10); + } } diff --git a/mac-cpp-source/tip/tip.h b/mac-cpp-source/tip/tip.h index a6e9831..c5ef944 100644 --- a/mac-cpp-source/tip/tip.h +++ b/mac-cpp-source/tip/tip.h @@ -74,6 +74,8 @@ enum { #define WM_COMMAND 2 #define SW_SHOW 1 #define SW_HIDE 2 +#define BM_GETCHECK 1 +#define BST_CHECKED 1 void SetRGBColor(long color, RGBColor *rgbColor); void SetColor(long color); @@ -91,6 +93,7 @@ void SetWindowText(int id, const char *str); void EnableWindow(int id, bool enabled); void ShowWindow(ControlHandle hCntl, int state); void ShowWindow(int id, int state); +long SendMessage(int id, int msg); void InvalidateRect(int id); void Rectangle(int left, int top, int right, int bottom); void DrawEdge(Rect *qrc, int edge, int grfFlags); @@ -221,6 +224,7 @@ extern const char *szQuit; #define IDB_EXPL 0xFF04 #define IDB_OKAY 0xFF05 #define IDB_READ 0xFF06 +#define IDB_BEEP 0xFF07 enum { hDefault, @@ -228,6 +232,7 @@ enum { hTestMonitor, hTestButton = IDB_TEST, hExitButton = IDB_QUIT, + hSoundCheckbox, // Extras added by MLT hExplainWnd = IDB_EXPL }; @@ -239,10 +244,13 @@ typedef struct { int y; int w; int h; + int type; ControlHandle hndl; } BtnList; extern BtnList tipBtns[]; +extern Rect CS_Stat, TP_Perc, SS_Jaz, SS_Sid0, TL_Sect, ES_Read, SE_Rect; + /******************************************************************************* * FUNCTION PROTOTYPES *******************************************************************************/ diff --git a/mac-cpp-source/tip/tip_main.cpp b/mac-cpp-source/tip/tip_main.cpp index 1b20221..fd58e17 100644 --- a/mac-cpp-source/tip/tip_main.cpp +++ b/mac-cpp-source/tip/tip_main.cpp @@ -43,7 +43,7 @@ void DoMouseDown(EventRecord &event); void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion); void DoDiskEvent(EventRecord &event); void SetPage(TipPage page); -ControlHandle FindControl(int id); +ControlHandle FindCntlHandle(int id); OSErr GetExplanationFSSpec(const char *name, FSSpec *docSpec); void OpenExplanationInSimpleText(); @@ -131,9 +131,11 @@ void NewTipWindow() { tipBtns[i].y + tipBtns[i].h - mainWndOrigin.v ); StrToPascal(title, tipBtns[i].name); - tipBtns[i].hndl = NewControl(tipWindow, &rect, title, false, 0, 0, 0, 0, tipBtns[i].id); + tipBtns[i].hndl = NewControl(tipWindow, &rect, title, false, 0, 0, 1, tipBtns[i].type, tipBtns[i].id); } + SetControlValue(FindCntlHandle(IDB_BEEP),1); // Check the sound control + page = kExplainPage; GetDC(hExplainWnd); @@ -176,7 +178,7 @@ void DisposeTipWindow() { DisposeWindow(tipWindow); } -ControlHandle FindControl(int id) { +ControlHandle FindCntlHandle(int id) { for(int i = 0; tipBtns[i].name; i++) { if (tipBtns[i].id == id) return tipBtns[i].hndl; @@ -309,11 +311,12 @@ void DoMouseDown(EventRecord &event) { GetPort(&oldPort); SetPort(thisWindow); GlobalToLocal(&mouse); - const bool hitButton = (!TBMouseDown(richText, mouse, thisWindow)) && - (FindControl(mouse, thisWindow, &thisControl) == inButton) && - (TrackControl(thisControl, mouse, 0) == inButton); + int part; + const bool hitCntl = (!TBMouseDown(richText, mouse, thisWindow)) && + (FindControl(mouse, thisWindow, &thisControl)) && + (part = TrackControl(thisControl, mouse, 0)); SetPort(oldPort); - if(hitButton) { + if(hitCntl && (part == inButton) || (part == inCheckBox)) { int id = GetControlReference(thisControl); switch(id) { case IDB_OKAY: @@ -325,6 +328,12 @@ void DoMouseDown(EventRecord &event) { case IDB_READ: OpenExplanationInSimpleText(); break; + case IDB_BEEP: + SetPort(thisWindow); + SetControlValue(thisControl, 1 - GetControlValue(thisControl)); + SetPort(oldPort); + printf("Value: %d\n", GetControlValue(thisControl)); + break; default: WndProc(WM_COMMAND, id); break; @@ -407,6 +416,7 @@ void SetPage(TipPage newPage) { ShowWindow(IDB_TEST, SW_SHOW); ShowWindow(IDB_EXPL, SW_SHOW); ShowWindow(IDB_QUIT, SW_SHOW); + ShowWindow(IDB_BEEP, SW_SHOW); break; case kExplainPage: ShowWindow(IDB_TEST, SW_HIDE); @@ -414,6 +424,7 @@ void SetPage(TipPage newPage) { ShowWindow(IDB_NEXT, SW_HIDE); ShowWindow(IDB_EXPL, SW_HIDE); ShowWindow(IDB_QUIT, SW_HIDE); + ShowWindow(IDB_BEEP, SW_HIDE); ShowWindow(IDB_OKAY, SW_SHOW); ShowWindow(IDB_READ, SW_SHOW); ShowWindow((*richText)->scroll, SW_SHOW); @@ -703,7 +714,7 @@ unsigned long GetSystemTime() { void SetWindowText(int id, const char *str) { Str255 pStr; StrToPascal(pStr, str); - ControlHandle hCntl = FindControl(id); + ControlHandle hCntl = FindCntlHandle(id); if(hCntl) { GetDC(hDefault); SetCTitle(hCntl, pStr); @@ -715,7 +726,7 @@ void SetWindowText(int id, const char *str) { * ENABLE WINDOW *******************************************************************************/ void EnableWindow(int id, bool enabled) { - ControlHandle hCntl = FindControl(id); + ControlHandle hCntl = FindCntlHandle(id); if(hCntl) { GetDC(hDefault); HiliteControl(hCntl, enabled ? 0 : 255); @@ -733,7 +744,7 @@ void ShowWindow(ControlHandle hCntl, int state) { } void ShowWindow(int id, int state) { - ControlHandle hCntl = FindControl(id); + ControlHandle hCntl = FindCntlHandle(id); if(hCntl) { GetDC(hDefault); ShowWindow(hCntl, state); @@ -741,6 +752,19 @@ void ShowWindow(int id, int state) { } } +/******************************************************************************* + * SEND MESSAGE + *******************************************************************************/ +long SendMessage(int id, int msg) { + if(msg == BM_GETCHECK) { + ControlHandle hCntl = FindCntlHandle(id); + if(hCntl) { + return GetControlValue(hCntl) ? BST_CHECKED: 0; + } + } + return 0; +} + /******************************************************************************* * INVALIDATE RECT *******************************************************************************/ diff --git a/mac-cpp-source/tip/tip_text.cpp b/mac-cpp-source/tip/tip_text.cpp index 77c0085..ef6408b 100644 --- a/mac-cpp-source/tip/tip_text.cpp +++ b/mac-cpp-source/tip/tip_text.cpp @@ -162,7 +162,33 @@ TextList TestGrayText[] = { {155, 39, "Testing Progress"}, {129, 77, "Spare Sectors Consumed"}, {61, 135, "Testing Location"}, - /*{219, 135, "Sound"},*/ + {219, 135, "Sound"}, {297, 135, "Error Summary"}, {0,0,0} }; + + +// ----------------------- Test Monitor Panel Definitions ------------------- + +#define SET_RECT(LEFT, TOP, RIGHT, BOTTOM) {TOP, LEFT, BOTTOM, RIGHT} + +Rect CS_Stat = SET_RECT(114, 8, 242, 28); +Rect TP_Perc = SET_RECT( 12, 56, 409, 72); +Rect SS_Jaz = SET_RECT( 12, 94, 409, 126); +Rect SS_Sid0 = SET_RECT( 12, 94, 409, 110); +Rect TL_Sect = SET_RECT( 75, 154, 203, 170); +Rect ES_Read = SET_RECT(346, 154, 409, 170); +Rect SE_Rect = SET_RECT(222, 154, 255, 221); + +BtnList tipBtns[] = { + {IDB_BACK, szBack, 157, 301, 80, 24}, + {IDB_NEXT, szNext, 236, 301, 80, 24}, + {IDB_QUIT, szQuit, 402, 301, 45, 24}, + {IDB_BEEP, "", 252, 211, 22, 22, checkBoxProc}, + // For Mac TIP only + {IDB_TEST, szPressToStart, 157, 301, 150, 24}, + {IDB_EXPL, "Explain", 330, 301, 60, 24}, + {IDB_OKAY, "Okay", 380, 301, 65, 24}, + {IDB_READ, "Open in SimpleText...", 210, 301, 160, 24}, + {0, 0, 0, 0, 0, 0} +}; \ No newline at end of file