Beispiel #1
0
VOID Finalize(VOID)
{
    APIRET rc;

    // Save Options to INI file
    SaveScoresToIni();
    SaveOptionsToIni();
    WinStoreWindowPos(szAppName, szKeyPosition, hwndFrame);


    // close the game engine and the associated async thread, if any
    Eng_Close();
    dprint("gameEng close\n");

    GfxEng->close();
    dprint("GfxEng close\n");


    // close the sound engine
    // this also takes care of any sound threads
    SndEng->close();
    dprint("SoundEng close");

    if( hrgnInvalid)
	GpiDestroyRegion( hpsClient, hrgnInvalid);
    if( hpsClient)
    {
        GpiAssociate( hpsClient, NULLHANDLE);
        GpiDestroyPS( hpsClient);
    }

    if( hpsPaint)
        GpiDestroyPS( hpsPaint);

    dprint("Destroyed hPS\n");

    DestroyHelpInstance();

    if (hwndFrame)
        WinDestroyWindow( hwndFrame);
    if (hmqMain)
        WinDestroyMsgQueue( hmqMain);
    if (habMain)
        WinTerminate( habMain);
    if (hGame)
        DosClose(hGame);

    dprint("Destroyed handles\n");


    if (debOut)
    {
        fprintf(debOut, "Exiting MakMan/2\n");
        fflush(debOut);
        fclose(debOut);
    }

    DosExit( EXIT_PROCESS, 0);

}   /* end Finalize() */
QRegion::~QRegion()
{
    if ( data->deref() ) {
	if ( data->rgn )
            GpiDestroyRegion( qt_display_ps(), data->rgn );
	delete data;
    }
}
QRegion &QRegion::operator=( const QRegion &r )
{
    r.data->ref();				// beware of r = r
    if ( data->deref() ) {
	if ( data->rgn )
            GpiDestroyRegion( qt_display_ps(), data->rgn );
	delete data;
    }
    data = r.data;
    return *this;
}
QRegion QRegion::pmCombine( const QRegion &r, int op ) const
{
    LONG both = CRGN_NOP, left = CRGN_NOP, right = CRGN_NOP;
    switch ( op ) {
	case QRGN_OR:
	    both = CRGN_OR;
	    left = right = CRGN_COPY;
	    break;
	case QRGN_AND:
	    both = CRGN_AND;
	    break;
	case QRGN_SUB:
	    both = CRGN_DIFF;
	    left = CRGN_COPY;
	    break;
	case QRGN_XOR:
	    both = CRGN_XOR;
	    left = right = CRGN_COPY;
	    break;
	default:
#if defined(QT_CHECK_RANGE)
	    qWarning( "QRegion: Internal error in pmCombine" );
#else
	    ;
#endif
    }

    QRegion result( FALSE );
    if ( !data->rgn && !r.data->rgn )
        return result;
    HPS hps = qt_display_ps();
    result.data->rgn = GpiCreateRegion( hps, 0, NULL );
    LONG rc = RGN_NULL; 
    if ( data->rgn && r.data->rgn ) {
        updateHandle( r.data->hgt ); // bring to the same coordinate space
	rc = GpiCombineRegion( hps, result.data->rgn, data->rgn, r.data->rgn, both );
        result.data->hgt = r.data->hgt;
    } else if ( data->rgn && left != CRGN_NOP ) {
	rc = GpiCombineRegion( hps, result.data->rgn, data->rgn, 0, left );
        result.data->hgt = data->hgt;
    } else if ( r.data->rgn && right != CRGN_NOP ) {
	rc = GpiCombineRegion( hps, result.data->rgn, r.data->rgn, 0, right );
        result.data->hgt = r.data->hgt;
    }
    if ( rc == RGN_NULL || rc == RGN_ERROR ) {
        GpiDestroyRegion( hps, result.data->rgn );
        result.data->rgn = result.data->hgt = 0;
    }
    return result;
}
Beispiel #5
0
void externalPaint(HWND hwnd)
{
    // hwnd is the value returned by QWidget::winId()

    RECTL rcl;
    WinQueryWindowRect(hwnd, &rcl);
    HPS hps = WinGetPS(hwnd);

    HRGN hrgn = GpiCreateRegion(hps, 1L, &rcl);
    ULONG rc = qt_WinProcessWindowObstacles(hwnd, NULL, hrgn, CRGN_DIFF,
                                            0 /* PWO_Default */);
    if (rc == RGN_RECT || rc == RGN_COMPLEX) {
        HRGN hrgnOld;
        GpiSetClipRegion (hps, hrgn, &hrgnOld);
        hrgn = hrgnOld;

        // Paint to hps using regular PM and GPI calls
    }

    GpiDestroyRegion (hps, hrgn);

    WinReleasePS (hps);
}
Beispiel #6
0
/*!
    \internal

    Deletes the given region handle.
 */
void QRegion::disposeHandle(HRGN hrgn)
{
    if (hrgn != 0)
        GpiDestroyRegion(qt_display_ps(), hrgn);
}
//----------------------------------------------------------------------------
// NPP_Print:
//----------------------------------------------------------------------------
void NP_LOADDS
NPP_Print(NPP instance, NPPrint* printInfo)
{
    if(printInfo == 0   )   // trap invalid parm
        return;

    if (instance != 0   )
    {
        PluginInstance* This = (PluginInstance*) instance->pdata;

        if (printInfo->mode == NP_FULL)
        {
            //
            // *Developers*: If your plugin would like to take over
            // printing completely when it is in full-screen mode,
            // set printInfo->pluginPrinted to TRUE and print your
            // plugin as you see fit.  If your plugin wants Netscape
            // to handle printing in this case, set printInfo->pluginPrinted
            // to FALSE (the default) and do nothing.  If you do want
            // to handle printing yourself, printOne is true if the
            // print button (as opposed to the print menu) was clicked.
            // On the Macintosh, platformPrint is a THPrint; on Windows,
            // platformPrint is a structure (defined in npapi.h) containing
            // the printer name, port, etc.
            //
            void* platformPrint = printInfo->print.fullPrint.platformPrint;
            NPBool printOne = printInfo->print.fullPrint.printOne;

            printInfo->print.fullPrint.pluginPrinted = FALSE; // Do the default

        }
        else    // If not fullscreen, we must be embedded
        {
            //
            // *Developers*: If your plugin is embedded, or is full-screen
            // but you returned false in pluginPrinted above, NPP_Print
            // will be called with mode == NP_EMBED.  The NPWindow
            // in the printInfo gives the location and dimensions of
            // the embedded plugin on the printed page.  On the Macintosh,
            // platformPrint is the printer port; on Windows, platformPrint
            // is the handle to the printing device context.
            //
            NPWindow* printWindow = &(printInfo->print.embedPrint.window);
            void* platformPrint = printInfo->print.embedPrint.platformPrint;

            /* get Presentation Space and save it */
            HPS hps = (HPS)platformPrint;
            LONG saveID = GpiSavePS(hps);

            /* create GPI various data structures about the drawing area */
            POINTL offWindow = { -(int)printWindow->x, -(int)printWindow->y };
            // POINTL endPoint = { (int)printWindow->width, (int)printWindow->height };
            RECTL rect = { (int)printWindow->x,
                           (int)printWindow->y,
                           (int)printWindow->x + (int)printWindow->width,
                           (int)printWindow->y + (int)printWindow->height };

            /* get model transform so origin is 0,0 */
            MATRIXLF matModel;
            GpiQueryModelTransformMatrix(hps, 9L, &matModel);
            GpiTranslate(hps, &matModel, TRANSFORM_ADD, &offWindow);
            GpiSetModelTransformMatrix(hps, 9L, &matModel, TRANSFORM_REPLACE);

            /* set clipping region so we don't accidently draw outside our rectangle */
            HRGN hrgn, hrgnOld;
            GpiCreateRegion(hps, 1, &rect);
            GpiSetClipRegion(hps, hrgn, &hrgnOld);

            /* draw clock */
            // TBD

            /* restore PS after drawing and delete created objects */
            GpiDestroyRegion(hps, hrgn);
            GpiDestroyRegion(hps, hrgnOld);
            GpiRestorePS(hps, saveID);
        }
    }
}