Exemplo n.º 1
0
void WeaselPanel::_ResizeWindow()
{
	if (!m_status.composing)
	{
		SetWindowPos( NULL, 0, 0, STATUS_ICON_SIZE, STATUS_ICON_SIZE, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
		return;
	}
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);

	CSize size = m_layout->GetContentSize();
	SetWindowPos(NULL, 0, 0, size.cx, size.cy, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
	dc.DeleteDC();
}
Exemplo n.º 2
0
//¸üнçÃæ
void WeaselPanel::Refresh()
{
	if (m_layout != NULL)
		delete m_layout;
	if (m_style.layout_type == LAYOUT_VERTICAL)
		m_layout = new VerticalLayout(m_style, m_ctx);
	else if (m_style.layout_type == LAYOUT_HORIZONTAL)
		m_layout = new HorizontalLayout(m_style, m_ctx);
	CDCHandle dc = GetDC();
	long fontHeight = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);
	CFont font;
	font.CreateFontW(fontHeight, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	dc.SelectFont(font);
	m_layout->DoLayout(dc);
	dc.DeleteDC();

	_ResizeWindow();
	_RepositionWindow();
	RedrawWindow();
}
Exemplo n.º 3
0
bool CPrintFolder::CalcLayout(CDCHandle dcPrinter)
{
	if(!dcPrinter.IsNull())
	{
		CRect rcPage(0, 0, 
		dcPrinter.GetDeviceCaps(PHYSICALWIDTH) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETX),
		dcPrinter.GetDeviceCaps(PHYSICALHEIGHT) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETY));
		
		// Fix for 98...PHYSICALWIDTH seems to fail on 98?
		if (rcPage.right == 0) 
		{
			rcPage.right = dcPrinter.GetDeviceCaps(HORZRES);
			rcPage.bottom = dcPrinter.GetDeviceCaps(VERTRES);
		}

		return CalcLayout(dcPrinter, rcPage);
	}
	
	return CalcLayout(dcPrinter, m_rcOutput);
}
Exemplo n.º 4
0
LRESULT CAnimMixer::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	drawBar(1);

  CDCHandle dc = (HDC) wParam;

	// prepare...
	CRect rc;
  GetClientRect(&rc);

	CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont());
	dc.SetTextColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	CPen blackPen;
	blackPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	CPenHandle oldPen = dc.SelectPen(blackPen);

	// fill background
	dc.FillSolidRect(&rc, RGB(174, 169, 167));

	// draw tl bar at y 45
	dc.MoveTo(mapTime(0), 45);
	dc.LineTo(rc.right, 45);

	// track grid
	CPen pen_grid;
	pen_grid.CreatePen(PS_DOT, 1, RGB(174*3/4, 169*3/4, 167*3/4)^RGB(174, 169, 167));

	dc.SelectPen(pen_grid);
	dc.SetROP2(R2_XORPEN);
	dc.SetBkColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	for (sInt trackY=46+22; trackY<rc.bottom; trackY+=22)
	{
		dc.MoveTo(mapTime(0), trackY);
		dc.LineTo(rc.right, trackY);
	}

	// bar marks
	dc.SetROP2(R2_COPYPEN);
	dc.SelectPen(blackPen);

	const sF32 xstep = 60000.0f / g_graph->m_bpmRate;
	const sF32 ixstep = g_graph->m_bpmRate / (60000.0f * m_frameStep);
	const sInt xms = (m_startPixel) * ixstep;
	const sInt xme = (m_startPixel + rc.right) * ixstep;

	LOGFONT lf;
	((CFontHandle) AtlGetDefaultGuiFont()).GetLogFont(lf);

	if (lf.lfHeight<0)
		lf.lfHeight=MulDiv(-lf.lfHeight, dc.GetDeviceCaps(LOGPIXELSY), 72);

	for (sInt i=fr::maximum(xms-1,0); i<=xme+1; i++)
	{
		const sInt xpos=mapTime(i*xstep);

		const sInt beat=i&3;

		dc.MoveTo(xpos, 45);
		dc.LineTo(xpos, 37-(beat==0)*2);

		TCHAR buf[32];
		sprintf(buf, "%d.%d", i/4, beat);

		dc.SetTextAlign(TA_BOTTOM|(i?TA_CENTER:TA_LEFT));
		dc.TextOut(xpos, 35, buf);

		if (!beat)
		{
			dc.MoveTo(xpos, rc.bottom);
			dc.LineTo(xpos, 45);
		}
	}

	dc.SelectPen(oldPen);
	dc.SelectFont(oldFont);

  return 1;
}
Exemplo n.º 5
0
//draw client area
void WeaselPanel::DoPaint(CDCHandle dc)
{
	CRect rc;
	GetClientRect(&rc);

	if (!m_status.composing)
	{
		if (m_status.ascii_mode)
			dc.DrawIconEx(0, 0, m_iconAlpha, 0, 0);
		else
			dc.DrawIconEx(0, 0, m_iconEnabled, 0, 0); 
		return;
	}

	// background
	{
		CBrush brush;
		brush.CreateSolidBrush(m_style.back_color);
		CRgn rgn;
		rgn.CreateRectRgnIndirect(&rc);
		dc.FillRgn(rgn, brush);

		CPen pen;
		pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, m_style.border, m_style.border_color);
		CPenHandle oldPen = dc.SelectPen(pen);
		CBrushHandle oldBrush = dc.SelectBrush(brush);
		dc.Rectangle(&rc);
		dc.SelectPen(oldPen);
		dc.SelectBrush(oldBrush);
	}

	long height = -MulDiv(m_style.font_point, dc.GetDeviceCaps(LOGPIXELSY), 72);

	CFont font;
	font.CreateFontW(height, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, 0, 0, 0, 0, m_style.font_face.c_str());
	CFontHandle oldFont = dc.SelectFont(font);

	dc.SetTextColor(m_style.text_color);
	dc.SetBkColor(m_style.back_color);
	dc.SetBkMode(TRANSPARENT);
	
	bool drawn = false;

	// draw preedit string
	if (!m_style.inline_preedit)
		drawn |= _DrawPreedit(m_ctx.preedit, dc, m_layout->GetPreeditRect());
	
	/* FIXME: What's this?
	// ascii mode icon
	if (m_status.ascii_mode && y > rc.top)
	{
		int icon_x = rc.right - STATUS_ICON_SIZE;
		int icon_y = (rc.top + y - m_style.spacing - STATUS_ICON_SIZE) / 2;
		dc.DrawIconEx(icon_x, icon_y, m_iconAlpha, 0, 0);
	}*/

	/* TODO: Deprecated? */
	// draw auxiliary string
	drawn |= _DrawPreedit(m_ctx.aux, dc, m_layout->GetAuxiliaryRect());

	// draw candidates
	drawn |= _DrawCandidates(dc);

	/* Nothing drawn, hide candidate window */
	if (!drawn)
		ShowWindow(SW_HIDE);

	dc.SelectFont(oldFont);	
}
Exemplo n.º 6
0
bool CPrintFolder::DrawImage(CDCHandle dc, CPoint point, IW::Image &image, IW::FolderItem *pItem)
{
	HFONT hOldFont = dc.SelectFont(m_font);
	UINT uTextStyle =  DT_NOPREFIX | DT_EDITCONTROL;
	if (m_bCenter) uTextStyle |= DT_CENTER;
	if (!m_bWrap) uTextStyle |= DT_WORD_ELLIPSIS; else uTextStyle |= DT_WORDBREAK;

	// Calc Text Size
	CSimpleArray<CString> arrayStrText;
	CSimpleValArray<int> arrayHeights;
	pItem->GetFormatText(arrayStrText, m_annotations, true);

	int i, nHeightText = 0;

	for(i = 0; i < arrayStrText.GetSize(); i++)
	{
		CRect r(point.x, 
			point.y + _sizeSection.cy, 
			point.x + _sizeSection.cx, 
			point.y + _sizeSection.cy);

		dc.DrawText(arrayStrText[i], -1,
			&r, uTextStyle | DT_CALCRECT);

		int nLimit = _sizeThumbNail.cy / 2;
		if (nHeightText + r.Height() > nLimit) 
		{
			arrayHeights.Add(nLimit - nHeightText);
			nHeightText = nLimit;
			break;
		}
		else
		{
			nHeightText += r.Height();
			arrayHeights.Add(r.Height());
		}
	}

	CSize sizeThumbNailLocal = _sizeThumbNail;	
	sizeThumbNailLocal.cy -= nHeightText;

	if (!image.IsEmpty())
	{
		IW::Page page = image.GetFirstPage();

		// Best fit rotate
		if (m_nPrintRotateBest > 0)
		{
			bool bRotate = ((sizeThumbNailLocal.cx > sizeThumbNailLocal.cy) &&
				(page.GetWidth() < page.GetHeight())) || 
				((sizeThumbNailLocal.cx < sizeThumbNailLocal.cy) &&
				(page.GetWidth() > page.GetHeight()));

			if (bRotate)
			{
				IW::Image imageRotate;

				if (m_nPrintRotateBest == 1)
				{
					IW::Rotate270(image, imageRotate, _pStatus);
				}
				else
				{
					IW::Rotate90(image, imageRotate, _pStatus);
				}

				image = imageRotate;
			}
		}	

		const int nSizeAverage = (page.GetWidth() + page.GetHeight()) / 2;

		page = image.GetFirstPage();
		page.SetBackGround(m_clrBackGround);

		const CRect rectBounding = image.GetBoundingRect();

		const int nWidthPels = dc.GetDeviceCaps(HORZRES); 
		const int nHeightPels = dc.GetDeviceCaps(VERTRES); 

		const long icx = rectBounding.Width();
		const long icy = rectBounding.Height();
		const long nDiv = 0x1000;		
		
		// Scale the image
		long sh = MulDiv(sizeThumbNailLocal.cx, nDiv, icx);
		long sw = MulDiv(sizeThumbNailLocal.cy, nDiv, icy);		
		long s =  IW::Min(sh, sw);
		
		const CSize sizeImage(MulDiv(page.GetWidth(), s, nDiv), MulDiv(page.GetHeight(), s, nDiv));		
		const CPoint pt(point.x + ((sizeThumbNailLocal.cx - sizeImage.cx) / 2) + m_nPadding,
			point.y + ((sizeThumbNailLocal.cy - sizeImage.cy) / 2) + m_nPadding);

		const CRect rectPrint(pt, sizeImage);

		if ((rectPrint.Width() < page.GetWidth()) && (rectPrint.Height() < page.GetHeight()))
		{
			IW::Image imageScaled;
			IW::Scale(image, imageScaled, rectPrint.Size(), _pStatus);
			image = imageScaled;
			page = image.GetFirstPage();
		}

		IW::CRender::DrawToDC(dc, page, rectPrint);
	}

	// Draw the Text!
	CRect rectText(point.x, 
		point.y + _sizeSection.cy - nHeightText, 
		point.x + _sizeSection.cx, 
		point.y + _sizeSection.cy);

	for(i = 0; i < arrayHeights.GetSize(); i++)
	{
		dc.DrawText(arrayStrText[i], -1, &rectText, uTextStyle);
		rectText.top += arrayHeights[i];
	}
		
	dc.SelectFont(hOldFont);

	

	return true;
}
Exemplo n.º 7
0
bool CPrintFolder::CalcLayout(CDCHandle dcPrinter, const CRect &rcPage)
{
	m_bHasPrinter = !dcPrinter.IsNull();	

	if(m_bHasPrinter)
	{
		if (rcPage.right > 0)
		{
			m_rcOutput = rcPage;
		}

		_sizeLogPixels.cx = dcPrinter.GetDeviceCaps(LOGPIXELSX);
		_sizeLogPixels.cy = dcPrinter.GetDeviceCaps(LOGPIXELSY);
	}


	if (m_fontTitle.m_hFont != 0) m_fontTitle.DeleteObject();
	if (m_font.m_hFont != 0) m_font.DeleteObject();

	int nTitleFontSize = 16;
	int nFontSize = 8;
	int nPaddingSize = 4;

	//Set up the font for the titles on the intro and ending pages
    NONCLIENTMETRICS ncm = {0};
    ncm.cbSize = sizeof(ncm);
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
	
    //Create the intro/end title font
	LOGFONT lf = ncm.lfMessageFont;	
	lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72);
	m_fontTitle.CreateFontIndirect(&lf);	
	lf.lfHeight = 0 - ::MulDiv(_sizeLogPixels.cy, nFontSize, 72);
	m_font.CreateFontIndirect(&lf);

	///////////////////////
	//convert from 1/1000" to twips
	_rectExtents.left = m_rcOutput.left + MulDiv(m_rcMargin.left, _sizeLogPixels.cx, 1000);
	_rectExtents.right = m_rcOutput.right - MulDiv(m_rcMargin.right, _sizeLogPixels.cx, 1000);
	_rectExtents.top = m_rcOutput.top + MulDiv(m_rcMargin.top, _sizeLogPixels.cy, 1000);
	_rectExtents.bottom = m_rcOutput.bottom - MulDiv(m_rcMargin.bottom, _sizeLogPixels.cy, 1000);

	m_nPadding = ::MulDiv(_sizeLogPixels.cy, nPaddingSize, 72);
	m_nFooterHeight = ::MulDiv(_sizeLogPixels.cy, nFontSize, 72) * 2;
	m_nHeaderHeight = ::MulDiv(_sizeLogPixels.cy, nTitleFontSize, 72) * 2;	

	// Do we want footers and headers?
	int nFooterHeaderHeight = 0;

	if (m_bShowFooter || m_bShowPageNumbers)
	{
		nFooterHeaderHeight += m_nFooterHeight;
	}

	if (m_bShowHeader)
	{
		nFooterHeaderHeight += m_nHeaderHeight;
	}

	int nImageRows = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cy;
	int nImageColumns = m_bPrintOnePerPage ? 1 : _sizeRowsColumns.cx;
	
	// Calculate the thumbnail size
	_sizeSection.cx = ((_rectExtents.right - _rectExtents.left) / nImageColumns);
	_sizeSection.cy = (((_rectExtents.bottom - _rectExtents.top) - nFooterHeaderHeight) / nImageRows);

	if (_sizeSection.cx < 10 || _sizeSection.cy < 10)
	{
		return false;
	}

	_sizeThumbNail = _sizeSection;
	_sizeThumbNail.cy -= (m_nPadding * 2);
	_sizeThumbNail.cx -= (m_nPadding * 2);
	
	if (_sizeThumbNail.cy < 10)
	{
		return false;
	}

	m_nMaxPage = GetPageCount();
	
	return true;
}