Annotation of rpl/src/encart.c, revision 1.52

1.1       bertrand    1: /*
                      2: ================================================================================
1.52    ! bertrand    3:   RPL/2 (R) version 4.1.21
1.50      bertrand    4:   Copyright (C) 1989-2015 Dr. BERTRAND Joël
1.1       bertrand    5: 
                      6:   This file is part of RPL/2.
                      7: 
                      8:   RPL/2 is free software; you can redistribute it and/or modify it
                      9:   under the terms of the CeCILL V2 License as published by the french
                     10:   CEA, CNRS and INRIA.
                     11:  
                     12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
                     13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                     14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
                     15:   for more details.
                     16:  
                     17:   You should have received a copy of the CeCILL License
                     18:   along with RPL/2. If not, write to info@cecill.info.
                     19: ================================================================================
                     20: */
                     21: 
                     22: 
1.11      bertrand   23: #include "rpl-conv.h"
1.1       bertrand   24: 
                     25: #ifdef MOTIF_SUPPORT
                     26: #  include <X11/Xlib.h>
1.28      bertrand   27: #  include "X11/xpm.h"
                     28: #  include "Xm/XmAll.h"
1.1       bertrand   29: #endif
                     30: 
                     31: 
                     32: void
1.42      bertrand   33: encart(struct_processus *s_etat_processus, integer8 duree)
1.1       bertrand   34: {
                     35: #  ifdef MOTIF_SUPPORT
                     36: #  include "rpl.xpm"
                     37: 
                     38:    Display             *display;
                     39: 
                     40:    int                 argc;
                     41:    int                 erreur;
                     42:    int                 hauteur;
                     43:    int                 hauteur_xpm;
                     44:    int                 largeur;
                     45:    int                 largeur_xpm;
                     46: 
                     47:    Pixel               couleur_arriere_plan;
                     48:    Pixel               couleur_avant_plan;
                     49: 
                     50:    Pixmap              pixmap_rpl;
                     51:    Pixmap              pixmap_rpl_masque;
                     52: 
                     53:    Position            hauteur_popup;
                     54:    Position            largeur_popup;
                     55: 
                     56:    String              *argv;
                     57: 
                     58:    struct timespec     attente;
                     59: 
                     60:    struct timeval      temps_ecoule;
                     61:    struct timeval      horodatage_initial;
                     62:    struct timeval      horodatage_final;
                     63: 
1.42      bertrand   64:    long                decor;
                     65:    long                fonctions;
1.1       bertrand   66: 
                     67:    Widget              cadre;
                     68:    Widget              form;
                     69:    Widget              objet_principal;
                     70:    Widget              pixmap;
                     71: 
                     72:    XEvent              evenement;
                     73: 
                     74:    XtAppContext        app;
                     75: 
                     76:    if (strstr(XmVERSION_STRING, "LessTif") != NULL)
                     77:    {
                     78:        printf("Lesstif is broken, please consider an upgrade to OpenMotif.\n");
                     79:        return;
                     80:    }
                     81: 
                     82:    argc = 0;
                     83:    argv = NULL;
                     84: 
                     85:    display = XOpenDisplay(NULL);
                     86: 
                     87:    // Si display est nul, il n'y pas de serveur X.
                     88: 
                     89:    if (display != NULL)
                     90:    {
                     91:        XCloseDisplay(display);
                     92: 
                     93:        objet_principal = XtVaOpenApplication(&app, "rpl",
                     94:                NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL);
                     95:        XSynchronize(XtDisplay(objet_principal), False);
                     96: 
                     97:        form = XtVaCreateManagedWidget("rplSplashScreen",
                     98:                xmFormWidgetClass, objet_principal,
                     99:                NULL);
                    100: 
                    101:        cadre = XtVaCreateManagedWidget("rplExternalFrame",
                    102:                xmFrameWidgetClass, form,
                    103:                XmNtopAttachment, XmATTACH_FORM,
                    104:                XmNbottomAttachment, XmATTACH_FORM,
                    105:                XmNleftAttachment, XmATTACH_FORM,
                    106:                XmNrightAttachment, XmATTACH_FORM,
                    107:                XmNtopOffset, 5,
                    108:                XmNleftOffset, 5,
                    109:                XmNrightOffset, 5,
                    110:                XmNbottomOffset, 5,
                    111:                XmNmarginWidth, 5,
                    112:                XmNmarginHeight, 5,
                    113:                NULL);
                    114:        
                    115:        XtVaGetValues(form,
                    116:                XmNforeground, &couleur_avant_plan,
                    117:                XmNbackground, &couleur_arriere_plan,
                    118:                NULL);
                    119: 
                    120:        if ((erreur = XCreatePixmapFromData(XtDisplay(form),
                    121:                DefaultRootWindow(XtDisplay(form)), rpl_xpm,
                    122:                &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0)
                    123:        {
                    124:            (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
                    125:            return;
                    126:        }
                    127: 
                    128:        pixmap = XtVaCreateManagedWidget("rplPixmap",
                    129:                xmLabelWidgetClass, cadre,
                    130:                XmNlabelType, XmPIXMAP,
                    131:                XmNlabelPixmap, pixmap_rpl,
                    132:                NULL);
                    133: 
                    134:        XtVaGetValues(objet_principal,
                    135:                XmNmwmDecorations, &decor,
                    136:                XmNmwmFunctions, &fonctions,
                    137:                NULL);
                    138: 
                    139:        decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH
                    140:                + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER);
                    141:        fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE
                    142:                + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE);
                    143: 
                    144:        largeur = WidthOfScreen(XtScreen(form));
                    145:        hauteur = HeightOfScreen(XtScreen(form));
                    146: 
                    147:        XtVaSetValues(objet_principal,
                    148:                XmNmwmDecorations, decor,
                    149:                XmNmwmFunctions, fonctions,
                    150:                NULL);
                    151: 
                    152: #if 0
                    153:        XtRealizeWidget(objet_principal);
                    154: 
                    155:        XtVaGetValues(objet_principal,
                    156:                XmNheight, &hauteur_popup,
                    157:                XmNwidth, &largeur_popup,
                    158:                NULL);
                    159: 
                    160:        XtVaSetValues(objet_principal,
                    161:                XmNx, (largeur - largeur_popup) / 2,
                    162:                XmNy, (hauteur - hauteur_popup) / 2,
                    163:                NULL);
                    164: #else
                    165:        sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm);
                    166: 
1.42      bertrand  167:        largeur_popup = (Position) (largeur_xpm + 28);
                    168:        hauteur_popup = (Position) (hauteur_xpm + 28);
1.1       bertrand  169: 
                    170:        XtVaSetValues(objet_principal,
                    171:                XmNx, (largeur - largeur_popup) / 2,
                    172:                XmNy, (hauteur - hauteur_popup) / 2,
                    173:                NULL);
                    174: 
                    175:        XtRealizeWidget(objet_principal);
                    176: #endif
                    177: 
                    178:        XFlush(XtDisplay(form));
                    179: 
                    180:        attente.tv_sec = 0;
                    181:        attente.tv_nsec = 1000;
                    182: 
                    183:        gettimeofday(&horodatage_initial, NULL);
                    184: 
                    185:        do
                    186:        {
                    187:            if (XtAppPending(app) != 0)
                    188:            {
                    189:                XtAppNextEvent(app, &evenement);
                    190:                XtDispatchEvent(&evenement);
                    191:            }
                    192: 
                    193:            nanosleep(&attente, NULL);
                    194:            gettimeofday(&horodatage_final, NULL);
                    195: 
                    196:            temps_ecoule.tv_sec = horodatage_final.tv_sec
                    197:                    - horodatage_initial.tv_sec;
                    198:            temps_ecoule.tv_usec = horodatage_final.tv_usec
                    199:                    - horodatage_initial.tv_usec;
                    200: 
                    201:            if (temps_ecoule.tv_usec < 0)
                    202:            {
                    203:                temps_ecoule.tv_usec += 1000000;
                    204:                temps_ecoule.tv_sec--;
                    205:            }
1.42      bertrand  206:        } while (((((double) temps_ecoule.tv_usec) / ((double) 1000000))
                    207:                + ((double) temps_ecoule.tv_sec))
                    208:                < (((double) duree) / ((double) 1000000)));
1.1       bertrand  209: 
                    210:        XtUnrealizeWidget(objet_principal);
                    211: 
                    212:        XmDestroyPixmap(XtScreen(form), pixmap_rpl);
                    213:        XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque);
                    214: 
                    215:        XtDestroyWidget(pixmap);
                    216:        XtDestroyWidget(cadre);
                    217:        XtDestroyWidget(form);
                    218:        XtDestroyWidget(objet_principal);
                    219: 
                    220:        while(XtAppPending(app) == 0)
                    221:        {
                    222:            nanosleep(&attente, NULL);
                    223:        }
                    224: 
                    225:        while(XtAppPending(app) != 0)
                    226:        {
                    227:            XtAppNextEvent(app, &evenement);
                    228:            XtDispatchEvent(&evenement);
                    229:            nanosleep(&attente, NULL);
                    230:        }
                    231: 
                    232:        XtDestroyApplicationContext(app);
                    233:    }
                    234: #  endif
                    235: 
                    236:    return;
                    237: }
                    238: 
                    239: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>