Added introduction page.

This commit is contained in:
Marcio T
2021-12-05 13:31:11 -07:00
parent b5f0328beb
commit 37dab8d0b7
6 changed files with 170 additions and 41 deletions

View File

@@ -8,6 +8,18 @@
#include "tip.h"
#define TITLE_TOP 11
#define BODY_TOP 54
#define BODY_LEFT 156
#define BODY_RIGHT 445
#define BODY_BOTTOM 280
#define BODY_WIDTH (BODY_RIGHT - BODY_LEFT)
#define BODY_HEIGHT (BODY_BOTTOM - BODY_TOP)
#define LOGO_1_LEFT 157
#define LOGO_1_TOP 57
/*******************************************************************************
* WinMain
*
@@ -30,6 +42,22 @@ void WinMain(uint8_t *DrivesSkipped) {
StartApplicationTimer();
}
/*******************************************************************************
* PAINT 3D HEADLINE
*******************************************************************************/
void Paint3DHeadline(const char *pszText, int Xleft, int Ytop) {
TextSize(24);
TextFace(bold);
TextFont(helvetica);
SetColor(WHITE_COLOR);
TextOut(Xleft, Ytop, pszText);
SetColor(BLACK_COLOR);
TextOut(Xleft+1, Ytop+1, pszText);
TextFont(applFont);
TextFace(0);
TextSize(10);
}
/*******************************************************************************
* WndProc
*
@@ -42,17 +70,80 @@ void WndProc(long iMessage, uint16_t wParam) {
if (iMessage == WM_PAINT) {
// Draw the Lower Horz Button Divider
GetDC(hMainWnd);
SetColor(GRAY_COLOR);
MoveTo(15, 289);
LineTo(446, 289);
SetColor(WHITE_COLOR);
LineTo(446, 290);
LineTo(14, 290);
ReleaseDC(hMainWnd);
// Draw the Gibson 'G' Logo
if(CurrentPage == INTRO_PAGE) {
GetDC(hIntroWnd);
SetColor(GRAY_COLOR);
MoveTo(LOGO_1_LEFT+1, LOGO_1_TOP+29);
LineTo(LOGO_1_LEFT+14, LOGO_1_TOP+29);
LineTo(LOGO_1_LEFT+14, LOGO_1_TOP+0);
SetColor(WHITE_COLOR);
LineTo(LOGO_1_LEFT+12, LOGO_1_TOP+0);
LineTo(LOGO_1_LEFT+0, LOGO_1_TOP+12);
LineTo(LOGO_1_LEFT+0, LOGO_1_TOP+30);
SetColor(GRAY_COLOR);
MoveTo(LOGO_1_LEFT+18, LOGO_1_TOP+14);
LineTo(LOGO_1_LEFT+46, LOGO_1_TOP+14);
LineTo(LOGO_1_LEFT+46, LOGO_1_TOP+12);
LineTo(LOGO_1_LEFT+34, LOGO_1_TOP+0);
SetColor(WHITE_COLOR);
LineTo(LOGO_1_LEFT+17, LOGO_1_TOP+0);
LineTo(LOGO_1_LEFT+17, LOGO_1_TOP+15);
SetColor(GRAY_COLOR);
MoveTo(LOGO_1_LEFT+33, LOGO_1_TOP+46);
LineTo(LOGO_1_LEFT+46, LOGO_1_TOP+46);
LineTo(LOGO_1_LEFT+46, LOGO_1_TOP+29);
LineTo(LOGO_1_LEFT+34, LOGO_1_TOP+17);
SetColor(WHITE_COLOR);
LineTo(LOGO_1_LEFT+32, LOGO_1_TOP+17);
LineTo(LOGO_1_LEFT+32, LOGO_1_TOP+47);
SetColor(GRAY_COLOR);
MoveTo(LOGO_1_LEFT+1, LOGO_1_TOP+35);
LineTo(LOGO_1_LEFT+12, LOGO_1_TOP+46);
LineTo(LOGO_1_LEFT+29, LOGO_1_TOP+46);
LineTo(LOGO_1_LEFT+29, LOGO_1_TOP+32);
SetColor(WHITE_COLOR);
LineTo(LOGO_1_LEFT+0, LOGO_1_TOP+32);
LineTo(LOGO_1_LEFT+0, LOGO_1_TOP+35);
// show the current logo bitmap
SplashTheBitmap();
// paint the 3D program title
Paint3DHeadline(szIntroTitle, BODY_LEFT, TITLE_TOP);
// now the rest of the stuff ...
SetColor(BLACK_COLOR);
#define WH_RECT(L,T,W,H) L, T, L + W, T + H
Rect rect;
SetRect(&rect, WH_RECT(221, BODY_TOP, 230, 60));
TETextBox(szIntroSubTitle, strlen(szIntroSubTitle), &rect, teFlushDefault);
SetRect(&rect, WH_RECT(BODY_LEFT, BODY_TOP+64, BODY_WIDTH, 115));
TETextBox(szIntroText, strlen(szIntroText), &rect, teFlushDefault);
ReleaseDC(hIntroWnd);
}
// Paint the Copyright Notice
GetDC(hMainWnd);
SetColor(GRAY_COLOR);
TextOut(15, 298, szCopyright_1);
TextOut(15, 311, szCopyright_2);
ReleaseDC(hMainWnd);
}
// -------------------------------------------------------------------------
// WM_COMMAND : a button was pressed

View File

@@ -4,11 +4,18 @@ extern WindowPtr tipWindow;
void run_tip();
typedef enum TipPage {
INTRO_PAGE,
PERFORM_TEST_PAGE,
EXPLAIN_RESULTS,
} TipPage;
#define MINIMUM_JAZ_SPARES 500
#define MAXIMUM_JAZ_SPARES 2557
#define MINIMUM_ZIP_SPARES 50
#define MAXIMUM_ZIP_SPARES 126
extern TipPage CurrentPage;
extern long CurrentDevice;
extern long DriveCount;
extern long JazDrive; // true if the current drive
@@ -16,6 +23,7 @@ extern long CartridgeStatus;
extern long LastLBAOnCartridge;
extern uint32_t StartingInstant;
extern long NumberOfLBAs;
extern long AdapterMaxSectors;
extern long Side_0_SparesCount; // JAZ has only one count
extern long Side_1_SparesCount; // ZIP has counts for both sides
extern long Initial_Side_0_Spares;
@@ -102,6 +110,8 @@ void StopApplicationTimer();
void PostQuitMessage();
unsigned long GetSystemTime();
bool PrepareDC(int which);
void SplashTheBitmap();
void Paint3DHeadline();
#define GetDC(h) {GrafPtr oldPort; \
GetPort(&oldPort); \
@@ -144,6 +154,9 @@ enum {
/*******************************************************************************
* STRINGS
*******************************************************************************/
extern const char *szIntroTitle;
extern const char *szIntroSubTitle;
extern const char *szIntroText;
extern const char *szWindowTitle;
extern const char *szCopyright_1;
@@ -234,6 +247,7 @@ enum {
hExitButton = IDB_QUIT,
hSoundCheckbox,
// Extras added by MLT
hIntroWnd = 5,
hExplainWnd = IDB_EXPL
};
@@ -275,6 +289,7 @@ void AllowProgramExit();
void ErrorSound();
void ProcessPendingMessages();
void WinMain(uint8_t *DrivesSkipped);
void Paint3DHeadline(const char *pszText, int Xleft, int Ytop);
void WndProc(long iMessage, uint16_t wParam);
void TestMonitorWndProc();
void ApplicationTimerProc();

View File

@@ -17,17 +17,13 @@
#include "tip.h"
#include "command_line.h"
enum TipPage {
kTestingPage,
kExplainPage,
} page;
static int gDone;
static bool allowColor;
static bool inited = false;
static bool timerEnabled = false;
static WindowPtr tipWindow;
static MenuHandle tipMenu;
static PicHandle tipIntroPic;
static TBHandle richText;
static const char *textFileName;
@@ -58,15 +54,13 @@ void run_tip() {
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");
if(!inited && CurrentPage == PERFORM_TEST_PAGE) {
// Start TIP as soon as the user dismisses the intro screen
inited = true;
uint8_t drivesSkipped;
@@ -136,7 +130,7 @@ void NewTipWindow() {
SetControlValue(FindCntlHandle(IDB_BEEP),1); // Check the sound control
page = kExplainPage;
CurrentPage = EXPLAIN_RESULTS;
GetDC(hExplainWnd);
// Create the text edit widget
@@ -145,7 +139,10 @@ void NewTipWindow() {
ReleaseDC(hExplainWnd);
SetPage(kTestingPage);
// Load the About box picture
tipIntroPic = GetPicture(128);
SetPage(INTRO_PAGE);
}
void AddTipMenus() {
@@ -189,11 +186,14 @@ ControlHandle FindCntlHandle(int id) {
bool PrepareDC(int which) {
SetPort(tipWindow);
switch(which) {
case hIntroWnd:
if(CurrentPage != INTRO_PAGE) return false;
break;
case hExplainWnd:
if(page != kExplainPage) return false;
if(CurrentPage != EXPLAIN_RESULTS) return false;
break;
case hTestMonitor:
if(page != kTestingPage) return false;
if(CurrentPage != PERFORM_TEST_PAGE) return false;
SetOrigin(-20, -10);
break;
case hMainWnd:
@@ -320,10 +320,13 @@ void DoMouseDown(EventRecord &event) {
int id = GetControlReference(thisControl);
switch(id) {
case IDB_OKAY:
SetPage(kTestingPage);
SetPage(PERFORM_TEST_PAGE);
break;
case IDB_EXPL:
SetPage(kExplainPage);
SetPage(EXPLAIN_RESULTS);
break;
case IDB_NEXT:
SetRichEditText(szInstructions);
break;
case IDB_READ:
OpenExplanationInSimpleText();
@@ -404,10 +407,21 @@ void StrToPascal(Str255 pStr, const char *str) {
}
void SetPage(TipPage newPage) {
if(page == newPage) return;
page = newPage;
switch(page) {
case kTestingPage:
if(CurrentPage == newPage) return;
CurrentPage = newPage;
switch(CurrentPage) {
case INTRO_PAGE:
ShowWindow(IDB_TEST, SW_HIDE);
ShowWindow(IDB_BACK, SW_HIDE);
ShowWindow(IDB_EXPL, SW_HIDE);
ShowWindow(IDB_BEEP, SW_HIDE);
ShowWindow(IDB_OKAY, SW_HIDE);
ShowWindow(IDB_READ, SW_HIDE);
ShowWindow((*richText)->scroll, SW_HIDE);
ShowWindow(IDB_QUIT, SW_SHOW);
ShowWindow(IDB_NEXT, SW_SHOW);
break;
case PERFORM_TEST_PAGE:
ShowWindow((*richText)->scroll, SW_HIDE);
ShowWindow(IDB_BACK, SW_HIDE);
ShowWindow(IDB_NEXT, SW_HIDE);
@@ -418,7 +432,7 @@ void SetPage(TipPage newPage) {
ShowWindow(IDB_QUIT, SW_SHOW);
ShowWindow(IDB_BEEP, SW_SHOW);
break;
case kExplainPage:
case EXPLAIN_RESULTS:
ShowWindow(IDB_TEST, SW_HIDE);
ShowWindow(IDB_BACK, SW_HIDE);
ShowWindow(IDB_NEXT, SW_HIDE);
@@ -529,7 +543,7 @@ void SetRichEditText(const char *name) {
TBReadSimpleText(richText, &docSpec);
if (name != szRunning && name != szNotRunning) {
SetPage(kExplainPage);
SetPage(EXPLAIN_RESULTS);
} else {
InvalidateRect(hDefault);
}
@@ -805,3 +819,16 @@ void ProcessPendingMessages() {
}
SystemTask();
}
/*******************************************************************************
* SPLASH THE BITMAP
*******************************************************************************/
void SplashTheBitmap() {
GetDC(hIntroWnd);
if(tipIntroPic) {
Rect rect;
SetRect(&rect, 16, 18, 16+120, 18/*+258*/ +220);
DrawPicture(tipIntroPic, &rect);
}
ReleaseDC(hIntroWnd);
}

View File

@@ -128,6 +128,21 @@ ErrorTypeList errorTypeList[] = {
0, 0
};
/********** Main Window Controls Text ************/
const char *szIntroTitle = "Trouble in Paradise";
const char *szIntroSubTitle = "FREEWARE by Steve Gibson\r" \
"Gibson Research Corporation\r" \
"http://grc.com ( v 2.1b )\r" \
"http://github.com/marciot/mac-tip";
const char *szIntroText =
"A Macintosh port of \"TIP\" for Windows by Marcio Teixeira, made possible by a "
"generous code donation by Steve Gibson.\r\r"
"This freeware utility determines whether an Iomega Zip or Jaz drive is prone "
"to developing the dreaded \"Click of Death\" syndrome. Gibson's "
"research into the maintenance, repair and data recovery of Iomega's removable "
"media mass storage products led to this capability.";
/****************** Control Text *****************/
const char *szBack = "< Back";