当前位置: 首页>>代码示例>>C++>>正文


C++ CSkinSimple::GetPanelOpacity方法代码示例

本文整理汇总了C++中CSkinSimple::GetPanelOpacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CSkinSimple::GetPanelOpacity方法的具体用法?C++ CSkinSimple::GetPanelOpacity怎么用?C++ CSkinSimple::GetPanelOpacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSkinSimple的用法示例。


在下文中一共展示了CSkinSimple::GetPanelOpacity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MakeBGBitMap

// Create a background bitmap simulating partial transparency
void CSimplePanelBase::MakeBGBitMap() {
    wxRect r;
    wxBitmap rawBmp;
    wxBitmap whiteBmp;
    wxImage bgImage;
    wxImage whiteImage;
    register unsigned char *bgImagePixels;
    register unsigned char *whitePixels;
    register int i, j, k;
    CSimpleGUIPanel* backgroundPanel = (CSimpleGUIPanel*)GetParent();
    wxPen bgPen(*wxWHITE, 1, wxTRANSPARENT);
    wxBrush bgBrush(*wxWHITE);
    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();

    wxASSERT(pSkinSimple);
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));

    int white_weight = pSkinSimple->GetPanelOpacity();
    int image_weight = MAX_OPACITY - white_weight;

// Workaround for CSimpleGUIPanel not reliably getting 
// Paint or EraseBackground events under Linux
#if (!(defined(__WXMSW_) || defined(__WXMAC__)))
    backgroundPanel->SetBackgroundBitmap();
#endif
    
    GetPosition(&r.x, &r.y);
    GetSize(&r.width, &r.height);
    wxBitmap *bgBmp(backgroundPanel->GetBackgroundBitMap());
    wxRect bgRect(0, 0, bgBmp->GetWidth(), bgBmp->GetHeight());
    if (bgRect.Contains(r)) {
        rawBmp = bgBmp->GetSubBitmap(r);
    } else {
        fprintf(stderr, "SimpleGUI background image is too small\n");
        rawBmp = wxBitmap(r.width, r.height);
        wxMemoryDC dc(rawBmp);
        wxPen rawPen(*wxBLACK, 1, wxTRANSPARENT);
        wxBrush rawBrush(*wxBLACK);
        dc.SetBackgroundMode(wxSOLID);
        dc.SetPen(rawPen);
        dc.SetBrush(rawBrush);
        dc.DrawRectangle(0, 0, r.width, r.height);
    }
    
    whiteBmp = wxBitmap(r.width, r.height);
    wxMemoryDC dc(whiteBmp);
    dc.SetBackgroundMode(wxSOLID);
    dc.SetPen(bgPen);
    dc.SetBrush(bgBrush);
    dc.DrawRoundedRectangle(0, 0, r.width, r.height, RECTANGLERADIUS);

    bgImage = rawBmp.ConvertToImage();
    bgImagePixels = bgImage.GetData(); // RGBRGBRGB...
    whiteImage = whiteBmp.ConvertToImage();
    whitePixels = whiteImage.GetData(); // RGBRGBRGB...

    for (i=0; i<r.width; ++i) {
        for (j=0; j<r.height; ++j) {
            if (*whitePixels) {
                k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight));
                *bgImagePixels++ = k / MAX_OPACITY;
                k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight));
                *bgImagePixels++ = k / MAX_OPACITY;
                k = (((unsigned int)*bgImagePixels * image_weight) + ((unsigned int)*whitePixels++ * white_weight));
                *bgImagePixels++ = k / MAX_OPACITY;
            } else {
                bgImagePixels += 3;
                whitePixels += 3;
            }
        }
    }

    m_TaskPanelBGBitMap = wxBitmap(bgImage);
    m_GotBGBitMap = true;
}
开发者ID:Milkyway-at-home,项目名称:BOINC,代码行数:76,代码来源:sg_PanelBase.cpp


注:本文中的CSkinSimple::GetPanelOpacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。