void MenuItem::Paint(HDC hDC) { RECT rc, rhi; StyleItem *pSI; COLORREF TC, BC; int j; GetTextRect(&rc); pSI = &mStyle.MenuFrame; if (m_bActive && false == m_bNOP) { // draw hilite bar GetItemRect(&rhi); pSI = &mStyle.MenuHilite; MakeStyleGradient(hDC, &rhi, pSI, pSI->bordered); TC = pSI->TextColor; BC = pSI->foregroundColor; } else if (m_bDisabled) { BC = TC = pSI->disabledColor; } else { TC = pSI->TextColor; BC = pSI->foregroundColor; } j = m_Justify; if (MENUITEM_CUSTOMTEXT != j) { if (MENUITEM_STANDARD_JUSTIFY == j) j = mStyle.MenuFrame.Justify; // draw menu item text //bbDrawText(hDC, GetDisplayString(), &rc, j | DT_MENU_STANDARD, TC); /* BlackboxZero 1.5.2012 */ BBDrawText(hDC, GetDisplayString(), -1, &rc, j | DT_MENU_STANDARD, pSI); } //#ifdef BBOPT_MENUICONS if ( Settings_menu.iconSize ) /* BlackboxZero 1.3.2012 */ this->DrawIcon(hDC); //#endif if (m_bChecked) // draw check-mark { int d, atright; //#ifdef BBOPT_MENUICONS if ( Settings_menu.iconSize ) { /* BlackboxZero 1.3.2012 */ if (m_ItemID & MENUITEM_ID_FOLDER) atright = MenuInfo.nBulletPosition == FOLDER_LEFT; else atright = true; } else { //#else if (MenuInfo.nItemLeftIndent != MenuInfo.nItemRightIndent) atright = MenuInfo.nBulletPosition != FOLDER_LEFT; else if (m_ItemID & MENUITEM_ID_FOLDER) atright = MenuInfo.nBulletPosition == FOLDER_LEFT; else atright = j != DT_LEFT; } //#endif rc.bottom = (rc.top = m_nTop) + m_nHeight + 1; if (atright) { d = MenuInfo.nItemRightIndent + mStyle.MenuHilite.borderWidth; rc.left = (rc.right = m_nLeft + m_nWidth) - d + 1; } else { d = MenuInfo.nItemLeftIndent + mStyle.MenuHilite.borderWidth; rc.right = (rc.left = m_nLeft) + d; } #if 1 bbDrawPix(hDC, &rc, BC, BS_CHECK); #else { bool pr, lit; const int w = 6; pSI = &mStyle.MenuHilite; pr = pSI->parentRelative; lit = m_bActive && false == m_bNOP; if (lit != pr) pSI = &mStyle.MenuFrame; rc.left = (rc.left + rc.right - w)/2; rc.right = rc.left + w; rc.top = (rc.top + rc.bottom - w)/2; rc.bottom = rc.top + w; if (pr) MakeGradient(hDC, rc, B_SOLID, pSI->TextColor, 0, false, BEVEL_FLAT, 0, 0, 0, 0); else MakeStyleGradient(hDC, &rc, pSI, false); } #endif } }
//=========================================================================== 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); }