MCPcopy Create free account
hub / github.com/NetHack/NetHack / adjust_window_pos

Function adjust_window_pos

outdated/sys/mac/macwin.c:1237–1288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1235}
1236
1237static void
1238adjust_window_pos(NhWindow *aWin, short width, short height)
1239{
1240 WindowRef theWindow = aWin->its_window;
1241#if TARGET_API_MAC_CARBON
1242 Rect r;
1243
1244 GetWindowBounds(theWindow, kWindowContentRgn, &r);
1245 RetrieveWinPos(theWindow, &r.top, &r.left);
1246 MoveWindow(theWindow, r.left, r.top, false);
1247 SizeWindow(theWindow, width, height, true);
1248 ConstrainWindowToScreen(theWindow, kWindowStructureRgn,
1249 kWindowConstrainMayResize
1250 | kWindowConstrainMoveRegardlessOfFit,
1251 NULL, NULL);
1252#else
1253 Rect scr_r = (*GetGrayRgn())->rgnBBox;
1254 const Rect win_ind = { 2, 2, 3, 3 };
1255 const short min_w = theWindow->portRect.right - theWindow->portRect.left,
1256 max_w =
1257 scr_r.right - scr_r.left - win_ind.left - win_ind.right;
1258 Point pos;
1259 short max_h;
1260
1261 SetPortWindowPort(theWindow);
1262 if (!RetrieveWinPos(theWindow, &pos.v, &pos.h)) {
1263 pos.v = 0; /* take window's existing position */
1264 pos.h = 0;
1265 LocalToGlobal(&pos);
1266 }
1267
1268 max_h = scr_r.bottom - win_ind.bottom - pos.v;
1269 if (height > max_h)
1270 height = max_h;
1271 if (height < MIN_HEIGHT)
1272 height = MIN_HEIGHT;
1273 if (width < min_w)
1274 width = min_w;
1275 if (width > max_w)
1276 width = max_w;
1277 SizeWindow(theWindow, width, height, true);
1278
1279 if (pos.v + height + win_ind.bottom > scr_r.bottom)
1280 pos.v = scr_r.bottom - height - win_ind.bottom;
1281 if (pos.h + width + win_ind.right > scr_r.right)
1282 pos.h = scr_r.right - width - win_ind.right;
1283 MoveWindow(theWindow, pos.h, pos.v, false);
1284#endif
1285 if (aWin->scrollBar)
1286 DrawScrollbar(aWin);
1287 return;
1288}
1289
1290/*
1291 * display/select/update the window.

Callers 1

mac_display_nhwindowFunction · 0.85

Calls 2

RetrieveWinPosFunction · 0.85
DrawScrollbarFunction · 0.85

Tested by

no test coverage detected