2021-10-15 16:43:09 +00:00
|
|
|
// Copyright (c) Jon Thysell <http://jonthysell.com>
|
|
|
|
// Licensed under the MIT License.
|
|
|
|
|
|
|
|
#include "MacCommon.h"
|
|
|
|
|
2021-11-05 02:54:28 +00:00
|
|
|
void ShowError(Str255 message, bool isFatal)
|
2021-10-15 16:43:09 +00:00
|
|
|
{
|
2021-10-16 00:29:07 +00:00
|
|
|
ParamText(message, EmptyString, EmptyString, EmptyString);
|
|
|
|
StopAlert(ErrorAlertResID, NilFilterProc);
|
2021-10-15 16:43:09 +00:00
|
|
|
|
|
|
|
if (isFatal)
|
|
|
|
{
|
|
|
|
ExitToShell();
|
|
|
|
}
|
|
|
|
}
|
2021-10-31 22:13:51 +00:00
|
|
|
|
|
|
|
void CenterRect(const Rect *pOuterRect, Rect *pInnerRect)
|
|
|
|
{
|
|
|
|
CenterRectH(pOuterRect, pInnerRect);
|
|
|
|
CenterRectV(pOuterRect, pInnerRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CenterRectH(const Rect *pOuterRect, Rect *pInnerRect)
|
|
|
|
{
|
|
|
|
OffsetRect(pInnerRect, pOuterRect->left - pInnerRect->left, 0);
|
|
|
|
OffsetRect(pInnerRect, (pOuterRect->right - pInnerRect->right) / 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CenterRectV(const Rect *pOuterRect, Rect *pInnerRect)
|
|
|
|
{
|
|
|
|
OffsetRect(pInnerRect, 0, pOuterRect->top - pInnerRect->top);
|
|
|
|
OffsetRect(pInnerRect, 0, (pOuterRect->bottom - pInnerRect->bottom) / 2);
|
2021-11-05 02:54:28 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 23:35:44 +00:00
|
|
|
void ConcatenateRect(const Rect *pLeftRect, const Rect *pRightRect, Rect *pDestRect)
|
|
|
|
{
|
|
|
|
Rect newRightRect;
|
|
|
|
|
|
|
|
newRightRect.top = pLeftRect->top;
|
|
|
|
newRightRect.left = pLeftRect->right;
|
|
|
|
newRightRect.bottom = newRightRect.top + (pRightRect->bottom - pRightRect->top);
|
|
|
|
newRightRect.right = newRightRect.left + (pRightRect->right - pRightRect->left);
|
|
|
|
|
|
|
|
UnionRect(pLeftRect, &newRightRect, pDestRect);
|
|
|
|
}
|
|
|
|
|
2021-11-05 02:54:28 +00:00
|
|
|
void GetBoxRect(const Rect *pOuterRect, const BoxAlignment boxAlignment, Rect *pBoxRect)
|
|
|
|
{
|
|
|
|
int32_t boxWidth, boxHeight;
|
|
|
|
|
|
|
|
boxWidth = (pOuterRect->right - pOuterRect->left) / 3;
|
|
|
|
boxHeight = (pOuterRect->bottom - pOuterRect->top) / 3;
|
|
|
|
|
|
|
|
switch (boxAlignment)
|
|
|
|
{
|
|
|
|
case Top:
|
|
|
|
pBoxRect->top = pOuterRect->top;
|
|
|
|
pBoxRect->left = pOuterRect->left + boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->right - boxWidth;
|
|
|
|
break;
|
|
|
|
case TopLeft:
|
|
|
|
pBoxRect->top = pOuterRect->top;
|
|
|
|
pBoxRect->left = pOuterRect->left;
|
|
|
|
pBoxRect->bottom = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->left + boxWidth;
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
pBoxRect->top = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->left;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->left + boxWidth;
|
|
|
|
break;
|
|
|
|
case BottomLeft:
|
|
|
|
pBoxRect->top = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->left;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom;
|
|
|
|
pBoxRect->right = pOuterRect->left + boxWidth;
|
|
|
|
break;
|
|
|
|
case Bottom:
|
|
|
|
pBoxRect->top = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->left + boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom;
|
|
|
|
pBoxRect->right = pOuterRect->right - boxWidth;
|
|
|
|
break;
|
|
|
|
case BottomRight:
|
|
|
|
pBoxRect->top = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->right - boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom;
|
|
|
|
pBoxRect->right = pOuterRect->right;
|
|
|
|
break;
|
|
|
|
case Right:
|
|
|
|
pBoxRect->top = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->right - boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->right;
|
|
|
|
break;
|
|
|
|
case TopRight:
|
|
|
|
pBoxRect->top = pOuterRect->top;
|
|
|
|
pBoxRect->left = pOuterRect->right - boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->right;
|
|
|
|
break;
|
|
|
|
case Center:
|
|
|
|
pBoxRect->top = pOuterRect->top + boxHeight;
|
|
|
|
pBoxRect->left = pOuterRect->left + boxWidth;
|
|
|
|
pBoxRect->bottom = pOuterRect->bottom - boxHeight;
|
|
|
|
pBoxRect->right = pOuterRect->right - boxWidth;
|
|
|
|
break;
|
|
|
|
}
|
2021-11-07 23:35:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetScaledPicFrame(const PicHandle picHandle, const uint8_t scale, Rect *pDestRect)
|
|
|
|
{
|
|
|
|
*pDestRect = (**(picHandle)).picFrame;
|
|
|
|
|
|
|
|
pDestRect->right = pDestRect->left + ((pDestRect->right - pDestRect->left) * max(scale, 1));
|
|
|
|
pDestRect->bottom = pDestRect->top + ((pDestRect->bottom - pDestRect->top) * max(scale, 1));
|
|
|
|
}
|