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

📄 renderer.cpp

📁 robocup rcssserver 运行防真机器人足球比赛所用的服务器端
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        if(tabIdx != pc->GetSelection() && !pc->HasFlag( wxFNB_BOTTOM ))        {                // Top default tabs                dc.SetPen(wxPen( pc->GetBorderColour() ));                int lineY = rect.height;                wxPen curPen = dc.GetPen();                curPen.SetWidth(1);                dc.SetPen(curPen);                dc.DrawLine(posx, lineY, posx+rect.width, lineY);        }        // Incase we are drawing the selected tab, we draw the border of it as well        // but without the bottom (upper line incase of wxBOTTOM)        if(tabIdx == pc->GetSelection())        {                wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));                wxBrush brush(*wxTRANSPARENT_BRUSH);                dc.SetPen(borderPen);                dc.SetBrush(brush);                dc.DrawPolygon(8, tabPoints);                // Delete the bottom line (or the upper one, incase we use wxBOTTOM)                dc.SetPen(wxPen(wxT("WHITE")));                dc.DrawLine(tabPoints[0], tabPoints[6]);        }        FillVC8GradientColor(pc, dc, tabPoints, tabIdx == pc->GetSelection(), tabIdx);        // Draw a thin line to the right of the non-selected tab        if(tabIdx != pc->GetSelection())        {                dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)));                dc.DrawLine(tabPoints[4].x-1, tabPoints[4].y, tabPoints[5].x-1, tabPoints[5].y);                dc.DrawLine(tabPoints[5].x-1, tabPoints[5].y, tabPoints[6].x-1, tabPoints[6].y);        }        // Text drawing offset from the left border of the        // rectangle        int textOffset;        // The width of the images are 16 pixels        int vc8ShapeLen = tabHeight - VERTICAL_BORDER_PADDING - 2;        if( pc->TabHasImage( tabIdx ) )                textOffset = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() * 2 + 16 + vc8ShapeLen;        else                textOffset = ((wxFlatNotebook *)pc->m_pParent)->GetPadding() + vc8ShapeLen;        // Draw the image for the tab if any        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;        if( pc->TabHasImage( tabIdx ) )        {                int imageXOffset = textOffset - 16 - ((wxFlatNotebook *)pc->m_pParent)->GetPadding();                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],                        posx + imageXOffset, imageYCoord, true);        }        wxFont boldFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);        // if selected tab, draw text in bold        if( tabIdx == pc->GetSelection() )        {                boldFont.SetWeight(wxFONTWEIGHT_BOLD);        }        dc.SetFont( boldFont );        dc.DrawText(pc->GetPageText(tabIdx), posx + textOffset, imageYCoord);        // draw 'x' on tab (if enabled)        if(pc->HasFlag(wxFNB_X_ON_TAB) && tabIdx == pc->GetSelection())        {                int textWidth, textHeight;                dc.GetTextExtent(pc->GetPageText(tabIdx), &textWidth, &textHeight);                int tabCloseButtonXCoord = posx + textOffset + textWidth + 1;                // take a bitmap from the position of the 'x' button (the x on tab button)                // this bitmap will be used later to delete old buttons                int tabCloseButtonYCoord = imageYCoord;                wxRect x_rect(tabCloseButtonXCoord, tabCloseButtonYCoord, 16, 16);                GetBitmap(dc, x_rect, m_tabXBgBmp);                wxBitmap bmp( 16, 16 );                // Draw the tab                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);        }}void wxFNBRendererVC8::FillVC8GradientColor(wxWindow* pageContainer, wxDC &dc, const wxPoint tabPoints[], const bool bSelectedTab, const int tabIdx){        // calculate gradient coefficients        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        if( m_first )        {                m_first = false;                pc->m_colorTo   = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 0);                pc->m_colorFrom = LightColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), 60);        }        wxColour col2 = pc->HasFlag( wxFNB_BOTTOM ) ? pc->GetGradientColourTo() : pc->GetGradientColourFrom();        wxColour col1 = pc->HasFlag( wxFNB_BOTTOM ) ? pc->GetGradientColourFrom() : pc->GetGradientColourTo();        // If colorful tabs style is set, override the tab color        if(pc->HasFlag(wxFNB_COLORFUL_TABS))        {                if( !pc->GetPageInfoVector()[tabIdx].GetColor().Ok() )                {                        // First time, generate color, and keep it in the vector                        wxColor tabColor(RandomColor());                        pc->GetPageInfoVector()[tabIdx].SetColor(tabColor);                }                if( pc->HasFlag(wxFNB_BOTTOM) )                {                        col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );                        col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );                }                else                {                        col1 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 50 );                        col2 = LightColour( pc->GetPageInfoVector()[tabIdx].GetColor() , 80 );                }        }        int size = abs(tabPoints[2].y - tabPoints[0].y) - 1;        double rstep = double((col2.Red() -   col1.Red())) / double(size), rf = 0,                gstep = double((col2.Green() - col1.Green())) / double(size), gf = 0,                bstep = double((col2.Blue() -  col1.Blue())) / double(size), bf = 0;        wxColour currCol;        int y = tabPoints[0].y;        // If we are drawing the selected tab, we need also to draw a line        // from 0->tabPoints[0].x and tabPoints[6].x -> end, we achieve this        // by drawing the rectangle with transparent brush        // the line under the selected tab will be deleted by the drwaing loop        if( bSelectedTab )                DrawTabsLine(pc, dc);        while( true )        {                if(pc->HasFlag( wxFNB_BOTTOM ))                {                        if(y > tabPoints[0].y + size)                                break;                }                else                {                        if(y < tabPoints[0].y - size)                                break;                }                currCol.Set(                        (unsigned char)(col1.Red() + rf),                        (unsigned char)(col1.Green() + gf),                        (unsigned char)(col1.Blue() + bf)                        );                dc.SetPen(bSelectedTab ? wxPen(pc->m_activeTabColor) : wxPen(currCol));                int startX = GetStartX(tabPoints, y, pc->GetParent()->GetWindowStyleFlag()) ;                int endX   = GetEndX(tabPoints, y, pc->GetParent()->GetWindowStyleFlag());                dc.DrawLine(startX, y, endX, y);                // Draw the border using the 'edge' point                dc.SetPen(wxPen(bSelectedTab ? wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW) : pc->m_colorBorder));                dc.DrawPoint(startX, y);                dc.DrawPoint(endX, y);                // Progress the color                rf += rstep; gf += gstep; bf += bstep;                pc->HasFlag( wxFNB_BOTTOM ) ? y++ : y--;        }}int wxFNBRendererVC8::GetStartX(const wxPoint tabPoints[], const int &y, long style){        double x1 = 0, x2 = 0, y1 = 0, y2 = 0;        // We check the 3 points to the left        bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;        bool match = false;        if(bBottomStyle)        {                for(int i=0; i<3; i++)                {                        if(y >= tabPoints[i].y && y < tabPoints[i+1].y)                        {                                x1 = tabPoints[i].x;                                x2 = tabPoints[i+1].x;                                y1 = tabPoints[i].y;                                y2 = tabPoints[i+1].y;                                match = true;                                break;                        }                }        }        else        {                for(int i=0; i<3; i++)                {                        if(y <= tabPoints[i].y && y > tabPoints[i+1].y)                        {                                x1 = tabPoints[i].x;                                x2 = tabPoints[i+1].x;                                y1 = tabPoints[i].y;                                y2 = tabPoints[i+1].y;                                match = true;                                break;                        }                }        }        if(!match)                return tabPoints[2].x;        // According to the equation y = ax + b => x = (y-b)/a        // We know the first 2 points        double a;        if(x2 == x1)                return static_cast<int>( x2 );        else                a = (y2 - y1) / (x2 - x1);        double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;        if(a == 0)                return static_cast<int>( x1 );        double x = (y - b) / a;        return static_cast<int>( x );}int wxFNBRendererVC8::GetEndX(const wxPoint tabPoints[], const int &y, long style){        double x1 = 0, x2 = 0, y1 = 0, y2 = 0;        // We check the 3 points to the left        bool bBottomStyle = style & wxFNB_BOTTOM ? true : false;        bool match = false;        if(bBottomStyle)        {                for(int i=7; i>3; i--)                {                        if(y >= tabPoints[i].y && y < tabPoints[i-1].y)                        {                                x1 = tabPoints[i].x;                                x2 = tabPoints[i-1].x;                                y1 = tabPoints[i].y;                                y2 = tabPoints[i-1].y;                                match = true;                                break;                        }                }        }        else        {                for(int i=7; i>3; i--)                {                        if(y <= tabPoints[i].y && y > tabPoints[i-1].y)                        {                                x1 = tabPoints[i].x;                                x2 = tabPoints[i-1].x;                                y1 = tabPoints[i].y;                                y2 = tabPoints[i-1].y;                                match = true;                                break;                        }                }        }        if(!match)                return tabPoints[3].x;        // According to the equation y = ax + b => x = (y-b)/a        // We know the first 2 points        double a = (y2 - y1) / (x2 - x1);        double b = y1 - ((y2 - y1) / (x2 - x1)) * x1;        if(a == 0)                return (int)x1;        // Vertical line        if(x1 == x2)                return (int)x1;        double x = (y - b) / a;        return (int)x;}void wxFNBRendererVC8::NumberTabsCanFit(wxWindow *pageContainer, std::vector<wxRect> &vTabInfo, int from){        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        int tabHeight, clientWidth;        wxRect rect = pc->GetClientRect();        clientWidth = rect.width;        /// Empty results        vTabInfo.clear();        tabHeight = CalcTabHeight( pageContainer );        // The drawing starts from posx        int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();        if( from < 0 )                from = pc->m_nFrom;        for(int i = from; i<(int)pc->GetPageInfoVector().GetCount(); i++)        {                int vc8glitch = tabHeight + wxFNB_HEIGHT_SPACER;                int tabWidth = CalcTabWidth( pageContainer, i, tabHeight );                if(posx + tabWidth + vc8glitch + GetButtonsAreaLength( pc ) >= clientWidth)                        break;                /// Add a result to the returned vector                wxRect tabRect(posx, VERTICAL_BORDER_PADDING, tabWidth , tabHeight);                vTabInfo.push_back(tabRect);                /// Advance posx                posx += tabWidth + wxFNB_HEIGHT_SPACER;        }}

⌨️ 快捷键说明

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