void clTabRendererCurved::Draw(wxDC& dc, const clTabInfo& tabInfo, const clTabColours& colours, size_t style) { const int TOP_SMALL_HEIGHT = 0; wxColour bgColour(tabInfo.IsActive() ? colours.activeTabBgColour : colours.inactiveTabBgColour); wxColour penColour(tabInfo.IsActive() ? colours.activeTabPenColour : colours.inactiveTabPenColour); wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); dc.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); dc.SetFont(font); if(style & kNotebook_BottomTabs) { // Bottom tabs { wxPoint points[6]; points[0] = tabInfo.m_rect.GetTopLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y + TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[1].y; points[5] = tabInfo.m_rect.GetTopRight(); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = tabInfo.m_rect.GetTopLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetBottomLeft().y - TOP_SMALL_HEIGHT - 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y + TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[1].y; points[5] = tabInfo.m_rect.GetTopRight(); points[5].x -= 2; dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } } else if(IS_VERTICAL_TABS(style)) { // Left side tabs wxRect rotatedRect(0, 0, tabInfo.m_rect.GetHeight(), tabInfo.m_rect.GetWidth()); wxBitmap b(rotatedRect.GetSize()); wxMemoryDC tmpDC(b); tmpDC.SetPen(colours.tabAreaColour); tmpDC.SetBrush(colours.tabAreaColour); tmpDC.DrawRectangle(rotatedRect); tmpDC.SetFont(font); tmpDC.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); tmpDC.SetPen(penColour); tmpDC.SetBrush(bgColour); if(tabInfo.IsActive()) { { wxPoint points[6]; points[0] = rotatedRect.GetBottomLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = rotatedRect.GetLeftTop().y + TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (rotatedRect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = rotatedRect.GetBottomRight(); tmpDC.SetPen(penColour); tmpDC.SetBrush(bgColour); tmpDC.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = rotatedRect.GetBottomLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = rotatedRect.GetLeftTop().y + TOP_SMALL_HEIGHT + 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (rotatedRect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = rotatedRect.GetBottomRight(); points[5].x -= 2; tmpDC.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); tmpDC.SetBrush(bgColour); tmpDC.DrawPolygon(6, points); } } else { // Inactive tabs wxDirection direction = wxNORTH; wxPoint basePoint = ((style & kNotebook_LeftTabs) ? rotatedRect.GetLeftTop() : rotatedRect.GetRightTop()); { wxPoint pt = basePoint; pt.x -= 1; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabPenColour, bgColour, direction); } { wxPoint pt = basePoint; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabInnerPenColour, bgColour, direction); } { wxPoint pt = basePoint; pt.x += 1; wxRect gr(pt, wxSize(1, rotatedRect.GetHeight())); tmpDC.SetPen(*wxTRANSPARENT_PEN); tmpDC.GradientFillLinear(gr, colours.inactiveTabPenColour, bgColour, direction); } } // Vertical tabs // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { tmpDC.DrawBitmap(tabInfo.GetBitmap(), tabInfo.m_bmpY, tabInfo.m_bmpX); } tmpDC.DrawText(tabInfo.m_label, tabInfo.m_textY, tabInfo.m_textX); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { tmpDC.DrawBitmap(colours.closeButton, tabInfo.m_bmpCloseY, tabInfo.m_bmpCloseX); } tmpDC.SelectObject(wxNullBitmap); wxImage img = b.ConvertToImage(); img = img.Rotate90((style & kNotebook_RightTabs)); b = wxBitmap(img); dc.DrawBitmap(b, tabInfo.m_rect.GetTopLeft()); } else { // Default tabs (placed at the top) { wxPoint points[6]; points[0] = tabInfo.m_rect.GetBottomLeft(); points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetLeftTop().y + TOP_SMALL_HEIGHT; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = tabInfo.m_rect.GetBottomRight(); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } { wxPoint points[6]; points[0] = tabInfo.m_rect.GetBottomLeft(); points[0].x += 1; points[1].x = points[0].x + majorCurveWidth; points[1].y = tabInfo.m_rect.GetLeftTop().y + TOP_SMALL_HEIGHT + 1; points[2].x = points[1].x + smallCurveWidth; points[2].y = points[1].y - TOP_SMALL_HEIGHT; points[3].x = points[0].x + (tabInfo.m_rect.GetWidth() - 2 - (majorCurveWidth + smallCurveWidth)); points[3].y = points[2].y; points[4].x = points[3].x + smallCurveWidth; points[4].y = points[3].y + TOP_SMALL_HEIGHT; points[5] = tabInfo.m_rect.GetBottomRight(); points[5].x -= 2; dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawPolygon(6, points); } } if(!IS_VERTICAL_TABS(style)) { // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { dc.DrawBitmap(tabInfo.GetBitmap(), tabInfo.m_bmpX + tabInfo.m_rect.GetX(), tabInfo.m_bmpY); } dc.DrawText(tabInfo.m_label, tabInfo.m_textX + tabInfo.m_rect.GetX(), tabInfo.m_textY); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { dc.DrawBitmap(colours.closeButton, tabInfo.m_bmpCloseX + tabInfo.m_rect.GetX(), tabInfo.m_bmpCloseY); } } }
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int /*flags*/) { #if wxUSE_GRAPHICS_CONTEXT wxGCDC dc(*(wxMemoryDC*)hdc); wxColour penColour(wxColourFromCAandAlpha(outline, alphaOutline)); wxColour brushColour(wxColourFromCAandAlpha(fill, alphaFill)); dc.SetPen(wxPen(penColour)); dc.SetBrush(wxBrush(brushColour)); dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize); return; #else #ifdef wxHAVE_RAW_BITMAP // TODO: do something with cornerSize wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); wxAlphaPixelData::Iterator p(pixData); for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); for (x=0; x<r.width; x++) { p.Red() = wxPy_premultiply(red, alphaFill); p.Green() = wxPy_premultiply(green, alphaFill); p.Blue() = wxPy_premultiply(blue, alphaFill); p.Alpha() = alphaFill; ++p; } } // Set the outline pixels ColourDesired cdo(outline.AsLong()); red = cdo.GetRed(); green = cdo.GetGreen(); blue = cdo.GetBlue(); for (x=0; x<r.width; x++) { p.MoveTo(pixData, x, 0); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, x, r.height-1); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, r.width-1, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } // Draw the bitmap hdc->DrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif #endif }
void clTabRendererClassic::Draw(wxWindow* parent, wxDC& dc, wxDC& fontDC, const clTabInfo& tabInfo, const clTabColours& colors, size_t style, eButtonState buttonState) { const int tabRaius = 1.5; clTabColours colours = colors; if(DrawingUtils::IsDark(colours.activeTabBgColour)) { InitDarkColours(colours, colours.activeTabBgColour); } else { InitLightColours(colours, colours.activeTabBgColour); } wxColour bgColour(tabInfo.IsActive() ? colours.activeTabBgColour : colours.inactiveTabBgColour); wxColour penColour(tabInfo.IsActive() ? colours.activeTabPenColour : colours.inactiveTabPenColour); wxFont font = GetTabFont(false); fontDC.SetTextForeground(tabInfo.IsActive() ? colours.activeTabTextColour : colours.inactiveTabTextColour); fontDC.SetFont(font); if(style & kNotebook_BottomTabs) { // Bottom tabs wxRect tabRect = tabInfo.GetRect(); tabRect.SetHeight(tabRect.GetHeight() + tabRaius); tabRect.SetY(tabRect.GetY() - tabRaius); { dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } { tabRect.Deflate(1); // The inner border dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } } else { // Default tabs (placed at the top) wxRect tabRect = tabInfo.GetRect(); tabRect.SetHeight(tabRect.GetHeight() + tabRaius); { dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } { tabRect.Deflate(1); // The inner border dc.SetPen(tabInfo.IsActive() ? colours.activeTabInnerPenColour : colours.inactiveTabInnerPenColour); dc.SetBrush(bgColour); dc.DrawRoundedRectangle(tabRect, tabRaius); } } // Draw bitmap if(tabInfo.GetBitmap().IsOk()) { const wxBitmap& bmp = (!tabInfo.IsActive() && tabInfo.GetDisabledBitmp().IsOk()) ? tabInfo.GetDisabledBitmp() : tabInfo.GetBitmap(); dc.DrawBitmap(bmp, tabInfo.m_bmpX + tabInfo.m_rect.GetX(), tabInfo.m_bmpY); } fontDC.DrawText(tabInfo.m_label, tabInfo.m_textX + tabInfo.m_rect.GetX(), tabInfo.m_textY); if(tabInfo.IsActive() && (style & kNotebook_CloseButtonOnActiveTab)) { DrawButton(parent, dc, tabInfo, colours, buttonState); } }