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

📄 renderer.cpp

📁 robocup rcssserver 运行防真机器人足球比赛所用的服务器端
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        int posx = ((wxFlatNotebook *)pc->m_pParent)->GetPadding();        int i = 0;        // Update all the tabs from 0 to 'pc->m_nFrom' to be non visible        for(i=0; i<pc->m_nFrom; i++)        {                pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));                pc->GetPageInfoVector()[i].GetRegion().Clear();        }        //----------------------------------------------------------        // Go over and draw the visible tabs        //----------------------------------------------------------        for(i=pc->m_nFrom; i<(int)pc->GetPageInfoVector().GetCount(); i++)        {                dc.SetPen(borderPen);                dc.SetBrush((i==pc->GetSelection()) ? selBrush : noselBrush);                // Now set the font to the correct font                dc.SetFont((i==pc->GetSelection()) ? boldFont : normalFont);                // Add the padding to the tab width                // Tab width:                // +-----------------------------------------------------------+                // | PADDING | IMG | IMG_PADDING | TEXT | PADDING | x |PADDING |                // +-----------------------------------------------------------+                int tabWidth = CalcTabWidth(pageContainer, i, tabHeight);                // Check if we can draw more                if(posx + tabWidth + GetButtonsAreaLength( pc ) >= clientWidth)                        break;                // By default we clean the tab region                pc->GetPageInfoVector()[i].GetRegion().Clear();                // Clean the 'x' buttn on the tab.                // A 'Clean' rectanlge, is a rectangle with width or height                // with values lower than or equal to 0                pc->GetPageInfoVector()[i].GetXRect().SetSize(wxSize(-1, -1));                // Draw the tab (border, text, image & 'x' on tab)                DrawTab(pc, dc, posx, i, tabWidth, tabHeight, pc->m_nTabXButtonStatus);                // Restore the text forground                dc.SetTextForeground(pc->m_activeTextColor);                // Update the tab position & size                int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;                pc->GetPageInfoVector()[i].SetPosition(wxPoint(posx, posy));                pc->GetPageInfoVector()[i].SetSize(wxSize(tabWidth, tabHeight));                posx += tabWidth;        }        // Update all tabs that can not fit into the screen as non-visible        for(; i<(int)pc->GetPageInfoVector().GetCount(); i++)        {                pc->GetPageInfoVector()[i].SetPosition(wxPoint(-1, -1));                pc->GetPageInfoVector()[i].GetRegion().Clear();        }        // Draw the left/right/close buttons        // Left arrow        DrawLeftArrow(pc, dc);        DrawRightArrow(pc, dc);        DrawX(pc, dc);        DrawDropDownArrow(pc, dc);}//------------------------------------------// Renderer manager//------------------------------------------wxFNBRendererMgr::wxFNBRendererMgr(){        // register renderers        m_renderers[-1] = wxFNBRendererPtr(new wxFNBRendererDefault());        m_renderers[wxFNB_VC71] = wxFNBRendererPtr(new wxFNBRendererVC71());        m_renderers[wxFNB_FANCY_TABS] = wxFNBRendererPtr(new wxFNBRendererFancy());        m_renderers[wxFNB_VC8] = wxFNBRendererPtr(new wxFNBRendererVC8());}wxFNBRendererMgr::~wxFNBRendererMgr(){}wxFNBRendererPtr wxFNBRendererMgr::GetRenderer(long style){        // since we dont have a style for default tabs, we        // test for all others - FIXME: add style for default tabs        if( !(style & wxFNB_VC71) && !(style & wxFNB_VC8) && !(style & wxFNB_FANCY_TABS) )                return m_renderers[-1];        if( style & wxFNB_VC71 )                return m_renderers[wxFNB_VC71];        if( style & wxFNB_FANCY_TABS )                return m_renderers[wxFNB_FANCY_TABS];        if( style & wxFNB_VC8 )                return m_renderers[wxFNB_VC8];        // the default is to return the default renderer        return m_renderers[-1];}//------------------------------------------// Default renderer//------------------------------------------void wxFNBRendererDefault::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus){                // Default style        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        wxPoint tabPoints[7];        tabPoints[0].x = posx;        tabPoints[0].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;        tabPoints[1].x = (int)(posx+(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI));        tabPoints[1].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);        tabPoints[2].x = tabPoints[1].x+2;        tabPoints[2].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;        tabPoints[3].x = (int)(posx+tabWidth-(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI))-2;        tabPoints[3].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - VERTICAL_BORDER_PADDING : VERTICAL_BORDER_PADDING;        tabPoints[4].x = tabPoints[3].x+2;        tabPoints[4].y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - (VERTICAL_BORDER_PADDING+2) : (VERTICAL_BORDER_PADDING+2);        tabPoints[5].x = (int)(tabPoints[4].x+(tabHeight-2)*tan((double)(pc->GetPageInfoVector())[tabIdx].GetTabAngle()/180.0*M_PI));        tabPoints[5].y = pc->HasFlag(wxFNB_BOTTOM) ? 2 : tabHeight - 2;        tabPoints[6].x = tabPoints[0].x;        tabPoints[6].y = tabPoints[0].y;        if(tabIdx == pc->GetSelection())        {                // Draw the tab as rounded rectangle                dc.DrawPolygon(7, tabPoints);        }        else        {                if(tabIdx != pc->GetSelection() - 1)                {                        // Draw a vertical line to the right of the text                        int pt1x, pt1y, pt2x, pt2y;                        pt1x = tabPoints[5].x;                        pt1y = pc->HasFlag(wxFNB_BOTTOM) ? 4 : tabHeight - 6;                        pt2x = tabPoints[5].x;                        pt2y = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - 4 : 4 ;                        dc.DrawLine(pt1x, pt1y, pt2x, pt2y);                }        }        if(tabIdx == pc->GetSelection())        {                wxPen savePen = dc.GetPen();                wxPen whitePen = wxPen(*wxWHITE);                whitePen.SetWidth(1);                dc.SetPen(whitePen);                wxPoint secPt = wxPoint(tabPoints[5].x + 1, tabPoints[5].y);                dc.DrawLine(tabPoints[0], secPt);                // Restore the pen                dc.SetPen(savePen);        }        // -----------------------------------        // Text and image drawing        // -----------------------------------        // Text drawing offset from the left border of the        // rectangle        int textOffset;        // The width of the images are 16 pixels        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();        int shapePoints = (int)(tabHeight * tan((double)pc->GetPageInfoVector()[tabIdx].GetTabAngle()/180.0*M_PI));        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 6 : 8;        hasImage ? textOffset = padding * 2 + 16 + shapePoints / 2 : textOffset = padding + shapePoints / 2 ;        textOffset += 2;        if(tabIdx != pc->GetSelection())        {                // Set the text background to be like the vertical lines                dc.SetTextForeground( pc->GetNonoActiveTextColor() );        }        if(hasImage)        {                int imageXOffset = textOffset - 16 - padding;                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],                        posx + imageXOffset, imageYCoord, true);        }        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);                // Draw the tab                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);        }}//------------------------------------------------------------------// Visual studio 7.1//------------------------------------------------------------------void wxFNBRendererVC71::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus){                // Visual studio 7.1 style        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));        wxPageContainer *pc = static_cast<wxPageContainer*>( pageContainer );        dc.SetPen((tabIdx == pc->GetSelection()) ? wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : borderPen);    dc.SetBrush(((tabIdx == pc->GetSelection()) ? wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)) : wxBrush(wxColour(247, 243, 233))));        if(tabIdx == pc->GetSelection())        {                int posy = pc->HasFlag(wxFNB_BOTTOM) ? 0 : VERTICAL_BORDER_PADDING;                int tabH = pc->HasFlag(wxFNB_BOTTOM) ? tabHeight - 5 : tabHeight - 3;                dc.DrawRectangle(posx, posy, tabWidth, tabH);                // Draw a black line on the left side of the                // rectangle                wxPen pen = wxPen(*wxBLACK);                dc.SetPen(pen);                int blackLineY1 = VERTICAL_BORDER_PADDING;                int blackLineY2 = tabH;                dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2);                // To give the tab more 3D look we do the following                // Incase the tab is on top,                // Draw a thik white line on topof the rectangle                // Otherwise, draw a thin (1 pixel) black line at the bottom                pen = wxPen(pc->HasFlag(wxFNB_BOTTOM) ? *wxBLACK : *wxWHITE);                dc.SetPen(pen);                int whiteLinePosY = pc->HasFlag(wxFNB_BOTTOM) ? blackLineY2 : VERTICAL_BORDER_PADDING ;                dc.DrawLine(posx , whiteLinePosY, posx + tabWidth + 1, whiteLinePosY);                // Draw a white vertical line to the left of the tab                dc.SetPen( *wxWHITE_PEN );                if( !pc->HasFlag(wxFNB_BOTTOM) ) blackLineY2 += 1;                dc.DrawLine(posx, blackLineY1, posx, blackLineY2);        }        else        {                // We dont draw a rectangle for non selected tabs, but only                // vertical line on the left                int blackLineY1 = pc->HasFlag(wxFNB_BOTTOM) ? VERTICAL_BORDER_PADDING + 2 : VERTICAL_BORDER_PADDING + 1;                int blackLineY2 = pc->GetSize().y - 5 ;                dc.DrawLine(posx + tabWidth, blackLineY1, posx + tabWidth, blackLineY2);        }        // -----------------------------------        // Text and image drawing        // -----------------------------------        // Text drawing offset from the left border of the        // rectangle        int textOffset;        // The width of the images are 16 pixels        int padding = static_cast<wxFlatNotebook*>( pc->GetParent() )->GetPadding();        bool hasImage = pc->GetPageInfoVector()[tabIdx].GetImageIndex() != -1;        int imageYCoord = pc->HasFlag(wxFNB_BOTTOM) ? 5 : 8;        hasImage ? textOffset = padding * 2 + 16 : textOffset = padding;        if(tabIdx != pc->GetSelection())        {                // Set the text background to be like the vertical lines                dc.SetTextForeground(pc->GetNonoActiveTextColor());        }        if(hasImage)        {                int imageXOffset = textOffset - 16 - padding;                dc.DrawBitmap((*pc->GetImageList())[pc->GetPageInfoVector()[tabIdx].GetImageIndex()],                        posx + imageXOffset, imageYCoord, true);        }        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);                // Draw the tab                DrawTabX(pc, dc, x_rect, tabIdx, btnStatus);        }}//------------------------------------------------------------------// Fancy style//------------------------------------------------------------------void wxFNBRendererFancy::DrawTab(wxWindow* pageContainer, wxDC &dc, const int &posx, const int &tabIdx, const int &tabWidth, const int &tabHeight, const int btnStatus){                // Fancy tabs - like with VC71 but with the following differences:        // - The Selected tab is colored with gradient color        wxPen borderPen = wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));

⌨️ 快捷键说明

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