Exemplo n.º 1
0
void SItemPanel::Draw(IRenderTarget *pRT,const CRect & rc)
{
    UpdateLayout();

    m_style.m_crBg=m_crBk;
    if((m_dwState & WndState_Hover) && m_crHover != CR_INVALID) m_style.m_crBg=m_crHover;
    if((m_dwState & WndState_Check) && m_crSelBk != CR_INVALID) m_style.m_crBg=m_crSelBk;

    //不继承宿主的字体,从系统字体开始
    SPainter painter;
    BeforePaint(pRT,painter);

    CAutoRefPtr<IRegion> rgn;
    pRT->GetClipRegion(&rgn);
    
    pRT->OffsetViewportOrg(rc.left,rc.top);
    if(rgn)
    {
        rgn->Offset(-rc.TopLeft());
    }
    BuildWndTreeZorder();
    RedrawRegion(pRT,rgn);
    pRT->OffsetViewportOrg(-rc.left,-rc.top);
    
    AfterPaint(pRT,painter);
}
Exemplo n.º 2
0
SItemPanel::SItemPanel(SWindow *pFrameHost,pugi::xml_node xmlNode,IItemContainer *pItemContainer)
    :m_pFrmHost(pFrameHost)
    ,m_pItemContainer(pItemContainer)
    ,m_dwData(0)
    ,m_crBk(CR_INVALID)
    ,m_crHover(CR_INVALID)
    ,m_crSelBk(RGBA(0,0,128,255))
    ,m_lpItemIndex(-1)
{
    SASSERT(m_pFrmHost);
    SASSERT(m_pItemContainer);
    SetContainer(this);
    if(xmlNode) 
    {
        InitFromXml(xmlNode);
        BuildWndTreeZorder();
    }
    m_evtSet.addEvent(EVENTID(EventItemPanelClick));
    m_evtSet.addEvent(EVENTID(EventItemPanelDbclick));
    m_evtSet.addEvent(EVENTID(EventItemPanelRclick));
    m_evtSet.addEvent(EVENTID(EventItemPanelHover));
    m_evtSet.addEvent(EVENTID(EventItemPanelLeave));
}