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); }
//---------------------------------------------------------------------------- // 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); } } }