void CLMainAuiTBArt::DrawDropDownButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) { wxAuiDefaultToolBarArt::DrawDropDownButton(dc, wnd, item, rect); #if 0 // Dark theme int textWidth = 0, textHeight = 0, textX = 0, textY = 0; int bmpX = 0, bmpY = 0, dropBmpX = 0, dropBmpY = 0; wxRect buttonRect = wxRect(rect.x, rect.y, rect.width - BUTTON_DROPDOWN_WIDTH, rect.height); wxRect dropDownRect = wxRect(rect.x + rect.width - BUTTON_DROPDOWN_WIDTH - 1, rect.y, BUTTON_DROPDOWN_WIDTH + 1, rect.height); if(m_flags & wxAUI_TB_TEXT) { dc.SetFont(m_font); int tx, ty; if(m_flags & wxAUI_TB_TEXT) { dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight); textWidth = 0; } dc.GetTextExtent(item.GetLabel(), &textWidth, &ty); } dropBmpX = dropDownRect.x + (dropDownRect.width / 2) - (m_buttonDropDownBmp.GetWidth() / 2); dropBmpY = dropDownRect.y + (dropDownRect.height / 2) - (m_buttonDropDownBmp.GetHeight() / 2); if(m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) { bmpX = buttonRect.x + (buttonRect.width / 2) - (item.GetBitmap().GetWidth() / 2); bmpY = buttonRect.y + ((buttonRect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2); textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1; textY = rect.y + rect.height - textHeight - 1; } else if(m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT) { bmpX = rect.x + 3; bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2); textX = bmpX + 3 + item.GetBitmap().GetWidth(); textY = rect.y + (rect.height / 2) - (textHeight / 2); } if(item.GetState() & wxAUI_BUTTON_STATE_PRESSED) { dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(140))); dc.DrawRectangle(buttonRect); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170))); dc.DrawRectangle(dropDownRect); } else if(item.GetState() & wxAUI_BUTTON_STATE_HOVER || item.IsSticky()) { dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170))); dc.DrawRectangle(buttonRect); dc.DrawRectangle(dropDownRect); } else if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED) { // Notice that this branch must come after the hover one to ensure the // correct appearance when the mouse hovers over a checked item.m_ dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170))); dc.DrawRectangle(buttonRect); dc.DrawRectangle(dropDownRect); } wxBitmap bmp; wxBitmap dropbmp; if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) { bmp = CreateDisabledBitmap(item.GetBitmap()); dropbmp = m_disabledButtonDropDownBmp; } else { bmp = item.GetBitmap(); dropbmp = m_buttonDropDownBmp; } if(!bmp.IsOk()) return; dc.DrawBitmap(bmp, bmpX, bmpY, true); dc.DrawBitmap(dropbmp, dropBmpX, dropBmpY, true); // set the item's text color based on if it is disabled dc.SetTextForeground(*wxBLACK); if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR); if((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty()) { dc.DrawText(item.GetLabel(), textX, textY); } #endif }
void CLMainAuiTBArt::DrawButton(wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) { wxAuiDefaultToolBarArt::DrawButton(dc, wnd, item, rect); #if 0 // if(!DrawingUtils::IsThemeDark()) { // wxAuiDefaultToolBarArt::DrawButton(dc, wnd, item, rect); // return; // } int textWidth = 0, textHeight = 0; if(m_flags & wxAUI_TB_TEXT) { dc.SetFont(m_font); int tx, ty; dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight); textWidth = 0; dc.GetTextExtent(item.GetLabel(), &textWidth, &ty); } int bmpX = 0, bmpY = 0; int textX = 0, textY = 0; if(m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM) { bmpX = rect.x + (rect.width / 2) - (item.GetBitmap().GetWidth() / 2); bmpY = rect.y + ((rect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2); textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1; textY = rect.y + rect.height - textHeight - 1; } else if(m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT) { bmpX = rect.x + 3; bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2); textX = bmpX + 3 + item.GetBitmap().GetWidth(); textY = rect.y + (rect.height / 2) - (textHeight / 2); } if(!(item.GetState() & wxAUI_BUTTON_STATE_DISABLED)) { if(item.GetState() & wxAUI_BUTTON_STATE_PRESSED) { dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(150))); dc.DrawRectangle(rect); } else if((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky()) { dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170))); // draw an even lighter background for checked item hovers (since // the hover background is the same color as the check background) if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED) dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(180))); dc.DrawRectangle(rect); } else if(item.GetState() & wxAUI_BUTTON_STATE_CHECKED) { // it's important to put this code in an else statement after the // hover, otherwise hovers won't draw properly for checked items dc.SetPen(wxPen(m_highlightColour)); dc.SetBrush(wxBrush(m_highlightColour.ChangeLightness(170))); dc.DrawRectangle(rect); } } wxBitmap bmp; if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) { bmp = CreateDisabledBitmap(item.GetBitmap()); } else bmp = item.GetBitmap(); if(bmp.IsOk()) dc.DrawBitmap(bmp, bmpX, bmpY, true); // set the item's text color based on if it is disabled dc.SetTextForeground(*wxBLACK); if(item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR); if((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty()) { dc.DrawText(item.GetLabel(), textX, textY); } #endif }
void wxAuiMSWToolBarArt::DrawDropDownButton( wxDC& dc, wxWindow* wnd, const wxAuiToolBarItem& item, const wxRect& rect) { if ( m_themed ) { wxUxThemeHandle hTheme(wnd, L"Toolbar"); wxUxThemeEngine* const te = wxUxThemeEngine::Get(); int dropDownWidth = 14; int textWidth = 0, textHeight = 0, textX = 0, textY = 0; int bmpX = 0, bmpY = 0; wxRect buttonRect = wxRect(rect.x, rect.y, rect.width - dropDownWidth, rect.height); wxRect dropDownRect = wxRect(rect.x + rect.width - dropDownWidth - 1, rect.y, dropDownWidth + 1, rect.height); if ( m_flags & wxAUI_TB_TEXT ) { dc.SetFont(m_font); int tx, ty; if ( m_flags & wxAUI_TB_TEXT ) { dc.GetTextExtent(wxT("ABCDHgj"), &tx, &textHeight); textWidth = 0; } dc.GetTextExtent(item.GetLabel(), &textWidth, &ty); } RECT btnR; wxCopyRectToRECT(buttonRect, btnR); RECT dropDownR; wxCopyRectToRECT(dropDownRect, dropDownR); int btnState; if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) btnState = TS_DISABLED; else if ( item.GetState() & wxAUI_BUTTON_STATE_PRESSED ) btnState = TS_PRESSED; else if ( item.GetState() & wxAUI_BUTTON_STATE_HOVER ) btnState = TS_HOT; else btnState = TS_NORMAL; te->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TP_SPLITBUTTON, btnState, &btnR, NULL); te->DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TP_SPLITBUTTONDROPDOWN, btnState, &dropDownR, NULL); if ( m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM ) { bmpX = buttonRect.x + (buttonRect.width / 2) - (item.GetBitmap().GetWidth() / 2); bmpY = buttonRect.y + ((buttonRect.height - textHeight) / 2) - (item.GetBitmap().GetHeight() / 2); textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1; textY = rect.y + rect.height - textHeight - 1; } else if ( m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT ) { bmpX = rect.x + 3; bmpY = rect.y + (rect.height / 2) - (item.GetBitmap().GetHeight() / 2); textX = bmpX + 3 + item.GetBitmap().GetWidth(); textY = rect.y + (rect.height / 2) - (textHeight / 2); } wxBitmap bmp; if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) { bmp = item.GetDisabledBitmap(); } else { bmp = item.GetBitmap(); } if ( !bmp.IsOk() ) return; dc.DrawBitmap(bmp, bmpX, bmpY, true); // set the item's text color based on if it is disabled dc.SetTextForeground(*wxBLACK); if ( item.GetState() & wxAUI_BUTTON_STATE_DISABLED ) dc.SetTextForeground(DISABLED_TEXT_COLOR); if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() ) { dc.DrawText(item.GetLabel(), textX, textY); } } else wxAuiGenericToolBarArt::DrawDropDownButton(dc, wnd, item, rect); }