mirror of
https://github.com/marciot/mac-tip.git
synced 2025-01-14 16:33:00 +00:00
Integrated help viewer.
This commit is contained in:
parent
74390a77fb
commit
be412c5782
@ -27,6 +27,7 @@ void main() {
|
|||||||
|
|
||||||
SIOUXSetTitle("\pIomega Tester Beta (" __DATE__ ")");
|
SIOUXSetTitle("\pIomega Tester Beta (" __DATE__ ")");
|
||||||
|
|
||||||
|
|
||||||
print_help();
|
print_help();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
1
mac-cpp-source/macos/text_box.cpp
Normal file
1
mac-cpp-source/macos/text_box.cpp
Normal file
File diff suppressed because one or more lines are too long
1
mac-cpp-source/macos/text_box.h
Normal file
1
mac-cpp-source/macos/text_box.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
/************************************************************
Text Box.h
AUTHOR: Marcio Luis Teixeira
CREATED: 3/16/95
LAST REVISION: 11/29/2021
(c) 1994-2021 by Marcio Luis Teixeira.
All rights reserved.
*************************************************************/
#include "ctype.h"
typedef struct {
TEHandle tbox;
Rect frame;
ControlHandle scroll;
short lastV;
short maxV;
} TBRec, *TBPtr, **TBHandle;
TBHandle TBNew( WindowPtr wind, const Rect *r );
void TBDispose( TBHandle html );
void TBUpdate( TBHandle html );
void TBResize( TBHandle html, const Rect *r );
void TBSetScroll( TBHandle html, short scroll );
bool TBMouseDown( TBHandle html, Point where, WindowPtr whichWindow );
OSErr TBReadSimpleText( TBHandle tb, const FSSpec *docSpec);
|
@ -28,6 +28,11 @@ void WinMain(int Device) {
|
|||||||
CurrentDevice = Device;
|
CurrentDevice = Device;
|
||||||
// test for an Iomega device
|
// test for an Iomega device
|
||||||
EnumerateIomegaDevices(CurrentDevice);
|
EnumerateIomegaDevices(CurrentDevice);
|
||||||
|
// Disable testing button when no drives present (added by mlt)
|
||||||
|
if (!DriveCount) {
|
||||||
|
EnableWindow(hTestButton, false);
|
||||||
|
SetRichEditText(szASPITrouble);
|
||||||
|
}
|
||||||
// now startup the timer for real-time features
|
// now startup the timer for real-time features
|
||||||
StartApplicationTimer();
|
StartApplicationTimer();
|
||||||
}
|
}
|
||||||
@ -37,7 +42,7 @@ void WinMain(int Device) {
|
|||||||
*
|
*
|
||||||
* This is the system's main window procedure
|
* This is the system's main window procedure
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void WndProc(long iMessage, long wParam) {
|
void WndProc(long iMessage, uint16_t wParam) {
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// WM_PAINT
|
// WM_PAINT
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@ -102,11 +107,15 @@ void WndProc(long iMessage, long wParam) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BtnList tipBtns[] = {
|
BtnList tipBtns[] = {
|
||||||
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
|
{IDB_BACK, szBack, 157, 301, 80, 24},
|
||||||
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
|
{IDB_NEXT, szNext, 236, 301, 80, 24},
|
||||||
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
|
{IDB_QUIT, szQuit, 402, 301, 45, 24},
|
||||||
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
|
// For Mac TIP only
|
||||||
{0, 0, 0, 0, 0, 0, 0}
|
{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}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
|
#include "ctype.h"
|
||||||
typedef Boolean bool;
|
|
||||||
|
|
||||||
extern WindowPtr tipWindow;
|
extern WindowPtr tipWindow;
|
||||||
|
|
||||||
@ -38,25 +37,27 @@ extern long SingleTransferLBA;
|
|||||||
// ----------------------- Macintosh Compatibility -----------------------
|
// ----------------------- Macintosh Compatibility -----------------------
|
||||||
|
|
||||||
enum AlertTypes {
|
enum AlertTypes {
|
||||||
ERR_DLG,
|
ERR_DLG,
|
||||||
YN_DLG
|
YN_DLG
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BACK_COLOR = -1,
|
BACK_COLOR = -1,
|
||||||
BLACK_COLOR = 0x000000,
|
BLACK_COLOR = 0x000000,
|
||||||
LTGRAY_COLOR = 0xc0c0c0,
|
LTGRAY_COLOR = 0xc0c0c0,
|
||||||
GRAY_COLOR = 0x808080,
|
GRAY_COLOR = 0x808080,
|
||||||
WHITE_COLOR = 0xffffff,
|
WHITE_COLOR = 0xffffff,
|
||||||
BLUE_COLOR = 0x0000ff,
|
BLUE_COLOR = 0x0000ff,
|
||||||
RED_COLOR = 0xff0000,
|
RED_COLOR = 0xff0000,
|
||||||
GREEN_COLOR = 0x00ff00,
|
GREEN_COLOR = 0x00ff00,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BDR_SUNKENOUTER 1
|
#define BDR_SUNKENOUTER 1
|
||||||
#define BF_RECT 1
|
#define BF_RECT 1
|
||||||
#define WM_PAINT 1
|
#define WM_PAINT 1
|
||||||
#define WM_COMMAND 2
|
#define WM_COMMAND 2
|
||||||
|
#define SW_SHOW 1
|
||||||
|
#define SW_HIDE 2
|
||||||
|
|
||||||
void SetColor(long color);
|
void SetColor(long color);
|
||||||
void SetColor(long color, long monoColor);
|
void SetColor(long color, long monoColor);
|
||||||
@ -70,6 +71,7 @@ void TextOut(int x, int y, const char *str);
|
|||||||
void TextOutCentered(int x, int y, int w, int h, const char *str);
|
void TextOutCentered(int x, int y, int w, int h, const char *str);
|
||||||
void SetWindowText(int id, const char *str);
|
void SetWindowText(int id, const char *str);
|
||||||
void EnableWindow(int id, bool enabled);
|
void EnableWindow(int id, bool enabled);
|
||||||
|
void ShowWindow(int id, int state);
|
||||||
void InvalidateRect(int id);
|
void InvalidateRect(int id);
|
||||||
void Rectangle(int left, int top, int right, int bottom);
|
void Rectangle(int left, int top, int right, int bottom);
|
||||||
void DrawEdge(Rect *qrc, int edge, int grfFlags);
|
void DrawEdge(Rect *qrc, int edge, int grfFlags);
|
||||||
@ -77,45 +79,44 @@ void StartApplicationTimer();
|
|||||||
void StopApplicationTimer();
|
void StopApplicationTimer();
|
||||||
void PostQuitMessage();
|
void PostQuitMessage();
|
||||||
unsigned long GetSystemTime();
|
unsigned long GetSystemTime();
|
||||||
|
bool PrepareDC(int which);
|
||||||
|
|
||||||
#define GetDC(h) {GrafPtr oldPort; \
|
#define GetDC(h) {GrafPtr oldPort; \
|
||||||
GetPort(&oldPort); \
|
GetPort(&oldPort); \
|
||||||
SetPort(tipWindow); \
|
if(PrepareDC(h)) {
|
||||||
if(h == hTestMonitor) SetOrigin(-20, -10); \
|
|
||||||
if(h == hMainWnd) SetOrigin(0, 40);
|
|
||||||
|
|
||||||
#define ReleaseDC(h) SetOrigin(0,0); \
|
#define ReleaseDC(h) } SetOrigin(0,0); \
|
||||||
SetPort(oldPort);}
|
SetPort(oldPort);}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------ Cartridge Status -------------------------------
|
// ------------------------------ Cartridge Status -------------------------------
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DISK_STATUS_UNKNOWN = 1,
|
DISK_STATUS_UNKNOWN = 1,
|
||||||
DISK_AT_SPEED = 2,
|
DISK_AT_SPEED = 2,
|
||||||
DISK_SPINNING_UP = 3,
|
DISK_SPINNING_UP = 3,
|
||||||
DISK_NOT_PRESENT = 4,
|
DISK_NOT_PRESENT = 4,
|
||||||
DISK_SPUN_DOWN = 5,
|
DISK_SPUN_DOWN = 5,
|
||||||
DISK_STALLED = 6,
|
DISK_STALLED = 6,
|
||||||
DISK_Z_TRACK_FAILURE = 7,
|
DISK_Z_TRACK_FAILURE = 7,
|
||||||
DISK_PROTECTED = 8,
|
DISK_PROTECTED = 8,
|
||||||
DISK_LOW_SPARES = 9,
|
DISK_LOW_SPARES = 9,
|
||||||
DISK_TEST_UNDERWAY = 10,
|
DISK_TEST_UNDERWAY = 10,
|
||||||
DISK_TEST_FAILURE = 11,
|
DISK_TEST_FAILURE = 11,
|
||||||
|
|
||||||
LAST_CART_STATUS = 11
|
LAST_CART_STATUS = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------- Testing Phase Status -----------------------------
|
// ---------------------------- Testing Phase Status -----------------------------
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
UNTESTED = 0,
|
UNTESTED = 0,
|
||||||
READY_TO_TEST = 1,
|
READY_TO_TEST = 1,
|
||||||
TESTING_STARTUP = 2,
|
TESTING_STARTUP = 2,
|
||||||
READING_DATA = 3,
|
READING_DATA = 3,
|
||||||
WRITING_PATT = 4,
|
WRITING_PATT = 4,
|
||||||
READING_PATT = 5,
|
READING_PATT = 5,
|
||||||
WRITING_DATA = 6
|
WRITING_DATA = 6
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -195,18 +196,31 @@ extern const char *szNext;
|
|||||||
extern const char *szQuit;
|
extern const char *szQuit;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
hMainWnd,
|
hMainWnd,
|
||||||
hTestMonitor,
|
hTestMonitor,
|
||||||
hTestButton,
|
hTestButton,
|
||||||
hExitButton
|
hExitButton,
|
||||||
|
// Extras added by MLT
|
||||||
|
hExplainWnd
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IDB_BACK 0xFF00
|
#define IDB_BACK 0xFF00
|
||||||
#define IDB_NEXT 0xFF01
|
#define IDB_NEXT 0xFF01
|
||||||
#define IDB_QUIT 0xFF02
|
#define IDB_QUIT 0xFF02
|
||||||
#define IDB_TEST 0xFF03
|
#define IDB_TEST 0xFF03
|
||||||
|
#define IDB_EXPL 0xFF04
|
||||||
|
#define IDB_OKAY 0xFF05
|
||||||
|
#define IDB_READ 0xFF06
|
||||||
|
|
||||||
typedef struct {long id; const char *name; int x; int y; int w; int h; bool visible;} BtnList;
|
typedef struct {
|
||||||
|
int id;
|
||||||
|
const char *name;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
ControlHandle hndl;
|
||||||
|
} BtnList;
|
||||||
extern BtnList tipBtns[];
|
extern BtnList tipBtns[];
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -233,7 +247,7 @@ void AllowProgramExit();
|
|||||||
void ErrorSound();
|
void ErrorSound();
|
||||||
void ProcessPendingMessages();
|
void ProcessPendingMessages();
|
||||||
void WinMain(int Device);
|
void WinMain(int Device);
|
||||||
void WndProc(long iMessage, long wParam);
|
void WndProc(long iMessage, uint16_t wParam);
|
||||||
void TestMonitorWndProc();
|
void TestMonitorWndProc();
|
||||||
void ApplicationTimerProc();
|
void ApplicationTimerProc();
|
||||||
void TestButtonClicked();
|
void TestButtonClicked();
|
||||||
|
@ -107,7 +107,7 @@ long Side_1_SparesCount; // ZIP has counts for both sides
|
|||||||
long Initial_Side_0_Spares;
|
long Initial_Side_0_Spares;
|
||||||
long Initial_Side_1_Spares;
|
long Initial_Side_1_Spares;
|
||||||
|
|
||||||
long TestingPhase; // 0 = not testing, no data ...
|
long TestingPhase = 0; // 0 = not testing, no data ...
|
||||||
long PercentComplete;
|
long PercentComplete;
|
||||||
long FirstLBASector;
|
long FirstLBASector;
|
||||||
long NumberOfLBAs;
|
long NumberOfLBAs;
|
||||||
@ -523,12 +523,6 @@ void SetCartridgeStatusToEAX(long eax) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LastCartridgeStatus = CartridgeStatus;
|
LastCartridgeStatus = CartridgeStatus;
|
||||||
// Disable testing button when no drives present
|
|
||||||
if (!DriveCount) {
|
|
||||||
// MLT: Added this check.
|
|
||||||
SetRichEditText(szASPITrouble);
|
|
||||||
goto DisableActions;
|
|
||||||
}
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
// Set the text of the "action initiate button"
|
// Set the text of the "action initiate button"
|
||||||
@ -544,7 +538,7 @@ void SetCartridgeStatusToEAX(long eax) {
|
|||||||
esi = szPressToStop;
|
esi = szPressToStop;
|
||||||
break;
|
break;
|
||||||
case DISK_NOT_PRESENT:
|
case DISK_NOT_PRESENT:
|
||||||
//SetRichEditText(szNotRunning);
|
SetRichEditText(szNotRunning);
|
||||||
goto DisableActions;
|
goto DisableActions;
|
||||||
case DISK_AT_SPEED:
|
case DISK_AT_SPEED:
|
||||||
eax = GetSpareSectorCounts(true); // update the Cart Condition
|
eax = GetSpareSectorCounts(true); // update the Cart Condition
|
||||||
@ -813,7 +807,7 @@ void TestTheDisk() {
|
|||||||
StopApplicationTimer();
|
StopApplicationTimer();
|
||||||
|
|
||||||
PreventProgramExit();
|
PreventProgramExit();
|
||||||
//SetRichEditText(szRunning);
|
SetRichEditText(szRunning);
|
||||||
CartridgeStatus = DISK_TEST_UNDERWAY;
|
CartridgeStatus = DISK_TEST_UNDERWAY;
|
||||||
TestingPhase = TESTING_STARTUP; // inhibit stopping now
|
TestingPhase = TESTING_STARTUP; // inhibit stopping now
|
||||||
SetWindowText(hTestButton, szPressToStop);
|
SetWindowText(hTestButton, szPressToStop);
|
||||||
|
@ -11,44 +11,63 @@
|
|||||||
#include "pstring.h"
|
#include "pstring.h"
|
||||||
#include "LaunchLib.h"
|
#include "LaunchLib.h"
|
||||||
#include "mac_vol.h"
|
#include "mac_vol.h"
|
||||||
|
#include "text_box.h"
|
||||||
#include "tip.h"
|
#include "tip.h"
|
||||||
|
|
||||||
WindowPtr tipWindow;
|
enum TipPage {
|
||||||
|
kTestingPage,
|
||||||
|
kExplainPage,
|
||||||
|
} page;
|
||||||
|
|
||||||
static int gDone;
|
static int gDone;
|
||||||
static bool AllowColor;
|
static bool allowColor;
|
||||||
static bool timerEnabled = true;
|
static bool inited = false;
|
||||||
static ControlHandle testBtn = 0;
|
static bool timerEnabled = false;
|
||||||
static ControlHandle exitBtn = 0;
|
static WindowPtr tipWindow;
|
||||||
|
static TBHandle richText;
|
||||||
|
static const char *textFileName;
|
||||||
|
|
||||||
void NewTipWindow();
|
void NewTipWindow();
|
||||||
void DestroyTipWindow();
|
void DisposeTipWindow();
|
||||||
void DoEvent(EventRecord &event, RgnHandle *cursorRgn);
|
void DoEvent(EventRecord &event, RgnHandle *cursorRgn);
|
||||||
void DoUpdate(WindowPtr window);
|
void DoUpdate(WindowPtr window);
|
||||||
void DoMouseDown(EventRecord &event);
|
void DoMouseDown(EventRecord &event);
|
||||||
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
|
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
|
||||||
void DoDiskEvent(EventRecord &event);
|
void DoDiskEvent(EventRecord &event);
|
||||||
|
void SetPage(TipPage page);
|
||||||
|
ControlHandle FindControl(int id);
|
||||||
|
OSErr GetExplanationFSSpec(const char *name, FSSpec *docSpec);
|
||||||
|
void OpenExplanationInSimpleText();
|
||||||
|
|
||||||
|
#define SET_POINT(x,y) {y,x};
|
||||||
|
|
||||||
|
const Point mainWndOrigin = SET_POINT(0, 40);
|
||||||
|
|
||||||
void run_tip(int id) {
|
void run_tip(int id) {
|
||||||
WinMain(id);
|
|
||||||
RgnHandle cursorRgn = NewRgn();
|
RgnHandle cursorRgn = NewRgn();
|
||||||
|
|
||||||
SetRichEditText(szInstructions);
|
|
||||||
NewTipWindow();
|
NewTipWindow();
|
||||||
EnableWindow(hTestButton, false);
|
EnableWindow(hTestButton, false);
|
||||||
|
SetRichEditText(szInstructions);
|
||||||
|
|
||||||
gDone = false;
|
gDone = false;
|
||||||
do {
|
do {
|
||||||
EventRecord event;
|
EventRecord event;
|
||||||
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
|
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), cursorRgn)) {
|
||||||
DoEvent(event, &cursorRgn);
|
DoEvent(event, &cursorRgn);
|
||||||
|
if(!inited && page == kTestingPage) {
|
||||||
|
printf("Starting tip\n");
|
||||||
|
// Start TIP as soon as the user dismisses the intro screen
|
||||||
|
inited = true;
|
||||||
|
WinMain(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(timerEnabled) {
|
if(timerEnabled) {
|
||||||
ApplicationTimerProc();
|
ApplicationTimerProc();
|
||||||
}
|
}
|
||||||
} while (!gDone);
|
} while (!gDone);
|
||||||
|
|
||||||
DestroyTipWindow();
|
DisposeTipWindow();
|
||||||
DisposeRgn(cursorRgn);
|
DisposeRgn(cursorRgn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,56 +76,83 @@ void NewTipWindow() {
|
|||||||
SysEnvRec theWorld;
|
SysEnvRec theWorld;
|
||||||
|
|
||||||
error = SysEnvirons(1, &theWorld);
|
error = SysEnvirons(1, &theWorld);
|
||||||
AllowColor = theWorld.hasColorQD;
|
allowColor = theWorld.hasColorQD;
|
||||||
|
|
||||||
|
const int wndHeight = 336 - 35;
|
||||||
|
const int wndWidth = 467;
|
||||||
|
|
||||||
Rect rect = qd.screenBits.bounds;
|
Rect rect = qd.screenBits.bounds;
|
||||||
rect.left = 8;
|
rect.left = 8;
|
||||||
rect.top = GetMBarHeight() + rect.left + 16;
|
rect.top = GetMBarHeight() + rect.left + 16;
|
||||||
rect.bottom = rect.top + 336 - 35;
|
rect.bottom = rect.top + wndHeight;
|
||||||
rect.right = rect.left + 467;
|
rect.right = rect.left + wndWidth;
|
||||||
|
|
||||||
Str255 title;
|
Str255 title;
|
||||||
StrToPascal(title, szWindowTitle);
|
StrToPascal(title, szWindowTitle);
|
||||||
tipWindow = AllowColor ?
|
tipWindow = allowColor ?
|
||||||
NewCWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0) :
|
NewCWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0) :
|
||||||
NewWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0);
|
NewWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0);
|
||||||
|
|
||||||
GetDC(hMainWnd);
|
GetDC(hMainWnd);
|
||||||
|
|
||||||
if (AllowColor) {
|
|
||||||
SetColor(BACK_COLOR);
|
|
||||||
RGBColor bgColor;
|
|
||||||
GetForeColor(&bgColor);
|
|
||||||
RGBBackColor(&bgColor);
|
|
||||||
}
|
|
||||||
TextSize(10);
|
TextSize(10);
|
||||||
|
|
||||||
|
// Create the controls
|
||||||
|
|
||||||
for(int i = 0; tipBtns[i].name; i++) {
|
for(int i = 0; tipBtns[i].name; i++) {
|
||||||
if (!tipBtns[i].visible) continue;
|
|
||||||
SetRect(&rect,
|
SetRect(&rect,
|
||||||
tipBtns[i].x,
|
tipBtns[i].x,
|
||||||
tipBtns[i].y,
|
tipBtns[i].y - mainWndOrigin.v,
|
||||||
tipBtns[i].x + tipBtns[i].w,
|
tipBtns[i].x + tipBtns[i].w,
|
||||||
tipBtns[i].y + tipBtns[i].h
|
tipBtns[i].y + tipBtns[i].h - mainWndOrigin.v
|
||||||
);
|
);
|
||||||
|
|
||||||
StrToPascal(title, tipBtns[i].name);
|
StrToPascal(title, tipBtns[i].name);
|
||||||
ControlHandle h = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
|
tipBtns[i].hndl = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
|
||||||
if(tipBtns[i].id == IDB_TEST) {
|
|
||||||
testBtn = h;
|
|
||||||
}
|
|
||||||
if(tipBtns[i].id == IDB_QUIT) {
|
|
||||||
exitBtn = h;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseDC(hMainWnd);
|
ReleaseDC(hMainWnd);
|
||||||
|
|
||||||
|
page = kExplainPage;
|
||||||
|
GetDC(hExplainWnd);
|
||||||
|
|
||||||
|
// Create the text edit widget
|
||||||
|
SetRect(&rect, 15, 15, 447, 250);
|
||||||
|
richText = TBNew(tipWindow, &rect);
|
||||||
|
|
||||||
|
ReleaseDC(hExplainWnd);
|
||||||
|
|
||||||
|
SetPage(kTestingPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DestroyTipWindow() {
|
void DisposeTipWindow() {
|
||||||
|
TBDispose(richText);
|
||||||
DisposeWindow(tipWindow);
|
DisposeWindow(tipWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlHandle FindControl(int id) {
|
||||||
|
for(int i = 0; tipBtns[i].name; i++) {
|
||||||
|
if (tipBtns[i].id == id)
|
||||||
|
return tipBtns[i].hndl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrepareDC(int which) {
|
||||||
|
SetPort(tipWindow);
|
||||||
|
switch(which) {
|
||||||
|
case hExplainWnd:
|
||||||
|
if(page != kExplainPage) return false;
|
||||||
|
break;
|
||||||
|
case hTestMonitor:
|
||||||
|
if(page != kTestingPage) return false;
|
||||||
|
SetOrigin(-20, -10);
|
||||||
|
break;
|
||||||
|
case hMainWnd:
|
||||||
|
SetOrigin(mainWndOrigin.h, mainWndOrigin.v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void DoEvent(EventRecord &event, RgnHandle *cursorRgn) {
|
void DoEvent(EventRecord &event, RgnHandle *cursorRgn) {
|
||||||
if(!SIOUXHandleOneEvent(&event)) {
|
if(!SIOUXHandleOneEvent(&event)) {
|
||||||
// If SIOUX didn't handle the event, then handle it ourselves
|
// If SIOUX didn't handle the event, then handle it ourselves
|
||||||
@ -117,23 +163,31 @@ void DoEvent(EventRecord &event, RgnHandle *cursorRgn) {
|
|||||||
case osEvt: DoMouseMove(event, cursorRgn); break;
|
case osEvt: DoMouseMove(event, cursorRgn); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoUpdate(WindowPtr window) {
|
void DoUpdate(WindowPtr window) {
|
||||||
BeginUpdate(window);
|
BeginUpdate(window);
|
||||||
SetPort(window);
|
SetPort(window);
|
||||||
EraseRect(&window->portRect);
|
SetColor(BACK_COLOR);
|
||||||
|
PaintRect(&window->portRect);
|
||||||
|
|
||||||
GetDC(hMainWnd);
|
GetDC(hMainWnd);
|
||||||
WndProc(WM_PAINT, 0);
|
WndProc(WM_PAINT, 0);
|
||||||
DrawControls(window);
|
|
||||||
ReleaseDC(hMainWnd);
|
ReleaseDC(hMainWnd);
|
||||||
|
|
||||||
GetDC(hTestMonitor);
|
GetDC(hTestMonitor);
|
||||||
TestMonitorWndProc();
|
TestMonitorWndProc();
|
||||||
ReleaseDC(hTestMonitor);
|
ReleaseDC(hTestMonitor);
|
||||||
|
|
||||||
|
GetDC(hExplainWnd);
|
||||||
|
SetColor(BLACK_COLOR);
|
||||||
|
EraseRect(&(*richText)->frame);
|
||||||
|
TBUpdate(richText);
|
||||||
|
DrawEdge(&(*richText)->frame, BDR_SUNKENOUTER, BF_RECT);
|
||||||
|
ReleaseDC(hExplainWnd);
|
||||||
|
|
||||||
|
UpdateControls(window, window->visRgn);
|
||||||
|
|
||||||
EndUpdate(window);
|
EndUpdate(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,24 +204,34 @@ void DoMouseDown(EventRecord &event) {
|
|||||||
SelectWindow(thisWindow);
|
SelectWindow(thisWindow);
|
||||||
}
|
}
|
||||||
else if(thisWindow == tipWindow) {
|
else if(thisWindow == tipWindow) {
|
||||||
long id = 0;
|
|
||||||
Point mouse = event.where;
|
Point mouse = event.where;
|
||||||
GetDC(hMainWnd);
|
GrafPtr oldPort;
|
||||||
|
GetPort(&oldPort);
|
||||||
|
SetPort(thisWindow);
|
||||||
GlobalToLocal(&mouse);
|
GlobalToLocal(&mouse);
|
||||||
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
|
const bool hitButton = (!TBMouseDown(richText, mouse, thisWindow)) &&
|
||||||
if(TrackControl(thisControl, mouse, 0) == inButton) {
|
(FindControl(mouse, thisWindow, &thisControl) == inButton) &&
|
||||||
id = GetControlReference(thisControl);
|
(TrackControl(thisControl, mouse, 0) == inButton);
|
||||||
|
SetPort(oldPort);
|
||||||
|
if(hitButton) {
|
||||||
|
int id = GetControlReference(thisControl);
|
||||||
|
switch(id) {
|
||||||
|
case IDB_OKAY:
|
||||||
|
SetPage(kTestingPage);
|
||||||
|
break;
|
||||||
|
case IDB_EXPL:
|
||||||
|
SetPage(kExplainPage);
|
||||||
|
break;
|
||||||
|
case IDB_READ:
|
||||||
|
OpenExplanationInSimpleText();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WndProc(WM_COMMAND, id);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReleaseDC(hMainWnd);
|
|
||||||
if(id) {
|
|
||||||
WndProc(WM_COMMAND, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case inDrag:
|
|
||||||
DragWindow(thisWindow, event.where, &(*GetGrayRgn())->rgnBBox);
|
|
||||||
break;
|
|
||||||
case inGrow:
|
case inGrow:
|
||||||
//DoGrowWindow(thisWindow, event);
|
//DoGrowWindow(thisWindow, event);
|
||||||
break;
|
break;
|
||||||
@ -222,6 +286,35 @@ void StrToPascal(Str255 pStr, const char *str) {
|
|||||||
strncpy((char*)pStr + 1, str, 255);
|
strncpy((char*)pStr + 1, str, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetPage(TipPage newPage) {
|
||||||
|
if(page == newPage) return;
|
||||||
|
page = newPage;
|
||||||
|
switch(page) {
|
||||||
|
case kTestingPage:
|
||||||
|
ShowWindow(IDB_TEST, SW_SHOW);
|
||||||
|
ShowWindow(IDB_BACK, SW_HIDE);
|
||||||
|
ShowWindow(IDB_NEXT, SW_HIDE);
|
||||||
|
ShowWindow(IDB_EXPL, SW_SHOW);
|
||||||
|
ShowWindow(IDB_OKAY, SW_HIDE);
|
||||||
|
ShowWindow(IDB_QUIT, SW_SHOW);
|
||||||
|
ShowWindow(IDB_READ, SW_HIDE);
|
||||||
|
HideControl((*richText)->scroll);
|
||||||
|
break;
|
||||||
|
case kExplainPage:
|
||||||
|
ShowWindow(IDB_TEST, SW_HIDE);
|
||||||
|
ShowWindow(IDB_BACK, SW_HIDE);
|
||||||
|
ShowWindow(IDB_NEXT, SW_HIDE);
|
||||||
|
ShowWindow(IDB_EXPL, SW_HIDE);
|
||||||
|
ShowWindow(IDB_OKAY, SW_SHOW);
|
||||||
|
ShowWindow(IDB_QUIT, SW_HIDE);
|
||||||
|
ShowWindow(IDB_READ, SW_SHOW);
|
||||||
|
ShowControl((*richText)->scroll);
|
||||||
|
TBSetScroll(richText, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
InvalidateRect(hMainWnd);
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SHOW ALERT BOX
|
* SHOW ALERT BOX
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -241,6 +334,55 @@ int ShowAlert(AlertTypes type, const char* format, ...) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* GET EXPLANATION FSSPEC
|
||||||
|
*
|
||||||
|
* Returns the FSSpec for an explanation file
|
||||||
|
*******************************************************************************/
|
||||||
|
OSErr GetExplanationFSSpec(const char *name, FSSpec *docSpec) {
|
||||||
|
Str255 docName;
|
||||||
|
StrToPascal(docName, name);
|
||||||
|
|
||||||
|
Str255 pathName;
|
||||||
|
pstrcpy(pathName, "\p:tip-doc:");
|
||||||
|
pstrcat(pathName, docName);
|
||||||
|
|
||||||
|
OSErr err = FSMakeFSSpec(0, 0, pathName, docSpec);
|
||||||
|
if(err) {
|
||||||
|
ShowAlert(ERR_DLG, "Can't find the \"%s\" file. Make sure it is inside the \"tip-doc\" folder.", name);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* OPEN EXPLANATION IN SIMPLE TEXT
|
||||||
|
*
|
||||||
|
* Opens the currently selected TIP explanation file using SimpleText
|
||||||
|
*
|
||||||
|
* This uses code from Thomas Tempelmann's C libraries
|
||||||
|
*
|
||||||
|
* http://www.tempel.org/macdev/index.html
|
||||||
|
*******************************************************************************/
|
||||||
|
void OpenExplanationInSimpleText() {
|
||||||
|
FSSpec docSpec;
|
||||||
|
FSSpec appSpec;
|
||||||
|
|
||||||
|
OSErr err = GetExplanationFSSpec(textFileName, &docSpec);
|
||||||
|
if(err != noErr) return;
|
||||||
|
|
||||||
|
err = FindApplicationFromDocument(&docSpec, &appSpec);
|
||||||
|
if(err) {
|
||||||
|
ShowAlert(ERR_DLG, "Can't find an application to open \"%s\". Is \"SimpleText\" installed?", textFileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = LaunchApplicationWithDocument(&appSpec, &docSpec, false);
|
||||||
|
if(err) {
|
||||||
|
ShowAlert(ERR_DLG, "Can't open \"%s\". If \"%#s\" is already running, please close it.", textFileName, appSpec.name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SET RICH EDIT TEXT
|
* SET RICH EDIT TEXT
|
||||||
*
|
*
|
||||||
@ -252,38 +394,28 @@ int ShowAlert(AlertTypes type, const char* format, ...) {
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
void SetRichEditText(const char *name) {
|
void SetRichEditText(const char *name) {
|
||||||
static const char *lastName = 0;
|
short fRefNum = 0;
|
||||||
if(name == lastName) return;
|
|
||||||
lastName = name;
|
|
||||||
|
|
||||||
if(ShowAlert(YN_DLG, "Would you like to read the document \"%s\" now?", name) == 2) {
|
// Don't reload a file that is already loaded
|
||||||
return;
|
|
||||||
}
|
|
||||||
Str255 docName;
|
|
||||||
StrToPascal(docName, name);
|
|
||||||
|
|
||||||
Str255 pathName;
|
if(textFileName == name) return;
|
||||||
pstrcpy(pathName, "\p:tip-doc:");
|
textFileName = name;
|
||||||
pstrcat(pathName, docName);
|
|
||||||
|
printf("Loading explanation file \"%s\"\n", name);
|
||||||
|
|
||||||
|
// Get the specification for the explanation file
|
||||||
|
|
||||||
FSSpec docSpec;
|
FSSpec docSpec;
|
||||||
FSSpec appSpec;
|
OSErr err = GetExplanationFSSpec(textFileName, &docSpec);
|
||||||
OSErr err = FSMakeFSSpec(0, 0, pathName, &docSpec);
|
if(err != noErr) return;
|
||||||
if(err) {
|
|
||||||
ShowAlert(ERR_DLG, "Can't find the \"%s\" file. Make sure it is inside the \"tip-doc\" folder.", name);
|
// Load the text from the data fork
|
||||||
return;
|
|
||||||
|
if (name != szRunning && name != szNotRunning) {
|
||||||
|
SetPage(kExplainPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = FindApplicationFromDocument(&docSpec, &appSpec);
|
TBReadSimpleText(richText, &docSpec);
|
||||||
if(err) {
|
|
||||||
ShowAlert(ERR_DLG, "Can't find an application to open \"%s\". Is \"SimpleText\" installed?", name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
err = LaunchApplicationWithDocument(&appSpec, &docSpec, false);
|
|
||||||
if(err) {
|
|
||||||
ShowAlert(ERR_DLG, "Can't open \"%s\". If \"%#s\" is already running, please close it.", name, appSpec.name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -291,7 +423,7 @@ void SetRichEditText(const char *name) {
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
void SetColor(long color) {
|
void SetColor(long color) {
|
||||||
if (AllowColor) {
|
if (allowColor) {
|
||||||
if(color == BACK_COLOR) color = LTGRAY_COLOR;
|
if(color == BACK_COLOR) color = LTGRAY_COLOR;
|
||||||
// Use colors when available
|
// Use colors when available
|
||||||
RGBColor rgbColor;
|
RGBColor rgbColor;
|
||||||
@ -325,7 +457,7 @@ void SetColor(long color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetColor(long color, long monoColor) {
|
void SetColor(long color, long monoColor) {
|
||||||
if (AllowColor) {
|
if (allowColor) {
|
||||||
SetColor(color);
|
SetColor(color);
|
||||||
} else {
|
} else {
|
||||||
SetColor(monoColor);
|
SetColor(monoColor);
|
||||||
@ -342,7 +474,7 @@ void DrawLed(int x, int y, long color) {
|
|||||||
// Draw the LED
|
// Draw the LED
|
||||||
SetColor(color);
|
SetColor(color);
|
||||||
PaintOval(&ledRect);
|
PaintOval(&ledRect);
|
||||||
if (AllowColor) {
|
if (allowColor) {
|
||||||
// Draw a recessed outline
|
// Draw a recessed outline
|
||||||
SetColor(BLACK_COLOR);
|
SetColor(BLACK_COLOR);
|
||||||
FrameOval(&ledRect);
|
FrameOval(&ledRect);
|
||||||
@ -372,7 +504,7 @@ void DrawLed(int x, int y, long color) {
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
void DrawEdge(Rect *qrc, int edge, int grfFlags) {
|
void DrawEdge(Rect *qrc, int edge, int grfFlags) {
|
||||||
if(edge == BDR_SUNKENOUTER && AllowColor) {
|
if(edge == BDR_SUNKENOUTER && allowColor) {
|
||||||
// Draw a sunken rectangle
|
// Draw a sunken rectangle
|
||||||
SetColor(GRAY_COLOR);
|
SetColor(GRAY_COLOR);
|
||||||
MoveTo(qrc->left,qrc->bottom-1);
|
MoveTo(qrc->left,qrc->bottom-1);
|
||||||
@ -453,9 +585,10 @@ unsigned long GetSystemTime() {
|
|||||||
void SetWindowText(int id, const char *str) {
|
void SetWindowText(int id, const char *str) {
|
||||||
Str255 pStr;
|
Str255 pStr;
|
||||||
StrToPascal(pStr, str);
|
StrToPascal(pStr, str);
|
||||||
if(testBtn && id == hTestButton) {
|
ControlHandle hCntl = FindControl(id);
|
||||||
|
if(hCntl) {
|
||||||
GetDC(hMainWnd);
|
GetDC(hMainWnd);
|
||||||
SetCTitle(testBtn, pStr);
|
SetCTitle(hCntl, pStr);
|
||||||
ReleaseDC(hMainWnd);
|
ReleaseDC(hMainWnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,9 +597,7 @@ void SetWindowText(int id, const char *str) {
|
|||||||
* ENABLE WINDOW
|
* ENABLE WINDOW
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
void EnableWindow(int id, bool enabled) {
|
void EnableWindow(int id, bool enabled) {
|
||||||
ControlHandle hCntl = 0;
|
ControlHandle hCntl = FindControl(id);
|
||||||
if(id == hTestButton) hCntl = testBtn;
|
|
||||||
if(id == hExitButton) hCntl = exitBtn;
|
|
||||||
if(hCntl) {
|
if(hCntl) {
|
||||||
GetDC(hMainWnd);
|
GetDC(hMainWnd);
|
||||||
HiliteControl(hCntl, enabled ? 0 : 255);
|
HiliteControl(hCntl, enabled ? 0 : 255);
|
||||||
@ -474,6 +605,21 @@ void EnableWindow(int id, bool enabled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* SHOW WINDOW
|
||||||
|
*******************************************************************************/
|
||||||
|
void ShowWindow(int id, int state) {
|
||||||
|
ControlHandle hCntl = FindControl(id);
|
||||||
|
if(hCntl) {
|
||||||
|
GetDC(hMainWnd);
|
||||||
|
if(state == SW_SHOW)
|
||||||
|
ShowControl(hCntl);
|
||||||
|
else
|
||||||
|
HideControl(hCntl);
|
||||||
|
ReleaseDC(hMainWnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* INVALIDATE RECT
|
* INVALIDATE RECT
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
1
mac-cpp-source/utils/ctype.h
Normal file
1
mac-cpp-source/utils/ctype.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
typedef Boolean bool;
typedef unsigned short uint16_t;
|
Loading…
x
Reference in New Issue
Block a user