Window API refactor

This commit is contained in:
elasota
2020-05-20 17:20:50 -04:00
parent 49c438b088
commit f53dc21475
26 changed files with 137 additions and 127 deletions

View File

@@ -36,7 +36,7 @@ void BringUpDialog (Dialog **theDialog, short dialogID, const DialogTextSubstitu
// CenterDialog(dialogID);
if (*theDialog == nil)
RedAlert(kErrDialogDidntLoad);
SetGraphicsPort(&(*theDialog)->GetWindow()->m_surface);
SetGraphicsPort((*theDialog)->GetWindow()->GetDrawSurface());
ShowWindow((*theDialog)->GetWindow());
DrawDefaultButton(*theDialog);
}

View File

@@ -454,8 +454,7 @@ void KeepWindowInBounds(Window *window)
int32_t leftNudge = std::max<int32_t>(-windowRect.Left(), 0);
int32_t rightNudge = std::min<int32_t>(thisMac.fullScreen.right - windowRect.Right(), 0);
window->m_wmX += leftNudge + rightNudge;
window->m_wmY += topNudge + bottomNudge;
window->SetPosition(window->GetPosition() + PortabilityLayer::Vec2i(leftNudge + rightNudge, topNudge + bottomNudge));
}
void HandleEditorResolutionChange(void)

View File

@@ -173,7 +173,7 @@ int16_t HouseFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
if (mouseEvt.m_eventType == GpMouseEventTypes::kMove)
{
mouseIs = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if ((houseEditText1.Contains(mouseIs)) ||
(houseEditText2.Contains(mouseIs)))
{

View File

@@ -119,7 +119,7 @@ void DoPause (void)
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&bounds, &bounds, srcCopy);
do

View File

@@ -379,7 +379,7 @@ void HandleLinkClick (Point wherePt)
return;
SetPortWindowPort(linkWindow);
wherePt -= linkWindow->TopLeftCoord();
wherePt -= linkWindow->GetTopLeftCoord();
part = FindControl(wherePt, linkWindow, &theControl);
if ((theControl != nil) && (part != 0))

View File

@@ -117,7 +117,7 @@ void RedrawSplashScreen (void)
SetPortWindowPort(mainWindow);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&workSrcRect, &workSrcRect, srcCopy);
// if (quickerTransitions)
@@ -126,7 +126,7 @@ void RedrawSplashScreen (void)
// DissBits(&workSrcRect);
CopyRectMainToWork(&workSrcRect);
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
PortabilityLayer::MenuManager::GetInstance()->SetMenuVisible(true);
}
@@ -144,7 +144,7 @@ void UpdateMainWindow (void)
{
PauseMarquee();
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&mainWindowRect, &mainWindowRect, srcCopy);
ResumeMarquee();
}
@@ -155,14 +155,14 @@ void UpdateMainWindow (void)
QOffsetRect(&tempRect, splashOriginH, splashOriginV);
LoadScaledGraphic(workSrcMap, kSplash8BitPICT, &tempRect);
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&workSrcRect, &mainWindowRect, srcCopy);
SetPortWindowPort(mainWindow);
DrawOnSplash(mainWindow->GetDrawSurface());
}
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
splashDrawn = true;
}
@@ -279,10 +279,10 @@ void OpenMainWindow (void)
}
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&mainWindowRect, &mainWindowRect, srcCopy);
mainWindow->m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
mainWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- CloseMainWindow
@@ -373,7 +373,7 @@ void HandleMainClick (Point wherePt, Boolean isDoubleClick)
return;
SetPortWindowPort(mainWindow);
wherePt -= mainWindow->TopLeftCoord();
wherePt -= mainWindow->GetTopLeftCoord();
DrawSurface *mainWindowSurface = mainWindow->GetDrawSurface();

View File

@@ -237,7 +237,7 @@ void RedrawMapContents (void)
QSetRect(&src, 0, 0, kMapRoomWidth, kMapRoomHeight);
QOffsetRect(&src, 0, type * kMapRoomHeight);
CopyBits((BitMap *)*GetGWorldPixMap(nailSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mapWindow)),
GetPortBitMapForCopyBits(mapWindow->GetDrawSurface()),
&src, &aRoom, srcCopy);
}
@@ -299,7 +299,7 @@ void RedrawMapContents (void)
//-------------------------------------------------------------- UpdateMapWindow
void DrawMapResizeBox(void)
{
DrawSurface *surface = &mapWindow->m_surface;
DrawSurface *surface = mapWindow->GetDrawSurface();
const Rect windowRect = surface->m_port.GetRect();
Rect growBoxRect = Rect::Create(windowRect.bottom - 14, windowRect.right - 14, windowRect.bottom, windowRect.right);
@@ -625,7 +625,7 @@ void HandleMapClick (const GpMouseInputEvent &theEvent)
SetPortWindowPort(mapWindow);
globalWhere = wherePt;
wherePt -= mapWindow->TopLeftCoord();
wherePt -= mapWindow->GetTopLeftCoord();
wherePt.h -= 1;
wherePt.v -= 1;

View File

@@ -432,7 +432,7 @@ Boolean PtInMarqueeHandle (Point where)
void DrawGliderMarquee (void)
{
DrawSurface *surface = GetWindowPort(mainWindow);
DrawSurface *surface = mainWindow->GetDrawSurface();
ImageInvert(*GetGWorldPixMap(blowerMaskMap), GetPortBitMapForCopyBits(surface), leftStartGliderSrc, marqueeGliderRect);
surface->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}

View File

@@ -143,7 +143,7 @@ void NewGame (short mode)
#ifdef COMPILEQT
if ((thisMac.hasQT) && (hasMovie))
{
theMovie.m_surface = &mainWindow->m_surface;
theMovie.m_surface = mainWindow->GetDrawSurface();
}
#endif
@@ -374,7 +374,7 @@ void HandleGameResolutionChange(void)
OpenMainWindow();
if (hasMovie)
theMovie.m_surface = &mainWindow->m_surface;
theMovie.m_surface = mainWindow->GetDrawSurface();
ResetLocale(true);
InitScoreboardMap();

View File

@@ -612,7 +612,7 @@ void CopyRectsQD (void)
{
short i;
DrawSurface *mainWindowGraf = GetWindowPort(mainWindow);
DrawSurface *mainWindowGraf = mainWindow->GetDrawSurface();
for (i = 0; i < numWork2Main; i++)
{
@@ -713,7 +713,7 @@ void CopyRectWorkToBack (Rect *theRect)
void CopyRectWorkToMain (Rect *theRect)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
theRect, theRect, srcCopy);
}
@@ -721,7 +721,7 @@ void CopyRectWorkToMain (Rect *theRect)
void CopyRectMainToWork (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
CopyBits(GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
(BitMap *)*GetGWorldPixMap(workSrcMap),
theRect, theRect, srcCopy);
}
@@ -730,7 +730,7 @@ void CopyRectMainToWork (Rect *theRect)
void CopyRectMainToBack (Rect *theRect)
{
CopyBits(GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
CopyBits(GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
(BitMap *)*GetGWorldPixMap(backSrcMap),
theRect, theRect, srcCopy);
}

View File

@@ -391,7 +391,7 @@ int16_t RoomFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
if (evt->IsLMouseDownEvent())
{
mouseIs = Point::Create(mouseEvent.m_x, mouseEvent.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if (tileSrc.Contains(mouseIs))
{
if (StillDown())
@@ -681,7 +681,7 @@ int16_t OriginalArtFilter(Dialog *dial, const TimeTaggedVOSEvent *evt)
const GpMouseInputEvent &mouseEvt = evt->m_vosEvent.m_event.m_mouseInputEvent;
mouseIs = Point::Create(mouseEvt.m_x, mouseEvt.m_y);
mouseIs -= dial->GetWindow()->TopLeftCoord();
mouseIs -= dial->GetWindow()->GetTopLeftCoord();
if (leftBound.Contains(mouseIs))
return 7;
else if (topBound.Contains(mouseIs))

View File

@@ -56,7 +56,7 @@ extern Boolean evenFrame, onePlayerLeft;
void MarkScoreboardPortDirty(void)
{
GetWindowPort(boardWindow)->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
boardWindow->GetDrawSurface()->m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
}
//-------------------------------------------------------------- RefreshScoreboard
@@ -71,7 +71,7 @@ void RefreshScoreboard (SInt16 mode)
RefreshPoints();
CopyBits((BitMap *)*GetGWorldPixMap(boardSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardSrcRect, &boardDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -293,7 +293,7 @@ void QuickGlidersRefresh (void)
surface->DrawString(textPoint, nGlidersStr, true);
CopyBits((BitMap *)*GetGWorldPixMap(boardGSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardGSrcRect, &boardGQDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -323,7 +323,7 @@ void QuickScoreRefresh (void)
surface->DrawString(textPoint, scoreStr, true);
CopyBits((BitMap *)*GetGWorldPixMap(boardPSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&boardPSrcRect, &boardPQDestRect, srcCopy);
MarkScoreboardPortDirty();
@@ -336,7 +336,7 @@ void QuickBatteryRefresh (Boolean flash)
if ((batteryTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy);
@@ -344,7 +344,7 @@ void QuickBatteryRefresh (Boolean flash)
else if ((batteryTotal < 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kHeliumBadge],
&badgesDestRects[kHeliumBadge],
srcCopy);
@@ -352,7 +352,7 @@ void QuickBatteryRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kBatteryBadge],
&badgesDestRects[kBatteryBadge],
srcCopy);
@@ -368,7 +368,7 @@ void QuickBandsRefresh (Boolean flash)
if ((bandsTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy);
@@ -376,7 +376,7 @@ void QuickBandsRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kBandsBadge],
&badgesDestRects[kBandsBadge],
srcCopy);
@@ -392,7 +392,7 @@ void QuickFoilRefresh (Boolean flash)
if ((foilTotal > 0) && (!flash))
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBadgesRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy);
@@ -400,7 +400,7 @@ void QuickFoilRefresh (Boolean flash)
else
{
CopyBits((BitMap *)*GetGWorldPixMap(badgeSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(boardWindow)),
GetPortBitMapForCopyBits(boardWindow->GetDrawSurface()),
&badgesBlankRects[kFoilBadge],
&badgesDestRects[kFoilBadge],
srcCopy);

View File

@@ -494,7 +494,7 @@ void DoControlPrefs (void)
prefDlg = PortabilityLayer::DialogManager::GetInstance()->LoadDialog(kControlPrefsDialID, kPutInFront, nullptr);
if (prefDlg == nil)
RedAlert(kErrDialogDidntLoad);
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
for (i = 0; i < 4; i++)
{
GetDialogItemRect(prefDlg, i + kRightControl, &controlRects[i]);
@@ -1204,7 +1204,7 @@ int16_t PrefsFilter (Dialog *dial, const TimeTaggedVOSEvent *evt)
const Window *window = dial->GetWindow();
const GpMouseInputEvent &mouseEvent = evt->m_vosEvent.m_event.m_mouseInputEvent;
const Point testPt = Point::Create(mouseEvent.m_x - window->m_wmX, mouseEvent.m_y - window->m_wmY);
const Point testPt = window->MouseToLocal(evt->m_vosEvent.m_event.m_mouseInputEvent);
int16_t hitCode = -1;
@@ -1263,20 +1263,20 @@ void DoSettingsMain (void)
case kDisplayButton:
FlashSettingsButton(surface, 0);
DoDisplayPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kSoundButton:
FlashSettingsButton(surface, 1);
DoSoundPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
FlushEvents(everyEvent, 0);
break;
case kControlsButton:
FlashSettingsButton(surface, 2);
DoControlPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kBrainsButton:
@@ -1288,7 +1288,7 @@ void DoSettingsMain (void)
}
FlashSettingsButton(surface, 3);
DoBrainsPrefs();
SetGraphicsPort(&prefDlg->GetWindow()->m_surface);
SetGraphicsPort(prefDlg->GetWindow()->GetDrawSurface());
break;
case kAllDefaultsButton:

View File

@@ -182,7 +182,7 @@ void DrawToolTiles (DrawSurface *surface)
QOffsetRect(&destRect, toolRects[i + 1].left + 2, toolRects[i + 1].top + 2);
CopyBits((BitMap *)*GetGWorldPixMap(toolSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(toolsWindow)),
GetPortBitMapForCopyBits(toolsWindow->GetDrawSurface()),
&srcRect, &destRect, srcCopy);
}
}
@@ -472,7 +472,7 @@ void HandleToolsClick (Point wherePt)
return;
SetPortWindowPort(toolsWindow);
wherePt -= toolsWindow->TopLeftCoord();
wherePt -= toolsWindow->GetTopLeftCoord();
part = FindControl(wherePt, toolsWindow, &theControl);
if ((theControl != nil) && (part != 0))

View File

@@ -57,7 +57,7 @@ void PourScreenOn (Rect *theRect)
columnRects[i].bottom = theRect->bottom;
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&columnRects[i], &columnRects[i], srcCopy);
QOffsetRect(&columnRects[i], 0, kChipHigh);
@@ -115,7 +115,7 @@ void WipeScreenOn (short direction, Rect *theRect)
for (i = 0; i < count; i++)
{
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(GetWindowPort(mainWindow)),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&wipeRect, &wipeRect, srcCopy);
QOffsetRect(&wipeRect, hOffset, vOffset);
@@ -135,7 +135,7 @@ void WipeScreenOn (short direction, Rect *theRect)
void DumpScreenOn (Rect *theRect)
{
DrawSurface *graf = GetWindowPort(mainWindow);
DrawSurface *graf = mainWindow->GetDrawSurface();
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(graf),

View File

@@ -36,8 +36,9 @@ void GetWindowLeftTop (WindowPtr theWindow, short *left, short *top)
}
else
{
*left = static_cast<short>(theWindow->m_wmX);
*top = static_cast<short>(theWindow->m_wmY);
const Point windowPos = theWindow->GetTopLeftCoord();
*left = windowPos.h;
*top = windowPos.v;
}
}
@@ -51,7 +52,7 @@ void GetWindowRect (WindowPtr theWindow, Rect *bounds)
{
Point upperLeft;
GetWindowLeftTop(theWindow, &upperLeft.h, &upperLeft.v);
*bounds = theWindow->m_surface.m_port.GetRect() + upperLeft;
*bounds = theWindow->GetSurfaceRect() + upperLeft;
}
}