Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04df9d5

Browse files
committed
Added dialog-centering code to splash()
1 parent d96cb50 commit 04df9d5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Mac/Modules/macosmodule.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ MacOS_splash(PyObject *self, PyObject *args)
502502
{
503503
int resid = -1;
504504
static DialogPtr curdialog;
505+
WindowRef theWindow;
506+
CGrafPtr thePort;
507+
short item;
508+
short xpos, ypos, width, height, swidth, sheight;
505509

506510
if (!PyArg_ParseTuple(args, "|i", &resid))
507511
return NULL;
@@ -510,8 +514,19 @@ MacOS_splash(PyObject *self, PyObject *args)
510514

511515
if ( resid != -1 ) {
512516
curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1);
513-
if ( curdialog )
517+
if ( curdialog ) {
518+
theWindow = GetDialogWindow(curdialog);
519+
thePort = GetWindowPort(theWindow);
520+
width = thePort->portRect.right - thePort->portRect.left;
521+
height = thePort->portRect.bottom - thePort->portRect.top;
522+
swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
523+
sheight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - LMGetMBarHeight();
524+
xpos = (swidth-width)/2;
525+
ypos = (sheight-height)/5 + LMGetMBarHeight();
526+
MoveWindow(theWindow, xpos, ypos, 0);
527+
ShowWindow(theWindow);
514528
DrawDialog(curdialog);
529+
}
515530
}
516531
Py_INCREF(Py_None);
517532
return Py_None;

0 commit comments

Comments
 (0)