Beispiel #1
0
int InitGUI (void)
{
    int step = 1;

    // Save original termio
#ifndef _STAND_ALONE
    if (mgIsServer)
#endif
        tcgetattr (0, &savedtermio);

    if (!InitMisc ()) {
        err_message (step, "Can not initialize miscellous things!");
        return step;
    }
    step++;

#ifndef _STAND_ALONE
    if (mgIsServer && !IsOnlyMe ()) {
        err_message (step, "There is already an instance of 'mginit'!");
        return step;
    }
    step++;
#endif

    // Init GAL engine.
    switch (InitGAL ()) {
    case ERR_CONFIG_FILE:
        err_message (step, "Reading configuration failure!");
        return step;

    case ERR_NO_ENGINE:
        err_message (step, "No graphics engine defined!");
        return step;

    case ERR_NO_MATCH:
        err_message (step, "Can not get graphics engine information!");
        return step;

    case ERR_GFX_ENGINE:
        err_message (step, "Can not initialize graphics engine!");
        return step;
    }
    step++;
    atexit (TerminateGAL);

    /* install signal handlers */
#ifndef _STAND_ALONE
    if (mgIsServer)
#endif
        InstallSEGVHandler ();

    if (!InitGDI ()) {
        err_message (step, "MiniGUI: Initialization of GDI resource failure!\n");
        return step;
    }
    step++;
    atexit (TerminateGDI);

    /* Init Screen DC here */
    if (!InitScreenDC ()) {
        err_message (step, "Can not initialize screen DC!");
        return step;
    }
    step++;
    atexit (TerminateScreenDC);

    g_rcScr.left = 0;
    g_rcScr.top = 0;
    g_rcScr.right = GetGDCapability (HDC_SCREEN, GDCAP_MAXX) + 1;
    g_rcScr.bottom = GetGDCapability (HDC_SCREEN, GDCAP_MAXY) + 1;

    if (!InitWindowElementColors ()) {
        err_message (step, "Can not initialize colors of window element!");
        return step;
    }
    step++;

#ifndef _STAND_ALONE
    if (mgIsServer) {
        // Load shared resource and create shared memory.
        if ((mgSharedRes = LoadSharedResource ()) == NULL) {
            err_message (step, "Can not load shared resource!");
            return step;
        }
        atexit (UnloadSharedResource);
        SHAREDRES_TERMIOS = savedtermio;
    }
    else {
        if ((mgSharedRes = AttachSharedResource ()) == NULL) {
            err_message (step, "Can not attach shared resource!");
            return step;
        }
        atexit (UnattachSharedResource);
    }
    step++;

#endif

    // Initialize resource
    if (!InitResource ()) {
        err_message (step, "Can not initialize resource!");
        return step;
    }
    step++;

#ifdef _STAND_ALONE

    // Init IAL engine..
    if (!InitLWEvent ()) {
        err_message (step, "Can not initialize low level event!");
        return step;
    }
    step++;

    atexit (TerminateLWEvent);

    __mg_dsk_msgs.OnIdle = IdleHandler4StandAlone;

    if (!StandAloneStartup ()) {
        fprintf (stderr, "Can not start MiniGUI-Lite StandAlone version.\n");
        return step;
    }

#else

    if (mgIsServer) {
        // Init IAL engine..
        if (!InitLWEvent ()) {
            err_message (step, "Can not initialize low level event!");
            return step;
        }
        step++;

        atexit (TerminateLWEvent);

        __mg_dsk_msgs.OnIdle = IdleHandler4Server;

        if (!ServerStartup ()) {
            fprintf (stderr, "Can not start the server of MiniGUI-Lite: mginit.\n");
            return step;
        }
    }
    else {
        if (!ClientStartup ()) {
            err_message (step, "Can not start client!");
            return step;
        }
        step++;

        __mg_dsk_msgs.OnIdle = IdleHandler4Client;
    }
#endif

    SetKeyboardLayout ("default");

    TerminateMgEtc ();
    return 0;
}
Beispiel #2
0
/* InvokeXLISP - invoke the xlisp interpreter */
int InvokeXLISP(xlCallbacks *callbacks,int argc,char *argv[])
{
    xlSubrDef *sdp;
    xlXSubrDef *xsdp;
    
    /* initialize xlisp */
    if (!xlInit(callbacks,argc,argv,NULL)) {
        Error("initializing xlisp");
        return FALSE;
    }

    /* set our platform type */
    xlSetSoftwareType("WIN95");

    /* add all of our functions */
    for (sdp = subrtab; sdp->name != NULL; ++sdp)
        xlSubr(sdp->name,sdp->subr);
    for (xsdp = xsubrtab; xsdp->name != NULL; ++xsdp)
        xlXSubr(xsdp->name,xsdp->subr);

    /* initialize the widget classes */
    InitWidgets();

    /* initialize the window classes */
    InitWindows();

    /* initialize the canvas class */
    InitCanvas();
    
    /* initialize the menu classes */
    InitMenus();

    /* initialize the edit classes */
    InitEdit();

    /* initialize the toolbar routines */
    InitToolbars();

    /* initialize the accelerator routines */
    InitAccelerators();

    /* initialize the listener routines */
    InitListener();

    /* initialize the miscellaneous routines */
    InitMisc();

    /* setup the *command-line* variable */
    xlVal = xlMakeCString((char *)GetCommandLine());
    xlSetValue(xlEnter("*COMMAND-LINE*"),xlVal);

    /* load the lisp code */
    xlLoadFile("xlispw.lsp");
    
    /* display the banner */
    xlInfo("%s",xlBanner());
    
    /* display the initial prompt */
    xlCallFunctionByName(NULL,0,"LISTENER-PROMPT",0);

    /* flush terminal output */
    xlosFlushOutput();

    /* return successfully */
    return TRUE;
}