mirror of
https://github.com/marciot/mac-tip.git
synced 2025-01-14 01:29:50 +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__ ")");
|
||||
|
||||
|
||||
print_help();
|
||||
|
||||
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;
|
||||
// test for an Iomega device
|
||||
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
|
||||
StartApplicationTimer();
|
||||
}
|
||||
@ -37,7 +42,7 @@ void WinMain(int Device) {
|
||||
*
|
||||
* This is the system's main window procedure
|
||||
*******************************************************************************/
|
||||
void WndProc(long iMessage, long wParam) {
|
||||
void WndProc(long iMessage, uint16_t wParam) {
|
||||
// -------------------------------------------------------------------------
|
||||
// WM_PAINT
|
||||
// -------------------------------------------------------------------------
|
||||
@ -102,11 +107,15 @@ void WndProc(long iMessage, long wParam) {
|
||||
}
|
||||
|
||||
BtnList tipBtns[] = {
|
||||
{IDB_TEST, szPressToStart, 200, 301, 160, 24, true}, // Added by MLT
|
||||
{IDB_BACK, szBack, 185-28, 301, 80, 24, false},
|
||||
{IDB_NEXT, szNext, 264-28, 301, 80, 24, false},
|
||||
{IDB_QUIT, szQuit, 367+35, 301, 45, 24, true},
|
||||
{0, 0, 0, 0, 0, 0, 0}
|
||||
{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}
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
typedef Boolean bool;
|
||||
#include "ctype.h"
|
||||
|
||||
extern WindowPtr tipWindow;
|
||||
|
||||
@ -38,25 +37,27 @@ extern long SingleTransferLBA;
|
||||
// ----------------------- Macintosh Compatibility -----------------------
|
||||
|
||||
enum AlertTypes {
|
||||
ERR_DLG,
|
||||
YN_DLG
|
||||
ERR_DLG,
|
||||
YN_DLG
|
||||
};
|
||||
|
||||
enum {
|
||||
BACK_COLOR = -1,
|
||||
BLACK_COLOR = 0x000000,
|
||||
LTGRAY_COLOR = 0xc0c0c0,
|
||||
GRAY_COLOR = 0x808080,
|
||||
WHITE_COLOR = 0xffffff,
|
||||
BLUE_COLOR = 0x0000ff,
|
||||
RED_COLOR = 0xff0000,
|
||||
GREEN_COLOR = 0x00ff00,
|
||||
BACK_COLOR = -1,
|
||||
BLACK_COLOR = 0x000000,
|
||||
LTGRAY_COLOR = 0xc0c0c0,
|
||||
GRAY_COLOR = 0x808080,
|
||||
WHITE_COLOR = 0xffffff,
|
||||
BLUE_COLOR = 0x0000ff,
|
||||
RED_COLOR = 0xff0000,
|
||||
GREEN_COLOR = 0x00ff00,
|
||||
};
|
||||
|
||||
#define BDR_SUNKENOUTER 1
|
||||
#define BF_RECT 1
|
||||
#define WM_PAINT 1
|
||||
#define WM_COMMAND 2
|
||||
#define SW_SHOW 1
|
||||
#define SW_HIDE 2
|
||||
|
||||
void SetColor(long color);
|
||||
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 SetWindowText(int id, const char *str);
|
||||
void EnableWindow(int id, bool enabled);
|
||||
void ShowWindow(int id, int state);
|
||||
void InvalidateRect(int id);
|
||||
void Rectangle(int left, int top, int right, int bottom);
|
||||
void DrawEdge(Rect *qrc, int edge, int grfFlags);
|
||||
@ -77,45 +79,44 @@ void StartApplicationTimer();
|
||||
void StopApplicationTimer();
|
||||
void PostQuitMessage();
|
||||
unsigned long GetSystemTime();
|
||||
bool PrepareDC(int which);
|
||||
|
||||
#define GetDC(h) {GrafPtr oldPort; \
|
||||
GetPort(&oldPort); \
|
||||
SetPort(tipWindow); \
|
||||
if(h == hTestMonitor) SetOrigin(-20, -10); \
|
||||
if(h == hMainWnd) SetOrigin(0, 40);
|
||||
#define GetDC(h) {GrafPtr oldPort; \
|
||||
GetPort(&oldPort); \
|
||||
if(PrepareDC(h)) {
|
||||
|
||||
#define ReleaseDC(h) SetOrigin(0,0); \
|
||||
SetPort(oldPort);}
|
||||
#define ReleaseDC(h) } SetOrigin(0,0); \
|
||||
SetPort(oldPort);}
|
||||
|
||||
|
||||
// ------------------------------ Cartridge Status -------------------------------
|
||||
// ------------------------------ Cartridge Status -------------------------------
|
||||
|
||||
enum {
|
||||
DISK_STATUS_UNKNOWN = 1,
|
||||
DISK_AT_SPEED = 2,
|
||||
DISK_SPINNING_UP = 3,
|
||||
DISK_NOT_PRESENT = 4,
|
||||
DISK_SPUN_DOWN = 5,
|
||||
DISK_STALLED = 6,
|
||||
DISK_Z_TRACK_FAILURE = 7,
|
||||
DISK_PROTECTED = 8,
|
||||
DISK_LOW_SPARES = 9,
|
||||
DISK_TEST_UNDERWAY = 10,
|
||||
DISK_TEST_FAILURE = 11,
|
||||
DISK_STATUS_UNKNOWN = 1,
|
||||
DISK_AT_SPEED = 2,
|
||||
DISK_SPINNING_UP = 3,
|
||||
DISK_NOT_PRESENT = 4,
|
||||
DISK_SPUN_DOWN = 5,
|
||||
DISK_STALLED = 6,
|
||||
DISK_Z_TRACK_FAILURE = 7,
|
||||
DISK_PROTECTED = 8,
|
||||
DISK_LOW_SPARES = 9,
|
||||
DISK_TEST_UNDERWAY = 10,
|
||||
DISK_TEST_FAILURE = 11,
|
||||
|
||||
LAST_CART_STATUS = 11
|
||||
LAST_CART_STATUS = 11
|
||||
};
|
||||
|
||||
// ---------------------------- Testing Phase Status -----------------------------
|
||||
|
||||
enum {
|
||||
UNTESTED = 0,
|
||||
READY_TO_TEST = 1,
|
||||
TESTING_STARTUP = 2,
|
||||
READING_DATA = 3,
|
||||
WRITING_PATT = 4,
|
||||
READING_PATT = 5,
|
||||
WRITING_DATA = 6
|
||||
UNTESTED = 0,
|
||||
READY_TO_TEST = 1,
|
||||
TESTING_STARTUP = 2,
|
||||
READING_DATA = 3,
|
||||
WRITING_PATT = 4,
|
||||
READING_PATT = 5,
|
||||
WRITING_DATA = 6
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
@ -195,18 +196,31 @@ extern const char *szNext;
|
||||
extern const char *szQuit;
|
||||
|
||||
enum {
|
||||
hMainWnd,
|
||||
hTestMonitor,
|
||||
hTestButton,
|
||||
hExitButton
|
||||
hMainWnd,
|
||||
hTestMonitor,
|
||||
hTestButton,
|
||||
hExitButton,
|
||||
// Extras added by MLT
|
||||
hExplainWnd
|
||||
};
|
||||
|
||||
#define IDB_BACK 0xFF00
|
||||
#define IDB_NEXT 0xFF01
|
||||
#define IDB_QUIT 0xFF02
|
||||
#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[];
|
||||
|
||||
/*******************************************************************************
|
||||
@ -233,7 +247,7 @@ void AllowProgramExit();
|
||||
void ErrorSound();
|
||||
void ProcessPendingMessages();
|
||||
void WinMain(int Device);
|
||||
void WndProc(long iMessage, long wParam);
|
||||
void WndProc(long iMessage, uint16_t wParam);
|
||||
void TestMonitorWndProc();
|
||||
void ApplicationTimerProc();
|
||||
void TestButtonClicked();
|
||||
|
@ -107,7 +107,7 @@ long Side_1_SparesCount; // ZIP has counts for both sides
|
||||
long Initial_Side_0_Spares;
|
||||
long Initial_Side_1_Spares;
|
||||
|
||||
long TestingPhase; // 0 = not testing, no data ...
|
||||
long TestingPhase = 0; // 0 = not testing, no data ...
|
||||
long PercentComplete;
|
||||
long FirstLBASector;
|
||||
long NumberOfLBAs;
|
||||
@ -523,12 +523,6 @@ void SetCartridgeStatusToEAX(long eax) {
|
||||
return;
|
||||
}
|
||||
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"
|
||||
@ -544,7 +538,7 @@ void SetCartridgeStatusToEAX(long eax) {
|
||||
esi = szPressToStop;
|
||||
break;
|
||||
case DISK_NOT_PRESENT:
|
||||
//SetRichEditText(szNotRunning);
|
||||
SetRichEditText(szNotRunning);
|
||||
goto DisableActions;
|
||||
case DISK_AT_SPEED:
|
||||
eax = GetSpareSectorCounts(true); // update the Cart Condition
|
||||
@ -813,7 +807,7 @@ void TestTheDisk() {
|
||||
StopApplicationTimer();
|
||||
|
||||
PreventProgramExit();
|
||||
//SetRichEditText(szRunning);
|
||||
SetRichEditText(szRunning);
|
||||
CartridgeStatus = DISK_TEST_UNDERWAY;
|
||||
TestingPhase = TESTING_STARTUP; // inhibit stopping now
|
||||
SetWindowText(hTestButton, szPressToStop);
|
||||
|
@ -11,44 +11,63 @@
|
||||
#include "pstring.h"
|
||||
#include "LaunchLib.h"
|
||||
#include "mac_vol.h"
|
||||
#include "text_box.h"
|
||||
#include "tip.h"
|
||||
|
||||
WindowPtr tipWindow;
|
||||
enum TipPage {
|
||||
kTestingPage,
|
||||
kExplainPage,
|
||||
} page;
|
||||
|
||||
static int gDone;
|
||||
static bool AllowColor;
|
||||
static bool timerEnabled = true;
|
||||
static ControlHandle testBtn = 0;
|
||||
static ControlHandle exitBtn = 0;
|
||||
static int gDone;
|
||||
static bool allowColor;
|
||||
static bool inited = false;
|
||||
static bool timerEnabled = false;
|
||||
static WindowPtr tipWindow;
|
||||
static TBHandle richText;
|
||||
static const char *textFileName;
|
||||
|
||||
void NewTipWindow();
|
||||
void DestroyTipWindow();
|
||||
void DisposeTipWindow();
|
||||
void DoEvent(EventRecord &event, RgnHandle *cursorRgn);
|
||||
void DoUpdate(WindowPtr window);
|
||||
void DoMouseDown(EventRecord &event);
|
||||
void DoMouseMove(EventRecord &event, RgnHandle *cursorRegion);
|
||||
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) {
|
||||
WinMain(id);
|
||||
RgnHandle cursorRgn = NewRgn();
|
||||
|
||||
SetRichEditText(szInstructions);
|
||||
NewTipWindow();
|
||||
EnableWindow(hTestButton, false);
|
||||
SetRichEditText(szInstructions);
|
||||
|
||||
gDone = false;
|
||||
do {
|
||||
EventRecord event;
|
||||
if (WaitNextEvent(everyEvent, &event, GetCaretTime(), 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) {
|
||||
ApplicationTimerProc();
|
||||
}
|
||||
} while (!gDone);
|
||||
|
||||
DestroyTipWindow();
|
||||
DisposeTipWindow();
|
||||
DisposeRgn(cursorRgn);
|
||||
}
|
||||
|
||||
@ -57,56 +76,83 @@ void NewTipWindow() {
|
||||
SysEnvRec 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.left = 8;
|
||||
rect.top = GetMBarHeight() + rect.left + 16;
|
||||
rect.bottom = rect.top + 336 - 35;
|
||||
rect.right = rect.left + 467;
|
||||
rect.bottom = rect.top + wndHeight;
|
||||
rect.right = rect.left + wndWidth;
|
||||
|
||||
Str255 title;
|
||||
StrToPascal(title, szWindowTitle);
|
||||
tipWindow = AllowColor ?
|
||||
tipWindow = allowColor ?
|
||||
NewCWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0) :
|
||||
NewWindow(NULL,&rect, title, true, 0, (WindowPtr)-1, true, 0);
|
||||
|
||||
GetDC(hMainWnd);
|
||||
|
||||
if (AllowColor) {
|
||||
SetColor(BACK_COLOR);
|
||||
RGBColor bgColor;
|
||||
GetForeColor(&bgColor);
|
||||
RGBBackColor(&bgColor);
|
||||
}
|
||||
TextSize(10);
|
||||
|
||||
// Create the controls
|
||||
|
||||
for(int i = 0; tipBtns[i].name; i++) {
|
||||
if (!tipBtns[i].visible) continue;
|
||||
SetRect(&rect,
|
||||
tipBtns[i].x,
|
||||
tipBtns[i].y,
|
||||
tipBtns[i].y - mainWndOrigin.v,
|
||||
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);
|
||||
ControlHandle h = 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;
|
||||
}
|
||||
tipBtns[i].hndl = NewControl(tipWindow, &rect, title, true, 0, 0, 0, 0, tipBtns[i].id);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
if(!SIOUXHandleOneEvent(&event)) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DoUpdate(WindowPtr window) {
|
||||
BeginUpdate(window);
|
||||
SetPort(window);
|
||||
EraseRect(&window->portRect);
|
||||
SetColor(BACK_COLOR);
|
||||
PaintRect(&window->portRect);
|
||||
|
||||
GetDC(hMainWnd);
|
||||
WndProc(WM_PAINT, 0);
|
||||
DrawControls(window);
|
||||
ReleaseDC(hMainWnd);
|
||||
|
||||
GetDC(hTestMonitor);
|
||||
TestMonitorWndProc();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -150,24 +204,34 @@ void DoMouseDown(EventRecord &event) {
|
||||
SelectWindow(thisWindow);
|
||||
}
|
||||
else if(thisWindow == tipWindow) {
|
||||
long id = 0;
|
||||
Point mouse = event.where;
|
||||
GetDC(hMainWnd);
|
||||
GrafPtr oldPort;
|
||||
GetPort(&oldPort);
|
||||
SetPort(thisWindow);
|
||||
GlobalToLocal(&mouse);
|
||||
if(FindControl(mouse, thisWindow, &thisControl) == inButton) {
|
||||
if(TrackControl(thisControl, mouse, 0) == inButton) {
|
||||
id = GetControlReference(thisControl);
|
||||
const bool hitButton = (!TBMouseDown(richText, mouse, thisWindow)) &&
|
||||
(FindControl(mouse, thisWindow, &thisControl) == inButton) &&
|
||||
(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;
|
||||
case inDrag:
|
||||
DragWindow(thisWindow, event.where, &(*GetGrayRgn())->rgnBBox);
|
||||
break;
|
||||
case inGrow:
|
||||
//DoGrowWindow(thisWindow, event);
|
||||
break;
|
||||
@ -222,6 +286,35 @@ void StrToPascal(Str255 pStr, const char *str) {
|
||||
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
|
||||
*******************************************************************************/
|
||||
@ -241,6 +334,55 @@ int ShowAlert(AlertTypes type, const char* format, ...) {
|
||||
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
|
||||
*
|
||||
@ -252,38 +394,28 @@ int ShowAlert(AlertTypes type, const char* format, ...) {
|
||||
*******************************************************************************/
|
||||
|
||||
void SetRichEditText(const char *name) {
|
||||
static const char *lastName = 0;
|
||||
if(name == lastName) return;
|
||||
lastName = name;
|
||||
short fRefNum = 0;
|
||||
|
||||
if(ShowAlert(YN_DLG, "Would you like to read the document \"%s\" now?", name) == 2) {
|
||||
return;
|
||||
}
|
||||
Str255 docName;
|
||||
StrToPascal(docName, name);
|
||||
// Don't reload a file that is already loaded
|
||||
|
||||
Str255 pathName;
|
||||
pstrcpy(pathName, "\p:tip-doc:");
|
||||
pstrcat(pathName, docName);
|
||||
if(textFileName == name) return;
|
||||
textFileName = name;
|
||||
|
||||
printf("Loading explanation file \"%s\"\n", name);
|
||||
|
||||
// Get the specification for the explanation file
|
||||
|
||||
FSSpec docSpec;
|
||||
FSSpec appSpec;
|
||||
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;
|
||||
OSErr err = GetExplanationFSSpec(textFileName, &docSpec);
|
||||
if(err != noErr) return;
|
||||
|
||||
// Load the text from the data fork
|
||||
|
||||
if (name != szRunning && name != szNotRunning) {
|
||||
SetPage(kExplainPage);
|
||||
}
|
||||
|
||||
err = FindApplicationFromDocument(&docSpec, &appSpec);
|
||||
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;
|
||||
}
|
||||
TBReadSimpleText(richText, &docSpec);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -291,7 +423,7 @@ void SetRichEditText(const char *name) {
|
||||
*******************************************************************************/
|
||||
|
||||
void SetColor(long color) {
|
||||
if (AllowColor) {
|
||||
if (allowColor) {
|
||||
if(color == BACK_COLOR) color = LTGRAY_COLOR;
|
||||
// Use colors when available
|
||||
RGBColor rgbColor;
|
||||
@ -325,7 +457,7 @@ void SetColor(long color) {
|
||||
}
|
||||
|
||||
void SetColor(long color, long monoColor) {
|
||||
if (AllowColor) {
|
||||
if (allowColor) {
|
||||
SetColor(color);
|
||||
} else {
|
||||
SetColor(monoColor);
|
||||
@ -342,7 +474,7 @@ void DrawLed(int x, int y, long color) {
|
||||
// Draw the LED
|
||||
SetColor(color);
|
||||
PaintOval(&ledRect);
|
||||
if (AllowColor) {
|
||||
if (allowColor) {
|
||||
// Draw a recessed outline
|
||||
SetColor(BLACK_COLOR);
|
||||
FrameOval(&ledRect);
|
||||
@ -372,7 +504,7 @@ void DrawLed(int x, int y, long color) {
|
||||
*******************************************************************************/
|
||||
|
||||
void DrawEdge(Rect *qrc, int edge, int grfFlags) {
|
||||
if(edge == BDR_SUNKENOUTER && AllowColor) {
|
||||
if(edge == BDR_SUNKENOUTER && allowColor) {
|
||||
// Draw a sunken rectangle
|
||||
SetColor(GRAY_COLOR);
|
||||
MoveTo(qrc->left,qrc->bottom-1);
|
||||
@ -453,9 +585,10 @@ unsigned long GetSystemTime() {
|
||||
void SetWindowText(int id, const char *str) {
|
||||
Str255 pStr;
|
||||
StrToPascal(pStr, str);
|
||||
if(testBtn && id == hTestButton) {
|
||||
ControlHandle hCntl = FindControl(id);
|
||||
if(hCntl) {
|
||||
GetDC(hMainWnd);
|
||||
SetCTitle(testBtn, pStr);
|
||||
SetCTitle(hCntl, pStr);
|
||||
ReleaseDC(hMainWnd);
|
||||
}
|
||||
}
|
||||
@ -464,9 +597,7 @@ void SetWindowText(int id, const char *str) {
|
||||
* ENABLE WINDOW
|
||||
*******************************************************************************/
|
||||
void EnableWindow(int id, bool enabled) {
|
||||
ControlHandle hCntl = 0;
|
||||
if(id == hTestButton) hCntl = testBtn;
|
||||
if(id == hExitButton) hCntl = exitBtn;
|
||||
ControlHandle hCntl = FindControl(id);
|
||||
if(hCntl) {
|
||||
GetDC(hMainWnd);
|
||||
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
|
||||
*******************************************************************************/
|
||||
|
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