static INT CreateMemoryPS (PINST pinstMain, HPS hpsTarget,
    PRECTL prclTargetWnd)
{
    SIZEL   sizl;
    HDC     hdcTarget = GpiQueryDevice(hpsTarget);

    pinstMain->hdcMem = DevOpenDC(pinstMain->hab,OD_MEMORY,"*",
        0L,NULL,hdcTarget);
    assert (pinstMain->hdcMem != DEV_ERROR);

    //
    // Set the size of the presentation space to be created.
    //
    sizl.cx = prclTargetWnd->xRight;
    sizl.cy = prclTargetWnd->yTop;

    //
    // Create the memory presentation space for the bitmap.
    //
    pinstMain->hpsMemRadar = GpiCreatePS(pinstMain->hab,
       pinstMain->hdcMem,&sizl,
       PU_PELS | GPIA_ASSOC | GPIT_MICRO);
    assert (pinstMain->hpsMemRadar != GPI_ERROR);

    return 0;
}
Пример #2
0
void qt_free_mem_ps(HPS hps)
{
    HDC hdc = GpiQueryDevice(hps);
    GpiAssociate(hps, NULLHANDLE);
    GpiDestroyPS(hps);
    DevCloseDC(hdc);
}
Пример #3
0
QT_BEGIN_NAMESPACE

HPS qt_alloc_mem_ps(int w, int h, HPS compat = 0)
{
    HDC hdcCompat = NULLHANDLE;
    if (compat)
        hdcCompat = GpiQueryDevice(compat);

    static PCSZ hdcData[4] = { "Display", NULL, NULL, NULL };
    HDC hdc = DevOpenDC(0, OD_MEMORY, "*", 4, (PDEVOPENDATA) hdcData, hdcCompat);
    if (!hdc) {
        qWarning( "alloc_mem_dc: DevOpenDC failed with %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    SIZEL size = { w, h };
    HPS hps = GpiCreatePS(0, hdc, &size, PU_PELS | GPIA_ASSOC | GPIT_MICRO);
    if (hps == NULLHANDLE) {
        qWarning("alloc_mem_dc: GpiCreatePS failed wit %08lX!", WinGetLastError(0));
        return NULLHANDLE;
    }
    // @todo later
//  if (QColor::hPal()) {
//      GpiSelectPalette(hps, QColor::hPal());
//  } else {
        // direct RGB mode
        GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL);
//  }
    return hps;
}
Пример #4
0
/*DOC
CLASS    XPalette
FUNCTION XPalette
GROUP    x-games/constructors/destructor
REMARKS  Default constructor for a palette object. Queries the WPS colors (0-9, 246-255) and stores
         them.
*/
XPalette::XPalette()
{
        int     i;

        // get HPS and HDC of the root window
        hpsDesktop = WinGetPS( HWND_DESKTOP );
        hdcDesktop = GpiQueryDevice( hpsDesktop );

        // get WPS colors
        GpiQueryRealColors( hpsDesktop, 0, 0, 256, (PLONG)aulWPSPalette );
        memcpy( &aulData[0], &aulWPSPalette[0], 256 * sizeof( ULONG ) );
} // XPalette::XPalette
Пример #5
0
void wxConvertVectorFontSize(
  FIXED                             fxPointSize
, PFATTRS                           pFattrs
)
{
    HPS                             hPS;
    HDC                             hDC;
    LONG                            lXFontResolution;
    LONG                            lYFontResolution;
    SIZEF                           vSizef;

    hPS = WinGetScreenPS(HWND_DESKTOP); // Screen presentation space

    //
    //   Query device context for the screen and then query
    //   the resolution of the device for the device context.
    //

    hDC = GpiQueryDevice(hPS);
    DevQueryCaps( hDC, CAPS_HORIZONTAL_FONT_RES, (LONG)1, &lXFontResolution);
    DevQueryCaps( hDC, CAPS_VERTICAL_FONT_RES, (LONG)1, &lYFontResolution);

    //
    //   Calculate the size of the character box, based on the
    //   point size selected and the resolution of the device.
    //   The size parameters are of type FIXED, NOT int.
    //   NOTE: 1 point == 1/72 of an inch.
    //

    // multiply first to avoid getting vSizef.cx,cy = 0 since fxPointSize
    // is normally < 72 and FontResolution is typically ca. 100
    vSizef.cx = (FIXED)( (fxPointSize * lXFontResolution) / 72 );
    vSizef.cy = (FIXED)( (fxPointSize * lYFontResolution) / 72 );

    if (pFattrs)
    {
        pFattrs->lMaxBaselineExt = MAKELONG( HIUSHORT( vSizef.cy ), 0 );
        pFattrs->lAveCharWidth   = MAKELONG( HIUSHORT( vSizef.cx ), 0 );
    }
    WinReleasePS(hPS);

} // end of wxConvertVectorPointSize
HDC
nsThebesDeviceContext::GetPrintHDC()
{
    if (mPrintingSurface) {
        switch (mPrintingSurface->GetType()) {
#ifdef XP_WIN
            case gfxASurface::SurfaceTypeWin32:
            case gfxASurface::SurfaceTypeWin32Printing:
                return reinterpret_cast<gfxWindowsSurface*>(mPrintingSurface.get())->GetDC();
#endif

#ifdef XP_OS2
            case gfxASurface::SurfaceTypeOS2:
                return GpiQueryDevice(reinterpret_cast<gfxOS2Surface*>(mPrintingSurface.get())->GetPS());
#endif

            default:
                NS_ERROR("invalid surface type in GetPrintHDC");
                break;
        }
    }

    return nsnull;
}
Пример #7
0
/*
 * Query the font used for various CSS properties (aID) from the system.
 * For OS/2, only very few fonts are defined in the system, so most of the IDs
 * resolve to the same system font.
 * The font queried will give back a string like
 *    9.WarpSans Bold
 *    12.Times New Roman Bold Italic
 *    10.Times New Roman.Strikeout.Underline
 *    20.Bitstream Vera Sans Mono Obli
 * (always restricted to 32 chars, at least before the second dot)
 * We use the value before the dot as the font size (in pt, and convert it to
 * px using the screen resolution) and then try to use the rest of the string
 * to determine the font style from it.
 */
nsresult nsSystemFontsOS2::GetSystemFont(nsSystemFontID aID, nsString* aFontName,
                                         gfxFontStyle *aFontStyle) const
{
#ifdef DEBUG_thebes
    printf("nsSystemFontsOS2::GetSystemFont: ");
#endif
    char szFontNameSize[MAXNAMEL];

    switch (aID)
    {
    case eSystemFont_Icon:
        QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL);
#ifdef DEBUG_thebes
        printf("IconText ");
#endif
        break;

    case eSystemFont_Menu:
        QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL);
#ifdef DEBUG_thebes
        printf("Menus ");
#endif
        break;

    case eSystemFont_Caption:
    case eSystemFont_MessageBox:
    case eSystemFont_SmallCaption:
    case eSystemFont_StatusBar:
    case eSystemFont_Tooltips:
    case eSystemFont_Widget:

    case eSystemFont_Window:      // css3
    case eSystemFont_Document:
    case eSystemFont_Workspace:
    case eSystemFont_Desktop:
    case eSystemFont_Info:
    case eSystemFont_Dialog:
    case eSystemFont_Button:
    case eSystemFont_PullDownMenu:
    case eSystemFont_List:
    case eSystemFont_Field:
        QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL);
#ifdef DEBUG_thebes
        printf("WindowText ");
#endif
        break;

    default:
        NS_WARNING("None of the listed font types, using WarpSans");
        if (!IsDBCS()) {
            strcpy(szFontNameSize, "9.WarpSans");
        } else {
            strcpy(szFontNameSize, "9.WarpSans Combined");
        }
    } // switch
#ifdef DEBUG_thebes
    printf(" (%s)\n", szFontNameSize);
#endif

    char *szFacename = strchr(szFontNameSize, '.');
    if (!szFacename || (*(szFacename++) == '\0'))
        return NS_ERROR_FAILURE;

    // local DPI for size will be taken into account below
    aFontStyle->size = atof(szFontNameSize);

    // determine DPI resolution of screen device to compare compute
    // font size in pixels
    HPS ps = WinGetScreenPS(HWND_DESKTOP);
    HDC dc = GpiQueryDevice(ps);
    // effective vertical resolution in DPI
    LONG vertScreenRes = 120; // assume 120 dpi as default
    DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &vertScreenRes);
    WinReleasePS(ps);

    // now scale to make pixels from points (1 pt = 1/72in)
    aFontStyle->size *= vertScreenRes / 72.0;

    NS_ConvertUTF8toUTF16 fontFace(szFacename);
    int pos = 0;

    // this is a system font in any case
    aFontStyle->systemFont = true;

    // bold fonts should have " Bold" in their names, at least we hope that they
    // do, otherwise it's bad luck
    NS_NAMED_LITERAL_CSTRING(spcBold, " Bold");
    if ((pos = fontFace.Find(spcBold.get(), false, 0, -1)) > -1) {
        aFontStyle->weight = FONT_WEIGHT_BOLD;
        // strip the attribute, now that we have set it in the gfxFontStyle
        fontFace.Cut(pos, spcBold.Length());
    } else {
        aFontStyle->weight = FONT_WEIGHT_NORMAL;
    }

    // FIXME: Set aFontStyle->stretch correctly!
    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;

    // similar hopes for italic and oblique fonts...
    NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic");
    NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique");
    NS_NAMED_LITERAL_CSTRING(spcObli, " Obli");
    if ((pos = fontFace.Find(spcItalic.get(), false, 0, -1)) > -1) {
        aFontStyle->style = FONT_STYLE_ITALIC;
        fontFace.Cut(pos, spcItalic.Length());
    } else if ((pos = fontFace.Find(spcOblique.get(), false, 0, -1)) > -1) {
        // oblique fonts are rare on OS/2 and not specially supported by
        // the GPI system, but at least we are trying...
        aFontStyle->style = FONT_STYLE_OBLIQUE;
        fontFace.Cut(pos, spcOblique.Length());
    } else if ((pos = fontFace.Find(spcObli.get(), false, 0, -1)) > -1) {
        // especially oblique often gets cut by the 32 char limit to "Obli",
        // so search for that, too (anything shorter would be ambiguous)
        aFontStyle->style = FONT_STYLE_OBLIQUE;
        // In this case, assume that this is the last property in the line
        // and cut off everything else, too
        // This is needed in case it was really Obliq or Obliqu...
        fontFace.Cut(pos, fontFace.Length());
    } else {
        aFontStyle->style = FONT_STYLE_NORMAL;
    }

    // just throw away any modifiers that are separated by dots (which are either
    // .Strikeout, .Underline, or .Outline, none of which have a corresponding
    // gfxFont property)
    if ((pos = fontFace.Find(".", false, 0, -1)) > -1) {
        fontFace.Cut(pos, fontFace.Length());
    }

#ifdef DEBUG_thebes
    printf("  after=%s\n", NS_LossyConvertUTF16toASCII(fontFace).get());
    printf("  style: %s %s %s\n",
           (aFontStyle->weight == FONT_WEIGHT_BOLD) ? "BOLD" : "",
           (aFontStyle->style == FONT_STYLE_ITALIC) ? "ITALIC" : "",
           (aFontStyle->style == FONT_STYLE_OBLIQUE) ? "OBLIQUE" : "");
#endif
    NS_NAMED_LITERAL_STRING(quote, "\""); // seems like we need quotes around the font name
    *aFontName = quote + fontFace + quote;

    return NS_OK;
}
/***********************************************************************
 *
 *      GpiValidate  - Gets HDC associated with the HPS, check option
 *                     for either TRANSFORM_REPLACE or TRANSFORM_ADD.
 *                     If TRANSFORM_ADD checks validity of elements
 *                     lM13, lM23 and lM33, i.e. 0, 0 and 1 respectively.
 *                     Copy passed matrix into engine structure if
 *                     TRANSFORM_ADD, else sets it to the UNITY matrix.
 *                     If any check fails log error and return a NULL
 *                     HDC otherwise the assoicaited HDC.
 *
 **********************************************************************/
HDC GPI_PRIVATE GpiValidate (                                   // GPIB
                             HPS       hps,                     // GPIB
                             PMATRIXLF pmatlfXform,             // GPIB
                             PXFORM    pxfrmTarget,             // GPIB
                             LONG      lOptions                 // GPIB
                            )                                   // GPIB
{
   HDC hdc;

   //
   // Validate passed params
   //
   // @TN  gabages in gabages out !

   if ((pmatlfXform == NULL) || (pxfrmTarget == NULL))
   {
       LogError( PMERR_INV_MATRIX_ELEMENT );
       return ( FALSE );
   }

   /*----------------------------------------------------------------*/
   /* This function is not valid with an Ink PS.                     */
   /*----------------------------------------------------------------*/
   if ( GpiQueryMicro( hps ) && GpiQueryInkPS( hps ) )
   {
       if (!ValidateDCHandle( hps ))
          LogError( PMERR_INV_HDC );
       else
          LogError( PMERR_INV_INKPS_FUNCTION );
       return ( (HDC) NULL );
   }

   /*
    * get HDC from HPS
    */
   hdc = GpiQueryDevice(hps);
   if (hdc == (HDC) NULL) {

        WinSetErrorInfo32 (
                           MAKEERRORID (SEVERITY_WARNING, PMERR_INV_HDC),
                           SEI_NOBEEP
                          );
       return((HDC)NULL);
   } /* endif */

   if (hdc == HDC_ERROR){
       return((HDC)NULL);
   } /* endif */
   /*
    * check option param
    */
   if (lOptions != TRANSFORM_REPLACE &&
       lOptions != TRANSFORM_ADD) {

      WinSetErrorInfo32 (
                         MAKEERRORID (SEVERITY_WARNING, PMERR_INV_TRANSFORM_TYPE),
                         SEI_NOBEEP
                        );
       return ((HDC) NULL);
   }
   /*
    * check passed matrix elements and copy into engine structure
    * if TRANSFORM_ADD
    */
   if (lOptions == TRANSFORM_ADD) {
       if (pmatlfXform->lM13 != 0 ||
           pmatlfXform->lM23 != 0 ||
           pmatlfXform->lM33 != 1) {

            WinSetErrorInfo32( MAKEERRORID( SEVERITY_WARNING,
                                          PMERR_INV_MATRIX_ELEMENT )
                           , SEI_NOBEEP
                           );
           return((HDC)NULL);
       }
       pxfrmTarget->fxM11 = pmatlfXform->fxM11;
       pxfrmTarget->fxM12 = pmatlfXform->fxM12;
       pxfrmTarget->fxM21 = pmatlfXform->fxM21;
       pxfrmTarget->fxM22 = pmatlfXform->fxM22;
       pxfrmTarget->lM41  = pmatlfXform->lM31;
       pxfrmTarget->lM42  = pmatlfXform->lM32;
   /*
    * else set engine structure to UNITY matrix
    */
   } else {
       pxfrmTarget->fxM11 = UNITY;
       pxfrmTarget->fxM12 = 0;
       pxfrmTarget->fxM21 = 0;
       pxfrmTarget->fxM22 = UNITY;
       pxfrmTarget->lM41  = 0;
       pxfrmTarget->lM42  = 0;

       pmatlfXform->lM13 = 0;
       pmatlfXform->lM23 = 0;
       pmatlfXform->lM33 = 1;
   }

   return(hdc);
}