Added speaker toggle

This commit is contained in:
Marcio T 2021-12-04 17:33:52 -07:00
parent 5ab24df256
commit 1af5e74aea
6 changed files with 79 additions and 36 deletions

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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
*******************************************************************************/

View File

@ -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
*******************************************************************************/

View File

@ -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}
};