Beispiel #1
0
void wxRibbonMetroArtProvider::DrawMinimisedPanel(
                        wxDC& dc,
                        wxRibbonPanel* wnd,
                        const wxRect& rect,
                        wxBitmap& bitmap)
{
    DrawPartialPageBackground(dc, wnd, rect, false);

    wxRect true_rect(rect);
    // RemovePanelPadding(&true_rect);
	
	wxRect client_rect(true_rect);
	client_rect.width -= 2;
	client_rect.y++;
	client_rect.height -= 2;
	
	if(wnd->GetExpandedPanel() != NULL)
    {
		dc.SetPen(m_button_bar_active_border_pen);
		dc.SetBrush (m_button_bar_active_background_colour);
		dc.DrawRectangle(client_rect);
    }
    else if(wnd->IsHovered())
    {
		dc.SetPen(m_button_bar_hover_border_pen);
		dc.SetBrush (m_panel_active_background_colour);
		dc.DrawRectangle(client_rect);
    }
	else {
		dc.SetPen(m_button_bar_hover_border_pen);
		dc.SetBrush (m_button_bar_hover_background_colour);
		dc.DrawRectangle(client_rect);		
	}

    wxRect preview;
    DrawMinimisedPanelCommon(dc, wnd, true_rect, &preview);
    dc.SetBrush(m_panel_active_background_colour);
    dc.SetPen(m_button_bar_hover_border_pen);
	dc.DrawRectangle(preview);

    if(bitmap.IsOk())
    {
        dc.DrawBitmap(bitmap, preview.x + (preview.width - bitmap.GetWidth()) / 2,
            preview.y + (preview.height - 7 - bitmap.GetHeight()) / 2, true);
    }

    DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
}
Beispiel #2
0
wxRect wxRibbonAUIArtProvider::GetPanelExtButtonArea(wxDC& dc,
                        const wxRibbonPanel* wnd,
                        wxRect rect)
{
    wxRect true_rect(rect);
    RemovePanelPadding(&true_rect);

    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;

    rect = wxRect(label_rect.GetRight()-13, label_rect.GetBottom()-13, 13, 13);
    return rect;
}
Beispiel #3
0
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);
    }
}
Beispiel #4
0
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);
    }
}
Beispiel #5
0
void wxRibbonAUIArtProvider::DrawScrollButton(
                        wxDC& dc,
                        wxWindow* WXUNUSED(wnd),
                        const wxRect& rect,
                        long style)
{
    wxRect true_rect(rect);
    wxPoint arrow_points[3];

    if((style & wxRIBBON_SCROLL_BTN_FOR_MASK) == wxRIBBON_SCROLL_BTN_FOR_TABS)
    {
        true_rect.y += 2;
        true_rect.height -= 2;
        dc.SetPen(m_tab_border_pen);
    }
    else
    {
        dc.SetPen(*wxTRANSPARENT_PEN);
        dc.SetBrush(m_background_brush);
        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
        dc.SetPen(m_page_border_pen);
    }

    switch(style & wxRIBBON_SCROLL_BTN_DIRECTION_MASK)
    {
    case wxRIBBON_SCROLL_BTN_LEFT:
        dc.DrawLine(true_rect.GetRight(), true_rect.y, true_rect.GetRight(),
            true_rect.y + true_rect.height);
        arrow_points[0] = wxPoint(rect.width / 2 - 2, rect.height / 2);
        arrow_points[1] = arrow_points[0] + wxPoint(5, -5);
        arrow_points[2] = arrow_points[0] + wxPoint(5,  5);
        break;
    case wxRIBBON_SCROLL_BTN_RIGHT:
        dc.DrawLine(true_rect.x, true_rect.y, true_rect.x,
            true_rect.y + true_rect.height);
        arrow_points[0] = wxPoint(rect.width / 2 + 3, rect.height / 2);
        arrow_points[1] = arrow_points[0] - wxPoint(5, -5);
        arrow_points[2] = arrow_points[0] - wxPoint(5,  5);
        break;
    case wxRIBBON_SCROLL_BTN_DOWN:
        dc.DrawLine(true_rect.x, true_rect.y, true_rect.x + true_rect.width,
            true_rect.y);
        arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 + 3);
        arrow_points[1] = arrow_points[0] - wxPoint( 5, 5);
        arrow_points[2] = arrow_points[0] - wxPoint(-5, 5);
        break;
    case wxRIBBON_SCROLL_BTN_UP:
        dc.DrawLine(true_rect.x, true_rect.GetBottom(),
            true_rect.x + true_rect.width, true_rect.GetBottom());
        arrow_points[0] = wxPoint(rect.width / 2, rect.height / 2 - 2);
        arrow_points[1] = arrow_points[0] + wxPoint( 5, 5);
        arrow_points[2] = arrow_points[0] + wxPoint(-5, 5);
        break;
    default:
        return;
    }

    int x = rect.x;
    int y = rect.y;
    if(style & wxRIBBON_SCROLL_BTN_ACTIVE)
    {
        ++x;
        ++y;
    }

    dc.SetPen(*wxTRANSPARENT_PEN);
    wxBrush B(m_tab_label_colour);
    dc.SetBrush(B);
    dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y);
}
Beispiel #6
0
void wxRibbonMetroArtProvider::DrawPanelBackground(
                        wxDC& dc,
                        wxRibbonPanel* wnd,
                        const wxRect& rect)
{
    DrawPartialPageBackground(dc, wnd, rect, false);

    wxRect true_rect(rect);
    RemovePanelPadding(&true_rect);
    bool has_ext_button = wnd->HasExtButton();

	// draw panel label
    {
		// int label_height;
        dc.SetFont(m_panel_label_font);
        dc.SetPen(*wxTRANSPARENT_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
        dc.SetTextForeground(m_panel_label_colour);

        wxRect label_rect(true_rect);
        wxString label = wnd->GetLabel();
        bool clip_label = false;
        wxSize label_size(dc.GetTextExtent(label));

        label_rect.SetX(label_rect.GetX() + 1);
        label_rect.SetWidth(label_rect.GetWidth() - 2);
        label_rect.SetHeight(label_size.GetHeight() + 2);
        label_rect.SetY(true_rect.GetBottom() - label_rect.GetHeight());
        // label_height = label_rect.GetHeight();

        wxRect label_bg_rect = label_rect;

        if(has_ext_button)
            label_rect.SetWidth(label_rect.GetWidth() - 13);

        if(label_size.GetWidth() > label_rect.GetWidth())
        {
            // Test if there is enough length for 3 letters and ...
            wxString new_label = label.Mid(0, 3) + wxT("...");
            label_size = dc.GetTextExtent(new_label);
            if(label_size.GetWidth() > label_rect.GetWidth())
            {
                // Not enough room for three characters and ...
                // Display the entire label and just crop it
                clip_label = true;
            }
            else
            {
                // Room for some characters and ...
                // Display as many characters as possible and append ...
                for(size_t len = label.Len() - 1; len >= 3; --len)
                {
                    new_label = label.Mid(0, len) + wxT("...");
                    label_size = dc.GetTextExtent(new_label);
                    if(label_size.GetWidth() <= label_rect.GetWidth())
                    {
                        label = new_label;
                        break;
                    }
                }
            }
        }

        dc.DrawRectangle(label_bg_rect);
        if(clip_label)
        {
            wxDCClipper clip(dc, label_rect);
            dc.DrawText(label, label_rect.x, label_rect.y +
                (label_rect.GetHeight() - label_size.GetHeight()) / 2);
        }
        else
        {
            dc.DrawText(label, label_rect.x +
                (label_rect.GetWidth() - label_size.GetWidth()) / 2,
                label_rect.y +
                (label_rect.GetHeight() - label_size.GetHeight()) / 2);
        }

        if(has_ext_button)
        {
            if(wnd->IsExtButtonHovered())
            {
                dc.SetPen(m_panel_hover_button_border_pen);
                dc.SetBrush(m_panel_hover_button_background_brush);
                dc.DrawRectangle(label_rect.GetRight(), label_rect.GetBottom() - 14, 14, 14);
                dc.DrawBitmap(m_panel_extension_bitmap[1], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
            }
            else
                dc.DrawBitmap(m_panel_extension_bitmap[0], label_rect.GetRight() + 3, label_rect.GetBottom() - 10, true);
        }
    }
	
	if (wnd->GetParent()->IsKindOf(CLASSINFO(wxFrame))) // expanded panels are in their own wxFrame otherwise normal panel
	{	
		wxRect shadow(rect);
		shadow.x +=4;
		shadow.y +=4;
		dc.SetPen(*wxRED);
		dc.DrawLine(shadow.GetBottomLeft(), shadow.GetBottomRight());
		dc.DrawLine(shadow.GetTopRight(), shadow.GetBottomRight());
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.SetPen(m_panel_border_pen);
		dc.DrawRoundedRectangle(rect, 1.0);
	}
	else
		DrawPanelBorder(dc, true_rect, m_panel_border_pen, m_panel_border_gradient_pen);
}