Exemple #1
0
int SListBoxEx::InsertItem(int iItem,pugi::xml_node xmlNode,LPARAM dwData/*=0*/)
{
    SItemPanel *pItemObj=SItemPanel::Create(this,xmlNode,this);

    if(iItem==-1 || iItem>=GetItemCount())
    {
        iItem=GetItemCount();
    }
    pItemObj->SetItemData(dwData);
    pItemObj->Move(CRect(0,0,m_rcClient.Width(),m_nItemHei));
    if(m_pItemSkin) pItemObj->SetSkin(m_pItemSkin);
    pItemObj->SetColor(m_crItemBg,m_crItemSelBg);

    m_arrItems.InsertAt(iItem,pItemObj);

    if(m_iSelItem>=iItem) m_iSelItem++;
    if(m_iHoverItem>=iItem) m_iHoverItem++;

    UpdatePanelsIndex(iItem,-1);

    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetItemCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);

    return iItem;
}
Exemple #2
0
BOOL SListBoxEx::SetItemCount(int nItems,LPCTSTR pszXmlTemplate)
{
    if(m_arrItems.GetCount()!=0) return FALSE;
    pugi::xml_document xmlDoc;
    pugi::xml_node xmlTemplate = m_xmlTempl.child(L"template");
    if(pszXmlTemplate)
    {
        SStringA strUtf8=S_CT2A(pszXmlTemplate,CP_UTF8);
        if(!xmlDoc.load_buffer((LPCSTR)strUtf8,strUtf8.GetLength(),pugi::parse_default,pugi::encoding_utf8)) return FALSE;
        xmlTemplate = xmlDoc.first_child();
    }
    if(!xmlTemplate) 
        return FALSE;
    
    
    m_arrItems.SetCount(nItems);
    for(int i=0;i<nItems;i++)
    {
        SItemPanel *pItemObj=SItemPanel::Create(this,xmlTemplate,this);
        pItemObj->Move(CRect(0,0,m_rcClient.Width(),m_nItemHei));
        if(m_pItemSkin) pItemObj->SetSkin(m_pItemSkin);
        pItemObj->SetColor(m_crItemBg,m_crItemSelBg);
        m_arrItems[i] = pItemObj;
        pItemObj->SetItemIndex(i);
    }
    
    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetItemCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);

    return TRUE;
}
Exemple #3
0
void SListBoxEx::DeleteItem(int iItem)
{
    if(iItem<0 || iItem>=GetItemCount()) return;
    if(m_pCapturedFrame == m_arrItems[iItem])
    {
        m_pCapturedFrame=NULL;
        ReleaseCapture();
    }

    m_arrItems[iItem]->Release();
    m_arrItems.RemoveAt(iItem);

    if(m_iSelItem==iItem) m_iSelItem=-1;
    else if(m_iSelItem>iItem) m_iSelItem--;
    if(m_iHoverItem==iItem) m_iHoverItem=-1;
    else if(m_iHoverItem>iItem) m_iHoverItem--;

    UpdatePanelsIndex(iItem,-1);

    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetItemCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);
}
Exemple #4
0
void SListBox::OnSize(UINT nType,CSize size)
{
    __super::OnSize(nType,size);
    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);
}
HRESULT CTestScrollView::DefaultMsgProc( UINT nMsg, WPARAM wparam, LPARAM lparam )
{
	HRESULT hr = CTxScrollView::DefaultMsgProc(nMsg, wparam, lparam);
	switch (nMsg)
	{
	case WM_CREATE:
		{
			CSize szView(1000,1000);
			SetViewSize(szView);
		}
		break;
	}
	return hr;
}
Exemple #6
0
void Dispatcher::setWidRect( Widget* pWid, const Rect& rc )
{
	WFX_CONDITION(pWid != NULL);

	Rect rcWid;
	rcWid = pWid->getRect();
	pWid->setVirtualSizeCached(FALSE);
	Rect rcSB = rcWid;
	Rect rcDraw = rcWid;
	Size szVirtual = pWid->getVirtualSize();
	Size szView(rcWid.getWidth(), rcWid.getHeight());
	BOOL bOutRangeHorz = szView.cx < szVirtual.cx;
	BOOL bOutRangeVert = szView.cy < szVirtual.cy;
	if (pWid->getSBFlag() & WESB_VERT)
	{
		WFX_CONDITION(pWid->getScrollBar(SB_VERT) != NULL);
		if (!bOutRangeVert)
		{
			rcSB.empty();
			pWid->getScrollBar(SB_VERT)->reset();
		}
		else
		{
			rcSB = pWid->getScrollBarRect(SB_VERT);
		}
		pWid->getScrollBar(SB_VERT)->setRect(rcSB);
		rcDraw.right -= rcSB.right - rcSB.left;
	}
	rcSB = rcWid;
	if (pWid->getSBFlag() & WESB_HORZ)
	{
		WFX_CONDITION(pWid->getScrollBar(SB_HORZ) != NULL);
		if (!bOutRangeHorz)
		{
			rcSB.empty();
			pWid->getScrollBar(SB_HORZ)->reset();
		}
		else
		{
			rcSB = pWid->getScrollBarRect(SB_HORZ);
		}
		pWid->getScrollBar(SB_HORZ)->setRect(rcSB);
		rcDraw.bottom -= rcSB.bottom - rcSB.top;
	}
	pWid->setClientRect(rcDraw);
	pWid->sendMessage(WM_SIZE, 0, 0);
}
Exemple #7
0
int SListBox::InsertItem(int nIndex, LPLBITEM pItem)
{
    SASSERT(pItem);

    if(nIndex==-1 || nIndex>GetCount())
    {
        nIndex = GetCount();
    }

    m_arrItems.InsertAt(nIndex, pItem);

    if(m_iSelItem >= nIndex) m_iSelItem++;
    if(m_iHoverItem >= nIndex) m_iHoverItem++;

    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);

    return nIndex;
}
Exemple #8
0
BOOL SListBox::DeleteString(int nIndex)
{
    if(nIndex<0 || nIndex>=GetCount()) return FALSE;


    if (m_arrItems[nIndex])
        delete m_arrItems[nIndex];
    m_arrItems.RemoveAt(nIndex);

    if(m_iSelItem==nIndex) m_iSelItem=-1;
    else if(m_iSelItem>nIndex) m_iSelItem--;
    if(m_iHoverItem==nIndex) m_iHoverItem=-1;
    else if(m_iHoverItem>nIndex) m_iHoverItem--;

    CRect rcClient;
    SWindow::GetClientRect(&rcClient);
    CSize szView(rcClient.Width(),GetCount()*m_nItemHei);
    if(szView.cy>rcClient.Height()) szView.cx-=m_nSbWid;
    SetViewSize(szView);

    return TRUE;
}