void FlatAuiTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background //Game Develop use a less visible gradient wxColor top_color = noBgGradient ? *wxWHITE : gdAuiStepColour(m_base_colour, 120); //Game Develop use a white background wxColor bottom_color = *wxWHITE; wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width+2, rect.height); // else if (m_flags &wxAUI_NB_LEFT) {} // else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3); //Game Develop invert gradient for bottom if (m_flags &wxAUI_NB_BOTTOM) dc.GradientFillLinear(r, top_color, bottom_color, wxNORTH); else //for wxAUI_NB_TOP dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines //Game Develop use a white background dc.SetPen(m_base_colour); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { //Game Develop use a white background dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(-1, 0, w+2, 4); } // else if (m_flags &wxAUI_NB_LEFT) {} // else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP { //Game Develop use a white background dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(-1, y-4, w+2, 4); } }
void VdkPanel::DoEraseBackground(wxDC &dc, const wxRect &rc) { if (!m_gbi) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_bgBrush); if (m_bi) { if (m_bi->borderPen.IsOk()) { dc.SetPen(m_bi->borderPen); } if (m_bi->bgColor.IsOk()) { wxBrush bgBrush(m_bi->bgColor); dc.SetBrush(bgBrush); } } dc.DrawRectangle(rc); } else { VdkDcClippingRegionDestroyer destroyer(dc, rc); m_Window->ResetDcOrigin(dc); TranslateDC(dc); dc.GradientFillLinear(m_Rect, m_gbi->beg, m_gbi->end, m_gbi->direction); } }
void clAuiTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background wxColor top_color = m_base_colour; wxColor bottom_color = m_base_colour; wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width+2, rect.height); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3); dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines dc.SetPen(m_border_pen); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { dc.SetBrush(m_bottom_rect_colour); dc.DrawRectangle(-1, 0, w+2, 4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else { //for wxAUI_NB_TOP dc.SetBrush(m_bottom_rect_colour); dc.DrawRectangle(-1, y-4, w+2, 4); } }
void GradientAreaDraw::Draw(wxDC &dc, wxRect rc) { dc.GradientFillLinear(rc, m_colour1, m_colour2, m_dir); dc.SetPen(m_borderPen); dc.SetBrush(wxNoBrush); dc.DrawRectangle(rc); }
void wxGD::Draw::GlossyGradient( wxDC &dc, wxRect &rect, wxColour &topStart, wxColour &bottomStart, wxColour &bottomEnd, wxColour &colour, bool hover ) { wxColour topEnd = colour; int r = colour.Red() + 45; if( r > 255 ) r = 225; int g = colour.Green() + 45; if( g > 255 ) g = 225; int b = colour.Blue() + 45; if( b > 255) b = 225; topStart = wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b ); r = colour.Red() - 75; if( r < 0 ) r = 15; g = colour.Green() - 75; if( g < 0 ) g = 15; b = colour.Blue() - 75; if( b < 0 ) b = 15; bottomStart = wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b ); r = colour.Red() - 15; if( r < 0 ) r = 30; g = colour.Green() - 15; if( g < 0 ) g = 30; b = colour.Blue() - 15; if( b < 0 ) b = 30; bottomEnd = wxColour( (unsigned char)r, (unsigned char)g, (unsigned char)b ); rect.SetHeight( rect.GetHeight() / 2 ); dc.GradientFillLinear( rect, topStart, topEnd, wxSOUTH ); rect.Offset( 0, rect.GetHeight() ); if( hover ) dc.GradientFillLinear( rect, bottomStart, topStart, wxSOUTH ); else dc.GradientFillLinear( rect, bottomStart, topEnd, wxSOUTH ); }
void wxRibbonMetroArtProvider::DrawToolGroupBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // TODO: there is no DrawToolGroupSeparator method currently wxRect line; line.x = rect.GetRight() + 4; line.y = rect.GetY() + 5; line.width = 1; line.height = rect.GetHeight() - 10; dc.GradientFillLinear(line, wxColour(232, 234, 237), wxColour(178, 183, 189), wxSOUTH); }
void wxRibbonAUIArtProvider::DrawTabCtrlBackground( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { wxRect gradient_rect(rect); gradient_rect.height--; dc.GradientFillLinear(gradient_rect, m_tab_ctrl_background_colour, m_tab_ctrl_background_gradient_colour, wxSOUTH); dc.SetPen(m_tab_border_pen); dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); }
void wxRibbonAUIArtProvider::DrawGalleryButton(wxDC& dc, wxRect rect, wxRibbonGalleryButtonState state, wxBitmap* bitmaps) { int extra_height = 0; int extra_width = 0; wxRect reduced_rect(rect); reduced_rect.Deflate(1); if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL) { reduced_rect.width++; extra_width = 1; } else { reduced_rect.height++; extra_height = 1; } wxBitmap btn_bitmap; switch(state) { case wxRIBBON_GALLERY_BUTTON_NORMAL: dc.GradientFillLinear(reduced_rect, m_gallery_button_background_colour, m_gallery_button_background_gradient_colour, wxSOUTH); btn_bitmap = bitmaps[0]; break; case wxRIBBON_GALLERY_BUTTON_HOVERED: dc.SetPen(m_gallery_item_border_pen); dc.SetBrush(m_gallery_button_hover_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width + extra_width, rect.height + extra_height); btn_bitmap = bitmaps[1]; break; case wxRIBBON_GALLERY_BUTTON_ACTIVE: dc.SetPen(m_gallery_item_border_pen); dc.SetBrush(m_gallery_button_active_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width + extra_width, rect.height + extra_height); btn_bitmap = bitmaps[2]; break; case wxRIBBON_GALLERY_BUTTON_DISABLED: dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_gallery_button_disabled_background_brush); dc.DrawRectangle(reduced_rect.x, reduced_rect.y, reduced_rect.width, reduced_rect.height); btn_bitmap = bitmaps[3]; break; } dc.DrawBitmap(btn_bitmap, reduced_rect.x + reduced_rect.width / 2 - 2, (rect.y + rect.height / 2) - 2, true); }
void wxRibbonAUIArtProvider::DrawToolGroupBackground( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { dc.SetPen(m_toolbar_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxRect bg_rect(rect); bg_rect.Deflate(1); dc.GradientFillLinear(bg_rect, m_tool_background_colour, m_tool_background_gradient_colour, wxSOUTH); }
/** * Render the event */ void CommentEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform &) { #if !defined(GD_NO_WX_GUI) x += 1; //Small border gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get(); renderingHelper->GetHTMLRenderer().SetDC(&dc); renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize()); //Prepare HTML texts gd::String str1 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com1)+"</FONT>"; gd::String str2 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com2)+"</FONT>"; //Calculate space constraints const int sideSeparation = 3; //Spacing between text and borders unsigned int textWidth = com2.empty() ? width-sideSeparation*2 : width/2-sideSeparation*2; renderingHelper->GetHTMLRenderer().SetSize(textWidth, 9999); renderingHelper->GetHTMLRenderer().SetHtmlText(str1); unsigned int text1Height = renderingHelper->GetHTMLRenderer().GetTotalHeight(); renderingHelper->GetHTMLRenderer().SetHtmlText(str2); unsigned int text2Height = renderingHelper->GetHTMLRenderer().GetTotalHeight(); //Prepare background dc.SetBrush(wxBrush(wxColour(r, v, b), wxBRUSHSTYLE_TRANSPARENT)); dc.SetPen(wxPen(wxColour(r/2, v/2, b/2), 1)); //Draw the background unsigned int height = std::max(text1Height, text2Height)+sideSeparation*2; height = std::max(height, (unsigned int)15); wxRect rectangle(x, y, width-2, height); dc.GradientFillLinear(rectangle, wxColour(r+20 > 255 ? 255 : r+20, v+20 > 255 ? 255 : v+20, b+20 > 255 ? 255 : b+20), wxColour(r, v, b), wxSOUTH); dc.DrawRectangle(rectangle); //Draw text { renderingHelper->GetHTMLRenderer().SetHtmlText(str1); wxArrayInt neededArray; renderingHelper->GetHTMLRenderer().Render(x + sideSeparation, y+sideSeparation, neededArray); } if ( !com2.empty() ) //Optional text { renderingHelper->GetHTMLRenderer().SetHtmlText(str2); wxArrayInt neededArray; renderingHelper->GetHTMLRenderer().Render(x + sideSeparation + textWidth + sideSeparation, y+sideSeparation, neededArray); } #endif }
void TripleSplitter::drawSash(wxDC& dc) { const int centerPosX = getCenterPosX(); const int centerWidth = getCenterWidth(); auto draw = [&](wxRect rect) { const int sash2ndHalf = 3; rect.width -= sash2ndHalf; dc.GradientFillLinear(rect, COLOR_SASH_GRADIENT_FROM, COLOR_SASH_GRADIENT_TO, wxEAST); rect.x += rect.width; rect.width = sash2ndHalf; dc.GradientFillLinear(rect, COLOR_SASH_GRADIENT_FROM, COLOR_SASH_GRADIENT_TO, wxWEST); static_assert(SASH_SIZE > sash2ndHalf, ""); }; const wxRect rectSashL(centerPosX, 0, SASH_SIZE, GetClientRect().height); const wxRect rectSashR(centerPosX + centerWidth - SASH_SIZE, 0, SASH_SIZE, GetClientRect().height); draw(rectSashL); draw(rectSashR); }
void UICalculateDistance::render(wxDC& dc) { int client_h = 0; int client_w = 0; GetClientSize (&client_w, &client_h); if (!(ApplicationConfiguration::GetInstance()->IsThemed())) { wxString str(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8); wxColour c_pen = (wxColour)str; wxString str2(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8); wxColour c_backg = (wxColour)str2; wxString str3(ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8); wxColour c_brush = (wxColour)str3; wxString str4(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8); dc.SetTextForeground((wxColour)str4); dc.SetPen(wxPen(c_pen)); dc.SetBrush(wxBrush(c_brush)); dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH); } std::ostringstream wop,wop2,wop3,wop4; wop << std::fixed << std::setprecision(3) << (distance*factor); double aux = 0.000; Position_x_Edit->GetValue().Trim().ToDouble(&aux); wop2 << std::fixed << std::setprecision (3) << aux; Position_y_Edit->GetValue().Trim().ToDouble(&aux); wop3 << std::fixed << std::setprecision (3) << aux; Position_z_Edit->GetValue().Trim().ToDouble(&aux); wop4 << std::fixed << std::setprecision (3) << aux; wxPoint box1_first(20-2,45-9); wxPoint box1_last(368,45+22); dc.DrawRoundedRectangle(box1_first.x, box1_first.y, box1_last.x-box1_first.x, box1_last.y-box1_first.y,3.1f); dc.DrawRotatedText(wxString(wop2.str().c_str(),wxConvUTF8),89+10-30-5,45, 0); dc.DrawRotatedText(wxString(wop3.str().c_str(),wxConvUTF8),89+10-30-5+92+10+15-3,45, 0); dc.DrawRotatedText(wxString(wop4.str().c_str(),wxConvUTF8),89+10-30-5+184+20+15+10-2,45, 0); wxFont font(10, wxSWISS, wxNORMAL,wxNORMAL, false, wxT("Tahoma")); wxFont font_ = dc.GetFont(); dc.SetFont(font); dc.DrawRotatedText(_T("Distance:"),20,12, 0); dc.DrawRotatedText(wxString(wop.str().c_str(),wxConvUTF8),20+65,12, 0); dc.SetFont(font_); }
void DefaultTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background m_baseColour = wxColour(75,75,75); wxColor top_color = m_baseColour.ChangeLightness(90); wxColor bottom_color = m_baseColour.ChangeLightness(110); wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width+2, rect.height); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3); dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines m_borderPen = top_color; dc.SetPen(m_borderPen); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { dc.SetBrush(wxBrush(bottom_color)); dc.DrawRectangle(-1, 0, w+2, 4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP { dc.SetBrush(m_baseColourBrush); dc.SetBrush(m_baseColour); dc.DrawRectangle(-1, y-4, w+2, 4); } }
void UIEAttributes::render(wxDC& dc) { int client_h = 0; int client_w = 0; GetClientSize (&client_w, &client_h); if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed())) { wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8); wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8); wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8); dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8))); dc.SetPen(wxPen(c_pen)); dc.SetBrush(wxBrush(c_brush)); dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH); } dc.DrawRotatedText(_T("Name: "),20,163, 0); dc.DrawRotatedText(_T("Type: "),20,188, 0); dc.DrawRotatedText(_T("Value:"),20,213, 0); }
void UIElementPrimitive::render(wxDC& dc) { int client_h = 0; int client_w = 0; GetClientSize (&client_w, &client_h); if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed())) { wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8); wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8); wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8); dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8))); dc.SetPen(wxPen(c_pen)); dc.SetBrush(wxBrush(c_brush)); dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH); } dc.DrawRotatedText(_T("Name: "),20,20, 0); dc.DrawRotatedText(_T("Model: "),20,40, 0); dc.DrawRotatedText(_T("Icon:"),20,60, 0); dc.DrawRotatedText(_T("Font:"),20,80, 0); dc.DrawRotatedText(_T("Description"),20,100, 0); }
void SAuiTabArt::DrawBackground(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { // draw background wxColor top_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour; wxColor bottom_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour; wxRect r; if (m_flags &wxAUI_NB_BOTTOM) r = wxRect(rect.x, rect.y, rect.width + 2, rect.height); else r = wxRect(rect.x, rect.y, rect.width + 2, rect.height); dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); // draw base lines dc.SetPen(wxPen(m_baseColour)); int y = rect.GetHeight(); int w = rect.GetWidth(); if (m_flags &wxAUI_NB_BOTTOM) { dc.SetBrush(wxBrush(bottom_color)); dc.DrawRectangle(-1, 0, w + 2, 4); } else { //dc.SetPen(*wxTRANSPARENT_PEN); //dc.SetBrush(wxBrush(m_activeColour)); //dc.SetBrush(wxBrush(wxColor(224, 238, 255))); //dc.DrawRectangle(-1, y - 4, w + 2, 4); dc.SetPen(m_borderPen); dc.DrawLine(-2, y - 1, w + 2, y - 1); } }
/////////////////////////////////////////////////////////////////////////////// // Draws the background of this control. // void KeyControl::DrawGradient( wxDC& dc ) const { const wxSize size = dc.GetSize(); const u32 numKeys = m_KeyArray->GetCount(); if ( numKeys > 1 ) { // Draw gradients u32 keyIndex = 0; while ( keyIndex < numKeys ) { const Key* keyA = m_KeyArray->GetKey( keyIndex++ ); if ( keyIndex >= numKeys ) { break; } const Key* keyB = m_KeyArray->GetKey( keyIndex ); const Math::Color3& colorA = keyA->GetColor(); const Math::Color3& colorB = keyB->GetColor(); i32 posA = GetPos( keyA->GetLocation() ); i32 width = ::abs( GetPos( keyB->GetLocation() ) - posA ); dc.GradientFillLinear( wxRect( posA, 0, width, size.y ), wxColor( colorA.r, colorA.g, colorA.b ), wxColor( colorB.r, colorB.g, colorB.b ) ); } } else if ( numKeys == 1 ) { // No gradient, solid fill const Key* key = m_KeyArray->GetKey( 0 ); dc.SetBrush( wxBrush( wxColor( key->GetColor().r, key->GetColor().g, key->GetColor().b ) ) ); dc.DrawRectangle( 0, 0, size.x, size.y ); } }
void UIElementVectorial::render(wxDC& dc) { int client_h = 0; int client_w = 0; GetClientSize (&client_w, &client_h); if (!(cpw::ApplicationConfiguration::GetInstance()->IsThemed())) { wxColour c_pen = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient2Colour().c_str(),wxConvUTF8); wxColour c_backg = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundGradient1Colour().c_str(),wxConvUTF8); wxColour c_brush = wxString(cpw::ApplicationConfiguration::GetInstance()->GetBackgroundColour().c_str(),wxConvUTF8); dc.SetTextForeground(wxColour(wxString(cpw::ApplicationConfiguration::GetInstance()->GetFontLightColour().c_str(),wxConvUTF8))); dc.SetPen(wxPen(c_pen)); dc.SetBrush(wxBrush(c_brush)); dc.GradientFillLinear( wxRect(0,0,client_w,client_h), c_backg, c_pen, wxSOUTH); } DrawStaticBox(dc,_T("Position"), wxPoint(20,294-60), wxSize(350,50)); wxPoint box1_first(20-2,10-2); wxPoint box1_last(368,82+2); dc.DrawRotatedText(_T("Name:"),20,10, 0); //dc.DrawRotatedText(_T("Border thickness"),20,40, 0); //dc.DrawRotatedText(_T("Border colour"),188,40, 0); }
void clAuiDockArt::DrawCaption(wxDC& dc, wxWindow* window, const wxString& text, const wxRect& rect, wxAuiPaneInfo& pane) { wxRect tmpRect(wxPoint(0, 0), rect.GetSize()); // Hackishly prevent assertions on linux if(tmpRect.GetHeight() == 0) tmpRect.SetHeight(1); if(tmpRect.GetWidth() == 0) tmpRect.SetWidth(1); #ifdef __WXOSX__ tmpRect = rect; window->PrepareDC(dc); // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); dc.SetFont(f); dc.SetPen(penColour); dc.SetBrush(bgColour); dc.DrawRectangle(tmpRect); // Fill the caption to look like OSX caption wxColour topColour("#d3d2d3"); wxColour bottomColour("#e8e8e8"); dc.GradientFillLinear(tmpRect, topColour, bottomColour, wxNORTH); dc.SetPen(penColour); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(dc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } dc.SetTextForeground(textColour); wxCoord w, h; dc.GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(dc, text, clip_rect.width); wxSize textSize = dc.GetTextExtent(draw_text); dc.SetTextForeground(textColour); dc.DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); #else wxBitmap bmp(tmpRect.GetSize()); { wxMemoryDC memDc; memDc.SelectObject(bmp); wxGCDC gdc; wxDC* pDC = NULL; if(!DrawingUtils::GetGCDC(memDc, gdc)) { pDC = &memDc; } else { pDC = &gdc; } // Prepare the colours wxColour bgColour, penColour, textColour; textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); bgColour = DrawingUtils::DarkColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 2.0); ; // Same as the notebook background colour penColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW); penColour = bgColour; wxFont f = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); pDC->SetFont(f); pDC->SetPen(penColour); pDC->SetBrush(bgColour); pDC->DrawRectangle(tmpRect); pDC->SetPen(penColour); pDC->SetBrush(*wxTRANSPARENT_BRUSH); pDC->DrawRectangle(tmpRect); int caption_offset = 0; if(pane.icon.IsOk()) { DrawIcon(gdc, tmpRect, pane); caption_offset += pane.icon.GetWidth() + 3; } else { caption_offset = 3; } pDC->SetTextForeground(textColour); wxCoord w, h; pDC->GetTextExtent(wxT("ABCDEFHXfgkj"), &w, &h); wxRect clip_rect = tmpRect; clip_rect.width -= 3; // text offset clip_rect.width -= 2; // button padding if(pane.HasCloseButton()) clip_rect.width -= m_buttonSize; if(pane.HasPinButton()) clip_rect.width -= m_buttonSize; if(pane.HasMaximizeButton()) clip_rect.width -= m_buttonSize; wxString draw_text = wxAuiChopText(gdc, text, clip_rect.width); wxSize textSize = pDC->GetTextExtent(draw_text); pDC->SetTextForeground(textColour); pDC->DrawText(draw_text, tmpRect.x + 3 + caption_offset, tmpRect.y + ((tmpRect.height - textSize.y) / 2)); memDc.SelectObject(wxNullBitmap); } dc.DrawBitmap(bmp, rect.x, rect.y, true); #endif }
void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxPoint offset(wnd->GetPosition()); wxWindow* parent = wnd->GetParent(); wxRibbonPanel* panel = NULL; for(; parent; parent = parent->GetParent()) { panel = wxDynamicCast(parent, wxRibbonPanel); if(panel != NULL) { if(!panel->IsHovered()) return; break; } offset += parent->GetPosition(); } if(panel == NULL) return; wxRect background(panel->GetSize()); RemovePanelPadding(&background); background.x++; background.width -= 2; dc.SetFont(m_panel_label_font); int caption_height = dc.GetTextExtent(panel->GetLabel()).GetHeight() + 7; background.y += caption_height - 1; background.height -= caption_height; wxRect paint_rect(rect); paint_rect.x += offset.x; paint_rect.y += offset.y; wxColour bg_clr, bg_grad_clr; #ifdef __WXMAC__ bg_grad_clr = m_page_hover_background_colour; bg_clr = m_page_hover_background_gradient_colour; #else bg_clr = m_page_hover_background_colour; bg_grad_clr = m_page_hover_background_gradient_colour; #endif paint_rect.Intersect(background); if(!paint_rect.IsEmpty()) { wxColour starting_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr, paint_rect.y, background.y, background.y + background.height)); wxColour ending_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr, paint_rect.y + paint_rect.height, background.y, background.y + background.height)); paint_rect.x -= offset.x; paint_rect.y -= offset.y; dc.GradientFillLinear(paint_rect, starting_colour, ending_colour , wxSOUTH); } }
void wxRibbonAUIArtProvider::DrawMinimisedPanel( wxDC& dc, wxRibbonPanel* wnd, const wxRect& rect, wxBitmap& bitmap) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxRect true_rect(rect); RemovePanelPadding(&true_rect); dc.SetPen(m_panel_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(true_rect.x, true_rect.y, true_rect.width, true_rect.height); true_rect.Deflate(1); if(wnd->IsHovered() || wnd->GetExpandedPanel()) { wxColour colour = m_page_hover_background_colour; wxColour gradient = m_page_hover_background_gradient_colour; #ifdef __WXMAC__ if(!wnd->GetExpandedPanel()) #else if(wnd->GetExpandedPanel()) #endif { wxColour temp = colour; colour = gradient; gradient = temp; } dc.GradientFillLinear(true_rect, colour, gradient, wxSOUTH); } wxRect preview; DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview); dc.SetPen(m_panel_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(preview.x, preview.y, preview.width, preview.height); preview.Deflate(1); wxRect preview_caption_rect(preview); preview_caption_rect.height = 7; preview.y += preview_caption_rect.height; preview.height -= preview_caption_rect.height; #ifdef __WXMAC__ dc.GradientFillLinear(preview_caption_rect, m_panel_hover_label_background_gradient_colour, m_panel_hover_label_background_colour, wxSOUTH); dc.GradientFillLinear(preview, m_page_hover_background_gradient_colour, m_page_hover_background_colour, wxSOUTH); #else dc.GradientFillLinear(preview_caption_rect, m_panel_hover_label_background_colour, m_panel_hover_label_background_gradient_colour, wxSOUTH); dc.GradientFillLinear(preview, m_page_hover_background_colour, m_page_hover_background_gradient_colour, wxSOUTH); #endif if(bitmap.IsOk()) { dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2, preview.y + (preview.height - bitmap.GetHeight()) / 2, true); } }
void wxRibbonAUIArtProvider::DrawPanelBackground( wxDC& dc, wxRibbonPanel* wnd, const wxRect& rect) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height); wxRect true_rect(rect); RemovePanelPadding(&true_rect); dc.SetPen(m_panel_border_pen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(true_rect.x, true_rect.y, true_rect.width, true_rect.height); true_rect.x++; true_rect.width -= 2; true_rect.y++; dc.SetFont(m_panel_label_font); wxSize label_size = dc.GetTextExtent(wnd->GetLabel()); int label_height = label_size.GetHeight() + 5; wxRect label_rect(true_rect); label_rect.height = label_height - 1; dc.DrawLine(label_rect.x, label_rect.y + label_rect.height, label_rect.x + label_rect.width, label_rect.y + label_rect.height); wxColour label_bg_colour = m_panel_label_background_colour; wxColour label_bg_grad_colour = m_panel_label_background_gradient_colour; if(wnd->IsHovered()) { label_bg_colour = m_panel_hover_label_background_colour; label_bg_grad_colour = m_panel_hover_label_background_gradient_colour; dc.SetTextForeground(m_panel_hover_label_colour); } else { dc.SetTextForeground(m_panel_label_colour); } dc.GradientFillLinear(label_rect, #ifdef __WXMAC__ label_bg_grad_colour, label_bg_colour, wxSOUTH); #else label_bg_colour, label_bg_grad_colour, wxSOUTH); #endif dc.SetFont(m_panel_label_font); dc.DrawText(wnd->GetLabel(), label_rect.x + 3, label_rect.y + 2); if(wnd->IsHovered()) { wxRect gradient_rect(true_rect); gradient_rect.y += label_rect.height + 1; gradient_rect.height = true_rect.height - label_rect.height - 3; #ifdef __WXMAC__ wxColour colour = m_page_hover_background_gradient_colour; wxColour gradient = m_page_hover_background_colour; #else wxColour colour = m_page_hover_background_colour; wxColour gradient = m_page_hover_background_gradient_colour; #endif dc.GradientFillLinear(gradient_rect, colour, gradient, wxSOUTH); } if(wnd->HasExtButton()) { if(wnd->IsExtButtonHovered()) { dc.SetPen(m_panel_hover_button_border_pen); dc.SetBrush(m_panel_hover_button_background_brush); dc.DrawRoundedRectangle(label_rect.GetRight() - 13, label_rect.GetBottom() - 13, 13, 13, 1.0); dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() - 10, label_rect.GetBottom() - 10, true); } else dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() - 10, label_rect.GetBottom() - 10, true); } }
void wxAuiGenericTabArt::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page, const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect, wxRect* out_button_rect, int* x_extent) { wxCoord normal_textx, normal_texty; wxCoord selected_textx, selected_texty; wxCoord texty; // if the caption is empty, measure some temporary text wxString caption = page.caption; if (caption.empty()) caption = wxT("Xj"); dc.SetFont(m_selectedFont); dc.GetTextExtent(caption, &selected_textx, &selected_texty); dc.SetFont(m_normalFont); dc.GetTextExtent(caption, &normal_textx, &normal_texty); // figure out the size of the tab wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap, page.active, close_button_state, x_extent); wxCoord tab_height = m_tabCtrlHeight - 3; wxCoord tab_width = tab_size.x; wxCoord tab_x = in_rect.x; wxCoord tab_y = in_rect.y + in_rect.height - tab_height; caption = page.caption; // select pen, brush and font for the tab to be drawn if (page.active) { dc.SetFont(m_selectedFont); texty = selected_texty; } else { dc.SetFont(m_normalFont); texty = normal_texty; } // create points that will make the tab outline int clip_width = tab_width; if (tab_x + clip_width > in_rect.x + in_rect.width) clip_width = (in_rect.x + in_rect.width) - tab_x; /* wxPoint clip_points[6]; clip_points[0] = wxPoint(tab_x, tab_y+tab_height-3); clip_points[1] = wxPoint(tab_x, tab_y+2); clip_points[2] = wxPoint(tab_x+2, tab_y); clip_points[3] = wxPoint(tab_x+clip_width-1, tab_y); clip_points[4] = wxPoint(tab_x+clip_width+1, tab_y+2); clip_points[5] = wxPoint(tab_x+clip_width+1, tab_y+tab_height-3); // FIXME: these ports don't provide wxRegion ctor from array of points #if !defined(__WXDFB__) && !defined(__WXCOCOA__) // set the clipping region for the tab -- wxRegion clipping_region(WXSIZEOF(clip_points), clip_points); dc.SetClippingRegion(clipping_region); #endif // !wxDFB && !wxCocoa */ // since the above code above doesn't play well with WXDFB or WXCOCOA, // we'll just use a rectangle for the clipping region for now -- dc.SetClippingRegion(tab_x, tab_y, clip_width+1, tab_height-3); wxPoint border_points[6]; if (m_flags &wxAUI_NB_BOTTOM) { border_points[0] = wxPoint(tab_x, tab_y); border_points[1] = wxPoint(tab_x, tab_y+tab_height-6); border_points[2] = wxPoint(tab_x+2, tab_y+tab_height-4); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y+tab_height-4); border_points[4] = wxPoint(tab_x+tab_width, tab_y+tab_height-6); border_points[5] = wxPoint(tab_x+tab_width, tab_y); } else //if (m_flags & wxAUI_NB_TOP) {} { border_points[0] = wxPoint(tab_x, tab_y+tab_height-4); border_points[1] = wxPoint(tab_x, tab_y+2); border_points[2] = wxPoint(tab_x+2, tab_y); border_points[3] = wxPoint(tab_x+tab_width-2, tab_y); border_points[4] = wxPoint(tab_x+tab_width, tab_y+2); border_points[5] = wxPoint(tab_x+tab_width, tab_y+tab_height-4); } // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} int drawn_tab_yoff = border_points[1].y; int drawn_tab_height = border_points[0].y - border_points[1].y; if (page.active) { // draw active tab // draw base background color wxRect r(tab_x, tab_y, tab_width, tab_height); dc.SetPen(wxPen(m_activeColour)); dc.SetBrush(wxBrush(m_activeColour)); dc.DrawRectangle(r.x+1, r.y+1, r.width-1, r.height-4); // this white helps fill out the gradient at the top of the tab dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); dc.DrawRectangle(r.x+2, r.y+1, r.width-3, r.height-4); // these two points help the rounded corners appear more antialiased dc.SetPen(wxPen(m_activeColour)); dc.DrawPoint(r.x+2, r.y+1); dc.DrawPoint(r.x+r.width-2, r.y+1); // set rectangle down a bit for gradient drawing r.SetHeight(r.GetHeight()/2); r.x += 2; r.width -= 3; r.y += r.height; r.y -= 2; // draw gradient background wxColor top_color = *wxWHITE; wxColor bottom_color = m_activeColour; dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); } else { // draw inactive tab wxRect r(tab_x, tab_y+1, tab_width, tab_height-3); // start the gradent up a bit and leave the inside border inset // by a pixel for a 3D look. Only the top half of the inactive // tab will have a slight gradient r.x += 3; r.y++; r.width -= 4; r.height /= 2; r.height--; // -- draw top gradient fill for glossy look wxColor top_color = m_baseColour; wxColor bottom_color = top_color.ChangeLightness(160); dc.GradientFillLinear(r, bottom_color, top_color, wxNORTH); r.y += r.height; r.y--; // -- draw bottom fill for glossy look top_color = m_baseColour; bottom_color = m_baseColour; dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH); } // draw tab outline dc.SetPen(m_borderPen); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawPolygon(WXSIZEOF(border_points), border_points); // there are two horizontal grey lines at the bottom of the tab control, // this gets rid of the top one of those lines in the tab control if (page.active) { if (m_flags &wxAUI_NB_BOTTOM) dc.SetPen(wxPen(m_baseColour.ChangeLightness(170))); // TODO: else if (m_flags &wxAUI_NB_LEFT) {} // TODO: else if (m_flags &wxAUI_NB_RIGHT) {} else //for wxAUI_NB_TOP dc.SetPen(m_baseColourPen); dc.DrawLine(border_points[0].x+1, border_points[0].y, border_points[5].x, border_points[5].y); } int text_offset = tab_x + 8; int close_button_width = 0; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { close_button_width = m_activeCloseBmp.GetWidth(); } int bitmap_offset = 0; if (page.bitmap.IsOk()) { bitmap_offset = tab_x + 8; // draw bitmap dc.DrawBitmap(page.bitmap, bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), true); text_offset = bitmap_offset + page.bitmap.GetWidth(); text_offset += 3; // bitmap padding } else { text_offset = tab_x + 8; } wxString draw_text = wxAuiChopText(dc, caption, tab_width - (text_offset-tab_x) - close_button_width); // draw tab text dc.DrawText(draw_text, text_offset, drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1); // draw focus rectangle if (page.active && (wnd->FindFocus() == wnd)) { wxRect focusRectText(text_offset, (drawn_tab_yoff + (drawn_tab_height)/2 - (texty/2) - 1), selected_textx, selected_texty); wxRect focusRect; wxRect focusRectBitmap; if (page.bitmap.IsOk()) focusRectBitmap = wxRect(bitmap_offset, drawn_tab_yoff + (drawn_tab_height/2) - (page.bitmap.GetHeight()/2), page.bitmap.GetWidth(), page.bitmap.GetHeight()); if (page.bitmap.IsOk() && draw_text.IsEmpty()) focusRect = focusRectBitmap; else if (!page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText; else if (page.bitmap.IsOk() && !draw_text.IsEmpty()) focusRect = focusRectText.Union(focusRectBitmap); focusRect.Inflate(2, 2); wxRendererNative::Get().DrawFocusRect(wnd, dc, focusRect, 0); } // draw close button if necessary if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) { wxBitmap bmp = m_disabledCloseBmp; if (close_button_state == wxAUI_BUTTON_STATE_HOVER || close_button_state == wxAUI_BUTTON_STATE_PRESSED) { bmp = m_activeCloseBmp; } int offsetY = tab_y-1; if (m_flags & wxAUI_NB_BOTTOM) offsetY = 1; wxRect rect(tab_x + tab_width - close_button_width - 1, offsetY + (tab_height/2) - (bmp.GetHeight()/2), close_button_width, tab_height); IndentPressedBitmap(&rect, close_button_state); dc.DrawBitmap(bmp, rect.x, rect.y, true); *out_button_rect = rect; } *out_tab_rect = wxRect(tab_x, tab_y, tab_width, tab_height); dc.DestroyClippingRegion(); }
void wxRibbonAUIArtProvider::DrawTab(wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRibbonPageTabInfo& tab) { if(tab.rect.height <= 1) return; dc.SetFont(m_tab_label_font); dc.SetPen(*wxTRANSPARENT_PEN); if(tab.active || tab.hovered || tab.highlight) { if(tab.active) { dc.SetFont(m_tab_active_label_font); dc.SetBrush(m_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + tab.rect.height - 1, tab.rect.width - 1, 1); } wxRect grad_rect(tab.rect); grad_rect.height -= 4; grad_rect.width -= 1; grad_rect.height /= 2; grad_rect.y = grad_rect.y + tab.rect.height - grad_rect.height - 1; dc.SetBrush(m_tab_active_top_background_brush); dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1, grad_rect.y - tab.rect.y - 3); if(tab.highlight) { dc.GradientFillLinear(grad_rect, m_tab_highlight_top_colour, m_tab_highlight_top_gradient_colour, wxSOUTH); } else { dc.GradientFillLinear(grad_rect, m_tab_active_background_colour, m_tab_active_background_gradient_colour, wxSOUTH); } } else { wxRect btm_rect(tab.rect); btm_rect.height -= 4; btm_rect.width -= 1; btm_rect.height /= 2; btm_rect.y = btm_rect.y + tab.rect.height - btm_rect.height - 1; dc.SetBrush(m_tab_hover_background_brush); dc.DrawRectangle(btm_rect.x, btm_rect.y, btm_rect.width, btm_rect.height); wxRect grad_rect(tab.rect); grad_rect.width -= 1; grad_rect.y += 3; grad_rect.height = btm_rect.y - grad_rect.y; dc.GradientFillLinear(grad_rect, m_tab_hover_background_top_colour, m_tab_hover_background_top_gradient_colour, wxSOUTH); } wxPoint border_points[5]; border_points[0] = wxPoint(0, 3); border_points[1] = wxPoint(1, 2); border_points[2] = wxPoint(tab.rect.width - 3, 2); border_points[3] = wxPoint(tab.rect.width - 1, 4); border_points[4] = wxPoint(tab.rect.width - 1, tab.rect.height - 1); dc.SetPen(m_tab_border_pen); dc.DrawLines(sizeof(border_points)/sizeof(wxPoint), border_points, tab.rect.x, tab.rect.y); wxRect old_clip; dc.GetClippingBox(old_clip); bool is_first_tab = false; wxRibbonBar* bar = wxDynamicCast(tab.page->GetParent(), wxRibbonBar); if(bar && bar->GetPage(0) == tab.page) is_first_tab = true; wxBitmap icon; if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS) { icon = tab.page->GetIcon(); if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) == 0) { if(icon.IsOk()) { int x = tab.rect.x + (tab.rect.width - icon.GetWidth()) / 2; dc.DrawBitmap(icon, x, tab.rect.y + 1 + (tab.rect.height - 1 - icon.GetHeight()) / 2, true); } } } if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) { wxString label = tab.page->GetLabel(); if(!label.IsEmpty()) { dc.SetTextForeground(m_tab_label_colour); dc.SetBackgroundMode(wxTRANSPARENT); int offset = 0; if(icon.IsOk()) offset += icon.GetWidth() + 2; int text_height; int text_width; dc.GetTextExtent(label, &text_width, &text_height); int x = (tab.rect.width - 2 - text_width - offset) / 2; if(x > 8) x = 8; else if(x < 1) x = 1; int width = tab.rect.width - x - 2; x += tab.rect.x + offset; int y = tab.rect.y + (tab.rect.height - text_height) / 2; if(icon.IsOk()) { dc.DrawBitmap(icon, x - offset, tab.rect.y + (tab.rect.height - icon.GetHeight()) / 2, true); } dc.SetClippingRegion(x, tab.rect.y, width, tab.rect.height); dc.DrawText(label, x, y); } } // Draw the left hand edge of the tab only for the first tab (subsequent // tabs use the right edge of the prior tab as their left edge). As this is // outside the rectangle for the tab, only draw it if the leftmost part of // the tab is within the clip rectangle (the clip region has to be cleared // to draw outside the tab). if(is_first_tab && old_clip.x <= tab.rect.x && tab.rect.x < old_clip.x + old_clip.width) { dc.DestroyClippingRegion(); dc.DrawLine(tab.rect.x - 1, tab.rect.y + 4, tab.rect.x - 1, tab.rect.y + tab.rect.height - 1); } }