Example #1
0
void CTitlePane::Render(CDC* pDC,CRect& area)
{
    LOGFONT lf;
    ::memset(&lf,0,sizeof(lf));
    ::strcpy(lf.lfFaceName,"Tahoma");
    lf.lfHeight = 120;
	lf.lfWeight = FW_BOLD;
    CFont f;
    f.CreatePointFontIndirect(&lf);
    CFont*old = pDC->SelectObject(&f);

    m_title.Draw(pDC);
    pDC->SelectObject(old);
    f.DeleteObject();





    ::memset(&lf,0,sizeof(lf));
    ::strcpy(lf.lfFaceName,"Arial");
    lf.lfHeight = 80;
    f.CreatePointFontIndirect(&lf);
    old = pDC->SelectObject(&f);

    m_details.Draw(pDC);
    pDC->SelectObject(old);
    f.DeleteObject();
}
void CGumpListView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();
	if (m_bInit) return;
	m_bInit = true;

	LoadGumpDesc(GUMP_DESC_FILE);

	CListCtrl& ctrl = GetListCtrl();

	ctrl.ModifyStyle(0, LVS_REPORT|LVS_SINGLESEL|LVS_SHOWSELALWAYS);
	ctrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

	LOGFONT lf;
	memset(&lf, 0, sizeof(lf));
	HGDIOBJ hFont = ::GetStockObject(OEM_FIXED_FONT);
	::GetObject(hFont, sizeof(lf), &lf);

	lf.lfHeight = 100;
	lf.lfPitchAndFamily = FIXED_PITCH;

	CFont font;

	font.CreatePointFontIndirect(&lf);

	ctrl.SetFont(&font);
	font.Detach();

	ctrl.InsertColumn(0, "Gump ID", LVCFMT_RIGHT,60);
	ctrl.InsertColumn(1, "Size",	LVCFMT_RIGHT,60);
	ctrl.InsertColumn(2, "Desc",	LVCFMT_LEFT,100);

	CString strText;
	cGumpLoader* pGumpLoader = GetDocument()->GetGumpLoader(); ASSERT(pGumpLoader);

	int w=0,h=0,iItem=0;
	for (int i = 0; i < pGumpLoader->GetGumpCount(); i++)
	{
		pGumpLoader->GetGumpSize(i, w, h);
		if (w==0 || h==0) continue;
		
		strText.Format("0x%04X", i);
		iItem = ctrl.InsertItem(i, strText);
		strText.Format("%dx%d", w,h);
		ctrl.SetItemText(iItem, 1, strText);
		ctrl.SetItemData(iItem, i);

		LPCTSTR desc = GetGumpDesc(i);
		if (desc)
			ctrl.SetItemText(iItem, 2, desc);

		//if (i > 100) break;
	}
	
}
void TextStyleCreateFont (const CBCGPTextStyleRef& textStyle, CBCGPDrawContext& drawCtx, CFont& font)
{
    LOGFONT lf;
    ZeroMemory (&lf, sizeof (lf));

    CString strFontName = textStyle.GetFontName ();
    double dPointSize = textStyle.GetFontSize ();

    lstrcpyn (lf.lfFaceName, strFontName, LF_FACESIZE);
    lf.lfHeight = (long)(dPointSize * 10 * drawCtx.GetScale ());
    lf.lfWeight = textStyle.IsBold () ? FW_BOLD : FW_NORMAL;
    lf.lfItalic = textStyle.IsItalic ();
    font.CreatePointFontIndirect (&lf, drawCtx.GetDC ());
}
Example #4
0
CFont* OSDRegion::CreateFont(int iFont, int iFontSize)
{
	CDC* pDC = GetDC();
	int iFontPoints = iFontSize == 0 ? -120 : iFontSize == 1 ? -140 : -180;
	int iFontWidth = iFontSize == 0 ? 14 : iFontSize == 1 ? 16 : 19;

	CFont* thefont  = new CFont();

	LOGFONT logFont;
	memset(&logFont, 0, sizeof(LOGFONT));
	logFont.lfCharSet = DEFAULT_CHARSET;
	logFont.lfWeight = FW_BOLD;
	logFont.lfHeight = iFontPoints;
	logFont.lfWidth = -iFontPoints/16;
	strcpy(logFont.lfFaceName, "Arial Narrow" );

	thefont->CreatePointFontIndirect(&logFont, pDC);

	ReleaseDC();
	return thefont;
}
/*
================
CSyntaxRichEditCtrl::InitFont
================
*/
void CSyntaxRichEditCtrl::InitFont(void)
{
	LOGFONT lf;
	CFont font;
	PARAFORMAT pf;
	int logx, tabSize;

	// set the font
	memset(&lf, 0, sizeof(lf));
	lf.lfHeight = FONT_HEIGHT * 10;
	lf.lfWidth = FONT_WIDTH * 10;
	lf.lfCharSet = ANSI_CHARSET;
	lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
	strcpy(lf.lfFaceName, FONT_NAME);
	font.CreatePointFontIndirect(&lf);

	SetFont(&font);

	// get the tab size in twips
	logx = ::GetDeviceCaps(GetDC()->GetSafeHdc(), LOGPIXELSX);
	tabSize = TAB_SIZE * FONT_WIDTH * 1440 / logx;

	// set the tabs
	memset(&pf, 0, sizeof(PARAFORMAT));
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS;

	for (pf.cTabCount = 0; pf.cTabCount < MAX_TAB_STOPS; pf.cTabCount++) {
		pf.rgxTabs[pf.cTabCount] = pf.cTabCount * tabSize;
	}

	SetParaFormat(pf);

	memset(&defaultCharFormat, 0, sizeof(defaultCharFormat));
	defaultCharFormat.dwMask = CFM_CHARSET | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_COLOR | CFM_PROTECTED | CFM_BACKCOLOR;
	defaultCharFormat.yHeight = FONT_HEIGHT * 20;
	defaultCharFormat.bCharSet = ANSI_CHARSET;
	defaultCharFormat.bPitchAndFamily = FIXED_PITCH | FF_MODERN;
	defaultCharFormat.crTextColor = SRE_COLOR_BLACK;
	defaultCharFormat.crBackColor = DEFAULT_BACK_COLOR;
	defaultCharFormat.dwEffects = CFE_PROTECTED;
	strcpy(defaultCharFormat.szFaceName, FONT_NAME);
	defaultCharFormat.cbSize = sizeof(defaultCharFormat);

	SetDefaultCharFormat(defaultCharFormat);

	defaultColor = SRE_COLOR_BLACK;
	singleLineCommentColor = SRE_COLOR_DARK_GREEN;
	multiLineCommentColor = SRE_COLOR_DARK_GREEN;
	stringColor[0] = stringColor[1] = SRE_COLOR_DARK_CYAN;
	literalColor = SRE_COLOR_GREY;
	braceHighlightColor = SRE_COLOR_RED;

	// get the default tom::ITextFont
	tom::ITextRange *irange;
	tom::ITextFont *ifont;

	m_TextDoc->Range(0, 0, &irange);
	irange->get_Font(&ifont);

	ifont->get_Duplicate(&m_DefaultFont);

	ifont->Release();
	irange->Release();
}
/////////////////////////////////////////////////////////////////////////////
// CCtlTipOfTheDayText message handlers
void CCtlTipOfTheDayText::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
  // get rectangle of the text area inside dialog
  RECT rectWin;
  GetWindowRect(&rectWin);
  ScreenToClient(&rectWin);

  // calculate positions of the upper and left rectangle and separating line
  int iy, ix0, ix1;
  RECT rectUp;
  RECT rectDn;
  ix0 = rectUp.left = rectDn.left = rectWin.left;
  ix1 = rectUp.right = rectDn.right = rectWin.right;
  iy = rectUp.bottom = rectDn.top = int((rectWin.bottom+rectWin.top)*0.25f);
  rectUp.top = rectWin.top;
  rectDn.bottom = rectWin.bottom;
  InflateRect(&rectDn, -5,-10);
  InflateRect(&rectUp, -5,-10);
  OffsetRect(&rectDn, 0,5);
  OffsetRect(&rectUp, 0,5);

  // draw white rectangle with sunken edge
  CBrush brWhite;
  brWhite.CreateStockObject(WHITE_BRUSH);
  dc.FillRect(&rectWin, &brWhite);
  dc.DrawEdge(&rectWin, BDR_SUNKENOUTER, BF_RIGHT|BF_BOTTOM|BF_TOP);

  // draw separating line
  CBrush brGray;
  brGray.CreateStockObject(GRAY_BRUSH);
  dc.SelectObject(brGray);
  dc.MoveTo(ix0-1, iy);
  dc.LineTo(ix1, iy);

  // create two fonts, big and small
  LOGFONT lf;

  ::ZeroMemory (&lf, sizeof (lf));
  lf.lfHeight = 145;
  lf.lfWeight = FW_BOLD;
  lf.lfItalic = FALSE;
  wcscpy(lf.lfFaceName, L"Times New Roman");
  CFont fontBig;
  fontBig.CreatePointFontIndirect (&lf);

  ::ZeroMemory (&lf, sizeof (lf));
  lf.lfHeight = 100;
  lf.lfWeight = FW_NORMAL;
  lf.lfItalic = FALSE;
  wcscpy(lf.lfFaceName, L"Arial");
  CFont fontSmall;
  fontSmall.CreatePointFontIndirect (&lf);

  // print heading with big font
  dc.SelectObject(&fontBig);
  dc.DrawText("Did you know...", &rectUp, DT_VCENTER|DT_SINGLELINE);

  // print text with small font
  dc.SelectObject(&fontSmall);
  dc.DrawText(m_strTipText, &rectDn, DT_WORDBREAK);
}