示例#1
0
int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, const char* spText, int len) 
{
    PCLIPRECT pClipRect;
    PDC pdc;
    SIZE size;
    RECT rcOutput;

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

    pdc = dc_HDC2PDC(hdc);

    coor_LP2SP (pdc, &pdc->CurTextPos.x, &pdc->CurTextPos.y);
    gdi_get_TabbedTextOut_extent (pdc, pdc->pLogFont, pdc->tabstop, spText, len, 
                &size, &pdc->CurTextPos);
    coor_SP2LP (pdc, &pdc->CurTextPos.x, &pdc->CurTextPos.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);

    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_tabbedtextout (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;
}
/************************ Coordinate system transfer *************************/
void GUIAPI SPtoLP(HDC hdc, POINT* pPt)
{
    /* DK[01/14/10]: Add condition to process case of hdc equal to 
     * HDC_SCREEN_SYS for fix bug 4348. */
    if (HDC_SCREEN == hdc || HDC_SCREEN_SYS == hdc) return;

    coor_SP2LP ((PDC)hdc, &pPt->x, &pPt->y);
}