Exemplo n.º 1
0
int BBDrawText(HDC hDC, const char *lpString, int nCount, LPRECT lpRect, UINT uFormat, StyleItem* pSI){
    bool bShadow = (pSI->validated & V_SHADOWCOLOR) && (pSI->ShadowColor != (CLR_INVALID));
    bool bOutline = (pSI->validated & V_OUTLINECOLOR) && (pSI->OutlineColor != (CLR_INVALID));
	
	if (bShadow){ // draw shadow
        RECT rcShadow;
		rcShadow.top = lpRect->top + pSI->ShadowY;
		rcShadow.bottom = lpRect->bottom + pSI->ShadowY;
		rcShadow.left = lpRect->left + pSI->ShadowX;
		rcShadow.right = lpRect->right + pSI->ShadowX;

        //SetTextColor(hDC, pSI->ShadowColor);
		bbDrawText(hDC, lpString, &rcShadow, uFormat, pSI->ShadowColor);
    }
	
    if (bOutline){ // draw outline
			//Draw the outline
	        RECT rcOutline;
	        _CopyOffsetRect(&rcOutline, lpRect, 1, 0);
	        //SetTextColor(hDC, pSI->OutlineColor);
			
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0,  1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,  -1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,  -1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0, -1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0, -1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
		//}
    }
    // draw text
    //SetTextColor(hDC, pSI->TextColor);
    bbDrawText(hDC, lpString, lpRect, uFormat, pSI->TextColor);
	return 1;//FIXME: Supposed to be DrawText(); - Should probably not call into bbDrawText to do the dirty work
}
Exemplo n.º 2
0
void MenuItem::Measure(HDC hDC, SIZE *size)
{
    const char *title = GetDisplayString();
    RECT r = { 0, 0, 0, 0 };
    bbDrawText(hDC, title, &r, DT_MENU_MEASURE_STANDARD, 0);
    size->cx = r.right;
    size->cy = MenuInfo.nItemHeight;
//#ifdef BBOPT_MENUICONS
    if (m_hIcon && Settings_menu.iconSize)/* BlackboxZero 1.3.2012 */
        size->cy = imax(MenuInfo.nIconSize+2, size->cy);
//#endif
}
Exemplo n.º 3
0
//===========================================================================
static void PaintToolbar(HDC hdc, RECT *rcPaint)
{
    RECT r;
    StyleItem *pSI;
    struct button *btn;

    HDC buf;
    HGDIOBJ bufother, other_font;
    int size;

    int margin, border, border_margin, button_padding, middle_padding, two_buttons;
    int tbW, tbH, tbLabelW, tbLabelX, tbClockX, tbWinLabelX, tbWinLabelW;
    int i, justify;

    tbW = TBInfo.width;
    tbH = TBInfo.height;
    buf = CreateCompatibleDC(NULL);
    bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

    if (NULL==Toolbar_hFont)
        Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
    other_font = SelectObject(buf, Toolbar_hFont);

    size = 6 + get_text_extend(buf, Toolbar_CurrentTime);
    if (tbClockW < size)
        tbClockW = size + 2*tbLabelIndent;

    size = get_text_extend(buf, Toolbar_WorkspaceName);
    tbLabelW = size + 2*tbLabelIndent;

    // The widest sets the width!
    tbLabelW = tbClockW = imax(tbH * 2, imax(tbLabelW, tbClockW));

    margin = tbMargin;
    border = mStyle.Toolbar.borderWidth;
    border_margin = margin + border;
    button_padding = (tbH - tbButtonWH) / 2 - border;
    middle_padding = button_padding;
    if (0 == button_padding)
        middle_padding -= mStyle.ToolbarButton.borderWidth;

    tbLabelX = border_margin;
    tbClockX = tbW - tbClockW - border_margin;
    two_buttons = 2*tbButtonWH + 2*button_padding + middle_padding;
    tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
    tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
    if (tbWinLabelW < 0) tbWinLabelW = 0;

    btn = Toolbar_Button;
    btn[0].r.left = tbLabelX + tbLabelW + button_padding;
    btn[1].r.left = btn[0].r.left + tbButtonWH + middle_padding;
    btn[2].r.left = tbClockX - 2*tbButtonWH - button_padding - middle_padding;
    btn[3].r.left = btn[2].r.left + tbButtonWH + middle_padding;
    btn[4].r.left = tbClockX;
    for (i = 0; i<5; i++) {
        btn[i].r.top    = (tbH - tbButtonWH) / 2;
        btn[i].r.bottom = btn[i].r.top + tbButtonWH;
        btn[i].r.right  = btn[i].r.left + tbButtonWH;
    }
    btn[4].r.right = tbClockX + tbClockW;

    //====================

    // Paint toolbar Style
    r.left = r.top = 0;
    r.right = tbW;
    r.bottom = tbH;
    pSI = &mStyle.Toolbar;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);

    //====================
    // Paint unpressed workspace/task buttons...

    r.left = r.top = 0;
    r.right = r.bottom = tbButtonWH;
    {
        HDC src;
        HGDIOBJ srcother;
        int x, y, f2, f1 = -1;
        src = CreateCompatibleDC(NULL);
        srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
        for (i = 0; i < 4; i++)
        {
            btn = Toolbar_Button + i;
            f2 = btn->pressed || (Toolbar_force_button_pressed && (i&1));
            x = btn->r.left, y = btn->r.top;
            pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;
            if (pSI->parentRelative) {
                RECT b;
                b.left = x, b.top = y, b.right = x+r.right, b.bottom = y+r.bottom;
                CreateBorder(buf, &b, pSI->borderColor, pSI->borderWidth);
            } else {
                if (f1 != f2) {
                    MakeStyleGradient(src, &r, pSI, pSI->bordered);
                    f1 = f2;
                }
                BitBlt(buf, x, y, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
            }
            bbDrawPix(buf, &btn->r, pSI->picColor, (i&1) ? BS_TRIANGLE : -BS_TRIANGLE);
        }

        DeleteObject(SelectObject(src, srcother));
        DeleteDC(src);
    }

    //====================

    r.top = (tbH - tbLabelH)/2;
    r.bottom = r.top + tbLabelH;
    SetBkMode(buf, TRANSPARENT);
    justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

    // Paint workspaces background...
    r.right = (r.left = tbLabelX) + tbLabelW;
    pSI = &mStyle.ToolbarLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_WorkspaceName, &r, justify, pSI->TextColor);

    // Paint window label background...
    r.right = (r.left = tbWinLabelX) + tbWinLabelW;
    pSI = &mStyle.ToolbarWindowLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentWindow, &r, justify, pSI->TextColor);

    // Paint clock background...
    r.right = (r.left = tbClockX) + tbClockW;
    pSI = &mStyle.ToolbarClock;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentTime, &r, justify, pSI->TextColor);

    //====================

    BitBltRect(hdc, buf, rcPaint);

    SelectObject(buf, other_font);
    DeleteObject(SelectObject(buf, bufother));
    DeleteDC(buf);
}
Exemplo n.º 4
0
static int get_text_extend(HDC hdc, const char *cp)
{
    RECT s = {0,0,0,0};
    bbDrawText(hdc, cp, &s, DT_CALCRECT|DT_NOPREFIX, 0);
    return s.right;
}