예제 #1
0
BOOL GUIAPI SetColorfulPalette (HDC hdc)
{
    PDC pdc;
    GAL_Color pal[256];

    pdc = dc_HDC2PDC (hdc);

    if (pdc->surface->format->BitsPerPixel == 8) {
        GAL_DitherColors (pal, 8);
        GAL_SetColors (pdc->surface, pal, 0, 256);
    }

    return FALSE;
}
예제 #2
0
void GUIAPI SetPixelRGB(HDC hdc, int x, int y, int r, int g, int b)
{
    PDC pdc;
    PCLIPRECT pClipRect;
    RECT rcOutput;
    gal_pixel pixel;
    GAL_Color color;

    pdc = dc_HDC2PDC (hdc);

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return;
        }
    }

    coor_LP2SP (pdc, &x, &y);

    rcOutput.left = x - 1;
    rcOutput.top  = y - 1;
    rcOutput.right = x + 1;
    rcOutput.bottom = y + 1;

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC (pdc->gc);

    color.r = r; color.g = g, color.b = b;
    pixel = GAL_MapColor (pdc->gc, &color);
    GAL_SetFgColor (pdc->gc, pixel);

    pClipRect = pdc->ecrgn.head;
    while (pClipRect)
    {
        if(PtInRect(&(pClipRect->rc), x, y)) {
            GAL_DrawPixel (pdc->gc, x, y, pixel);
            break;
        }
        pClipRect = pClipRect->next;
    }
    
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
    pthread_mutex_unlock(&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);
}
예제 #3
0
int GUIAPI GetMaxFontWidth (HDC hdc)
{
    PDC pdc = dc_HDC2PDC(hdc);
    DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont;
    DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont;
    int sbc_max_width = (*sbc_devfont->font_ops->get_max_width)
                        (pdc->pLogFont, sbc_devfont);
    int mbc_max_width = 0;

    if (mbc_devfont)
        mbc_max_width = (*mbc_devfont->font_ops->get_max_width)
                        (pdc->pLogFont, mbc_devfont);

    return (sbc_max_width > mbc_max_width) ? sbc_max_width : mbc_max_width;
}
예제 #4
0
/************************ Circle and Rectangle *******************************/
void GUIAPI Circle(HDC hdc, int x, int y, int r)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    RECT rcOutput;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return;
        }
    }

    // Transfer logical to device to screen here.
    coor_LP2SP(pdc, &x, &y);

    rcOutput.left = x - r;
    rcOutput.top  = y - r;
    rcOutput.right = x + r + 1;
    rcOutput.bottom = y + r + 1;

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC (pdc->gc);
    GAL_SetFgColor (pdc->gc, pdc->pencolor);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping (pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right -1 , pClipRect->rc.bottom - 1);
            GAL_Circle (pdc->gc, x, y, r, pdc->pencolor);
        }
            
        pClipRect = pClipRect->next;
    }

    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
    pthread_mutex_unlock(&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);
}
void GUIAPI DPtoLP (HDC hdc, POINT* pPt)
{
    PDC pdc;

    pdc = dc_HDC2PDC (hdc);

    if (pdc->mapmode != MM_TEXT) {
        pPt->x = (pPt->x - pdc->ViewOrig.x)
             * pdc->WindowExtent.x / pdc->ViewExtent.x
             + pdc->WindowOrig.x;

        pPt->y = (pPt->y - pdc->ViewOrig.y)
             * pdc->WindowExtent.y / pdc->ViewExtent.y
             + pdc->WindowOrig.y;
    }
}
예제 #6
0
/*
 *  Function: DeleteCompatibleDC (HDC hdc)
 *      This function delete the memory DC, and free the associated memory.
 *  Parameters:
 *      HDC hdc: the DC handle want to delete.
 *  Return:
 *      FALSE: the specified HDC is not a valid memory DC.
 *      TRUE:  deleted.
 */
void GUIAPI DeleteCompatibleDC(HDC hdc)
{
    PDC pMemDC;
    
    pMemDC = dc_HDC2PDC(hdc);

    // free gl resource
    GAL_FreeGC (pMemDC->gc);

    // free clip region info
    EmptyClipRgn (&pMemDC->lcrgn);
    EmptyClipRgn (&pMemDC->ecrgn);

    // free DC slot
    free (pMemDC);
}
예제 #7
0
BOOL GUIAPI GetPalette (HDC hdc, int start, int len, GAL_Color* cmap)
{
    PDC pdc;
    GAL_Palette* pal;

    pdc = dc_HDC2PDC (hdc);

    pal = pdc->surface->format->palette;

    if (pal && ((start + len) <= pal->ncolors)) {
        memcpy (cmap, pal->colors + start, sizeof (GAL_Color) * len);
        return TRUE;
    }
    
    return FALSE;
}
예제 #8
0
gal_pixel GUIAPI GetPixel(HDC hdc, int x, int y)
{
    PDC pdc;
    PCLIPRECT pClipRect;
    int color = 0;
    RECT rcOutput;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return PIXEL_invalid;
        }
    }

    coor_LP2SP (pdc, &x, &y);

    rcOutput.left = x - 1;
    rcOutput.top  = y - 1;
    rcOutput.right = x + 1;
    rcOutput.bottom = y + 1;

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC (pdc->gc);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if(PtInRect(&(pClipRect->rc), x, y)) {
            GAL_GetPixel (pdc->gc, x, y, &color);
            break;
        }
        pClipRect = pClipRect->next;
    }

    if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (TRUE, &rcOutput);
    pthread_mutex_unlock(&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);

    return color;
}
예제 #9
0
/****************************** Bitmap Support *******************************/
void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    RECT rcOutput;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            return;
        }
    }

    // Transfer logical to device to screen here.
    w += x; h += y;
    coor_LP2SP(pdc, &x, &y);
    coor_LP2SP(pdc, &w, &h);
    rcOutput.left = x;
    rcOutput.top  = y;
    rcOutput.right = w;
    rcOutput.bottom = h;
    NormalizeRect (&rcOutput);
    w = RECTW (rcOutput); h = RECTH (rcOutput);

    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);
    
    // set graphics context.
    GAL_SetGC (pdc->gc);
    GAL_SetFgColor (pdc->gc, pdc->brushcolor);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);
        
            GAL_FillBox (pdc->gc, x, y, w, h, pdc->brushcolor);
        }

        pClipRect = pClipRect->next;
    }

    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
}
예제 #10
0
gal_pixel GUIAPI RGB2Pixel (HDC hdc, int r, int g, int b)
{
    PDC pdc;
    gal_pixel pixel;
    GAL_Color color = {r, g, b};

    pdc = dc_HDC2PDC (hdc);

    pthread_mutex_lock (&__mg_gdilock);

    GAL_SetGC (pdc->gc);
    pixel = GAL_MapColor (pdc->gc, &color);

    pthread_mutex_unlock (&__mg_gdilock);
 
    return pixel;
}
예제 #11
0
/*
 * Function: int GUIAPI GetGDCapability( int iItem) 
 *      This Function return DC parameters.
 * Parameters:
 *      The element want to retrive.
 * Return:
 *      The parameter.
 */
unsigned int GUIAPI GetGDCapability (HDC hdc, int iItem )
{
    PDC pdc;
    unsigned int iret = 0xFFFFFFFF;

    pdc = dc_HDC2PDC (hdc);

    pthread_mutex_lock (&__mg_gdilock);

    // set graphics context.
    GAL_SetGC (pdc->gc);

    switch (iItem)
    {
        case GDCAP_DEPTH:
            iret = GAL_BitsPerPixel (pdc->gc);
            break;

        case GDCAP_BPP:
            iret = GAL_BytesPerPixel (pdc->gc);
            break;

        case GDCAP_COLORNUM:
            iret = GAL_Colors (pdc->gc);
            break;
 
        case GDCAP_HPIXEL:
            iret = GAL_Width (pdc->gc);
            break;

        case GDCAP_VPIXEL:
            iret = GAL_Height (pdc->gc);
            break;

        case GDCAP_MAXX:
            iret = GAL_Width (pdc->gc) - 1;
            break;

        case GDCAP_MAXY:
            iret = GAL_Height (pdc->gc) - 1;
            break;
    }

    pthread_mutex_unlock(&__mg_gdilock);
    return iret;
}
예제 #12
0
void ScreenCopy (int sx, int sy, HDC hdc, int dx, int dy)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    int offx, offy;
    int boxLeft, boxTop, boxWidth, boxHeight;
    RECT* prc;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            return;
        }
    }
    else
        return;

    coor_LP2SP(pdc, &dx, &dy);
    offx = sx - dx;
    offy = sy - dy;

    ShowCursorForGDI(FALSE, &g_rcScr);

    GAL_SetGC (PHYSICALGC);
    GAL_DisableClipping (pdc->gc);

    pClipRect = pdc->ecrgn.head;
    while (pClipRect)
    {
        prc = &pClipRect->rc;
        boxLeft   = prc->left   + offx;
        boxTop    = prc->top    + offy;
        boxWidth  = prc->right  - prc->left;
        boxHeight = prc->bottom - prc->top;

        GAL_CopyBox (pdc->gc, boxLeft, boxTop, boxWidth, boxHeight, prc->left, prc->top);

        pClipRect = pClipRect->next;
    }

    ShowCursorForGDI(TRUE, &g_rcScr);
}
예제 #13
0
/******************* General drawing attributes *******************************/
Uint32 GUIAPI GetDCAttr (HDC hdc, int attr)
{
    PDC pdc;

    pdc = dc_HDC2PDC (hdc);

#if 1
    if (attr < NR_DC_ATTRS && attr >= 0) {
        Uint32* attrs = (Uint32*) (&pdc->bkcolor);

        return attrs [attr];
    }
#else
    switch (attr) {
    case DC_ATTR_BK_COLOR:
        return (Uint32) pdc->bkcolor;
    case DC_ATTR_BK_MODE:
        return (Uint32) pdc->bkmode;
    case DC_ATTR_TEXT_COLOR:
        return (Uint32) pdc->textcolor;
    case DC_ATTR_TAB_STOP:
        return (Uint32) pdc->tabstop;
    case DC_ATTR_PEN_COLOR:
        return (Uint32) pdc->pencolor;
    case DC_ATTR_BRUSH_COLOR:
        return (Uint32) pdc->brushcolor;
    case DC_ATTR_PEN_TYPE:
        return (Uint32) pdc->pentype;
    case DC_ATTR_BRUSH_TYPE:
        return (Uint32) pdc->brushtype;
    case DC_ATTR_CHAR_EXTRA:
        return (Uint32) pdc->cExtra;
    case DC_ATTR_ALINE_EXTRA:
        return (Uint32) pdc->alExtra;
    case DC_ATTR_BLINE_EXTRA:
        return (Uint32) pdc->blExtra;
    case DC_ATTR_MAP_MODE:
        return (Uint32) pdc->mapmode;
    }
#endif

    return 0;
}
예제 #14
0
/*
 * Function: void GUIAPI ReleaseDC(HDC hDC)
 *     This function release the specified DC.
 * Parameter:
 *     HDC hDC: The DC handle want to release.
 * Return:
 *     None. 
 */
void GUIAPI ReleaseDC (HDC hDC)
{
    PMAINWIN pWin;
    PDC pdc;
    PCONTROL pCtrl;

    pdc = dc_HDC2PDC(hDC);

    EmptyClipRgn (&pdc->lcrgn);

    pWin = (PMAINWIN)(pdc->hwnd);
    if (pWin && pWin->privCDC == hDC) {
        /* for private DC, we reset the clip region info. */
        pthread_mutex_lock (&pdc->pGCRInfo->lock);

        pdc->oldage = pdc->pGCRInfo->age;
        ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn);

        if (pdc->bIsClient)
            WndClientRect (pdc->hwnd, &pdc->DevRC);
        else
            WndRect (pdc->hwnd, &pdc->DevRC);

        IntersectClipRect (&pdc->ecrgn, &pdc->DevRC);

        pCtrl = Control (pdc->hwnd);
        if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN))
            RestrictControlECRGN (&pdc->ecrgn, pCtrl);

        pthread_mutex_unlock (&pdc->pGCRInfo->lock);
    }
    else {
        EmptyClipRgn (&pdc->ecrgn);
        pdc->pGCRInfo = NULL;
        pdc->oldage = 0;

        pthread_mutex_lock (&dcslot);
        pdc->inuse = FALSE;
        pthread_mutex_unlock(&dcslot);
    }

}
예제 #15
0
/*
 * Function: HDC GUIAPI CreateCompatibleDC (HDC hdc)
 *     This function create a memory dc, which is compatible 
 *     with specified hdc.
 * Parameters:
 *     HDC hdc: the specified DC handle.
 * Return:
 *     None.
 */
HDC GUIAPI CreateCompatibleDC(HDC hdc)
{
    GAL_GC gc;
    PDC pdc;
    PDC pMemDC = NULL;

    pdc = dc_HDC2PDC(hdc);

    if (!(pMemDC = malloc (sizeof(DC)))) return HDC_INVALID;
    pthread_mutex_lock (&__mg_gdilock);
    if (GAL_AllocateGC (pdc->gc, RECTW (pdc->DevRC), RECTH (pdc->DevRC), 
            GAL_BytesPerPixel (pdc->gc), &gc) != 0) {
        pthread_mutex_unlock (&__mg_gdilock);
        return HDC_INVALID;
    }
    pthread_mutex_unlock (&__mg_gdilock);

    memcpy (pMemDC, pdc, sizeof(DC));

    pMemDC->DataType = TYPE_HDC;
    pMemDC->DCType   = TYPE_MEMDC;
    pMemDC->inuse = TRUE;
    pMemDC->gc = gc;

    // clip region info
    InitClipRgn (&pMemDC->lcrgn, &sg_FreeClipRectList);
    InitClipRgn (&pMemDC->ecrgn, &sg_FreeClipRectList);
    pMemDC->pGCRInfo = NULL;
    pMemDC->oldage = 0;

    pMemDC->DevRC.left = 0;
    pMemDC->DevRC.top  = 0;
    pMemDC->DevRC.right = RECTW(pdc->DevRC);
    pMemDC->DevRC.bottom = RECTH(pdc->DevRC);

    SetClipRgn (&pMemDC->ecrgn, &pMemDC->DevRC);
    
    return (HDC)pMemDC;
}
예제 #16
0
int GUIAPI GetFontHeight (HDC hdc)
{
    PDC pdc = dc_HDC2PDC(hdc);
    return pdc->pLogFont->size;
}
예제 #17
0
void GUIAPI DrawIcon(HDC hdc, int x, int y, int w, int h, HICON hicon)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    PICON picon = (PICON)hicon;
    int i;
    int imagesize;
    BYTE* iconimage;
    BYTE* andbits = NULL;
    BYTE* xorbits = NULL;
    RECT rcOutput;

    pdc = dc_HDC2PDC(hdc);

    if (dc_IsGeneralHDC(hdc)) {
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            return;
        }
    }

    if(w <= 0) w = picon->width;
    if(h <= 0) h = picon->height;

    // Transfer logical to device to screen here.
    w += x;
    h += y;
    coor_LP2SP(pdc, &x, &y);
    coor_LP2SP(pdc, &w, &h);
    rcOutput.left = x;
    rcOutput.top  = y;
    rcOutput.right = w;
    rcOutput.bottom = h;
    NormalizeRect (&rcOutput);
    w = RECTW (rcOutput);
    h = RECTH (rcOutput);

    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    GAL_SetGC (pdc->gc);

    imagesize = w * h * GAL_BytesPerPixel (pdc->gc);
    if ((iconimage = malloc (imagesize)) == NULL)
        goto free_ret;

    if (w != picon->width || h != picon->height) {
        andbits = malloc (imagesize);
        xorbits = malloc (imagesize);
        if (andbits == NULL || xorbits == NULL)
            goto free_ret;

        GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->AndBits, w, h, andbits);
        GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->XorBits, w, h, xorbits);
    }
    else {
        andbits = picon->AndBits;
        xorbits = picon->XorBits;
    }

    GAL_GetBox (pdc->gc, x, y, w, h, iconimage);

    for(i = 0; i < imagesize; i++) {
        iconimage[i] &= andbits [i];
        iconimage[i] ^= xorbits [i];
    }

    pClipRect = pdc->ecrgn.head;
    while (pClipRect) {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                            pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            GAL_PutBox(pdc->gc, x, y, w, h, iconimage);
        }

        pClipRect = pClipRect->next;
    }

free_ret:
    if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput);

    free (iconimage);
    if (w != picon->width || h != picon->height) {
        free (andbits);
        free (xorbits);
    }
}
예제 #18
0
BOOL GUIAPI FillBoxWithBitmapPart (HDC hdc, int x, int y, int w, int h,
                int bw, int bh, const BITMAP* pBitmap, int xo, int yo)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    void* scaledBitmap = NULL;
    void* partBitmap = NULL;
    int sw = pBitmap->bmWidth, sh = pBitmap->bmHeight;
    RECT rcOutput;
    int bpp;

    if (pBitmap->bmWidth <= 0 || pBitmap->bmHeight <= 0 || pBitmap->bmBits == NULL)
        return FALSE;

    pdc = dc_HDC2PDC(hdc);
    bpp = GAL_BytesPerPixel (pdc->gc);

    if (dc_IsGeneralHDC(hdc)) {

        if (!dc_GenerateECRgn (pdc, FALSE)) {
            return TRUE;
        }
    }

    // Transfer logical to device to screen here.
    w += x; h += y;
    coor_LP2SP(pdc, &x, &y);
    coor_LP2SP(pdc, &w, &h);
    rcOutput.left = x;
    rcOutput.top = y;
    rcOutput.right = w;
    rcOutput.bottom = h;
    NormalizeRect (&rcOutput);
    w = RECTW (rcOutput); h = RECTH (rcOutput);

    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC(pdc->gc);

    if (bw <= 0 || bh <= 0) {
        scaledBitmap = pBitmap->bmBits;
        bw = sw;
        bh = sh;
    }
    else if (bw == sw && bh == sh)
        scaledBitmap = pBitmap->bmBits;
    else {
        if ((scaledBitmap = malloc (GAL_BoxSize(pdc->gc, w, h))) == NULL)
            goto free_ret;
        GAL_ScaleBox (pdc->gc, sw, sh, pBitmap->bmBits, bw, bh, scaledBitmap);
    }

    // extract part box
    if ((partBitmap = malloc (GAL_BoxSize(pdc->gc, w, h))) == NULL)
        goto free_ret;
    bmpGetBoxPart (bpp, w, h, partBitmap, bw, bh, scaledBitmap, xo, yo);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            if (pBitmap->bmType != BMP_TYPE_COLORKEY)
                GAL_PutBox (pdc->gc, x, y, w, h, partBitmap);
            else
                GAL_PutBoxMask (pdc->gc, x, y, w, h, partBitmap, pBitmap->bmColorKey);
        }

        pClipRect = pClipRect->next;
    }

free_ret:
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);

    if (bw != sw || bh != sh)
        free (scaledBitmap);
    free (partBitmap);

    return TRUE;
}
예제 #19
0
int GUIAPI GetTextAboveLineExtra (HDC hdc)
{
    return dc_HDC2PDC (hdc)->alExtra;
}
예제 #20
0
int GUIAPI GetTextBellowLineExtra (HDC hdc)
{
    return dc_HDC2PDC (hdc)->blExtra;
}
예제 #21
0
void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh,
                       HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop)
{
    PCLIPRECT pClipRect;
    PDC psdc, pddc;
    void* srcBitmap = NULL; 
    void* scaledBitmap = NULL;
    RECT rcOutput;

    psdc = dc_HDC2PDC(hsdc);
    pddc = dc_HDC2PDC(hddc);

    if (dc_IsGeneralHDC(hddc)) {
        if (!dc_GenerateECRgn (pddc, FALSE)) {
            return;
        }
    }

    // Transfer logical to device to screen here.
    sw += sx; sh += sy;
    coor_LP2SP(psdc, &sx, &sy);
    coor_LP2SP(psdc, &sw, &sh);
    (sw > sx) ? (sw -= sx) : (sw = sx - sw);
    (sh > sy) ? (sh -= sy) : (sh = sy - sh);

    dw += dx; dh += dy;
    coor_LP2SP(pddc, &dx, &dy);
    coor_LP2SP(pddc, &dw, &dh);
    rcOutput.left = dx;
    rcOutput.top = dy;
    rcOutput.right = dw;
    rcOutput.bottom = dh;
    NormalizeRect (&rcOutput);
    dw -= dx; dh -= dy;

    if (!dc_IsMemHDC(hddc)) ShowCursorForGDI(FALSE, &g_rcScr);
    GAL_SetGC (psdc->gc);

    if ((srcBitmap = malloc (GAL_BoxSize (psdc->gc, sw, sh))) == NULL || 
        (scaledBitmap = malloc (GAL_BoxSize (pddc->gc, dw, dh))) == NULL)
        goto free_ret;

    GAL_GetBox (psdc->gc, sx, sy, sw, sh, srcBitmap);
    GAL_ScaleBox (psdc->gc, sw, sh, srcBitmap, dw, dh, scaledBitmap);

    GAL_SetGC (pddc->gc);

    pClipRect = pddc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping (pddc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            GAL_PutBox (pddc->gc, dx, dy, dw, dh, scaledBitmap);
        }

        pClipRect = pClipRect->next;
    }

free_ret:
    if (!dc_IsMemHDC(hddc)) ShowCursorForGDI (TRUE, &g_rcScr);

    free (srcBitmap);
    free (scaledBitmap);
}
예제 #22
0
int GUIAPI GetTextCharacterExtra (HDC hdc)
{
    return dc_HDC2PDC (hdc)->cExtra;
}
예제 #23
0
int DrawTextEx (HDC hdc, const char* pText, int nCount, 
                RECT* pRect, int indent, UINT nFormat)
{
    PDC pdc;
    int n, nLines = 0, width = 0;
    BOOL bOutput = TRUE;
    int x, y;
    RECT rcDraw, rcOutput;
    int nTabWidth, tabs; 
    SIZE size;
    int line_height;

    pdc = dc_HDC2PDC(hdc);

    if (nCount == -1)
        nCount = strlen (pText);

    line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra;

    if (nFormat & DT_TABSTOP)
        nTabWidth = HIWORD (nFormat) * 
                    (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                    (pdc->pLogFont, pdc->pLogFont->sbc_devfont);

    else
        nTabWidth = pdc->tabstop * 
                    (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                    (pdc->pLogFont, pdc->pLogFont->sbc_devfont);

    // Transfer logical to device to screen here.
    rcDraw = *pRect;
    coor_LP2SP(pdc, &rcDraw.left, &rcDraw.top);
    coor_LP2SP(pdc, &rcDraw.right, &rcDraw.bottom);
    NormalizeRect (&rcDraw);

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE))
            bOutput = FALSE;
    }

    pthread_mutex_lock (&__mg_gdilock);

    // set graphics context.
    GAL_SetGC (pdc->gc);

    // Draw text here.
    if (nFormat & DT_CALCRECT)
        bOutput = FALSE;

    y = rcDraw.top;
    if (nFormat & DT_SINGLELINE) {
        if (nFormat & DT_BOTTOM)
            y = rcDraw.bottom - pdc->pLogFont->size;
        else if (nFormat & DT_VCENTER)
            y = rcDraw.top + ((RECTH (rcDraw) - pdc->pLogFont->size) >> 1);
    }

    while (nCount != 0) {
        int nOutput;
        int maxwidth;

        if (nLines == 0) {
            maxwidth = rcDraw.right - rcDraw.left - indent;
            if (maxwidth <= 0) {
                // new line
                y += pdc->pLogFont->size;
                nLines ++;
                continue;
            }
        }
        else
            maxwidth = rcDraw.right - rcDraw.left;
        
        gdi_start_new_line (pdc->pLogFont);
        tabs = txtGetOneLine (pdc, pText, nCount, nTabWidth, maxwidth, nFormat, &n);

        gdi_get_TextOut_extent (pdc, pdc->pLogFont, pText, n, &size);
        width = size.cx + tabs * nTabWidth;
        n += tabs;

        if ( (pText[n-1] == '\n' || pText[n-1] == '\r') 
             && !(nFormat & DT_SINGLELINE) ) {
            int tmpx = 0, tmpy = 0;

            nOutput = n - 1;
            width -= gdi_width_one_char (pdc->pLogFont, pdc->pLogFont->sbc_devfont, 
                            pText + n - 1, 1, &tmpx, &tmpy);
        }
        else
            nOutput = n;
            
        if (nFormat & DT_RIGHT)
            x = rcDraw.right - width;
        else if (nFormat & DT_CENTER)
            x = rcDraw.left + ((RECTW (rcDraw) - width) >> 1);
        else
            x = rcDraw.left;
        x += (nLines ? 0 : indent);

        rcOutput.left   = x;
        rcOutput.top    = y;
        rcOutput.right  = rcOutput.left + width;
        rcOutput.bottom = rcOutput.top + line_height;
        NormalizeRect(&rcOutput);

        if (nFormat & DT_CALCRECT) {
            if (nLines == 0)
                *pRect = rcOutput;
            else
                GetBoundRect (pRect, pRect, &rcOutput);
        }

        // draw one line
        if (bOutput && width > 0) {
            if (!dc_IsMemHDC(hdc)) ShowCursorForGDI(FALSE, &rcOutput);

            if (nFormat & DT_NOCLIP)
                txtDrawOneLine (pdc, pText, nOutput, x, y, 
                        &rcOutput, nFormat, nTabWidth);
            else {
                RECT rcClip;
                IntersectRect (&rcClip, &rcOutput, &rcDraw);
                txtDrawOneLine (pdc, pText, nOutput, x, y, 
                        &rcClip, nFormat, nTabWidth);
            }
        
            if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput);
        }

        pText += n;

        // new line
        y += line_height;
        nLines ++;

        // left characters
        nCount = nCount - n;
    }
예제 #24
0
int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText,
		int nCount, int nTabs, int *pTabPos, int nTabOrig)
{
    PDC pdc;
    int line_len, sub_len;
    int nr_tab = 0, tab_pos, def_tab;
    int x_orig = x, max_x = x;
    int line_height;
    int nr_delim_newline, nr_delim_tab;

    if (nCount == 0) return 0;
    if (nCount < 0) nCount = strlen (spText);

    pdc = dc_HDC2PDC(hdc);

    line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra;
    y += pdc->alExtra;
    if (nTabs == 0 || pTabPos == NULL) {
        int ave_width = (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width)
                        (pdc->pLogFont, pdc->pLogFont->sbc_devfont);
        def_tab = ave_width * pdc->tabstop;
    }
    else
        def_tab = pTabPos [nTabs - 1];

    while (nCount) {
        line_len = substrlen (spText, nCount, '\n', &nr_delim_newline);

        nCount -= line_len + nr_delim_newline;

        nr_tab = 0;
        x = x_orig;
        tab_pos = nTabOrig;
        while (line_len) {
            int i, width;

            sub_len = substrlen (spText, line_len, '\t', &nr_delim_tab);

            width = TextOutLen (hdc, x, y, spText, sub_len);

            x += width; 
            if (x >= tab_pos) {
                while (x >= tab_pos)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
                for (i = 0; i < nr_delim_tab - 1; i ++)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
            }
            else {
                for (i = 0; i < nr_delim_tab; i ++)
                    tab_pos += (nr_tab >= nTabs) ? def_tab : pTabPos [nr_tab++];
            }

            x = tab_pos;

            line_len -= sub_len + nr_delim_tab;
            spText += sub_len + nr_delim_tab;
        }

        if (max_x < x) max_x = x;

        spText += nr_delim_newline;
        y += line_height * nr_delim_newline;
    }

    return max_x - x_orig;
}
예제 #25
0
int GUIAPI TextOutLen (HDC hdc, int x, int y, const char* spText, int len)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    RECT rcOutput;
    SIZE size;

    if (len == 0) return 0;
    if (len < 0) len = strlen (spText);

    pdc = dc_HDC2PDC(hdc);

    gdi_get_TextOut_extent (pdc, pdc->pLogFont, spText, len, &size);
    {
        // update text out position
        int width = size.cx;

        extent_x_SP2LP (pdc, &width);
        pdc->CurTextPos.x = x + width;
        pdc->CurTextPos.y = y;
    }

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return size.cx;
        }
    }

    // Transfer logical to device to screen here.
    coor_LP2SP(pdc, &x, &y);

    rcOutput.left = x;
    rcOutput.top  = y;
    rcOutput.right = x + size.cx + 1;
    rcOutput.bottom = y + size.cy + 1;
    NormalizeRect(&rcOutput);

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC(pdc->gc);

    // set text out mode.
    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            gdi_strnwrite (pdc, x, y, spText, len);
        }
            
        pClipRect = pClipRect->next;
    }

    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
    pthread_mutex_unlock(&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);

    return size.cx;
}
예제 #26
0
void GUIAPI LineTo (HDC hdc, int x, int y)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    RECT rcOutput;
    int startx, starty;

    pdc = dc_HDC2PDC(hdc);

    startx = pdc->CurPenPos.x;
    starty = pdc->CurPenPos.y;

    // Move the current pen pos.
    pdc->CurPenPos.x = x;
    pdc->CurPenPos.y = y;

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return;
        }
    }

    // Transfer logical to device to screen here.
    coor_LP2SP(pdc, &x, &y);
    coor_LP2SP(pdc, &startx, &starty);
    rcOutput.left = startx;
    rcOutput.top  = starty;
    rcOutput.right = x;
    rcOutput.bottom = y;
    NormalizeRect (&rcOutput);
    InflateRect (&rcOutput, 1, 1);

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    // set graphics context.
    GAL_SetGC (pdc->gc);
    GAL_SetFgColor (pdc->gc, pdc->pencolor);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping (pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);

            if(starty == y) {
                if (startx > x)
                    GAL_DrawHLine (pdc->gc, x, y, startx - x, pdc->pencolor);
                else
                    GAL_DrawHLine (pdc->gc, startx, y, x - startx, pdc->pencolor);
            }
            else
                GAL_Line (pdc->gc, startx, starty, x, y, pdc->pencolor);
        }
            
        pClipRect = pClipRect->next;
    }

    if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (TRUE, &rcOutput);
    pthread_mutex_unlock (&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);
}
예제 #27
0
void GUIAPI FocusRect(HDC hdc, int x0, int y0, int x1, int y1)
{
    PCLIPRECT pClipRect;
    PDC pdc;
    int l, t, r, b, w, h;
    RECT rcOutput;
    size_t sizeh, sizev;
    BYTE* vbuff = NULL;
    BYTE* hline1 = NULL, * hline2 = NULL;
    BYTE* vline1 = NULL, * vline2 = NULL;
    int bpp;
    BYTE xor_byte;

    pdc = dc_HDC2PDC(hdc);
    bpp = GAL_BytesPerPixel (pdc->gc);

    if (GAL_BitsPerPixel (pdc->gc) < 8)
        xor_byte = 0x0F;
    else
        xor_byte = 0xFF;

    if (dc_IsGeneralHDC(hdc)) {
        pthread_mutex_lock (&pdc->pGCRInfo->lock);
        if (!dc_GenerateECRgn (pdc, FALSE)) {
            pthread_mutex_unlock (&pdc->pGCRInfo->lock);
            return;
        }
    }

    // Transfer logical to device to screen here.
    coor_LP2SP(pdc, &x0, &y0); 
    coor_LP2SP(pdc, &x1, &y1); 

    l = MIN (x0, x1); t = MIN (y0, y1); r = MAX (x0, x1); b = MAX (y0, y1);
    rcOutput.left = l; rcOutput.top = t;
    rcOutput.right = r + 1; rcOutput.bottom = b + 1;

    pthread_mutex_lock (&__mg_gdilock);
    IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound);
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput);

    GAL_SetGC (pdc->gc);

    w = r - l + 1;
    h = b - t - 1;

    if (w == 0 || h == 0)
        goto my_exit;

    sizeh = w * bpp;
    sizev = h * bpp;
#ifdef HAVE_ALLOCA
    if (!(vbuff = alloca ((sizeh << 1) + (sizev << 1))))
#else
    if (!(vbuff = malloc ((sizeh << 1) + (sizev << 1))))
#endif
        goto my_exit;

    if (w > 0) {
        int i, j;
        int offset;
       
        hline1 = vbuff;
        hline2 = vbuff + sizeh;

        GAL_GetBox (pdc->gc, l, t, w, 1, hline1);
        GAL_GetBox (pdc->gc, l, b, w, 1, hline2);

        offset = 0;
        for (i = 0; i < w; i += 2) {
            for (j = 0; j < bpp; j++) {
                hline1[offset + j] ^= xor_byte;
                hline2[offset + j] ^= xor_byte;
            }
            offset += bpp << 1; 
        }
    }
    
    if (h > 0) {
        int i, j, offset;
        
        vline1 = vbuff + (sizeh << 1);
        vline2 = vbuff + (sizeh << 1) + sizev;
            
        GAL_GetBox (pdc->gc, l, t + 1, 1, h, vline1);
        GAL_GetBox (pdc->gc, r, t + 1, 1, h, vline2);
        
        offset = 0;
        for (i = 0; i < h; i += 2) {
            for (j = 0; j < bpp; j++) {
                vline1[offset + j] ^= xor_byte;
                vline2[offset + j] ^= xor_byte;
            }
            offset += bpp << 1; 
        }
    }

    // set graphics context.
    GAL_SetGC (pdc->gc);

    pClipRect = pdc->ecrgn.head;
    while(pClipRect)
    {
        if (DoesIntersect (&rcOutput, &pClipRect->rc)) {
            GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top,
                    pClipRect->rc.right - 1, pClipRect->rc.bottom - 1);
            
            if (hline1) {
                GAL_PutBox (pdc->gc, l, t, w, 1, hline1);
                GAL_PutBox (pdc->gc, l, b, w, 1, hline2);
            }
            
            if (vline1) {
                GAL_PutBox (pdc->gc, l, t + 1, 1, h, vline1);
                GAL_PutBox (pdc->gc, r, t + 1, 1, h, vline2);
            }
        }
            
        pClipRect = pClipRect->next;
    }
    
my_exit:
    if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput);
    pthread_mutex_unlock (&__mg_gdilock);
    if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock);
#ifndef HAVE_ALLOCA
    free (vbuff);
#endif
}
예제 #28
0
파일: logfont.c 프로젝트: VVillwin/minigui
void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font)
{
    if (!log_font) return;
    memcpy (log_font, dc_HDC2PDC (hdc)->pLogFont, sizeof (LOGFONT));
}
예제 #29
0
Uint32 GUIAPI SetDCAttr (HDC hdc, int attr, Uint32 value)
{
    Uint32 old_value;
    PDC pdc;

    pdc = dc_HDC2PDC (hdc);

#if 1
    if (attr < NR_DC_ATTRS && attr >= 0) {
        Uint32* attrs = (Uint32*) (&pdc->bkcolor);

        old_value = attrs [attr];
        attrs [attr] = value;
        return old_value;
    }
#else
    switch (attr) {
    case DC_ATTR_BK_COLOR:
        old_value = (Uint32) pdc->bkcolor;
        pdc->bkcolor = (gal_pixel)value;
        return old_value;
    case DC_ATTR_BK_MODE:
        old_value = (Uint32) pdc->bkmode;
        pdc->bkmode = (int)value;
        return old_value;
    case DC_ATTR_TEXT_COLOR:
        old_value = (Uint32) pdc->textcolor;
        pdc->textcolor = (gal_pixel)value;
        return old_value;
    case DC_ATTR_TAB_STOP:
        old_value = (Uint32) pdc->tabstop;
        pdc->tabstop = (int)value;
        return old_value;
    case DC_ATTR_PEN_COLOR:
        old_value = (Uint32) pdc->pencolor;
        pdc->pencolor = (gal_pixel)value;
        return old_value;
    case DC_ATTR_BRUSH_COLOR:
        old_value = (Uint32) pdc->brushcolor;
        pdc->brushcolor = (gal_pixel)value;
        return old_value;
    case DC_ATTR_PEN_TYPE:
        old_value = (Uint32) pdc->pentype;
        pdc->pentype = (int)value;
        return old_value;
    case DC_ATTR_BRUSH_TYPE:
        old_value = (Uint32) pdc->brushtype;
        pdc->brushtype = (int)value;
        return old_value;
    case DC_ATTR_CHAR_EXTRA:
        old_value = (Uint32) pdc->cExtra;
        pdc->cExtra = (int)value;
        return old_value;
    case DC_ATTR_ALINE_EXTRA:
        old_value = (Uint32) pdc->alExtra;
        pdc->alExtra = (int)value;
        return old_value;
    case DC_ATTR_BLINE_EXTRA:
        old_value = (Uint32) pdc->blExtra;
        pdc->blExtra = (int)value;
        return old_value;
    case DC_ATTR_MAP_MODE:
        old_value = (Uint32) pdc->mapmode;
        pdc->mapmode = (int)value;
        return old_value;
    }
#endif

    return 0;
}