Пример #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::InitWindow()
{
	// 初始化数据管理器
	m_Data.Init(m_hWnd);
	// 创建分类按钮
	CHorizontalLayoutUI* pTabBar = (CHorizontalLayoutUI*)m_PaintManager.FindControl(_T("tabbar"));
	if(pTabBar)
	{
		TABBTN aTypes[] = {
			{_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), _T("精选")},
			{_T("1003"), _T("风景")},
			{_T("1004"), _T("美女")},
			{_T("1007"), _T("小清新")},
			{_T("1002"), _T("动漫")},
			{_T("1005"), _T("萌宠")},
			{_T("1006"), _T("明星")},
			{_T("1001"), _T("创意")},
			{_T("1008"), _T("汽车")},
			{_T("8009"), _T("颜色")},
		};
		COptionUI* pFirst = NULL;
		for(int i = 0; i < sizeof(aTypes) / sizeof(TABBTN); ++i)
		{
			TABBTN Tab = aTypes[i];
			COptionUI* pOption = new COptionUI();
			pOption->SetName(_T("wp_tabbtn"));
			pOption->SetText(Tab.sText);
			pOption->SetUserData(Tab.sType);
			pOption->SetGroup(_T("tabbar"));
			pOption->SetFixedHeight(25);
			pOption->SetFixedWidth(65);
			pOption->SetHotImage(_T("file='main/224.bmp' corner='4,4,4,4'"));
			pOption->SetSelectedImage(_T("file='main/224.bmp' corner='4,4,4,4'"));
			pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify1);
			pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify2);
			pTabBar->Add(pOption);
			if(pFirst == NULL) pFirst = pOption;
		}

		if(pFirst != NULL) pFirst->Selected(true);
	}

	m_Data.LoadBizhi(_T("8009|1003|1004|1007|1002|1005|1006|1001|1008"), 1, 10);
}
Пример #3
0
bool main_frame::OnWeiboContentEvent( void *param )
{
	TEventUI *pEvent = (TEventUI*)param;
	if (pEvent->Type == UIEVENT_SETFOCUS )
	{
		CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
		if (pWeiboCotentContainer)
		{
			pWeiboCotentContainer->SetBorderColor(RGB(0,0,255));
		}
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(pEvent->pSender);
		if (pRichEdit)
		{
			CDuiString strText = pRichEdit->GetText();
			if (strText.GetLength() == 0)
			{
				CLabelUI *plabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("defaultShowText")));
				if (plabel)
				{
					plabel->SetVisible(false);
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_KILLFOCUS )
	{
		CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
		if (pWeiboCotentContainer)
		{
			pWeiboCotentContainer->SetBorderColor(RGB(204,204,204));
		}
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			CDuiString strText = pRichEdit->GetText();
			if (strText.GetLength() == 0)
			{
				CLabelUI *plabel = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("defaultShowText")));
				if (plabel)
				{
					plabel->SetVisible(true);
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_MOUSELEAVE)
	{
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			if (!pRichEdit->IsFocused())
			{
				CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
				if (pWeiboCotentContainer)
				{
					pWeiboCotentContainer->SetBorderColor(RGB(204,204,204));
				}
			}
		}
	}
	else if (pEvent->Type == UIEVENT_MOUSEENTER)
	{
		CRichEditUI *pRichEdit = static_cast<CRichEditUI*>(m_PaintManager.FindControl(_T("weiboContent")));
		if (pRichEdit)
		{
			if (!pRichEdit->IsFocused())
			{
				CHorizontalLayoutUI *pWeiboCotentContainer = static_cast<CHorizontalLayoutUI*>(m_PaintManager.FindControl(_T("weiboContentContainer")));
				if (pWeiboCotentContainer)
				{
					pWeiboCotentContainer->SetBorderColor(RGB(0,0,255));
				}
			}
		}
	}

	return true;
}
Пример #4
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);
	}
}
Пример #5
0
void CListUIEx::SetItemData(int nItem, int nColumn,	CControlUI* pControl)
{
	CHorizontalLayoutUI *pSubHor = GetListSubItem(nItem, nColumn);
	pSubHor->SetAttribute("inset", "3,1,3,1");
	pSubHor->Add(pControl);//添加到父控件
}