コード例 #1
0
void CDuiFrameWnd::AddFiles( const std::vector<PlayFileInfo> &vctString, bool bInit )
{
    COptionUI *pOptionTmp;
	CVerticalLayoutUI* pLayout = NULL;
    CDuiString  strTmp;
    TCHAR       szName[_MAX_FNAME];
    TCHAR       szExt[_MAX_EXT];
    unsigned    i, uWantedCount;

    pLayout = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("playlist")));
    if (! pLayout)
    {
        return;
    }

    for(i = 0, uWantedCount = 0; i < vctString.size(); i++)
    {
        if (IsWantedFile(vctString[i].szFileName))
        {
            _tsplitpath_s(vctString[i].szFileName, NULL, 0, NULL, 0, szName, _MAX_FNAME, szExt, _MAX_EXT);
            strTmp.Format(_T("%s%s"), szName, szExt);   // 文件名

            pOptionTmp = new COptionUI;
            pOptionTmp->SetTextColor(0xFFC8C6CB);
            pOptionTmp->SetHotTextColor(0xFFC8C6CB);
            pOptionTmp->SetSelectedTextColor(0xFFC8C6CB);
            pOptionTmp->SetTag(U_TAG_PLAYLIST);
            pOptionTmp->SetText(strTmp);  
            pOptionTmp->SetAttribute(_T("height"), _T("22"));
            pOptionTmp->SetAttribute(_T("inset"), _T("7,0,0,0"));
            pOptionTmp->SetAttribute(_T("align"), _T("center"));
			pOptionTmp->SetAttribute(_T("font"),_T("4"));
			pOptionTmp->SetUserData(vctString[i].szFileName);
			pOptionTmp->SetName(vctString[i].szFileName);
			pOptionTmp->SetSelectedImage(_T("file='btn_bk.png'"));
            pLayout->Add(pOptionTmp);
            uWantedCount++;

            if (! bInit)
            {
                m_cPlayList.Add(vctString[i]);          // 完整路径
            }
        }        
    }

    Rand(m_queRand, uWantedCount);
    ShowPlaylist(true);
}
コード例 #2
0
void CMainDlg::Notify(TNotifyUI& msg)
{
	//throw std::exception("The method or operation is not implemented.");
	//单击事件
	if(msg.sType == DUI_MSGTYPE_CLICK)
	{ 
		//点击关闭按钮
		if(msg.pSender->GetName() == _T("sys_close_btn"))	//退出
			Close(0);  
		//点击添加按钮
		else if(msg.pSender->GetName() == _T("add_option"))
		{
			//新建一个option按钮
			CDialogBuilder builder;
			COptionUI * p = static_cast<COptionUI *>(builder.Create(_T("option.xml"),0,NULL,&m_pm)); 
			if(NULL == p)
				return;
			CContainerUI * pContainer = static_cast<CContainerUI *>(m_pm.FindControl(_T("main_option_layout")));
			int nCount = pContainer->GetCount();
			static int i = 1;
			CDuiString str1;
			
			str1.Format(_T("新增按钮%d"), i);
			p->SetText(str1);
			pContainer->AddAt(p, nCount - 1);
			CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab")));
			if(NULL != pTab)
			{
				CDuiString str2;
				str2.Format(_T("新增界面%d"), i);
				//增加一个界面,这里可以像上边option一样使用xml创建
				CButtonUI * pButton = new CButtonUI;
				pButton->SetTextColor(0xffffffff);
				pButton->SetText(str2);
				pTab->Add(pButton);
				p->SetTag(pTab->GetCount() - 1);
			}
			 i++;
		}
	}
	//切换选项卡按钮时根据不同的按钮,选中不同的界面
	else if(msg.sType == DUI_MSGTYPE_SELECTCHANGED)
	{
		if(msg.pSender->GetName() == _T("option_1"))
		{
			CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab")));
			if(NULL != pTab)
			{
				CControlUI * pControl = pTab->FindSubControl(_T("tab_01"));
				if(NULL != pControl)
					pTab->SelectItem(pControl);
			}
		}
		else if(msg.pSender->GetName() == _T("option_2"))
		{
			CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab")));
			if(NULL != pTab)
			{
				CControlUI * pControl = pTab->FindSubControl(_T("tab_02"));
				if(NULL != pControl)
					pTab->SelectItem(pControl);
			}
		}
		else if(msg.pSender->GetName() == _T("option"))
		{
			CTabLayoutUI * pTab = static_cast<CTabLayoutUI *>(m_pm.FindControl(_T("main_tab")));
			pTab->SelectItem(msg.pSender->GetTag());
		}
	}
}