⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 renderer.cpp

📁 robocup rcssserver 运行防真机器人足球比赛所用的服务器端
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include <wx/wxflatnotebook/renderer.h>#include <wx/wxflatnotebook/wxflatnotebook.h> // for the styles#include <wx/wxflatnotebook/fnb_resources.h>#include <wx/image.h>wxFNBRenderer::wxFNBRenderer(): m_tabXBgBmp(16, 16), m_xBgBmp(16, 14), m_leftBgBmp(16, 14), m_rightBgBmp(16, 14){}wxFNBRenderer::~wxFNBRenderer(){}int wxFNBRenderer::GetLeftButtonPos(wxWindow* pageContainer){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        wxRect rect = pc->GetClientRect();        int clientWidth = rect.width;        if(style & wxFNB_NO_X_BUTTON)                return clientWidth - 38;        else                return clientWidth - 54;}int wxFNBRenderer::GetRightButtonPos(wxWindow* pageContainer){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        wxRect rect = pc->GetClientRect();        int clientWidth = rect.width;        if(style & wxFNB_NO_X_BUTTON)                return clientWidth - 22;        else                return clientWidth - 38;}int wxFNBRenderer::GetDropArrowButtonPos(wxWindow *pageContainer){        return GetRightButtonPos(pageContainer);}int wxFNBRenderer::GetXPos(wxWindow* pageContainer){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        wxRect rect = pc->GetClientRect();        int clientWidth = rect.width;        if(style & wxFNB_NO_X_BUTTON)                return clientWidth;        else                return clientWidth - 22;}int wxFNBRenderer::GetButtonsAreaLength(wxWindow* pageContainer){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        // ''        if(style & wxFNB_NO_NAV_BUTTONS && style & wxFNB_NO_X_BUTTON && !(style & wxFNB_DROPDOWN_TABS_LIST))                return 0;        // 'x'        if((style & wxFNB_NO_NAV_BUTTONS) && !(style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))                return 22;        // '<>'        if(!(style & wxFNB_NO_NAV_BUTTONS) && (style & wxFNB_NO_X_BUTTON) && !(style & wxFNB_DROPDOWN_TABS_LIST))                return 53 - 16;        // 'vx'        if((style & wxFNB_DROPDOWN_TABS_LIST) && !(style & wxFNB_NO_X_BUTTON))                return 22 + 16;        // 'v'        if((style & wxFNB_DROPDOWN_TABS_LIST) && (style & wxFNB_NO_X_BUTTON))                return 22;        // '<>x'        return 53;}void wxFNBRenderer::DrawLeftArrow(wxWindow* pageContainer, wxDC& dc){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        if(style & wxFNB_NO_NAV_BUTTONS)                return;        // Make sure that there are pages in the container        if(pc->GetPageInfoVector().empty())                return;        // Set the bitmap according to the button status        wxBitmap arrowBmp;        switch(pc->m_nLeftButtonStatus)        {        case wxFNB_BTN_HOVER:                arrowBmp = wxBitmap(left_arrow_hilite_xpm);                break;        case wxFNB_BTN_PRESSED:                arrowBmp = wxBitmap(left_arrow_pressed_xpm);                break;        case wxFNB_BTN_NONE:        default:                arrowBmp = wxBitmap(left_arrow_xpm);                break;        }        if(pc->m_nFrom == 0)        {                // Handle disabled arrow                arrowBmp = wxBitmap(left_arrow_disabled_xpm);        }        arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));        // Erase old bitmap        int posx = GetLeftButtonPos( pc );        dc.DrawBitmap(m_leftBgBmp, posx, 6);        // Draw the new bitmap        dc.DrawBitmap(arrowBmp, posx, 6, true);}void wxFNBRenderer::DrawRightArrow(wxWindow* pageContainer, wxDC& dc){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        long style = pc->GetParent()->GetWindowStyleFlag();        if(style & wxFNB_NO_NAV_BUTTONS)                return;        // Make sure that there are pages in the container        if(pc->GetPageInfoVector().empty())                return;        // Set the bitmap according to the button status        wxBitmap arrowBmp;        switch(pc->m_nRightButtonStatus)        {        case wxFNB_BTN_HOVER:                arrowBmp = wxBitmap(right_arrow_hilite_xpm);                break;        case wxFNB_BTN_PRESSED:                arrowBmp = wxBitmap(right_arrow_pressed_xpm);                break;        case wxFNB_BTN_NONE:        default:                arrowBmp = wxBitmap(right_arrow_xpm);                break;        }        // Check if the right most tab is visible, if it is        // don't rotate right anymore        if(pc->GetPageInfoVector()[pc->GetPageInfoVector().GetCount()-1].GetPosition() != wxPoint(-1, -1))        {                arrowBmp = wxBitmap(right_arrow_disabled_xpm);        }        arrowBmp.SetMask(new wxMask(arrowBmp, MASK_COLOR));        // erase old bitmap        int posx = GetRightButtonPos( pc ) ;        dc.DrawBitmap(m_rightBgBmp, posx, 6);        // Draw the new bitmap        dc.DrawBitmap(arrowBmp, posx, 6, true);}void wxFNBRenderer::DrawDropDownArrow(wxWindow* pageContainer, wxDC& dc){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        // Check if this style is enabled        long style = pc->GetParent()->GetWindowStyleFlag();        if(! (style & wxFNB_DROPDOWN_TABS_LIST) )                return;        // Make sure that there are pages in the container        if(pc->GetPageInfoVector().empty())                return;        // Set the bitmap according to the button status        wxBitmap xbmp;        switch(pc->m_nArrowDownButtonStatus)        {        case wxFNB_BTN_HOVER:                xbmp = wxBitmap(down_arrow_hilite_xpm);                break;        case wxFNB_BTN_PRESSED:                xbmp = wxBitmap(down_arrow_pressed_xpm);                break;        case wxFNB_BTN_NONE:        default:                xbmp = wxBitmap(down_arrow_xpm);                break;        }        xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));        // erase old bitmap        int posx = GetDropArrowButtonPos( pc );        dc.DrawBitmap(m_xBgBmp, posx, 6);        // Draw the new bitmap        dc.DrawBitmap(xbmp, posx, 6, true);}void wxFNBRenderer::DrawX(wxWindow* pageContainer, wxDC& dc){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        // Check if this style is enabled        long style = pc->GetParent()->GetWindowStyleFlag();        if(style & wxFNB_NO_X_BUTTON)                return;        // Make sure that there are pages in the container        if(pc->GetPageInfoVector().empty())                return;        // Set the bitmap according to the button status        wxBitmap xbmp;        switch(pc->m_nXButtonStatus)        {        case wxFNB_BTN_HOVER:                xbmp = wxBitmap(x_button_hilite_xpm);                break;        case wxFNB_BTN_PRESSED:                xbmp = wxBitmap(x_button_pressed_xpm);                break;        case wxFNB_BTN_NONE:        default:                xbmp = wxBitmap(x_button_xpm);                break;        }        xbmp.SetMask(new wxMask(xbmp, MASK_COLOR));        // erase old bitmap        int posx = GetXPos( pc );        dc.DrawBitmap(m_xBgBmp, posx, 6);        // Draw the new bitmap        dc.DrawBitmap(xbmp, posx, 6, true);}void wxFNBRenderer::PaintStraightGradientBox(wxDC& dc, const wxRect& rect, const wxColour& startColor, const wxColour& endColor, bool  vertical){        int rd, gd, bd, high = 0;        rd = endColor.Red() - startColor.Red();        gd = endColor.Green() - startColor.Green();        bd = endColor.Blue() - startColor.Blue();        /// Save the current pen and brush        wxPen savedPen = dc.GetPen();        wxBrush savedBrush = dc.GetBrush();        if ( vertical )                high = rect.GetHeight()-1;        else                high = rect.GetWidth()-1;        if( high < 1 )                return;        for (int i = 0; i <= high; ++i)        {                int r = startColor.Red() +  ((i*rd*100)/high)/100;                int g = startColor.Green() + ((i*gd*100)/high)/100;                int b = startColor.Blue() + ((i*bd*100)/high)/100;                wxPen p(wxColor(r, g, b));                dc.SetPen(p);                if ( vertical )                        dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);                else                        dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);        }        /// Restore the pen and brush        dc.SetPen( savedPen );        dc.SetBrush( savedBrush );}void wxFNBRenderer::DrawTabX(wxWindow* pageContainer, wxDC& dc, const wxRect& rect, const int& tabIdx, const int btnStatus){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        if(!pc->HasFlag(wxFNB_X_ON_TAB))                return;        /// We draw the 'x' on the active tab only        if(tabIdx != pc->GetSelection() || tabIdx < 0)                return;        // Set the bitmap according to the button status        wxBitmap xBmp;        switch(btnStatus)        {        case wxFNB_BTN_HOVER:                xBmp = wxBitmap(x_button_hilite_xpm);                break;        case wxFNB_BTN_PRESSED:                xBmp = wxBitmap(x_button_pressed_xpm);                break;        case wxFNB_BTN_NONE:        default:                xBmp = wxBitmap(x_button_xpm);                break;        }        /// Set the masking        xBmp.SetMask(new wxMask(xBmp, MASK_COLOR));        // erase old button        dc.DrawBitmap(m_tabXBgBmp, rect.x, rect.y);        // Draw the new bitmap        dc.DrawBitmap(xBmp, rect.x, rect.y, true);        // Update the vectpr        wxRect rr(rect.x, rect.y, 14, 13);        pc->GetPageInfoVector()[tabIdx].SetXRect( rr );}void wxFNBRenderer::GetBitmap(wxDC &dc, const wxRect &rect, wxBitmap &bmp){        wxMemoryDC mem_dc;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -