Beispiel #1
0
void CInformationPanel::ApplyStyle()
{
	if (m_hwnd!=NULL) {
		CreateDrawFont(m_StyleFont,&m_Font);

		LOGFONT lf={};
		lf.lfHeight=m_Style.ButtonSize.Height;
		lf.lfCharSet=SYMBOL_CHARSET;
		::lstrcpy(lf.lfFaceName,TEXT("Marlett"));
		m_IconFont.Create(&lf);

		CalcFontHeight();

		m_ItemButtonWidth=m_FontHeight*15/10+m_Style.ItemButtonPadding.Horz();
	}
}
Beispiel #2
0
bool CInformationPanel::SetFont(const LOGFONT *pFont)
{
	if (!m_Font.Create(pFont))
		return false;
	if (m_hwnd!=NULL) {
		CalcFontHeight();
		if (m_fUseRichEdit) {
			SetWindowFont(m_hwndProgramInfo,m_Font.GetHandle(),FALSE);
			UpdateProgramInfoText();
		} else {
			SetWindowFont(m_hwndProgramInfo,m_Font.GetHandle(),TRUE);
		}
		SendSizeMessage();
		Invalidate();
	}
	return true;
}
Beispiel #3
0
LRESULT CInformationPanel::OnMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	switch (uMsg) {
	case WM_CREATE:
		{
			InitializeUI();

			if (!m_Font.IsCreated())
				CreateDefaultFont(&m_Font);
			m_BackBrush.Create(m_Theme.Style.Back.Fill.GetSolidColor());
			m_ProgramInfoBackBrush.Create(m_Theme.ProgramInfoStyle.Back.Fill.GetSolidColor());
			CalcFontHeight();

			m_HotButton=-1;

			CProgramInfoItem *pProgramInfoItem=
				static_cast<CProgramInfoItem*>(GetItem(ITEM_PROGRAMINFO));
			CreateProgramInfoEdit();
			if (pProgramInfoItem->IsVisible())
				::ShowWindow(m_hwndProgramInfo,SW_SHOW);
		}
		return 0;

	HANDLE_MSG(hwnd,WM_COMMAND,OnCommand);

	case WM_SIZE:
		if (IsItemVisible(ITEM_PROGRAMINFO)) {
			RECT rc;

			GetItemRect(ITEM_PROGRAMINFO,&rc);
			TVTest::Theme::SubtractBorderRect(m_Theme.ProgramInfoStyle.Back.Border,&rc);
			::MoveWindow(m_hwndProgramInfo,rc.left,rc.top,
						 rc.right-rc.left,rc.bottom-rc.top,TRUE);
		}
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;

			::BeginPaint(hwnd,&ps);
			Draw(ps.hdc,ps.rcPaint);
			::EndPaint(hwnd,&ps);
		}
		return 0;

	case WM_CTLCOLORSTATIC:
		{
			HDC hdc=reinterpret_cast<HDC>(wParam);

			::SetTextColor(hdc,m_Theme.ProgramInfoStyle.Fore.Fill.GetSolidColor());
			::SetBkColor(hdc,m_Theme.ProgramInfoStyle.Back.Fill.GetSolidColor());
			return reinterpret_cast<LRESULT>(m_ProgramInfoBackBrush.GetHandle());
		}

	case WM_LBUTTONDOWN:
		{
			int Button=ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam));

			if (Button>=0) {
				SetHotButton(Button);
				::SetCapture(hwnd);
			}
		}
		return 0;

	case WM_LBUTTONUP:
		if (::GetCapture()==hwnd) {
			if (m_HotButton>=0) {
				SetHotButton(ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)));

				switch (m_HotButton) {
				case BUTTON_PROGRAMINFOPREV:
					::SendMessage(hwnd,WM_COMMAND,CM_PROGRAMINFOPREV,0);
					break;
				case BUTTON_PROGRAMINFONEXT:
					::SendMessage(hwnd,WM_COMMAND,CM_PROGRAMINFONEXT,0);
					break;
				}
			}

			::ReleaseCapture();
		}
		return 0;

	case WM_RBUTTONUP:
		{
			HMENU hmenu;
			POINT pt;

			hmenu=::LoadMenu(m_hinst,MAKEINTRESOURCE(IDM_INFORMATIONPANEL));
			for (int i=0;i<NUM_ITEMS;i++)
				CheckMenuItem(hmenu,CM_INFORMATIONPANEL_ITEM_FIRST+i,
							  MF_BYCOMMAND | (IsItemVisible(i)?MFS_CHECKED:MFS_UNCHECKED));
			pt.x=GET_X_LPARAM(lParam);
			pt.y=GET_Y_LPARAM(lParam);
			::ClientToScreen(hwnd,&pt);
			::TrackPopupMenu(::GetSubMenu(hmenu,0),TPM_RIGHTBUTTON,pt.x,pt.y,0,hwnd,NULL);
			::DestroyMenu(hmenu);
		}
		return TRUE;

	case WM_MOUSEMOVE:
		{
			SetHotButton(ButtonHitTest(GET_X_LPARAM(lParam),GET_Y_LPARAM(lParam)));

			if (::GetCapture()==NULL) {
				TRACKMOUSEEVENT tme;
				tme.cbSize=sizeof(TRACKMOUSEEVENT);
				tme.dwFlags=TME_LEAVE;
				tme.hwndTrack=hwnd;
				::TrackMouseEvent(&tme);
			}
		}
		return 0;

	case WM_MOUSELEAVE:
	case WM_CAPTURECHANGED:
		if (m_HotButton>=0)
			SetHotButton(-1);
		return 0;

	case WM_SETCURSOR:
		if ((HWND)wParam==hwnd) {
			if (LOWORD(lParam)==HTCLIENT && m_HotButton>=0) {
				::SetCursor(GetActionCursor());
				return TRUE;
			}
		} else if ((HWND)wParam==m_hwndProgramInfo
				&& LOWORD(lParam)==HTCLIENT
				&& m_fUseRichEdit
				&& m_fProgramInfoCursorOverLink) {
			::SetCursor(GetLinkCursor());
			return TRUE;
		}
		break;

	case WM_NOTIFY:
		switch (reinterpret_cast<LPNMHDR>(lParam)->code) {
		case EN_MSGFILTER:
			{
				MSGFILTER *pMsgFilter=reinterpret_cast<MSGFILTER*>(lParam);

				switch (pMsgFilter->msg) {
				case WM_RBUTTONUP:
					TVTest::EventInfoUtil::EventInfoContextMenu(hwnd,m_hwndProgramInfo);
					break;

				case WM_LBUTTONDOWN:
					m_ProgramInfoClickPos.x=GET_X_LPARAM(pMsgFilter->lParam);
					m_ProgramInfoClickPos.y=GET_Y_LPARAM(pMsgFilter->lParam);
					break;

				case WM_MOUSEMOVE:
					m_ProgramInfoClickPos.x=-1;
					m_ProgramInfoClickPos.y=-1;
					{
						POINT pt={GET_X_LPARAM(pMsgFilter->lParam),GET_Y_LPARAM(pMsgFilter->lParam)};

						if (CRichEditUtil::LinkHitTest(m_hwndProgramInfo,pt,m_ProgramInfoLinkList)>=0) {
							m_fProgramInfoCursorOverLink=true;
							::SetCursor(GetLinkCursor());
						} else {
							m_fProgramInfoCursorOverLink=false;
						}
					}
					break;

				case WM_LBUTTONUP:
					{
						POINT pt={GET_X_LPARAM(pMsgFilter->lParam),GET_Y_LPARAM(pMsgFilter->lParam)};

						if (m_ProgramInfoClickPos.x==pt.x && m_ProgramInfoClickPos.y==pt.y)
							CRichEditUtil::HandleLinkClick(m_hwndProgramInfo,pt,m_ProgramInfoLinkList);
					}
					break;
				}
			}
			return 0;

#if 0
		case EN_LINK:
			{
				ENLINK *penl=reinterpret_cast<ENLINK*>(lParam);

				if (penl->msg==WM_LBUTTONUP)
					CRichEditUtil::HandleLinkClick(penl);
			}
			return 0;
#endif
		}
		break;

	case WM_DISPLAYCHANGE:
		m_Offscreen.Destroy();
		return 0;

	case WM_DESTROY:
		m_BackBrush.Destroy();
		m_ProgramInfoBackBrush.Destroy();
		m_Offscreen.Destroy();
		m_hwndProgramInfo=NULL;
		return 0;
	}

	return ::DefWindowProc(hwnd,uMsg,wParam,lParam);
}