Exemplo n.º 1
0
static void setup_anim_mem_dc (HWND hwnd, ANIMATIONINFO* anim_info)
{
    gal_pixel bk_pixel;
    HDC hdc;

    if (!anim_info->anim)
        return;

    if (anim_info->mem_dc)
        DeleteCompatibleDC (anim_info->mem_dc);
    hdc = GetClientDC (hwnd);
#ifdef _USE_NEWGAL
    anim_info->mem_dc = CreateCompatibleDCEx (hdc,
                    anim_info->anim->width, anim_info->anim->height);
#else
    anim_info->mem_dc = CreateCompatibleDC (hdc);
#endif

    if (GetWindowExStyle (hwnd) & WS_EX_TRANSPARENT)
        bk_pixel = GetWindowBkColor (GetParent (hwnd));
    else
        bk_pixel = GetWindowBkColor (hwnd);

    SetBkColor (anim_info->mem_dc, bk_pixel);
    SetBrushColor (anim_info->mem_dc, bk_pixel);
    FillBox (anim_info->mem_dc, 0, 0,
            GetGDCapability (hdc, GDCAP_MAXX)+1,
            GetGDCapability (hdc, GDCAP_MAXY)+1);

    ReleaseDC (hdc);
}
Exemplo n.º 2
0
static void draw_scroll_button (HWND hWnd, HDC hdc, RECT *title_rc, PPROPSHEETDATA propsheet, DWORD style)
{
    RECT btn_rect = {0, 0, 0, 0};
    int l, r, t, b;

    btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->top + 1 : title_rc->top;
    btn_rect.right = GetMainWinMetrics (MWM_SB_WIDTH) - 4;
    btn_rect.bottom = ((style & 0xf0L) == PSS_BOTTOM) ? title_rc->bottom + 2: title_rc->bottom - 2;
        
    t = btn_rect.top + 5;
    r = btn_rect.right;
    b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 7 : btn_rect.bottom - 4;

    SelectClipRect (hdc, &btn_rect);
    SetBrushColor (hdc, GetWindowBkColor (hWnd));
    FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right + 3, btn_rect.bottom); 
    SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK));
    for ( ; t <= b; r--, t++, b--) {
        MoveTo (hdc, r, t);
        LineTo (hdc, r, b);
    }
    
    btn_rect.left = propsheet->head_rc.right - GetMainWinMetrics(MWM_SB_WIDTH);
    //btn_rect.top = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.top - 1 : btn_rect.top;
    l = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.left + 5 : btn_rect.left + 4;
    r = btn_rect.right = propsheet->head_rc.right;
    b = ((style & 0xf0L) == PSS_BOTTOM) ? btn_rect.bottom - 8 : btn_rect.bottom - 5;
    t = btn_rect.top + 6;
    SelectClipRect (hdc, &btn_rect);
    SetBrushColor (hdc, GetWindowBkColor (hWnd));
    FillBox (hdc, btn_rect.left, btn_rect.top, btn_rect.right, btn_rect.bottom);
    SetPenColor (hdc, GetWindowElementColorEx (hWnd, WEC_3DBOX_DARK));
    for ( ; t <= b; l++, t++, b--) {
        MoveTo (hdc, l, t);
        LineTo (hdc, l, b);
    }

}
static void DrawCoolBox (HWND hWnd, HDC hdc, PCOOLBARCTRL pdata)
{
    COOLBARITEMDATA* tmpdata;
    RECT rc;
    int l,t;
    WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd);
    DWORD color;
    DWORD mainc = GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY);
  
    GetClientRect (hWnd, &rc);

    if (pdata->BackBmp) {
        FillBoxWithBitmap (hdc, 0, 0, rc.right, rc.bottom, pdata->BackBmp);
    }

    color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_DARKEST);
    SetPenColor (hdc,
            RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), 
                GetBValue (color), GetAValue (color)));
    MoveTo (hdc, 0, 0);
    LineTo (hdc, rc.right, 0);
    MoveTo (hdc, 0, rc.bottom - 2);
    LineTo (hdc, rc.right, rc.bottom - 2);

    color = info->we_rdr->calc_3dbox_color (mainc, LFRDR_3DBOX_COLOR_LIGHTEST);
    SetPenColor (hdc,
            RGBA2Pixel (hdc, GetRValue (color), GetGValue (color), 
                GetBValue (color), GetAValue (color)));
    MoveTo (hdc, 0, 1);
    LineTo (hdc, rc.right, 1);
    MoveTo (hdc, 0, rc.bottom - 1);
    LineTo (hdc, rc.right, rc.bottom - 1);

    tmpdata = pdata->head;
    while (tmpdata) {
        l = tmpdata->RcTitle.left;
        t = tmpdata->RcTitle.top;
      
        switch (tmpdata->ItemType) {
        case TYPE_BARITEM:
        {
            WINDOWINFO *info = (WINDOWINFO*)GetWindowInfo (hWnd);
            RECT rcTmp;
            rcTmp.left = l + 2;
            rcTmp.top = 4;
            rcTmp.right = l + 4;
            rcTmp.bottom = rc.bottom - 4;

            info->we_rdr->draw_3dbox (hdc, &rcTmp, 
                GetWindowElementAttr (hWnd, WE_MAINC_THREED_BODY),
                LFRDR_BTN_STATUS_PRESSED);
        }
            break;

        case TYPE_BMPITEM:
            FillBoxWithBitmap (hdc, l + 2, t + 2, 
                            pdata->ItemWidth, pdata->ItemHeight, tmpdata->Bmp);
            break;

        case TYPE_TEXTITEM:
        {
            SIZE size;
            int h;
            WINDOWINFO *info;
            RECT rc;

            if (tmpdata->Caption == NULL || tmpdata->Caption [0] == '\0')
                break;

            GetTextExtent (hdc, tmpdata->Caption, -1, &size);
            h = (pdata->ItemHeight - size.cy) / 2;

            SetBkMode (hdc, BM_TRANSPARENT);
            if (tmpdata->Disable) {
                info = (WINDOWINFO*)GetWindowInfo (hWnd);
                rc.left = l + 2;
                rc.top = t + h + 2;
                rc.right = rc.left + size.cx;
                rc.bottom = rc.top + size.cy;
                info->we_rdr->disabled_text_out (hWnd, hdc,
                    tmpdata->Caption, &rc, DT_SINGLELINE);
            }
            else {
                SetBkColor (hdc, GetWindowBkColor (hWnd));
                SetTextColor (hdc, PIXEL_black);
                TextOut (hdc, l+2, t + h + 2, tmpdata->Caption);
            }

            break;
        }

        default:
            break;
        }

        tmpdata = tmpdata->next;
    }

    if ((tmpdata = GetCurSel (pdata)) == NULL)
        return;

    draw_hilight_box (hWnd, hdc, tmpdata);
}
Exemplo n.º 4
0
static void pbarOnDraw (HWND hwnd, HDC hdc, PROGRESSDATA* pData, BOOL fVertical)
{
    RECT    rcClient;
    int     x, y, w, h;
    ldiv_t   ndiv_progress;
    unsigned int     nAllPart;
    unsigned int     nNowPart;
    int     whOne, nRem;
    int     ix, iy;
    int     i;
    int     step;
    
    if (pData->nMax == pData->nMin)
        return;
    
    if ((pData->nMax - pData->nMin) > 5)
        step = 5;
    else
        step = 1;

    GetClientRect (hwnd, &rcClient);

    x = rcClient.left + WIDTH_PBAR_BORDER;
    y = rcClient.top + WIDTH_PBAR_BORDER;
    w = RECTW (rcClient) - (WIDTH_PBAR_BORDER << 1);
    h = RECTH (rcClient) - (WIDTH_PBAR_BORDER << 1);

    ndiv_progress = ldiv (pData->nMax - pData->nMin, step);
    nAllPart = ndiv_progress.quot;
    
    ndiv_progress = ldiv (pData->nPos - pData->nMin, step);
    nNowPart = ndiv_progress.quot;
    if (fVertical)
        ndiv_progress = ldiv (h, nAllPart);
    else
        ndiv_progress = ldiv (w, nAllPart);
        
    whOne = ndiv_progress.quot;
    nRem = ndiv_progress.rem;

    SetBrushColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL));
 
    if (whOne >= 4) {
        if (fVertical) {
            for (i = 0, iy = y + h - 1; i < nNowPart; ++i) {
                if ((iy - whOne) < y) 
                    whOne = iy - y;

                FillBox (hdc, x + 1, iy - whOne, w - 2, whOne - 1);
                iy -= whOne;
                if(nRem > 0) {
                    iy --;
                    nRem --;
                }
            }
        }
        else {
            for (i = 0, ix = x + 1; i < nNowPart; ++i) {
                if ((ix + whOne) > (x + w)) 
                    whOne = x + w - ix;

                FillBox (hdc, ix, y + 1, whOne - 1, h - 2);
                ix += whOne;
                if(nRem > 0) {
                    ix ++;
                    nRem --;
                }
            }
        }
    }
    else {
        // no vertical support
        double d = (nNowPart*1.0)/nAllPart;

        if (fVertical) {
            int prog = (int)(h*d);

            FillBox (hdc, x + 1, rcClient.bottom - WIDTH_PBAR_BORDER - prog, 
                    w - 2, prog);
        }
        else {
            char szText[8];
            SIZE text_ext;
            RECT rc_clip = rcClient;
            int prog = (int)(w*d);

            FillBox (hdc, x, y + 1, (int)(w*d), h - 2);

            SetBkMode (hdc, BM_TRANSPARENT);
            sprintf (szText, "%.0f%%", (d*100));
            GetTextExtent (hdc, szText, -1, &text_ext);
            x += ((w - text_ext.cx) >> 1);
            y += ((h - text_ext.cy) >> 1);

            rc_clip.right = prog;
            SelectClipRect (hdc, &rc_clip);
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_HILIGHT_NORMAL));
            SetBkColor (hdc, GetWindowElementColorEx (hwnd, BKC_HILIGHT_NORMAL));
            TextOut (hdc, x, y, szText);

            rc_clip.right = rcClient.right;
            rc_clip.left = prog;
            SelectClipRect (hdc, &rc_clip);
            SetTextColor (hdc, GetWindowElementColorEx (hwnd, FGC_CONTROL_NORMAL));
            SetBkColor (hdc, GetWindowBkColor (hwnd));
            TextOut (hdc, x, y, szText);
        }
    }
}
Exemplo n.º 5
0
static void btnPaintContent (PCONTROL pCtrl, HDC hdc, DWORD dwStyle, 
                             RECT* prcText)
{
    switch (dwStyle & BS_CONTENTMASK)
    {
        case BS_TEXT:
        case BS_LEFTTEXT:
        {
            UINT uFormat;
            
            if (dwStyle & BS_MULTLINE)
                uFormat = DT_WORDBREAK;
            else
                uFormat = DT_SINGLELINE;

            if ((dwStyle & BS_TYPEMASK) == BS_PUSHBUTTON
                    || (dwStyle & BS_TYPEMASK) == BS_DEFPUSHBUTTON
                    || (dwStyle & BS_PUSHLIKE))
                uFormat |= DT_CENTER | DT_VCENTER;
            else {
                uFormat = DT_TOP | DT_LEFT;

                if ((dwStyle & BS_ALIGNMASK) == BS_LEFT)
                    uFormat = DT_WORDBREAK | DT_LEFT;
                else if ((dwStyle & BS_ALIGNMASK) == BS_RIGHT)
                    uFormat = DT_WORDBREAK | DT_RIGHT;
                else if ((dwStyle & BS_ALIGNMASK) == BS_CENTER)
                    uFormat = DT_WORDBREAK | DT_CENTER;
            
                if ((dwStyle & BS_ALIGNMASK) == BS_TOP)
                    uFormat = DT_SINGLELINE | DT_TOP;
                else if ((dwStyle & BS_ALIGNMASK) == BS_BOTTOM)
                    uFormat = DT_SINGLELINE | DT_BOTTOM;
                else if ((dwStyle & BS_ALIGNMASK) == BS_VCENTER)
                    uFormat = DT_SINGLELINE | DT_VCENTER;
            }
            
            SetBkColor (hdc, GetWindowBkColor ((HWND)pCtrl));
            if (dwStyle & WS_DISABLED) {
                RECT rc = *prcText;
                
                SetBkMode (hdc, BM_TRANSPARENT);
                SetTextColor (hdc, PIXEL_lightwhite);
                OffsetRect (prcText, 2, 2);
                DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat);
                
                SetTextColor (hdc, PIXEL_darkgray);
                DrawText (hdc, pCtrl->spCaption, -1, &rc, uFormat);
            }
            else {
                SetBkMode (hdc, BM_TRANSPARENT);
                SetTextColor (hdc, PIXEL_black);
                OffsetRect (prcText, 1, 1);
                DrawText (hdc, pCtrl->spCaption, -1, prcText, uFormat);
            }
        }
        break;
        
        case BS_BITMAP:
            if (BUTTON_DATA(pCtrl)) {
                int x = prcText->left;
                int y = prcText->top;
                int w = RECTWP (prcText);
                int h = RECTHP (prcText);
                PBITMAP bmp = (PBITMAP)(BUTTON_DATA(pCtrl));

                if (dwStyle & BS_REALSIZEIMAGE) {
                    x += (w - bmp->bmWidth) >> 1;
                    y += (h - bmp->bmHeight) >> 1;
                    w = h = 0;
                }
                FillBoxWithBitmap (hdc, x, y, w, h, bmp);
            }
        break;
         
        case BS_ICON:
            if (BUTTON_DATA(pCtrl)) {
                int x = prcText->left;
                int y = prcText->top;
                int w = RECTWP (prcText);
                int h = RECTHP (prcText);
                HICON icon = (HICON)(BUTTON_DATA(pCtrl));

                if (dwStyle & BS_REALSIZEIMAGE) {
                    int iconw, iconh;

                    GetIconSize (icon, &iconw, &iconh);
                    x += (w - iconw) >> 1;
                    y += (h - iconh) >> 1;
                    w = h = 0;
                }

                DrawIcon (hdc, x, y, w, h, icon);
            }