platform/platform_window.c
/*	Displays a simple dialogue window.
*/
Displays a simple dialogue window.
Displays a simple dialogue window .
void plMessageBox(const char *ccTitle, const char *ccMessage, ...)
{
	char	cOut[2048];
	va_list	vlArguments;
	pFUNCTION_UPDATE();
	va_start(vlArguments, ccMessage);
	vsprintf(cOut, ccMessage, vlArguments);
	va_end(vlArguments);
	printf("Platform: %s", cOut);
#ifndef _WIN32
	{
		int     iDefaultScreen;
		XEvent  xEvent;
		Display *dMessageDisplay;
		Window  wMessageWindow;
		dMessageDisplay = XOpenDisplay(NULL);
		if (!dMessageDisplay)
		{
			plSetError("Failed to open display!\n");
			return;
		}
		iDefaultScreen = DefaultScreen(dMessageDisplay);
		wMessageWindow = XCreateSimpleWindow(
			dMessageDisplay,
			RootWindow(dMessageDisplay, iDefaultScreen),
			50, 50,
			512, 64,
			1,
			BlackPixel(dMessageDisplay, iDefaultScreen),
			WhitePixel(dMessageDisplay, iDefaultScreen));
		XStoreName(dMessageDisplay, wMessageWindow, ccTitle);
		XSelectInput(dMessageDisplay, wMessageWindow, ExposureMask | KeyPressMask);
		XMapWindow(dMessageDisplay, wMessageWindow);
		for (;;)
		{
			XNextEvent(dMessageDisplay, &xEvent);
			if (xEvent.type == Expose)
			{
				XDrawString(dMessageDisplay, wMessageWindow, DefaultGC(dMessageDisplay, iDefaultScreen), 10, 10, cOut, strlen(cOut));
				XDrawString(dMessageDisplay, wMessageWindow, DefaultGC(dMessageDisplay, iDefaultScreen), 10, 54, "Press any key to continue...", 32);
			}
			else if (xEvent.type == KeyPress)
				break;
		}
		XCloseDisplay(dMessageDisplay);
	}
#else   
	MessageBoxEx(NULL, cOut, ccTitle, MB_SETFOREGROUND | MB_ICONERROR, 0);
#endif
}
void plMessageBox ( const char * ccTitle , const char * ccMessage , ... ) { char cOut [ 2048 ] ; va_list vlArguments ; pFUNCTION_UPDATE ( ) ; va_start ( vlArguments , ccMessage ) ; vsprintf ( cOut , ccMessage , vlArguments ) ; va_end ( vlArguments ) ; printf ( " " , cOut ) ; #ifndef _WIN32 { int iDefaultScreen ; XEvent xEvent ; Display * dMessageDisplay ; Window wMessageWindow ; dMessageDisplay = XOpenDisplay ( NULL ) ; if ( ! dMessageDisplay ) { plSetError ( " \n " ) ; return ; } iDefaultScreen = DefaultScreen ( dMessageDisplay ) ; wMessageWindow = XCreateSimpleWindow ( dMessageDisplay , RootWindow ( dMessageDisplay , iDefaultScreen ) , 50 , 50 , 512 , 64 , 1 , BlackPixel ( dMessageDisplay , iDefaultScreen ) , WhitePixel ( dMessageDisplay , iDefaultScreen ) ) ; XStoreName ( dMessageDisplay , wMessageWindow , ccTitle ) ; XSelectInput ( dMessageDisplay , wMessageWindow , ExposureMask | KeyPressMask ) ; XMapWindow ( dMessageDisplay , wMessageWindow ) ; for ( ; ; ) { XNextEvent ( dMessageDisplay , & xEvent ) ; if ( xEvent . type == Expose ) { XDrawString ( dMessageDisplay , wMessageWindow , DefaultGC ( dMessageDisplay , iDefaultScreen ) , 10 , 10 , cOut , strlen ( cOut ) ) ; XDrawString ( dMessageDisplay , wMessageWindow , DefaultGC ( dMessageDisplay , iDefaultScreen ) , 10 , 54 , " " , 32 ) ; } else if ( xEvent . type == KeyPress ) break ; } XCloseDisplay ( dMessageDisplay ) ; } #else MessageBoxEx ( NULL , cOut , ccTitle , MB_SETFOREGROUND | MB_ICONERROR , 0 ) ; #endif }
Displays a simple dialogue window.
Displays a simple dialogue window .
// Also print a message out, on the off chance the message box fails. // Windows