void SpeedDialConfigController::InitL()
{
	OP_ASSERT(m_thumbnail != NULL);
	if (!m_thumbnail)
		LEAVE(OpStatus::ERR_NULL_POINTER);

	m_dialog = OP_NEW_L(QuickOverlayDialog, ());
	OP_ASSERT(m_thumbnail->GetParentOpSpeedDial());
	m_dialog->SetBoundingWidget(*m_thumbnail->GetParentOpSpeedDial());
	m_dialog->SetAnimationType(QuickOverlayDialog::DIALOG_ANIMATION_FADE);

	m_dialog->SetResizeOnContentChange(FALSE);

	if (m_mode == ADD)
	{
		LEAVE_IF_ERROR(SetDialog("Speed Dial Configuration Dialog", m_dialog));
	}
	else
	{
		LEAVE_IF_ERROR(SetDialog("Speed Dial Edit Dialog", m_dialog));
	}

	InitAddressL();

	if (m_mode == ADD)
	{
		InitPageViewsL();
		InitExtensionViewsL();

		// we want to request enough suggestions to fill all slots;
		// it's not a problem if we request too many ;)
		unsigned num = SUGGESTION_COUNT +
			g_desktop_extensions_manager->GetExtensionsCount();
		LEAVE_IF_ERROR(RequestExtensionsFeed(num));
	}
	else
	{
		InitTitleL();
	}

	LEAVE_IF_ERROR(SetThumbnail(*m_thumbnail));

	if (m_mode == ADD)
		g_desktop_extensions_manager->AddInstallListener(this);
}
示例#2
0
void CSrmmProxyWindow::OnRenderThumbnail(int width, int height)
{
	HBITMAP hbmp = CreateDwmBitmap(width, height);
	HDC hdc = CreateCompatibleDC(0);
	SelectObject(hdc, hbmp);

	RGBQUAD rgb0, rgb1;
	rgb0.rgbRed =  0; rgb0.rgbGreen =  0; rgb0.rgbBlue =  0;
	rgb1.rgbRed = 19; rgb1.rgbGreen = 58; rgb1.rgbBlue = 89;
	DrawGradient(hdc, 0, 0, width, height, &rgb0, &rgb1);

	HFONT hfntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
	SetTextColor(hdc, RGB(255, 255, 255));
	SetBkMode(hdc, TRANSPARENT);

	RECT rc;
	SIZE sz;
	SetRect(&rc, 5, 5, width-10, height-10);

	int avatarWidth = 0;
	int avatarHeight = 0;
	if (true)
	{
		AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)m_hContact, 0);
		if (ace && (ace != (AVATARCACHEENTRY *)CALLSERVICE_NOTFOUND))
		{
			if (ace->bmWidth < width / 4)
			{
				avatarWidth = ace->bmWidth;
				avatarHeight = ace->bmHeight;
			} else
			{
				avatarWidth = width / 4;
				avatarHeight = avatarWidth * ace->bmHeight / ace->bmWidth;
			}

			AVATARDRAWREQUEST avdr = {0};
			avdr.cbSize = sizeof(avdr);
			avdr.hContact = m_hContact;
			avdr.hTargetDC = hdc;
			avdr.rcDraw = rc;
			avdr.rcDraw.bottom = avdr.rcDraw.top + avatarHeight;
			avdr.rcDraw.right = avdr.rcDraw.left + avatarWidth;
			avdr.dwFlags = AVDRQ_FALLBACKPROTO | AVDRQ_FORCEALPHA;

			avdr.alpha = 255;
			CallService(MS_AV_DRAWAVATAR, 0, (LPARAM)&avdr);

			rc.left += avatarWidth + 5;
		}
	}

	char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0);
	
	if (true)
	{
		CONTACTINFO ci = {0};
		ci.cbSize = sizeof(ci);
		ci.hContact = m_hContact;
		ci.szProto = proto;
		ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
		if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci))
		{
			TCHAR name[128]; name[0] = 0;
			switch (ci.type)
			{
				case CNFT_ASCIIZ:
					mir_sntprintf(name, SIZEOF(name), _T("%s"), ci.pszVal);
					mir_free((void *)ci.pszVal);
					break;
				case CNFT_DWORD:
					mir_sntprintf(name, SIZEOF(name), _T("%u"), ci.dVal);
					break;
			}

			TextOut(hdc, rc.left + 20, rc.top, name, lstrlen(name));
			GetTextExtentPoint32(hdc, name, lstrlen(name), &sz);
		}
	}

	if (true)
	{
		HIMAGELIST hIml = (HIMAGELIST)CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0);
		int iIcon = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)m_hContact, 0);
		ImageList_Draw(hIml, iIcon, hdc, rc.left, rc.top + (sz.cy - 16) / 2, ILD_TRANSPARENT);
	}

	rc.top += sz.cy + 5;

	rc.left += 10;

	struct
	{
		TCHAR *text;
		bool out;
	} msgs[10] = {0};

	if (true)
	{
		int hMsgs = 0;
		int n = 0;
		HANDLE hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDLAST, (WPARAM)m_hContact, 0);
		while (hEvent)
		{
			BYTE buf[1024];
			DBEVENTINFO dbei = {0};
			dbei.cbSize = sizeof(dbei);
			dbei.cbBlob = sizeof(buf);
			dbei.pBlob = buf;
			if (!CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
			{
				if (dbei.eventType == EVENTTYPE_MESSAGE)
				{
					msgs[n].text = DbGetEventTextT(&dbei, CP_ACP);
					msgs[n].out = dbei.flags & DBEF_SENT ? true : false;

					RECT rcCopy = rc;
					hMsgs += DrawText(hdc, msgs[n].text, -1, &rcCopy, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP|DT_CALCRECT);
					if (n && hMsgs > rc.bottom - rc.top)
					{
						mir_free(msgs[n].text);
						msgs[n].text = 0;
						break;
					}

					hMsgs += 3;

					if (++n >= SIZEOF(msgs)) break;
				}
			}
			hEvent = (HANDLE)CallService(MS_DB_EVENT_FINDPREV, (WPARAM)hEvent, 0);
		}
	}

	if (true)
	{
		for (int i = SIZEOF(msgs); i--; )
		{
			if (!msgs[i].text) continue;

			TCHAR szDir[] = { (msgs[i].out ? (WCHAR)0xbb : (WCHAR)0xab), 0 };
			rc.left -= 10;
			DrawText(hdc, szDir, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP);
			rc.left += 10;

			rc.top += 3 + DrawText(hdc, msgs[i].text, -1, &rc, DT_LEFT|DT_NOPREFIX|DT_WORDBREAK|DT_TOP);
			mir_free(msgs[i].text);
		}
	}

	SelectObject(hdc, hfntSave);

	DeleteDC(hdc);
	MakeBitmapOpaque(hbmp);
	SetThumbnail(hbmp);
	DeleteObject(hbmp);
}