/* ================================================================================ RPL/2 (R) version 4.0.12 Copyright (C) 1989-2010 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl.conv.h" #ifdef MOTIF_SUPPORT # include # include # include #endif void encart(struct_processus *s_etat_processus, unsigned long duree) { # ifdef MOTIF_SUPPORT # include "rpl.xpm" Display *display; int argc; int erreur; int hauteur; int hauteur_xpm; int largeur; int largeur_xpm; Pixel couleur_arriere_plan; Pixel couleur_avant_plan; Pixmap pixmap_rpl; Pixmap pixmap_rpl_masque; Position hauteur_popup; Position largeur_popup; String *argv; struct timespec attente; struct timeval temps_ecoule; struct timeval horodatage_initial; struct timeval horodatage_final; unsigned long decor; unsigned long fonctions; Widget cadre; Widget form; Widget objet_principal; Widget pixmap; XEvent evenement; XtAppContext app; if (strstr(XmVERSION_STRING, "LessTif") != NULL) { printf("Lesstif is broken, please consider an upgrade to OpenMotif.\n"); return; } argc = 0; argv = NULL; display = XOpenDisplay(NULL); // Si display est nul, il n'y pas de serveur X. if (display != NULL) { XCloseDisplay(display); objet_principal = XtVaOpenApplication(&app, "rpl", NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL); XSynchronize(XtDisplay(objet_principal), False); form = XtVaCreateManagedWidget("rplSplashScreen", xmFormWidgetClass, objet_principal, NULL); cadre = XtVaCreateManagedWidget("rplExternalFrame", xmFrameWidgetClass, form, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopOffset, 5, XmNleftOffset, 5, XmNrightOffset, 5, XmNbottomOffset, 5, XmNmarginWidth, 5, XmNmarginHeight, 5, NULL); XtVaGetValues(form, XmNforeground, &couleur_avant_plan, XmNbackground, &couleur_arriere_plan, NULL); if ((erreur = XCreatePixmapFromData(XtDisplay(form), DefaultRootWindow(XtDisplay(form)), rpl_xpm, &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } pixmap = XtVaCreateManagedWidget("rplPixmap", xmLabelWidgetClass, cadre, XmNlabelType, XmPIXMAP, XmNlabelPixmap, pixmap_rpl, NULL); XtVaGetValues(objet_principal, XmNmwmDecorations, &decor, XmNmwmFunctions, &fonctions, NULL); decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER); fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE); largeur = WidthOfScreen(XtScreen(form)); hauteur = HeightOfScreen(XtScreen(form)); XtVaSetValues(objet_principal, XmNmwmDecorations, decor, XmNmwmFunctions, fonctions, NULL); #if 0 XtRealizeWidget(objet_principal); XtVaGetValues(objet_principal, XmNheight, &hauteur_popup, XmNwidth, &largeur_popup, NULL); XtVaSetValues(objet_principal, XmNx, (largeur - largeur_popup) / 2, XmNy, (hauteur - hauteur_popup) / 2, NULL); #else sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm); largeur_popup = largeur_xpm + 28; hauteur_popup = hauteur_xpm + 28; XtVaSetValues(objet_principal, XmNx, (largeur - largeur_popup) / 2, XmNy, (hauteur - hauteur_popup) / 2, NULL); XtRealizeWidget(objet_principal); #endif XFlush(XtDisplay(form)); attente.tv_sec = 0; attente.tv_nsec = 1000; gettimeofday(&horodatage_initial, NULL); do { if (XtAppPending(app) != 0) { XtAppNextEvent(app, &evenement); XtDispatchEvent(&evenement); } nanosleep(&attente, NULL); gettimeofday(&horodatage_final, NULL); temps_ecoule.tv_sec = horodatage_final.tv_sec - horodatage_initial.tv_sec; temps_ecoule.tv_usec = horodatage_final.tv_usec - horodatage_initial.tv_usec; if (temps_ecoule.tv_usec < 0) { temps_ecoule.tv_usec += 1000000; temps_ecoule.tv_sec--; } } while (((temps_ecoule.tv_usec / ((double) 1000000)) + temps_ecoule.tv_sec) < (duree / ((double) 1000000))); XtUnrealizeWidget(objet_principal); XmDestroyPixmap(XtScreen(form), pixmap_rpl); XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque); XtDestroyWidget(pixmap); XtDestroyWidget(cadre); XtDestroyWidget(form); XtDestroyWidget(objet_principal); while(XtAppPending(app) == 0) { nanosleep(&attente, NULL); } while(XtAppPending(app) != 0) { XtAppNextEvent(app, &evenement); XtDispatchEvent(&evenement); nanosleep(&attente, NULL); } XtDestroyApplicationContext(app); } # endif return; } // vim: ts=4