예제 #1
0
void CColorPicker::InitWindow()
{
	CVerticalLayoutUI* pColorContiner = static_cast<CVerticalLayoutUI*>(GetPaintMgr()->FindControl(_T("color")));
	for (int i = 0; (i < 5) && (pColorContiner != NULL); i ++)
	{
		CHorizontalLayoutUI* pLine = new CHorizontalLayoutUI();
		pLine->SetFixedHeight(12);
		pColorContiner->Add(pLine);
		for (int j = 0; j < 8; j++)
		{
			CButtonUI* pOne = new CButtonUI();
			pOne->ApplyAttributeList(_T("bordersize=\"1\" bordercolor=\"#FF000000\" width=\"10\" height=\"10\""));
			pOne->SetBkColor(Colors[i][j]);
			pLine->Add(pOne);
			if (i < 7)
			{
				CControlUI* pMargin = new CControlUI();
				pMargin->SetFixedWidth(2);
				pLine->Add(pMargin);
			}
		}
	}

	SIZE size = GetPaintMgr()->GetInitSize();
	MoveWindow( based_point_.x - static_cast<LONG>(size.cx / 2), based_point_.y - size.cy, size.cx, size.cy, FALSE);
}
예제 #2
0
void CMainWnd::Notify( TNotifyUI &msg )
{
	if(msg.sType.CompareNoCase(DUI_MSGTYPE_SCROLL) == 0)
	{
		CVerticalLayoutUI* pTabPanel = (CVerticalLayoutUI*)msg.pSender;
		CString sName = msg.pSender->GetName();
		int nPage = (int)msg.wParam;
		CString sTabPanel = sName;
		int nIdx = sTabPanel.Find(_T("@"));
		if(nIdx == -1) return;
		CString sType = sTabPanel.Mid(nIdx + 1);
		if(nPage < 1) nPage = 1;
		if(nPage > 200) nPage = 200;

		int nScrollPos = (nPage - 1) * pTabPanel->GetVerticalScrollBar()->GetLineSize();
		SIZE szSize = {0, nScrollPos};
		pTabPanel->SetScrollPos(szSize, false);

		m_Data.LoadBizhi(sType, nPage, 10);
	}
	else if(msg.sType.CompareNoCase(DUI_MSGTYPE_SELECTCHANGED) == 0)
	{
		COptionUI* pTabBtn = (COptionUI*)msg.pSender;
		CTabLayoutUI* pTabLayout = (CTabLayoutUI*)m_PaintManager.FindControl(_T("wp_tablayout"));
		CString sName = pTabBtn->GetName();
		if(sName == _T("wp_tabbtn") && pTabLayout)
		{
			CString sType = pTabBtn->GetUserData();
			CString sTabPanel;
			sTabPanel.Format(_T("wp_tabpanel@%s"), sType);
			CVerticalLayoutUI* pTabPanel = (CVerticalLayoutUI*)m_PaintManager.FindControl(sTabPanel);
			if(pTabPanel == NULL)
			{
				m_Data.LoadBizhi(sType, 1, 10);
			}
			else
			{
				pTabLayout->SelectItem(pTabPanel);
			}
		}
	}
	else if(msg.sType.CompareNoCase(DUI_MSGTYPE_CLICK_WPFAV) == 0)
	{
		MessageBox(NULL, _T("收藏成功"), _T("百度壁纸 - 提示"), MB_OK);
	}
	else if(msg.sType.CompareNoCase(DUI_MSGTYPE_CLICK_WPSET) == 0)
	{
		CWPButton* pWPBtn = (CWPButton*)msg.pSender;
		pWPBtn->SetWP();
	}
	return WindowImplBase::Notify(msg);
}
예제 #3
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);
}
예제 #4
0
void CColorPicker::Notify(TNotifyUI& msg)
{
	if (_tcsicmp(msg.sType, _T("click")) == 0)
	{
		CControlUI* pOne = static_cast<CControlUI*>(paint_manager_.FindControl(msg.ptMouse));
		if (_tcsicmp(pOne->GetClass(), _T("ButtonUI")) == 0)
		{
			DWORD nColor = pOne->GetBkColor();
			CVerticalLayoutUI* pColorContiner = static_cast<CVerticalLayoutUI*>(paint_manager_.FindControl(_T("color")));
			pColorContiner->SetBkColor(nColor);
			UpdateWindow(m_hWnd);
			Sleep(500);
			chat_dialog_->SetTextColor(nColor);
		}
	}
}
예제 #5
0
파일: UICombo.cpp 프로젝트: kovrov/scrap
LRESULT CDropDownWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if( uMsg == WM_CREATE ) {
		m_pm.Init(m_hWnd);
		// The trick is to add the items to the new container. Their owner gets
		// reassigned by this operation - which is why it is important to reassign
		// the items back to the righfull owner/manager when the window closes.
		CControlCanvasUI* pWindow = new CControlCanvasUI;
		CVerticalLayoutUI* pLayout = new CVerticalLayoutUI;
		for( int i = 0; i < m_pOwner->GetCount(); i++ ) pLayout->Add(static_cast<CControlUI*>(m_pOwner->GetItem(i)));
		pLayout->SetAutoDestroy(false);
		pLayout->EnableScrollBar();
		pWindow->Add(pLayout);
		m_pm.AttachDialog(pWindow);
		return 0;
	}
	else if( uMsg == WM_CLOSE ) {
		m_pOwner->SetManager(m_pOwner->GetManager(), m_pOwner->GetParent());
		m_pOwner->SetPos(m_pOwner->GetPos());
		m_pOwner->SetFocus();
	}
	else if( uMsg == WM_LBUTTONUP ) {
		PostMessage(WM_KILLFOCUS);
	}
	else if( uMsg == WM_KEYDOWN ) {
		switch( wParam ) {
		case VK_ESCAPE:
			m_pOwner->SelectItem(m_iOldSel);
			// FALL THROUGH...
		case VK_RETURN:
			PostMessage(WM_KILLFOCUS);
			break;
		default:
			TEventUI event;
			event.Type = UIEVENT_KEYDOWN;
			event.chKey = wParam;
			m_pOwner->Event(event);
			return 0;
		}
	}
	else if( uMsg == WM_KILLFOCUS ) {
		if( m_hWnd != (HWND) wParam ) PostMessage(WM_CLOSE);
	}
	LRESULT lRes = 0;
	if( m_pm.MessageHandler(uMsg, wParam, lParam, lRes) ) return lRes;
	return CWindowWnd::HandleMessage(uMsg, wParam, lParam);
}
예제 #6
0
void CVideoFrame::OnPrepare(TNotifyUI& msg)
{
	CVerticalLayoutUI* pVideoLayoutUI = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("videoViewLayout")));

	if (pVideoLayoutUI)
	{
		CDuiRect rcWindow;
		GetWindowRect(m_hWnd, &rcWindow);
		rcWindow.top += 80;
		LONG height = rcWindow.bottom - rcWindow.top;
		LONG width = rcWindow.right - rcWindow.left;

		int nControlWidth = pVideoLayoutUI->GetFixedWidth();//pActiveXUI->GetWidth();
		int nControlHeight = pVideoLayoutUI->GetFixedHeight();//pActiveXUI->GetHeight();
		RECT posRect;
		posRect = rcWindow;
		posRect.top = (height - nControlHeight)/2;
		posRect.left= (width - nControlWidth) /2;
		posRect.bottom = posRect.top + nControlHeight;
		posRect.right = posRect.left + nControlWidth;

		pVideoLayoutUI->SetVisible(true);
		pVideoLayoutUI->SetPos(posRect);
	}
	
	CWebBrowserUI* pActiveXUI = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("htmlView")));
	if( pActiveXUI ) 
	{
		pActiveXUI->SetVisible(true);

		pActiveXUI->SetDelayCreate(true);
		CWebEventHandlerEx *pWebHandle = new CWebEventHandlerEx;
		pActiveXUI->SetWebBrowserEventHandler(pWebHandle);
		//这行代码,如果注释掉,就不会去掉边框,IE有bug,第二次加载网页才会让事件处理器有效
		pActiveXUI->Navigate2(L"about:blank");    

		std::wstring strHtml = CPaintManagerUI::GetInstancePath() + _T("UIRes\\html\\video.html");
		pActiveXUI->Navigate2(strHtml.c_str());
		//pActiveXUI->Navigate2(L"http://www.baidu.com/");
	}
}
예제 #7
0
void CDuiFrameWnd::DeleteFileItem()
{
	COptionUI* pOption = NULL;
	CVerticalLayoutUI* pLayout = (CVerticalLayoutUI*)m_PaintManager.FindControl(_T("playlist"));
	int nIndex = pLayout->GetCount();

	for (int i = 0; i < nIndex;i++)
	{
		pOption = (COptionUI*)pLayout->GetItemAt(i);
		if (pOption->IsSelected())
		{
			CDuiString strPath = pOption->GetUserData();
			m_cPlayList.deleteFile(strPath.GetData());
			pLayout->RemoveAt(i);
			break;
		}

	}


}
예제 #8
0
void CHelloDuilibWnd::InitWindow()
{
	CLabelUI* helloTxUI = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("apptitle")));
	helloTxUI->SetText(_T("hehe"));
	CButtonUI* btnClose = static_cast<CButtonUI*>(m_PaintManager.FindControl(_T("closebtn")));
	CVerticalLayoutUI* layoutBody = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("body")));

	CLabelUI* txtUI = new CLabelUI();
	layoutBody->Add(txtUI);
	txtUI->SetFloat(true);
	txtUI->SetPos({ 10, 300, 0, 0 });
	txtUI->SetFixedWidth(200);
	txtUI->SetFixedHeight(20);
	txtUI->SetText(_T("Hello Dynamic Text"));

	btnClose->OnEvent += MakeDelegate(this, &CHelloDuilibWnd::OnCloseClicked);

	CDialogBuilder builder;
	CVerticalLayoutUI* userControl = static_cast<CVerticalLayoutUI*>(builder.Create(_T("HelloControl.xml"),(LPCTSTR)0));
	CControlUI* testLabel = userControl->FindSubControl(_T("myLabel"));
	layoutBody->Add(userControl);

	layoutBody->NeedUpdate();
	
	CControlUI* myLabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("myLabel")));
	
	if (myLabel)
	{
	}

}
예제 #9
0
CContainerUI * CScalableLayout::CreateLayout( CScalableNode::Ptr pNode,int nLevel )
{
	CContainerUI *pLayout = pNode->IsHor ?
		static_cast<CContainerUI*>(new CHorizontalLayoutUI) : 
		static_cast<CContainerUI*>(new CVerticalLayoutUI);

	pLayout->SetBkColor(pNode->BkColor);

	for (CScalableNode::Iter i = pNode->ChildBegin();
		i != pNode->ChildEnd();
		i++)
	{
		bool bLeaf = true;
		for (CScalableNode::Iter j = (*i)->ChildBegin();
			j != (*i)->ChildEnd();
			j++)
		{
			if ((*j)->Level == nLevel)
			{
				bLeaf = false;
				break;
			}
		}
		if (bLeaf)
		{
			CContainerUI *pItemContainer = new CContainerUI;
			CButtonUI *pItem = new CButtonUI;
			pItem->SetName((*i)->Name);
			pItem->SetBkColor((*i)->BkColor);

			pItem->SetShowHtml();
			pItem->SetTextStyle(DT_CENTER|DT_VCENTER);
			
			CDuiString sText;
			if ((*i)->Text.IsEmpty())
			{
				sText.Format(_T("{p}{c #FFCCCCCC}%s{/c}{/p}"),
					(LPCTSTR)(*i)->Description);
			}
			else
			{
				sText.Format(_T("{p}%s{n}{c #FFCCCCCC}%s{/c}{/p}"),
					(LPCTSTR)(*i)->Text,(LPCTSTR)(*i)->Description);
			}
			pItem->SetText(sText);
			
			pItemContainer->Add(pItem);

			pLayout->Add(pItemContainer);
		}
		else
		{
			pLayout->Add(CreateLayout(*i,nLevel));
		}
	}


	if (!pNode->Description.IsEmpty())
	{
		CVerticalLayoutUI *pWrapper = new CVerticalLayoutUI;
		pWrapper->Add(pLayout);

		pLayout->SetInset(CDuiRect(5,5,5,0));

		CLabelUI *pDescription = new CLabelUI;
		pDescription->SetFixedHeight(20);
		pDescription->SetTextStyle(DT_CENTER);
		pDescription->SetBkColor(pNode->BkColor);

		pDescription->SetText(pNode->Description);
		pWrapper->Add(pDescription);

		return pWrapper;
	}

	return pLayout;
}
예제 #10
0
void CQuizWnd::show_result()
{
	wchar_t ndx[3] = L"1";
	auto& quizInfo = m_songInfo->GetQuizInfo();
	size_t cnt = quizInfo.get_quiz_count();
	size_t right_cnt = 0;
	std::wstring image_right = L"New\\勾.png";
	std::wstring image_wrong = L"New\\叉.png";
	for (size_t i = 0; i < cnt; i++) {
		auto quiz = quizInfo.get_quiz(i);
		if (quiz) {
			CButtonUI* btn = static_cast<CButtonUI*>(m_PaintManager.FindControl(((wstring)BTN_QUESTION_PREFIX + ndx).c_str())); assert(btn);
			if (quiz->get_answer() == quiz->get_user_answer()) {
				btn->SetNormalImage(image_right.c_str());
				btn->SetFocusedImage(image_right.c_str());
				btn->SetHotImage(image_right.c_str());
				btn->SetPushedImage(image_right.c_str());
				right_cnt++;
			} else {
				btn->SetNormalImage(image_wrong.c_str());
				btn->SetFocusedImage(image_wrong.c_str());
				btn->SetHotImage(image_wrong.c_str());
				btn->SetPushedImage(image_wrong.c_str());
			}
			ndx[0]++;
			if (ndx[0] == 58) {
				ndx[0] = L'1';
				ndx[1] = L'0';
			}
		}
	}

	// remove options
	CVerticalLayoutUI* options = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(L"options"));
	if (!options)return; options->RemoveAll();

	// show result
	std::wstring html_path = m_songInfo->get_tmp_path() + L"\\" + m_songInfo->get_id() + L"\\result.html";
	std::wofstream out(html_path); if (!out.is_open())return;
	std::wstringstream ss;
	ss << L"<HTML>"
		L"<head>"
		L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
		L"<title>lyric</title>"
		L"</head>"
		L"<BODY SCROLL=NO align='center' bgcolor='#FFFFBF' topmargin='2' leftmargin='2'>"
		L"<h3 align='CENTER'>"
		L"<font size='5' color=#FF8600>You have " << right_cnt << L" out of " << cnt << L" right answers." << L"</font>"
		L"</h3>";

	if (right_cnt < cnt) {
			ss << L"<h4 align='CENTER'"
			L"<font size='3' color=#000000>You missed questions. Read the book again or try a diffrent book.</font>"
			L"</h4>"
			L"</BODY>"
			L"</HTML>";
	} else {
		ss << L"<h4 align='CENTER'"
			L"<font size='3' color=#000000>You passed this quiz. Congratulations!</font>"
			L"</h4>"
			L"</BODY>"
			L"</HTML>";
	}

	std::wstring w = ss.str();
	std::string u;
	utf8::utf16to8(w.begin(), w.end(), std::back_inserter(u));
	out << u.c_str();
	out.close();
	m_question->Navigate(const_cast<wchar_t*>(html_path.c_str()), nullptr, nullptr, nullptr, nullptr);

	// save total score
	CConfig::get_instance()->add_score(right_cnt * 10);

	// show score wnd
	CScoreWnd* wnd = new CScoreWnd(L"ScoreWnd.xml");
	wnd->Create(m_hWnd, L"ScoreWnd", UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
	wnd->ShowModal();
	delete wnd;
	PostMessage(WM_CLOSE);
}
예제 #11
0
void CQuizWnd::ShowQuiz(int ndx)
{
	assert(m_songInfo); 
	assert(m_question);

	auto& quizInfo = m_songInfo->GetQuizInfo();
	auto quiz = quizInfo.get_quiz(ndx - 1);
	if (!quiz) return;

	// show question
	std::wstring html_path = m_songInfo->get_tmp_path() + L"\\" + m_songInfo->get_id() + L"\\question.html";
	std::wofstream out(html_path); if (!out.is_open())return;
	std::wstringstream ss;
	ss << L"<HTML>"
		L"<head>"
		L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
		L"<title>lyric</title>"
		L"</head>"
		L"<BODY SCROLL=NO bgcolor='#FFFFBF' topmargin='2' leftmargin='2'>"
		L"<h3 align='LEFT'>"
		L"<font size='5' color=#000000>" << quiz->get_question() << L"</font>"
		L"</h3>"
		L"</BODY>"
		L"</HTML>";
	std::wstring w = ss.str();
	std::string u;
	utf8::utf16to8(w.begin(), w.end(), std::back_inserter(u));
	out << u.c_str();
	out.close();
	m_question->Navigate(const_cast<wchar_t*>(html_path.c_str()), nullptr, nullptr, nullptr, nullptr);


	// show options
	CVerticalLayoutUI* options = static_cast<CVerticalLayoutUI*>(m_PaintManager.FindControl(L"options"));
	if (!options)return; options->RemoveAll();
	
	std::list<song::Mp3Info::QuizInfo::Quiz::OptionAndContent> list;
	quiz->get_questions(list);
	for (auto option_and_content : list) {
		// add container
		CHorizontalLayoutUI* container = new CHorizontalLayoutUI();
		container->SetFixedHeight(50);
		options->Add(container);

		// add option
		CButtonUI* btn_option = new CButtonUI();
		btn_option->SetFixedWidth(50);
		btn_option->SetFixedWidth(50);
		std::wstring option = option_and_content.first;
		btn_option->SetName((BTN_OPTION_PREFIX + option).c_str());
		btn_option->SetNormalImage((NORMAL_OPTION_PREFIX + option + POSTFIX_PNG).c_str());
		btn_option->SetFocusedImage((NORMAL_OPTION_PREFIX + option + POSTFIX_PNG).c_str());
		btn_option->SetHotImage((HOT_OPTION_PREFIX + option + POSTFIX_PNG).c_str());
		btn_option->SetPushedImage((HOT_OPTION_PREFIX + option + POSTFIX_PNG).c_str());
		container->Add(btn_option);
		
		// add content
		CActiveXUI* content = new CActiveXUI();
		container->Add(content);
		IWebBrowser2* pWebBrwser = nullptr;
		content->SetDelayCreate(false);              // 相当于界面设计器里的DelayCreate属性改为FALSE,在duilib自带的FlashDemo里可以看到此属性为TRUE             
		content->CreateControl(CLSID_WebBrowser);    // 相当于界面设计器里的Clsid属性里填入{8856F961-340A-11D0-A96B-00C04FD705A2},建议用CLSID_WebBrowser,如果想看相应的值,请见<ExDisp.h>
		content->GetControl(IID_IWebBrowser2, (void**)&pWebBrwser);
		assert(pWebBrwser); if (!pWebBrwser)return;
		ss.str(L""); ss.clear();
		ss << L"<HTML>"
			L"<head>"
			L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
			L"<title>lyric</title>"
			L"</head>"
			L"<BODY SCROLL=NO bgcolor='#FFFFBF' topmargin='2' leftmargin='2'>"
			L"<TABLE WIDTH=100% HEIGHT=100%><TR WIDTH=100% HEIGHT=100%><TD style=\"font-family:微软雅黑; font-size:20px; \">"
			L"<font size='3' color=#000000>" << option_and_content.second << L"</font>"
			L"</TD></TR></TABLE>"
			L"</BODY>"
			L"</HTML>";
		std::wstring w = ss.str();
		std::string u;
		utf8::utf16to8(w.begin(), w.end(), std::back_inserter(u));
		std::wstring html_path = m_songInfo->get_tmp_path() + L"\\" + m_songInfo->get_id() + L"\\content_" + option + L".html";
		std::wofstream out(html_path); if (!out.is_open())return;
		out << u.c_str();
		out.close();
		pWebBrwser->Navigate(const_cast<wchar_t*>(html_path.c_str()), nullptr, nullptr, nullptr, nullptr);
		pWebBrwser->Release();
		
		// add line gap
		CHorizontalLayoutUI* line_gap = new CHorizontalLayoutUI();
		line_gap->SetFixedHeight(50); 
		options->Add(line_gap);
	}

	// if user had chosen an answer before, show it.
	auto user_answer = quiz->get_user_answer();
	if (!user_answer.empty()) {
		std::wstring option_btn_name = BTN_OPTION_PREFIX + user_answer;
		CButtonUI* btn = static_cast<CButtonUI*>(m_PaintManager.FindControl(option_btn_name.c_str()));
		if (btn) {
			g_prev_clicked_button_option = nullptr;
			UpdateButtonUi2(btn, user_answer);
		}
	}

	g_cur_quiz_info = quiz;
	ss.str(L""); ss.clear();
	ss << ndx;
	std::wstring question_ndx = ss.str();
	std::wstring question_btn_name = BTN_QUESTION_PREFIX + ss.str();
	CButtonUI* question_btn = static_cast<CButtonUI*>(m_PaintManager.FindControl(question_btn_name.c_str()));
	if (question_btn) {
		g_prev_clicked_button = nullptr;
		UpdateButtonUi(question_btn, question_ndx);
	}
}