Ejemplo n.º 1
0
void ecMemoryLayoutWindow::OnPaint(wxPaintEvent& event)
{
    wxPaintDC dc(this);

    PrepareDC(dc);

    ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
    if (pDoc == NULL) // no document so nothing to draw
        return;

#if 0    
    // clear the lists of region and section rectangles used for hit testing
    
    listRegionRect.RemoveAll ();
    listSectionRect.RemoveAll ();
    
    // setup background mode
    
    int nOldBkMode = pDC->SetBkMode (TRANSPARENT);
    
    // setup font
    
    CFont fntName;
    if (!fntName.CreatePointFont (80, _T("MS Sans Serif"), pDC))
        return;
    CFont * pOldFont = pDC->SelectObject (&fntName);
    
    // determine max unit count for any region
    
    mem_map * pMemoryMap = &CConfigTool::GetConfigToolDoc()->MemoryMap;
    
    // calculate the unit scaling for DISPLAY_MODE 1
    
    UINT uPixelsPerUnit = UNIT_WIDTH_MIN;
    RECT rectClientRect;
    if (m_uUnitCountMax != 0) // if there is something to draw
    {
        
        GetClientRect (&rectClientRect);
        uPixelsPerUnit = __max ((m_uClientWidth - HORIZ_BORDER * 2) / m_uUnitCountMax, UNIT_WIDTH_MIN);
        m_uViewWidth = uPixelsPerUnit * m_uUnitCountMax + HORIZ_BORDER * 2;
    }
    
    // draw the regions
    
    UINT uRegion = 0;
    UINT uUnitCount;
    list <mem_region>::iterator region;
    for (region = pMemoryMap->region_list.begin (); region != pMemoryMap->region_list.end (); ++region)
    {
        uUnitCount = 0;
        for (list <mem_section_view>::iterator section_view = region->section_view_list.begin (); section_view != region->section_view_list.end (); ++section_view)
            uUnitCount += (section_view->section == NULL ? 1 : UNITS_PER_SECTION);
        
        if (DISPLAY_MODE == 1)
            DrawRegion (pDC, uRegion++, uUnitCount, uPixelsPerUnit, region);
        else // DISPLAY_MODE == 2
            DrawRegion (pDC, uRegion++, uUnitCount, (rectClientRect.right - HORIZ_BORDER * 2) / uUnitCount, region);
    }    
    
    pDC->SelectObject (pOldFont);
    pDC->SetBkMode (nOldBkMode);
#endif
}
Ejemplo n.º 2
0
void CPadView::OnChoosePrintFont()
{
	CWaitCursor wait;
	CFont* pFont = GetPrinterFont();
	LOGFONT lf;
	LPLOGFONT plf = NULL;
	if (pFont != NULL)
	{
		pFont->GetObject(sizeof(LOGFONT), &lf);
		plf = &lf;
	}

	// magic to get printer dialog that would be used if we were printing!
	CPrintDialog dlgPrint(FALSE);
	if (!AfxGetApp()->GetPrinterDeviceDefaults(&dlgPrint.m_pd))
	{
		AfxMessageBox(IDP_ERR_GET_DEVICE_DEFAULTS);
		return;
	}
	wait.Restore();
	HDC hdcPrint = dlgPrint.CreatePrinterDC();
	if (hdcPrint == NULL)
	{
		AfxMessageBox(IDP_ERR_GET_PRINTER_DC);
		return;
	}

	CDC dcScreen;
	dcScreen.Attach(::GetDC(NULL));
	CDC dcPrint;
	dcPrint.Attach(hdcPrint);

	if (plf != NULL)
	{
		// need to map initial logfont to screen metrics.
		::ScaleLogFont(plf, dcPrint, dcScreen);
	}

	// now bring up the dialog since we know the printer DC
	CFontDialog dlg(plf, CF_PRINTERFONTS, &dcPrint);
	if (dlg.DoModal() == IDOK)
	{
		// map the resulting logfont back to printer metrics.
		lf = dlg.m_lf;
		::ScaleLogFont(&lf, dcScreen, dcPrint);

		SetPrinterFont(NULL);
		m_fontPrint.DeleteObject();
		if (m_fontPrint.CreateFontIndirect(&lf))
		{
			SetPrinterFont(&m_fontPrint);
			m_lfDefPrintFont = lf;

			// notify container that content has changed
			GetDocument()->UpdateAllItems(NULL);
		}
	}
	//NOTE: destructor will call dcPrint.DeleteDC

	::ReleaseDC(NULL, dcScreen.Detach());
}
Ejemplo n.º 3
0
void CTreeListFrame::Initialize()
{
	// creates all the objects in frame -
	// header, tree, horizontal scroll bar

   int scrollBarWidth  = GetSystemMetrics(SM_CXHSCROLL);
   int scrollBarHeight = GetSystemMetrics(SM_CYHSCROLL);

	CRect m_wndRect;
	GetWindowRect(&m_wndRect);
	CRect m_headerRect;

	// create the header
	{
		//m_headerRect.left = m_headerRect.top = -1;
		m_headerRect.left = m_headerRect.top = 0;
		m_headerRect.right = m_wndRect.Width();

		getTree().m_wndHeader.Create(WS_CHILD | WS_VISIBLE | HDS_BUTTONS | HDS_HORZ, m_headerRect, this, ID_TREE_LIST_HEADER);
	}

	CSize textSize;
	// set header's pos, dimensions and image list
	{
		LOGFONT logfont;

		CFont *pFont = GetParent()->GetFont();
		pFont->GetLogFont( &logfont );

		getTree().m_headerFont.CreateFontIndirect( &logfont );
		getTree().m_wndHeader.SetFont(&getTree().m_headerFont);

		CDC *pDC = getTree().m_wndHeader.GetDC();
		pDC->SelectObject(&getTree().m_headerFont);
		textSize = pDC->GetTextExtent("A");

		//getTree().m_wndHeader.SetWindowPos(&wndTop, -1, -1, m_headerRect.Width(), textSize.cy+4, SWP_SHOWWINDOW);
		getTree().m_wndHeader.SetWindowPos(&wndTop, 0, 0, m_headerRect.Width(), textSize.cy+4, SWP_SHOWWINDOW);

		getTree().m_cImageList.Create(IDB_HEADERSORTARROWS, 16, 10, RGB(192,192,192));
		getTree().m_wndHeader.SetImageList(&getTree().m_cImageList);
	}

	CRect m_treeRect;

	// create the tree itself
	{
		GetWindowRect(&m_wndRect);

		m_treeRect.left   = 0;
		m_treeRect.top    = textSize.cy + 4;
		m_treeRect.right  = m_headerRect.Width() - 5;
		//m_treeRect.bottom = m_wndRect.Height() - GetSystemMetrics(SM_CYHSCROLL) - 4;
		m_treeRect.bottom = m_wndRect.Height() - GetSystemMetrics(SM_CYHSCROLL);

		getTree().Create(WS_BORDER | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, m_treeRect, this, ID_TREE_LIST_CTRL);
	}

	// finally, create the horizontal scroll bar
	{
		CRect m_scrollRect;
		m_scrollRect.left   = 0;
		m_scrollRect.top    = m_treeRect.bottom;
		int scrollRectTop   = m_wndRect.bottom   - GetSystemMetrics(SM_CYHSCROLL);
		m_scrollRect.right  = m_treeRect.Width() - GetSystemMetrics(SM_CXVSCROLL);
		m_scrollRect.bottom = m_wndRect.bottom;

		m_horScrollBar.Create(WS_CHILD | WS_VISIBLE | WS_DISABLED | SBS_HORZ | SBS_TOPALIGN, m_scrollRect, this, ID_TREE_LIST_SCROLLBAR);
	}

	SortTree(0, TRUE, getTree().GetRootItem());
}
Ejemplo n.º 4
0
void CXTPPopupItem::CalculateWidth()
{
    if (m_pRichRender)
    {
        return;
    }

    if (m_pUIElement)
    {
        XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL);

        CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width());
        m_rcItem.right = m_rcItem.left + sz.cx;
        m_rcItem.bottom = m_rcItem.top + sz.cy;
        return;
    }

    CXTPImageManagerIcon* pIcon = GetImage();

    if (pIcon)
    {
        m_rcItem.right = m_rcItem.left + pIcon->GetWidth();
        return;
    }

    if (m_nAlign & DT_WORDBREAK) return;

    CWindowDC dc(NULL);
    CRect rcText(0, 0, 0, m_rcItem.Height());

    CFont fntUnderline;
    CFont* pFont = GetTextFont();

    if (IsHyperLink() && IsUnderline() || IsBold())
    {
        LOGFONT lpLogFont;
        pFont->GetLogFont(&lpLogFont);
        lpLogFont.lfUnderline = (IsHyperLink() && IsUnderline());
        lpLogFont.lfWeight = IsBold() ? FW_BOLD : FW_NORMAL;

        VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont));
        pFont = &fntUnderline;
    }

    CXTPFontDC font(&dc, pFont);

    dc.DrawText(m_strCaption, rcText, m_nAlign | DT_CALCRECT);

    if (m_nAlign & DT_RIGHT)
    {
        m_rcItem.left = m_rcItem.right - rcText.Width();
    }
    else if (m_nAlign & DT_CENTER)
    {
        LONG lCentrl = m_rcItem.left + m_rcItem.Width()/2;
        m_rcItem.left = lCentrl - rcText.Width()/2;
        m_rcItem.right = m_rcItem.left + rcText.Width();
    }
    else
    {
        m_rcItem.right = m_rcItem.left + rcText.Width();
    }
}
Ejemplo n.º 5
0
//绘画界面
void CGameClientView::DrawGameView(CDC * pDC, int nWidth, int nHeight)
{
	//绘画背景
	DrawViewImage(pDC,m_ImageBack,enMode_Spread);
	DrawViewImage(pDC,m_ImageCenter,enMode_Centent);
	CImageHandle HandleHeadBg(&m_ImageHeadBg);
	
	//放弃标志
	CImageHandle HnadleUserPass(&m_ImageUserPass);
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		if (m_bPass[i]) 
		{
			m_ImageUserPass.AlphaDrawImage(pDC,m_pPass[i].x,m_pPass[i].y,RGB(255,0,255));
		}
	}

	//绘画用户
	TCHAR szBuffer[32];
	for (WORD i=0;i<GAME_PLAYER;i++)
	{
		//变量定义
		WORD wUserTimer=GetUserTimer(i);
		const tagUserData * pUserData=GetUserInfo(i);
		pDC->SetTextColor(RGB(0,255,255));

		//绘画用户
		if (pUserData!=NULL)
		{
			//m_ImageHeadBg.BitBlt(pDC->m_hDC,m_ptFace[i].x-2,m_ptFace[i].y-2);
			//用户名字
			//pDC->SetTextColor((wUserTimer>0)?RGB(250,250,250):RGB(220,220,220));
			//pDC->SetTextAlign(i==0||i==2?TA_RIGHT:TA_LEFT);
			pDC->TextOut(m_ptName[i].x,m_ptName[i].y,pUserData->szName,lstrlen(pUserData->szName));
			pDC->TextOut(m_pZhanPaiName[i].x,m_pZhanPaiName[i].y-30,pUserData->szName,lstrlen(pUserData->szName));
			pDC->TextOut(nWidth/2-2*m_nXFace-2*m_nXBorder,2*m_nYFace+m_nYBorder-2*16+i*16+26,pUserData->szName,lstrlen(pUserData->szName));
			//设置上一局成绩
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lForeScore[i]);
			pDC->TextOut(nWidth/2+7,2*m_nYFace+m_nYBorder-2*16+i*16+26,szBuffer,lstrlen(szBuffer));
			//设置总成绩
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lAllScore[i]);
			pDC->TextOut(nWidth/2+2*m_nXFace+2*m_nXBorder,2*m_nYFace+m_nYBorder-2*16+i*16+26,szBuffer,lstrlen(szBuffer));
		
			
			

			//剩余扑克
			if (pUserData->cbUserStatus>=US_PLAY)
			{
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("(%ld 张)"),m_bCardCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+17*m_nXFace+6*m_nXBorder,m_pZhanPaiName[i].y-30,szBuffer,lstrlen(szBuffer));

				//设置掀人次数
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("掀牌:%d次"),m_bXianCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+12*m_nXFace+2*m_nXBorder,m_pZhanPaiName[i].y-30,szBuffer,lstrlen(szBuffer));
				//设置被掀次数
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("被掀:%d次"),m_bBeiXianCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+12*m_nXFace+2*m_nXBorder,m_pZhanPaiName[i].y-43,szBuffer,lstrlen(szBuffer));
				//设置占牌数目
				_snprintf(szBuffer,sizeof(szBuffer),TEXT("%d"),m_bZhanPaiCount[i]);
				pDC->TextOut(m_pZhanPaiName[i].x+500+4*m_nXBorder,m_pZhanPaiName[i].y-25,szBuffer);

					//绘画时间标志
			   DrawTime(pDC,nWidth,nHeight);

			}

			//其他信息
			if (wUserTimer!=0) DrawUserTimer(pDC,m_ptTimer[i].x,m_ptTimer[i].y,wUserTimer);
			if (pUserData->cbUserStatus==US_READY) DrawUserReady(pDC,m_ptReady[i].x,m_ptReady[i].y);
			DrawUserFace(pDC,pUserData->wFaceID,m_ptFace[i].x,m_ptFace[i].y,pUserData->cbUserStatus==US_OFFLINE);
			
		}
	}
	
	

	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bCouPaiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"扣牌");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"扣牌");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"扣牌");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}
	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bXianPaiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"掀牌");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"掀牌");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"掀牌");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}
	//描述信息
	for(BYTE i=0;i<GAME_PLAYER;i++)
		if (m_bQiangCiTitle[i]==true)
		{
			//创建资源
			CFont InfoFont;
			InfoFont.CreateFont(-36,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("黑体"));

			//设置 DC
			pDC->SetTextColor(RGB(201,229,133));
			pDC->SetTextAlign(TA_CENTER|TA_TOP);
			CFont * pOldFont=pDC->SelectObject(&InfoFont);

			//绘画信息
			if(i%2)
				pDC->TextOut(nWidth/2,m_ptFace[i].y-6*m_nYFace-8,"抢刺");
			else if(m_ptFace[i].x<nWidth/2)
				pDC->TextOut(m_ptFace[i].x+5*m_nXFace,m_ptFace[i].y-8,"抢刺");
			else 
				pDC->TextOut(m_ptFace[i].x-4*m_nXFace,m_ptFace[i].y-8,"抢刺");


			//清理资源
			pDC->SelectObject(pOldFont);
			InfoFont.DeleteObject();
		}

	return;
}
Ejemplo n.º 6
0
//  Keys Text
//------------------------------------------------------------------------------------------------------------
void cAmp::DrawKeysText()
{
	CFont* cf = cfont[view.cfP];  //~
	#define  clr(r,g,b)  cf->Fclr = D3DXCOLOR(r,g,b,1)
	//if (shift) {  cf->StrWr("shift", xSize/2,Fy);  }
	//if (ctrl) {  cf->StrWr("ctrl", xSize/2+40,Fy);  }
	//if (alt) {  cf->StrWr("alt", xSize/2+70,Fy);  }

/*  Edit name  */
	if (ed==ED_nTab)
	{
		clr(0.5,0.9,1);  int y = yB_pli;
		cf->StrWr("Tab name: ", 1,y);
		cf->StrWr(sed, cf->xwr+10,y);
		
		int x = cf->xwr+1;  // cursor |
		fTi+=dt;  if (fTi > 0.7f) fTi=0.f;  //blink
		D3DRECT r= {x, y, x+2, y+cf->Fy};  pDev->Clear(1, &r, clFl, RGB(fTi*200+50,fTi*200,0), 1.f, 0);
	}
/*  Edit search  */
	if (ed==ED_nFind)
	{
		clr(0.3,1,0);  int y = yB_pli;
		cf->StrWr("Search: ", 1,y);
		cf->StrWr(sed, cf->xwr+10,y);  //x2
		
		int x = cf->xwr+1;  // cursor |
		fTi+=dt;  if (fTi > 0.7f) fTi=0.f;  //blink
		D3DRECT r= {x, y, x+2, y+cf->Fy};  pDev->Clear(1, &r, clFl, RGB(0,fTi*200+50,0), 1.f, 0);
	}

///  Keys list
	if (ed!=ED_Keys)  return;
	cf = cfont[view.cfG];  //~

	int y = yB_gc, x=5;
	clr(1,1,1);
	cf->StrWr("Global HotKeys", 15, yB_gc-90+15);
	cf->StrWr("OK", 150+18, yB_gc-80+2);
	clr(0.5,0.8,1.0);
	cf->StrWr("Function        Shift Ctrl Alt      Key", 15, yB_gc-25);
	clr(0.6,0.7,0.7);
	cf->StrWr("LMB- choose  RMB- on/off", x+120, yB_gc-90+40);
	for (int i=0; i<FU_ALL; i++)
	{
		if (vKeys[i].on)
			clr(1,1,1);  else  clr(0.5,0.6,0.7);

		cf->StrWr(cswFuns[i], 5+x, y);

		if (i == yPickKey && bPickingKey)
		{	clr(1,1,1);
			cf->StrCopy(" Press new key...");	}
		else
			strKeyName(vKeys[i].vk, vKeys[i].sc, cf->str);
		
		cf->Write(xB_gck+5+x, y);
		y += yH_gc + 16*cyFadd[i]/2;
	}
}
void CKSInputDialog::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	CDC memDC;
	CBitmap bkBit,*oldBkBit;
	CRect client;
	RECT clientRect,edtRect;
	dc.GetClipBox(client);
	if(memDC.CreateCompatibleDC(&dc))
	{
		memDC.SetBkMode(TRANSPARENT);
		if(bkBit.CreateCompatibleBitmap(&dc,client.Width(),client.Height()))
		{
			oldBkBit = memDC.SelectObject(&bkBit);
			/*
			CBrush brh;
			brh.CreateSolidBrush( RGB(0,0,255) );
			brh.UnrealizeObject();
			memDC.FillRect( client , &brh );
			*/
			if(m_config)
			{
				CRect parentRect;
				CWnd * parentWnd = GetParent();
				ASSERT(parentWnd != NULL);
				parentWnd->GetWindowRect(parentRect);
				GetWindowRect(&clientRect);
				m_config->m_bkImg.m_Dest.x = -(clientRect.left);
				m_config->m_bkImg.m_Dest.y = -(clientRect.top);
				m_config->m_bkImg.m_DestSize.cx = parentRect.Width();
				m_config->m_bkImg.m_DestSize.cy = parentRect.Height();
				m_config->m_bkImg.m_Src.x = 0;
				m_config->m_bkImg.m_Src.y = 0;
				m_config->m_bkImg.m_SrcSize.cx = m_config->m_bkImg.GetWidth();
				m_config->m_bkImg.m_SrcSize.cy = m_config->m_bkImg.GetHeight();
				m_config->m_bkImg.Display(&memDC);
				/*
				dc.StretchBlt(0,0,client.Width(),client.Height(),&memDC
				,0,0,m_config->m_bkImg.GetWidth(),m_config->m_bkImg.GetHeight(),SRCCOPY);
				*/
			}
			//////////////////////////////////////////////////////////////////////////
			// 设置字体
			LOGFONT lf;
			memset(&lf,0,sizeof lf);
			lf.lfCharSet = GB2312_CHARSET;
			strcpy(lf.lfFaceName,m_fontName.GetBuffer(1));
			lf.lfHeight = m_fontSize;
			lf.lfWeight = FW_BOLD;			

			CFont font;
			CFont *pOldFont;						// 新添加的老字体资源
			font.CreateFontIndirect(&lf);
			// memDC.SelectObject(font);			// 隐掉
			pOldFont = memDC.SelectObject(&font);	// 新添加获得老字体资源		
			//////////////////////////////////////////////////////////////////////////
			// 取得字体属性
			TEXTMETRIC tm;
			memset(&tm,0,sizeof tm);
			memDC.GetTextMetrics(&tm);
			CSize fs = memDC.GetTextExtent(m_prompt);
			int textWidth = fs.cx;//tm.tmAveCharWidth * (m_prompt.GetLength() + 1);
			//////////////////////////////////////////////////////////////////////////
			// 设置字体颜色
			memDC.SetTextColor(m_fontColor);
			//////////////////////////////////////////////////////////////////////////
			GetWindowRect(&clientRect);
			ScreenToClient(&clientRect);
			m_edtInput.GetWindowRect(&edtRect);
			ScreenToClient(&edtRect);
			int x,y;
			RECT textRect;
			if(clientRect.right > textWidth)
			{
				x = (clientRect.right - textWidth) / 2;
				textRect.left = x;
				textRect.right = textRect.left + textWidth;
			}
			else
			{
				x = 20;
				textRect.left = x;
				textRect.right = clientRect.right - 20;
			}
			
			//y = (edtRect.top - tm.tmHeight - 2);
			y = 5;
			memDC.MoveTo(x,y);
			textRect.top = y;
			
			textRect.bottom = y + GetTextLineHeight(fs.cy,textRect.right-textRect.left
				,fs.cx);
			memDC.DrawText(m_prompt,&textRect,DT_WORDBREAK|DT_CENTER);
			//////////////////////////////////////////////////////////////////////////
			
			dc.BitBlt(0,0,client.Width(),client.Height(),&memDC,0,0,SRCCOPY);
			memDC.SelectObject(pOldFont);				// 新添加的把老字体资源选回去
			font.DeleteObject();
			//brh.DeleteObject();
			memDC.SelectObject(oldBkBit);
			memDC.DeleteDC();
		}
	}
}
Ejemplo n.º 8
0
void CTreeOptionsCtrlEx::OnCreateImageList()
{
	CDC* pDCScreen = CDC::FromHandle(::GetDC(HWND_DESKTOP)); // explicitly use screen-dc, for proper RTL support
	if (pDCScreen)
	{
		const int iBmpWidth = 16;
		const int iBmpHeight = 16;
		const int iBitmaps = 13;
		CBitmap bmpControls;
		if (bmpControls.CreateCompatibleBitmap(pDCScreen, iBmpWidth*iBitmaps, iBmpHeight))
		{
			if (m_ilTree.Create(iBmpWidth, iBmpHeight, m_uImageListColorFlags | ILC_MASK, 0, 1))
			{
				CDC dcMem;
				if (dcMem.CreateCompatibleDC(pDCScreen))
				{
					HTHEME hTheme = (g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed()) ? g_xpStyle.OpenThemeData(NULL, L"BUTTON") : NULL;
					CBitmap* pOldBmp = dcMem.SelectObject(&bmpControls);
					dcMem.FillSolidRect(0, 0, iBmpWidth*iBitmaps, iBmpHeight, GetSysColor(COLOR_WINDOW));

					//int iCtrlWidth = iBmpWidth - 2;
					//int iCtrlHeight = iBmpHeight - 2;
					int iCtrlWidth = 16 - 3;
					int iCtrlHeight = 16 - 3;
					int iCtrlLeft = (iBmpWidth - iCtrlWidth) / 2;
					int iCtrlTop = (iBmpHeight - iCtrlHeight) / 2;

					// checkbox
					CRect rcBmp(0, 0, 0+iBmpWidth, 0+iBmpHeight);
					CRect rcCtrl(iCtrlLeft, iCtrlTop, iCtrlLeft+iCtrlWidth, iCtrlTop+iCtrlHeight);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					}
					else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT);

					// checkbox checked
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*1);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					}
					else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT);

					// radio
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*2);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_FLAT);

					// radio checked
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*3);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_FLAT);

					// checkbox disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*4);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT);

					// checkbox checked disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*5);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					// radio disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*6);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_INACTIVE | DFCS_FLAT);

					// radio checked disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*7);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					// checkbox checked tri-state
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*8);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT);

					// checkbox checked tri-state disabled 
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*9);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					ASSERT( TREEOPTSCTRLIMG_EDIT == 11 );
					rcBmp.MoveToX(iBmpWidth*11);
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*11);
					CFont font;
					if (font.CreatePointFont(10, _T("Courier")))
					{
						CFont* pOldFont = dcMem.SelectObject(&font);
						dcMem.TextOut(rcCtrl.left+2, rcCtrl.top, _T("I"));
						dcMem.SelectObject(pOldFont);
					}
					CRect rcEdge(rcBmp);
					rcEdge.top += 1;
					rcEdge.bottom -= 1;
					dcMem.DrawEdge(&rcEdge, EDGE_ETCHED, BF_RECT);

					if (hTheme){
						g_xpStyle.CloseThemeData(hTheme);
						hTheme = NULL;
					}

					hTheme = (g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed()) ? g_xpStyle.OpenThemeData(NULL, L"COMBOBOX") : NULL;
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*12);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, CP_DROPDOWNBUTTON, CBXS_NORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, CP_DROPDOWNBUTTON, CBXS_NORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | DFCS_FLAT);

					dcMem.SelectObject(pOldBmp);
					m_ilTree.Add(&bmpControls, RGB(255,0,255));
					if (hTheme)
						g_xpStyle.CloseThemeData(hTheme);
				}
			}
		}
		::ReleaseDC(HWND_DESKTOP, *pDCScreen);
	}
}
Ejemplo n.º 9
0
//获取一个字符的点阵信息
int CChannelNameSet::GetBuffer(int ch, int nFont)
{
	freeData();
	
	//创建字体。
	CFont   hFont; 
	hFont.CreateFont(nFont,0,0,0, 
		FW_NORMAL,0, 
		0,0,DEFAULT_CHARSET, 
		OUT_TT_PRECIS,CLIP_TT_ALWAYS,   
		PROOF_QUALITY   ,DEFAULT_PITCH,   
		"宋体 "); 
	
	//设置字体到当前设备。
	CDC*pDC = GetDC();
	CFont* pOldFont = pDC->SelectObject( &hFont);
	
	//设置字体图形变换矩阵         
	MAT2 mat2;
	SetMat(&mat2);
	
	GLYPHMETRICS gm;
	
	//获取这个字符图形需要的字节的大小。
	DWORD dwNeedSize = pDC->GetGlyphOutline(ch,GGO_BITMAP,&gm,0,NULL,&mat2);
	if (dwNeedSize > 0 && dwNeedSize < 0xFFFF)
	{
		if( ch == '\t' ) 
			return 4 * gm.gmCellIncX; 
		
		m_pBuf = (byte*)(malloc(dwNeedSize));
		if ( m_pBuf)
		{
			//获取字符图形的数据到缓冲区。
			pDC->GetGlyphOutline(ch,GGO_BITMAP,&gm,dwNeedSize,m_pBuf,&mat2);
			m_nWidth = gm.gmBlackBoxX;
			m_nHeight = gm.gmBlackBoxY;
		}
	}
	else if( dwNeedSize == 0xFFFFFFFF || dwNeedSize == 0 || ch < 0x21 ) 
	{ 
		//要生成的文字是空格或tab只需返回宽度 
		if( ch == ' ') 
			return gm.gmCellIncX; 
		else   if( ch == '\t' ) 
			return 4 * gm.gmCellIncX; 
		else 
		{
			UINT nSubstituteChar = ' '; 
			pDC-> GetGlyphOutline( nSubstituteChar, GGO_NATIVE, &gm, 
				0, NULL, &mat2 ); 
			if( ch < 256 ) //西文 
				return gm.gmCellIncX; 
			else //中文空两个空格 
				return 2*gm.gmCellIncX; 
		} 
	} 
	else
	{
		dwNeedSize = 0;
	}
	
	pDC->SelectObject(pOldFont);
	ReleaseDC(pDC);
	
	return dwNeedSize;
}
Ejemplo n.º 10
0
//标注
void CSmooth::DoLable( CDC* dc, double zvalue )
{
    //	dc->Ellipse(ptArray.GetAt(0).x-50,ptArray.GetAt(0).y-50,ptArray.GetAt(0).x+50,ptArray.GetAt(0).y+50);
    //if (zvalue!=1750) return;
    int i;
    int kkkmmm = 0;
    double bzjd_m;
    double dX1, dY1, dX2, dY2, dX3, dY3;
    const double pie = 3.1416;
    CString TextString;
    LOGFONT myFont;
    double r1;
    bool bSearched;

    myFont.lfHeight = 780;
    myFont.lfWidth = 460;
    myFont.lfEscapement = 0;
    myFont.lfWeight = 400;
    myFont.lfItalic = 0;
    myFont.lfUnderline = 0;
    myFont.lfStrikeOut = 0;
    myFont.lfOutPrecision = 0;
    myFont.lfClipPrecision = 0;
    myFont.lfQuality = 0;
    myFont.lfPitchAndFamily = 0;
    myFont.lfCharSet = 0;
    strcpy( myFont.lfFaceName, "Arial" );

    //寻找标注点的位置及字体的标注角度
    r1 = 0;
    int nnk = 0;
    double RS = 0;
    i = ptArray.GetSize() - 1;
    TextString.Format( "%7.2f", zvalue );

    int iWidth = TextString.GetLength() * myFont.lfWidth;
    int iHeight = myFont.lfHeight;
    int iNeedDots = ( int )floor( iWidth / dts ) + 1;

    if ( i >= 10 )
    {
        for ( int t = 5; t <= i - 10; t++ )
        {
            bSearched = false;//假设没有找到。。。
            int iik = t;
            dX1 = ptArray.GetAt( iik ).x;
            dY1 = ptArray.GetAt( iik ).y;
            dX2 = ptArray.GetAt( iik + 1 ).x;
            dY2 = ptArray.GetAt( iik + 1 ).y;
            dX3 = ptArray.GetAt( iik + 2 ).x;
            dY3 = ptArray.GetAt( iik + 2 ).y;
            double dist = sqrt( ( dX1 - dX2 ) * ( dX1 - dX2 ) + ( dY1 - dY2 ) * ( dY1 - dY2 ) ) + sqrt( ( dX3 - dX2 ) * ( dX3 - dX2 ) + ( dY3 - dY2 ) * ( dY3 - dY2 ) );
            double mmk, kkm, xc, yc, ro;
            do
            {
                double pf1 = dX1 * dX1 + dY1 * dY1 - dX2 * dX2 - dY2 * dY2;
                double pf2 = dX2 * dX2 + dY2 * dY2 - dX3 * dX3 - dY3 * dY3;
                if ( dY1 == dY2 ) goto lbl100;
                mmk = pf2 - ( ( dY2 - dY3 ) / ( dY1 - dY2 ) ) * pf1;
                kkm = 2 * ( dX2 - dX3 - ( dY2 - dY3 ) * ( dX1 - dX2 ) / ( dY1 - dY2 ) );
                if ( abs( kkm ) < 0.0001 ) goto lbl100;
                xc = mmk / kkm;//(xc,yc)为园心,ro为半径
                yc = ( pf2 - 2 * ( dX1 - dX2 ) * xc ) / ( 2 * ( dY1 - dY2 ) );
                ro = sqrt( ( yc - dX2 ) * ( yc - dX2 ) + ( yc - dY2 ) * ( yc - dY2 ) );
                if ( ro < myFont.lfHeight * 5 )
                {
                    bSearched = false;
                    break;
                }

lbl100:		  //如果满足要求的话,继续。。。
                bSearched = true;
                if ( dist > iWidth ) break;
                iik++;
                if ( iik + 2 > i - 10 )
                {
                    bSearched = false;  //点的个数不够,停止追踪
                    break;
                }
                dX1 = dX2;
                dY1 = dY2;
                dX2 = dX3;
                dY2 = dY3;
                dX3 = ptArray.GetAt( iik + 2 ).x;
                dY3 = ptArray.GetAt( iik + 2 ).y;
                dist += sqrt( ( dX3 - dX2 ) * ( dX3 - dX2 ) + ( dY3 - dY2 ) * ( dY3 - dY2 ) );
//		dc->Ellipse(ptArray.GetAt(iik+2).x-10,ptArray.GetAt(iik+2).y-10,ptArray.GetAt(iik+2).x+10,ptArray.GetAt(iik+2).y+10);
            }
            while( 1 );
            if ( bSearched == true )
            {
                kkkmmm = t;
                break;
            }
        }
        if ( bSearched == false || kkkmmm == 0 )
        {
            return;
        }
        dc->Ellipse( ptArray.GetAt( kkkmmm ).x - 40, ptArray.GetAt( kkkmmm ).y - 40, ptArray.GetAt( kkkmmm ).x + 40, ptArray.GetAt( kkkmmm ).y + 40 );

        double xzwz = ptArray.GetAt( kkkmmm ).x;
        double yzwz = ptArray.GetAt( kkkmmm ).y;

        double dltx = ptArray.GetAt( kkkmmm ).x - ptArray.GetAt( kkkmmm + iNeedDots ).x;
        double dlty = ptArray.GetAt( kkkmmm ).y - ptArray.GetAt( kkkmmm + iNeedDots ).y;
        double fzqz;

        if ( dltx != 0 )
        {
            fzqz = -atan( dlty / dltx );
            if ( dlty == 0 ) fzqz = 0;
        }
        else
            double fzqz = 3 * pie / 2;

        bzjd_m = -fzqz;
        if ( ( fzqz < pie / 2 && fzqz > 0 ) || ( fzqz < -3 * pie / 2 && fzqz > -2 * pie ) || ( fzqz > pie && fzqz < 3 * pie / 2 ) || ( fzqz > -pie && fzqz < -pie / 2 ) )
        {
//			xzwz += (sqrt(iHeight*iHeight+iWidth*iWidth)/2 * cos(fzqz - atan(iHeight/iWidth)));
//			yzwz += (sqrt(iHeight*iHeight+iWidth*iWidth)/2 * sin(fzqz - atan(iHeight/iWidth)));
            //xzwz = xzwz - abs(myFont.lfWidth * cos(fzqz)) - abs(myFont.lfHeight * sin(fzqz) / 2);
//			yzwz = yzwz - abs(myFont.lfHeight * cos(fzqz) / 2) + abs(myFont.lfWidth * sin(fzqz));
        }
        else
        {
//			xzwz -= (sqrt(iHeight*iHeight+iWidth*iWidth)/2 * cos(fzqz - atan(iHeight/iWidth)));
//			yzwz += (sqrt(iHeight*iHeight+iWidth*iWidth)/2 * sin(fzqz - atan(iHeight/iWidth)));
//			xzwz = xzwz - abs(myFont.lfWidth * cos(fzqz)) + abs(myFont.lfHeight * sin(fzqz) / 2);
//			yzwz = yzwz - abs(myFont.lfHeight * cos(fzqz) / 2) - abs(myFont.lfWidth * sin(fzqz));
        }

        myFont.lfEscapement = fzqz * 1800 / pie;
        //标注
        CFont NewFont;
        NewFont.CreateFontIndirect( &myFont );
        CFont* OrgFont = dc->SelectObject( &NewFont );
        dc->TextOut( xzwz, yzwz, TextString, 5 ); //TextString.GetLength());
        dc->SelectObject( OrgFont );
        NewFont.DeleteObject();
        OrgFont->DeleteObject();
    }
}
Ejemplo n.º 11
0
void CXTPPopupPaintManager::DrawItem(CDC* pDC, CXTPPopupItem* pItem)
{
	CRect rc = pItem->GetRect();

	if (pItem->GetBackgroundColor() != (COLORREF)-1)
		pDC->FillSolidRect(rc, pItem->GetBackgroundColor());

	if (pItem->GetBorderColor() != (COLORREF)-1)
		pDC->Draw3dRect(rc, pItem->GetBorderColor(), pItem->GetBorderColor());

	CXTPImageManagerIcon* pIcon = pItem->GetImage();

	if (pIcon)
	{
		rc.OffsetRect(pItem->GetIconOffset());

		if (pItem->IsPressed() && pItem->IsSelected())
		{
			if (pItem->IsButton())
				DrawButton(pDC, pItem);

			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetCheckedIcon());
		}
		else if (pItem->IsSelected() || pItem->IsPressed())
		{
			if (pItem->IsButton())
				DrawButton(pDC, (CXTPPopupItem*)pItem);

			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetHotIcon());
		}
		else
		{
			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetIcon());
		}
		return;
	}

	if (pItem->IsButton())
		DrawButton(pDC, (CXTPPopupItem*)pItem);

	if (!pItem->GetCaption().IsEmpty())
	{
		CXTPRichRender* pRichRender = pItem->m_pRichRender;

		CFont fntUnderline;
		CFont* pFont = pItem->GetTextFont();

		if ((pItem->IsSelected() && pItem->IsHyperLink() && pItem->IsUnderline()) || pItem->IsBold())
		{
			LOGFONT lpLogFont;
			pFont->GetLogFont(&lpLogFont);
			lpLogFont.lfUnderline = (pItem->IsSelected() && pItem->IsHyperLink() && pItem->IsUnderline());
			lpLogFont.lfWeight = pItem->IsBold() ? FW_BOLD : FW_NORMAL;

			VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont));
			pFont = &fntUnderline;
		}
		CRect rcText(pItem->GetRect());

		CXTPFontDC font(pDC, pFont);

		if (pRichRender)
		{
			pRichRender->DrawText(pDC, rcText);
		}
		else
		{
			if ((pItem->GetTextAlignment() & (DT_WORDBREAK | DT_VCENTER)) == (DT_WORDBREAK | DT_VCENTER))
			{
				CRect rcTextHeight(rcText.left, 0, rcText.right, 0);
				pDC->DrawText(pItem->GetCaption(), rcTextHeight, pItem->GetTextAlignment() | DT_CALCRECT);
				rcText.top = (rcText.top + rcText.bottom - rcTextHeight.bottom) / 2;
			}

			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(pItem->GetTextColor() == (COLORREF)-1 ? m_clrText : pItem->GetTextColor());

			pDC->DrawText(pItem->GetCaption(), rcText, pItem->GetTextAlignment());
		}
	}
}
Ejemplo n.º 12
0
void CHeaderCtrlCl::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CHeaderCtrl::OnPaint()
	int nItem; 
	nItem = GetItemCount();//得到有几个单元 
	for(int i = 0; i<nItem;i ++) 
	{ 
		CRect tRect;
		GetItemRect(i,&tRect);//得到Item的尺寸
		int R = m_R,G = m_G,B = m_B;
		CRect nRect(tRect);//拷贝尺寸到新的容器中 
		nRect.left++;//留出分割线的地方 
		//绘制立体背景 
		for(int j = tRect.top;j<=tRect.bottom;j++) 
		{ 
			nRect.bottom = nRect.top+1; 
			CBrush _brush; 
			_brush.CreateSolidBrush(RGB(R,G,B));//创建画刷 
			dc.FillRect(&nRect,&_brush); //填充背景 
			_brush.DeleteObject(); //释放画刷 
			R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
			if (R<0)R = 0;
			if (G<0)G = 0;
			if (B<0)B= 0;
			nRect.top = nRect.bottom; 
		} 
		dc.SetBkMode(TRANSPARENT);
		CFont nFont ,* nOldFont; 
		//dc.SetTextColor(RGB(250,50,50)); 
		dc.SetTextColor(m_color);
		nFont.CreateFont(m_fontHeight,m_fontWith,0,0,0,FALSE,FALSE,0,0,0,0,0,0,_TEXT("宋体"));//创建字体 
		nOldFont = dc.SelectObject(&nFont);

		UINT nFormat = 1;
		if (m_Format[i]=='0')
		{
			nFormat = DT_LEFT;
			tRect.left+=3;
		}
		else if (m_Format[i]=='1')
		{
			nFormat = DT_CENTER;
		}
		else if (m_Format[i]=='2')
		{
			nFormat = DT_RIGHT;
			tRect.right-=3;
		}
		TEXTMETRIC metric;
		dc.GetTextMetrics(&metric);
		int ofst = 0;
		ofst = tRect.Height() - metric.tmHeight;
		tRect.OffsetRect(0,ofst/2);
		dc.DrawText(m_HChar[i],&tRect,nFormat);
		dc.SelectObject(nOldFont); 
		nFont.DeleteObject(); //释放字体 
	} 
	//画头部剩余部分
	CRect rtRect;
	CRect clientRect;
	GetItemRect(nItem - 1,rtRect);
	GetClientRect(clientRect);
	rtRect.left = rtRect.right+1;
	rtRect.right = clientRect.right;
	int R = m_R,G = m_G,B = m_B;
	CRect nRect(rtRect);
	//绘制立体背景 
	for(int j = rtRect.top;j<=rtRect.bottom;j++) 
	{ 
		nRect.bottom = nRect.top+1; 
		CBrush _brush; 
		_brush.CreateSolidBrush(RGB(R,G,B));//创建画刷 
		dc.FillRect(&nRect,&_brush); //填充背景 
		_brush.DeleteObject(); //释放画刷 
		R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
		if (R<0)R = 0;
		if (G<0)G = 0;
		if (B<0)B= 0;
		nRect.top = nRect.bottom; 
	} 
}
Ejemplo n.º 13
0
void CProgressCtrlX::DrawText(const CDrawInfo& info, const CRect &rcMax, const CRect &rcBar)
{
    if(!(info.dwStyle&PBS_TEXTMASK))
        return;
    BOOL fVert = info.dwStyle&PBS_VERTICAL;
    CDC *pDC = info.pDC;
    int nValue = 0;
    CString sFormat;
    GetWindowText(sFormat);
    switch(info.dwStyle&PBS_TEXTMASK)
    {
    case PBS_SHOW_PERCENT:
        if(sFormat.IsEmpty())
            sFormat = "%d%%";
        // retrieve current position and range
        nValue = (int)((float)(info.nCurPos-info.nLower) * 100 / ((info.nUpper-info.nLower == 0) ? 1 : info.nUpper-info.nLower));
        break;
    case PBS_SHOW_POSITION:
        if(sFormat.IsEmpty())
            sFormat = "%d";
        // retrieve current position
        nValue = info.nCurPos;
        break;
    }

    if (sFormat.IsEmpty())
        return;

    CFont* pFont = GetFont();
    CSelFont sf(pDC, pFont);
    CSelTextColor tc(pDC, m_clrTextOnBar);
    CSelBkMode bm(pDC, TRANSPARENT);
    CSelTextAlign	ta(pDC, TA_BOTTOM|TA_CENTER);
    CPoint ptOrg = pDC->GetWindowOrg();
    CString sText;
    sText.Format(sFormat, nValue);

    LONG grad = 0;
    if(pFont)
    {
        LOGFONT lf;
        pFont->GetLogFont(&lf);
        grad = lf.lfEscapement/10;
    }
    int x = 0, y = 0, dx = 0, dy = 0;
    CSize sizText = pDC->GetTextExtent(sText);
    if(grad == 0)         {
        x = sizText.cx;
        y = sizText.cy;
        dx = 0;
        dy = sizText.cy;
    }
    else if(grad == 90)   {
        x = sizText.cy;
        y = sizText.cx;
        dx = sizText.cy;
        dy = 0;
    }
    else if(grad == 180)  {
        x = sizText.cx;
        y = sizText.cy;
        dx = 0;
        dy = -sizText.cy;
    }
    else if(grad == 270)  {
        x = sizText.cy;
        y = sizText.cx;
        dx = -sizText.cy;
        dy = 0;
    }
    else ASSERT(0); // angle not supported
#if 0
    // required "math.h"
    double pi = 3.1415926535;
    double rad = grad*pi/180;
    dx = sz.cy*sin(rad);
    dy = sz.cy*cos(rad);
#endif
    CPoint pt = pDC->GetViewportOrg();
    if(info.dwStyle&PBS_TIED_TEXT)
    {
        CRect rcFill(ConvertToReal(info, rcBar));
        if((fVert ? y : x) <= rcBar.Width())
        {
            pDC->SetViewportOrg(rcFill.left + (rcFill.Width() + dx)/2,
                                rcFill.top + (rcFill.Height() + dy)/2);
            DrawClippedText(info, rcBar, sText, ptOrg);
        }
    }
    else
    {
        pDC->SetViewportOrg(info.rcClient.left + (info.rcClient.Width() + dx)/2,
                            info.rcClient.top + (info.rcClient.Height() + dy)/2);
        if(m_clrTextOnBar == m_clrTextOnBk)
            // if the same color for bar and background draw text once
            DrawClippedText(info, rcMax, sText, ptOrg);
        else
        {
            // else, draw clipped parts of text

            // draw text on gradient
            if(rcBar.left != rcBar.right)
                DrawClippedText(info, rcBar, sText, ptOrg);

            // draw text out of gradient
            if(rcMax.right > rcBar.right)
            {
                tc.Select(m_clrTextOnBk);
                CRect rc(rcMax);
                rc.left = rcBar.right;
                DrawClippedText(info, rc, sText, ptOrg);
            }
            if(rcMax.left < rcBar.left)
            {
                tc.Select(m_clrTextOnBk);
                CRect rc(rcMax);
                rc.right = rcBar.left;
                DrawClippedText(info, rc, sText, ptOrg);
            }
        }
    }
    pDC->SetViewportOrg(pt);
}
Ejemplo n.º 14
0
int MenuFunctions::CalculateMenuWidth(HMENU hMenu)
{
    // create a copy of the font that shoule be used to render a menu
	NONCLIENTMETRICS nm;
	LOGFONT lf;
	CFont menuFont;
    TCHAR menuItemText[_MAX_PATH];

    nm.cbSize = sizeof(NONCLIENTMETRICS);
	VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, nm.cbSize,&nm, 0));
    lf = nm.lfMenuFont;
    menuFont.CreateFontIndirect(&lf);

    CDC dc;

    dc.Attach(::GetDC(NULL));       // get screen DC
    dc.SaveDC();
    dc.SelectObject(&menuFont);

    // look at each item and work out its width
    int maxWidth = 0;
    int itemCount = ::GetMenuItemCount(hMenu);

    for (int item = 0 ; item < itemCount ; item++)
    {
        // get each items data
        int itemWidth = f_iconWidth + f_menuBorder;
	    MENUITEMINFO	itemInfo;
        itemInfo.dwTypeData = menuItemText;
        itemInfo.cch = _MAX_PATH - 1;

	    memset(&itemInfo, 0, sizeof(MENUITEMINFO));
	    itemInfo.cbSize = sizeof(MENUITEMINFO);

	    itemInfo.fMask = MIIM_SUBMENU /*| MIIM_STRING*/;
	    ::GetMenuItemInfo(hMenu, item, TRUE, &itemInfo);

        if (itemInfo.hSubMenu != 0)
        {
            // its a popup menu, include the width of the > arrow
            itemWidth += f_popupArrowSize;
        }
        if (itemInfo.wID == 0)
        {
            // its a separator, dont measure the text
        }
        else
        {
            // measure the text using the font
            CSize textSize;
            CString itemText = menuItemText;
            // expand any tabs in the menu text
            itemText.Replace("\t", "    ");

            textSize = dc.GetTextExtent(itemText);
            itemWidth += textSize.cx;
        }
        if (itemWidth > maxWidth)
        {
            maxWidth = itemWidth;
        }
    }

    dc.RestoreDC(-1);
    ::ReleaseDC(NULL, dc.Detach());
    return maxWidth;
}
Ejemplo n.º 15
0
void CPropertiesWnd::InitPropList()
{
	SetPropListFont();

	m_wndPropList.EnableHeaderCtrl(FALSE);
	m_wndPropList.EnableDescriptionArea();
	m_wndPropList.SetVSDotNetLook();
	m_wndPropList.MarkModifiedProperties();

	CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观"));

	pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框")));

	CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("边框"), _T("Dialog Frame"), _T("其中之一: 无(None)、细(Thin)、可调整大小(Resizable)、对话框外框(Dialog Frame)"));
	pProp->AddOption(_T("None"));
	pProp->AddOption(_T("Thin"));
	pProp->AddOption(_T("Resizable"));
	pProp->AddOption(_T("Dialog Frame"));
	pProp->AllowEdit(FALSE);

	pGroup1->AddSubItem(pProp);
	pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("标题"), (_variant_t) _T("关于"), _T("指定窗口标题栏中显示的文本")));

	m_wndPropList.AddProperty(pGroup1);

	CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("窗口大小"), 0, TRUE);

	pProp = new CMFCPropertyGridProperty(_T("高度"), (_variant_t) 250l, _T("指定窗口的高度"));
	pProp->EnableSpinControl(TRUE, 50, 300);
	pSize->AddSubItem(pProp);

	pProp = new CMFCPropertyGridProperty( _T("宽度"), (_variant_t) 150l, _T("指定窗口的宽度"));
	pProp->EnableSpinControl(TRUE, 50, 200);
	pSize->AddSubItem(pProp);

	m_wndPropList.AddProperty(pSize);

	CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("字体"));

	LOGFONT lf;
	CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
	font->GetLogFont(&lf);

	lstrcpy(lf.lfFaceName, _T("宋体, Arial"));

	pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体")));
	pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("使用系统字体"), (_variant_t) true, _T("指定窗口使用“MS Shell Dlg”字体")));

	m_wndPropList.AddProperty(pGroup2);

	CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("杂项"));
	pProp = new CMFCPropertyGridProperty(_T("(名称)"), _T("应用程序"));
	pProp->Enable(FALSE);
	pGroup3->AddSubItem(pProp);

	CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), NULL, _T("指定默认的窗口颜色"));
	pColorProp->EnableOtherButton(_T("其他..."));
	pColorProp->EnableAutomaticButton(_T("默认"), ::GetSysColor(COLOR_3DFACE));
	pGroup3->AddSubItem(pColorProp);

	static TCHAR BASED_CODE szFilter[] = _T("图标文件(*.ico)|*.ico|所有文件(*.*)|*.*||");
	pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("图标"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("指定窗口图标")));

	pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c:\\")));

	m_wndPropList.AddProperty(pGroup3);

	CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构"));

	CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级"));
	pGroup4->AddSubItem(pGroup41);

	CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级"));
	pGroup41->AddSubItem(pGroup411);

	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明")));
	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明")));
	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明")));

	pGroup4->Expand(FALSE);
	m_wndPropList.AddProperty(pGroup4);
}
Ejemplo n.º 16
0
//»æ»­³ïÂë
void CGoldView::DrawGoldView(CDC * pDC, int nXPos, int nYPos, bool bCount,bool bCenter,BYTE bDUser)
{
	//¼ÓÔØλͼ
	CImageHandle ImageHandle(&m_ImageGold);

	if(!bCenter)
	{
		//»æ»­³ïÂë
		int nYPosDraw=nYPos-GOLD_IMAGE_HEIGHT/2;
		int iDrawCount =0;
		for (LONG i=0;i<CountArray(m_lGoldCount);i++)
		{
			for (LONG j=0;j<m_lGoldCount[i];j++)
			{
				iDrawCount++;
				m_ImageGold.AlphaDrawImage(pDC,nXPos-GOLD_IMAGE_WIDTH/2,nYPosDraw,GOLD_IMAGE_WIDTH,GOLD_IMAGE_HEIGHT,
					(CountArray(m_lGoldCount)-i-1)*GOLD_IMAGE_WIDTH,0,RGB(255,0,255));
				nYPosDraw-=3;
				if(iDrawCount>=m_lMaxLayer)break;
			}
			if(iDrawCount>=m_lMaxLayer)break;
		}
	}
	else //ÖÐÐijïÂë
	{
		//»æ»­³ïÂë
		int nYPosDraw=nYPos-GOLD_IMAGE_HEIGHT/2;
		int nXPosDraw=nXPos-GOLD_IMAGE_HEIGHT/2;
		int iCount = 0,iDrawCount =0;
		int xTemp=0,yTemp=0;
		for (LONG i=0;i<CountArray(m_lGoldCount);i++)
		{
			for (LONG j=0;j<m_lGoldCount[i];j++)
			{
				iDrawCount++;
				m_ImageGold.AlphaDrawImage(pDC,nXPosDraw+xTemp,nYPosDraw+GOLD_IMAGE_HEIGHT/2+2,GOLD_IMAGE_WIDTH,
					GOLD_IMAGE_HEIGHT,(CountArray(m_lGoldCount)-i-1)*GOLD_IMAGE_WIDTH,0,RGB(255,0,255));
				nYPosDraw-=3;
				if(iDrawCount>=m_lMaxLayer)
				{
					iDrawCount=0;
					nYPosDraw=nYPos-GOLD_IMAGE_HEIGHT/2;
					iCount++;
					if(iCount==1)
					{
						xTemp=GOLD_IMAGE_WIDTH;
					}
					else if(iCount==2)
					{
						xTemp=-GOLD_IMAGE_WIDTH;
					}
					else if(iCount==3)
					{
						xTemp=GOLD_IMAGE_WIDTH*2;
					}
					else if(iCount==4)
					{
						xTemp=-GOLD_IMAGE_WIDTH*2;
					}
				}	
			}
		}
	}

	//»æ»­Êý×Ö
	if((m_lGold>=1L)&&(bCount==true))
	{
		CFont ViewFont;			
		if(bCenter)
		{
			ViewFont.CreateFont(-17,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial"));
			pDC->SetTextColor(RGB(255,255,4));
		}
		else 
		{
			ViewFont.CreateFont(-15,0,0,0,400,0,0,0,134,3,2,1,1,TEXT("Arial"));
			pDC->SetTextColor(RGB(255,255,4));
		}
		CFont *pOldFont=pDC->SelectObject(&ViewFont);

		int iBkMode = pDC->SetBkMode( TRANSPARENT );

		TCHAR szBuffer[64]=TEXT("");
		GetGlodString(m_lGold,szBuffer);
		int iY = nYPos+GOLD_IMAGE_HEIGHT/((bCenter)?1:2)+1;
		int iX = (bDUser!=4)?0:62;
		CRect DrawRect(nXPos-50+iX,iY,nXPos+46,iY+12);
		if(bDUser!=4)
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&DrawRect,DT_CENTER|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);
		else 
		{
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&DrawRect,DT_LEFT|DT_VCENTER|DT_NOCLIP|DT_SINGLELINE);
		}
		pDC->SetBkMode(iBkMode);

		pDC->SelectObject(pOldFont);
		ViewFont.DeleteObject();	
	}

	return;
}
Ejemplo n.º 17
0
void XorGate::Draw(CDC* pDC){
	CRect rect(this->base_point.x, this->base_point.y, this->base_point.x + this->GetLength() * 10 - 20, this->base_point.y + this->GetLength() * 10 - 20);
	this->baseRect = rect;
	this->arrow = this->GetArrow();
	VERIFY(radius >= 0);
	VERIFY(radius <= 3);
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap bmp;
	switch (radius){
	case 0:
		bmp.LoadBitmapW(IDB_XOR_0);
		this->outs[0] = CRect(rect.right, (rect.bottom + rect.top) / 2 - 5, rect.right + 10, (rect.bottom + rect.top) / 2 + 5);
		this->ins[0] = CRect(rect.left - 10, (rect.bottom + rect.top) / 2 - 25, rect.left, (rect.bottom + rect.top) / 2 - 15);
		this->ins[1] = CRect(rect.left - 10, (rect.bottom + rect.top) / 2 + 15, rect.left, (rect.bottom + rect.top) / 2 + 25);
		break;
	case 1:
		bmp.LoadBitmapW(IDB_XOR_90);
		this->outs[0] = CRect((rect.left + rect.right) / 2 - 5, rect.bottom - 3, (rect.left + rect.right) / 2 + 5, rect.bottom + 7);
		this->ins[0] = CRect((rect.left + rect.right) / 2 - 25, rect.top - 10, (rect.left + rect.right) / 2 - 15, rect.top);
		this->ins[1] = CRect((rect.left + rect.right) / 2 + 15, rect.top - 10, (rect.left + rect.right) / 2 + 25, rect.top);
		break;
	case 2:
		bmp.LoadBitmapW(IDB_XOR_180);
		this->outs[0] = CRect(rect.left - 5, (rect.bottom + rect.top) / 2 - 5, rect.left + 5, (rect.bottom + rect.top) / 2 + 5);
		this->ins[0] = CRect(rect.right + 5, (rect.bottom + rect.top) / 2 - 25, rect.right + 15, (rect.bottom + rect.top) / 2 - 15);
		this->ins[1] = CRect(rect.right + 5, (rect.bottom + rect.top) / 2 + 15, rect.right + 15, (rect.bottom + rect.top) / 2 + 25);
		break;
	case 3:
		bmp.LoadBitmapW(IDB_XOR_270);
		this->outs[0] = CRect((rect.left + rect.right) / 2 - 5, rect.top - 5, (rect.left + rect.right) / 2 + 5, rect.top + 5);
		this->ins[0] = CRect((rect.left + rect.right) / 2 - 25, rect.bottom, (rect.left + rect.right) / 2 - 15, rect.bottom + 10);
		this->ins[1] = CRect((rect.left + rect.right) / 2 + 15, rect.bottom, (rect.left + rect.right) / 2 + 25, rect.bottom + 10);
		break;

	}
	static_assert(sizeof(int) == sizeof(LONG), "이 플랫폼은 지원하지않습니다.");
	BITMAP bmpinfo;
	bmp.GetBitmap(&bmpinfo);
	memDC.SelectObject(&bmp);
	pDC->TransparentBlt(this->base_point.x, this->base_point.y, 60, 60, &memDC, 0, 0, bmpinfo.bmWidth, bmpinfo.bmHeight, RGB(0, 0, 0));
	CPen pen2;
	pen2.CreatePen(PS_SOLID, 3, RGB(0, 0, 0));
	pDC->SelectObject(pen2);
	switch (radius){
	case 0:
		pDC->MoveTo(outs[0].left, (outs[0].top + outs[0].bottom) / 2);
		pDC->LineTo(outs[0].right - outs[0].Width() / 2, (outs[0].top + outs[0].bottom) / 2);

		pDC->MoveTo(ins[0].left + ins[0].Width() / 2, (ins[0].top + ins[0].bottom) / 2);
		pDC->LineTo(ins[0].right, (ins[0].top + ins[0].bottom) / 2);

		pDC->MoveTo(ins[1].left + ins[1].Width() / 2, (ins[1].top + ins[1].bottom) / 2);
		pDC->LineTo(ins[1].right, (ins[1].top + ins[1].bottom) / 2);
		break;
	case 1:
		pDC->MoveTo((outs[0].left + outs[0].right) / 2, outs[0].top);
		pDC->LineTo(outs[0].right - outs[0].Width() / 2, (outs[0].top + outs[0].bottom) / 2);

		pDC->MoveTo((ins[0].left + ins[0].right) / 2, ins[0].top + ins[0].Height() / 2);
		pDC->LineTo((ins[0].left + ins[0].right) / 2, ins[0].top);

		pDC->MoveTo((ins[1].left + ins[1].right) / 2, ins[1].top + ins[1].Height() / 2);
		pDC->LineTo((ins[1].left + ins[1].right) / 2, ins[1].top);
		break;
	case 2:
		pDC->MoveTo(outs[0].left, (outs[0].top + outs[0].bottom) / 2);
		pDC->LineTo(outs[0].right - outs[0].Width() / 2, (outs[0].top + outs[0].bottom) / 2);

		pDC->MoveTo(ins[0].left, (ins[0].top + ins[0].bottom) / 2);
		pDC->LineTo(ins[0].right - ins[0].Width() / 2, (ins[0].top + ins[0].bottom) / 2);

		pDC->MoveTo(ins[1].left, (ins[1].top + ins[1].bottom) / 2);
		pDC->LineTo(ins[1].right - ins[1].Width() / 2, (ins[1].top + ins[1].bottom) / 2);
		break;
	case 3:
		pDC->MoveTo((outs[0].left + outs[0].right) / 2, outs[0].top);
		pDC->LineTo(outs[0].right - outs[0].Width() / 2, (outs[0].top + outs[0].bottom) / 2);

		pDC->MoveTo((ins[0].left + ins[0].right) / 2, ins[0].top + ins[0].Height() / 2);
		pDC->LineTo((ins[0].left + ins[0].right) / 2, ins[0].top);

		pDC->MoveTo((ins[1].left + ins[1].right) / 2, ins[1].top + ins[1].Height() / 2);
		pDC->LineTo((ins[1].left + ins[1].right) / 2, ins[1].top);
	}
	pen2.DeleteObject();
	//글자를 그립니다
	CFont font;
	font.CreateFont(15,                     // 글자높이
		6,                     // 글자너비
		0,                      // 출력각도
		0,                      // 기준 선에서의각도
		FW_HEAVY,              // 글자굵기
		FALSE,                  // Italic 적용여부
		FALSE,                  // 밑줄적용여부
		FALSE,                  // 취소선적용여부
		DEFAULT_CHARSET,       // 문자셋종류
		OUT_DEFAULT_PRECIS,    // 출력정밀도
		CLIP_DEFAULT_PRECIS,   // 클리핑정밀도
		DEFAULT_QUALITY,       // 출력문자품질
		DEFAULT_PITCH,         // 글꼴Pitch
		_T("Time New Romans")           // 글꼴
		);
	pDC->SelectObject(&font);
	pDC->SetTextColor(RGB(250, 250, 250));
	pDC->SetBkMode(TRANSPARENT);
	pDC->DrawText(this->name, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	font.DeleteObject();
}
Ejemplo n.º 18
0
void CKofBCGPFontComboBox::OnPaint()
{
	if ((GetStyle () & 0x0003L) == CBS_SIMPLE)
	{
		Default ();
		return;
	}

	if (!m_bVisualManagerStyle && !m_bOnGlass)
	{
		Default ();
		return;
	}

	CPaintDC dc(this); // device context for painting
	BYTE alpha = 0;
	if (m_bOnGlass)
	{
		alpha = 255;
	}
	CBCGPMemDC memDC (dc, this, alpha);
	CDC* pDC = &memDC.GetDC ();

	CRect rectClient;
	GetClientRect (rectClient);

	CBCGPDrawManager dm (*pDC);
	dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1);
//  得注释掉这句话
// 	SendMessage (WM_PRINTCLIENT, (WPARAM) pDC->GetSafeHdc (), (LPARAM) PRF_CLIENT);
	const int cxDropDown = ::GetSystemMetrics (SM_CXVSCROLL) + 4;

	int nCurSel = GetCurSel();
	if (CB_ERR != nCurSel)
	{
		if (m_Images.GetSafeHandle () == NULL)
		{
			CBCGPLocalResource locaRes;
			m_Images.Create (IDB_BCGBARRES_FONT, nImageWidth, 0, RGB (255, 255, 255));
		}

		CFont fontSelected;
		CFont* pOldFont = NULL;
		CRect rc(rectClient);		
		rc.right -= cxDropDown;

		CBCGPFontDesc* pDesc = (CBCGPFontDesc*)GetItemDataPtr(nCurSel);
		if (pDesc != NULL)
		{			
			if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE))
			{
				CPoint ptImage (rc.left + 3, rc.top + (rc.Height () - nImageHeight) / 2);
				m_Images.Draw (pDC, pDesc->GetImageIndex (), ptImage, ILD_NORMAL);
			}

			rc.left += nImageWidth + 9;

			if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET)
			{
				LOGFONT lf;
				globalData.fontRegular.GetLogFont (&lf);

				lstrcpy (lf.lfFaceName, pDesc->m_strName);

				if (pDesc->m_nCharSet != DEFAULT_CHARSET)
				{
					lf.lfCharSet = pDesc->m_nCharSet;
				}

				if (lf.lfHeight < 0)
				{
					lf.lfHeight -= 4;
				}
				else
				{
					lf.lfHeight += 4;
				}

				fontSelected.CreateFontIndirect (&lf);
				pOldFont = pDC->SelectObject (&fontSelected);
			}
		}

		CString strText;
		GetLBText (nCurSel, strText);

		pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER);

		if (pOldFont != NULL)
		{
			pDC->SelectObject (pOldFont);
		}
	}

	m_rectBtn = rectClient;
	m_rectBtn.left = m_rectBtn.right - cxDropDown;

	m_rectBtn.DeflateRect (2, 2);

	CBCGPDrawOnGlass dog (m_bOnGlass);

	CKofBCGPToolbarComboBoxButton buttonDummy;
#ifndef _BCGSUITE_
	buttonDummy.m_bIsCtrl = TRUE;

	CBCGPVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#else
	CMFCVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#endif

	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrBarShadow);
	rectClient.DeflateRect (1, 1);
	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrWindow);
}
Ejemplo n.º 19
0
void QnSkinDialog::DrawCaption(CDC* pDC, CRect rcDest, CRect rcSrc, BOOL bActive)
{
	// 画背景
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = memDC.SelectObject(bActive ? m_pThemeDialog->m_pBmpActiveBorder : m_pThemeDialog->m_pBmpInActiveBorder);
	if (pOldBitmap == NULL)
		return;

	//topLeft
	pDC->BitBlt(0, 0, m_pThemeDialog->m_nTopLeft, m_pThemeDialog->m_nToTop, 
		&memDC, 0, 0, SRCCOPY);
	//top
	CRect rc1(m_pThemeDialog->m_nTopLeft, 0, rcDest.Width()-m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop);
	CRect rc2(m_pThemeDialog->m_nTopLeft, 0, rcSrc.Width()-m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop);
	StretchDraw(pDC, &memDC, rc1, rc2);

	//topRight
	pDC->BitBlt(rcDest.right-m_pThemeDialog->m_nTopRight, 0, m_pThemeDialog->m_nTopRight, m_pThemeDialog->m_nToTop, 
		&memDC, rcSrc.right-m_pThemeDialog->m_nTopRight, 0, SRCCOPY);

	memDC.SelectObject(pOldBitmap);
	memDC.DeleteDC();

	// 画其他
	Graphics graph(pDC->m_hDC);
	
	// 画图标
	if (m_pIconImage) {
		if (m_rtIconImage.Width() <= 0) {
			m_rtIconImage.left = 0;
			m_rtIconImage.right = m_pIconImage->GetWidth();
		}
		if (m_rtIconImage.Height() <= 0) {
			m_rtIconImage.top = 0;
			m_rtIconImage.bottom = m_pIconImage->GetHeight();
		}
		int dcy = m_rtIconImage.Height()>=24?4:(24-m_rtIconImage.Height())/2+4;
		graph.DrawImage(m_pIconImage, RectF(m_pThemeDialog->m_nToLeft, dcy, m_rtIconImage.Width(), m_rtIconImage.Height()), 
			m_rtIconImage.left, m_rtIconImage.top, m_rtIconImage.Width(), m_rtIconImage.Height(), UnitPixel);
	}

	// 写标题
	if (_tcslen(m_strTitle)) {
// 		CString str;
// 		GetWindowText( str );
		LOGFONT lf;
		GetFont()->GetLogFont(&lf);
		lf.lfWeight = m_bTitleBold?FW_BOLD:FW_NORMAL;
		lf.lfHeight = 12;
		CFont boldFont;
		boldFont.CreateFontIndirect(&lf);
		CFont *pOldFont = pDC->SelectObject(&boldFont);
 		pDC->SetTextColor(m_clTitle);

		// RGB(158,11,11)
		// RGB(0,70,213)
		pDC->SetBkMode(TRANSPARENT);
		CRect rText = rcDest;
		rText.right -= m_pThemeDialog->m_nToRight;		
		if (m_ptTitle.x < 0 || m_ptTitle.y < 0) {
			rText.top += 4;
			rText.left += m_pThemeDialog->m_nToLeft+m_rtIconImage.Width()+2;
		} else {
			rText.top = m_ptTitle.y;
			rText.left = m_ptTitle.x;
		}
		pDC->DrawText( m_strTitle, rText, DT_SINGLELINE | DT_LEFT | DT_VCENTER |DT_END_ELLIPSIS);
		pDC->SelectObject(pOldFont);
	}

	//画最小与最大与关闭按钮
	DWORD dwStyle = GetWindowLong(m_hWnd, GWL_STYLE);
	if (dwStyle & WS_SYSMENU) {
		UINT nHitTest = 0;
		UINT nButtonState = 0;
		if (m_nDownHitTest) {
			if (m_nDownHitTest == m_nMoveHitTest) {
				nHitTest = m_nDownHitTest;
				nButtonState = 1;
			}
		}
		else if (m_nMoveHitTest) {
			nHitTest = m_nMoveHitTest;
			nButtonState = 2;
		}

		Image* pObjImage;
		CRect rc;

		GetCaptionButtonRect(rc, SC_CLOSE);
		pObjImage = m_pThemeDialog->m_pImageCloseBtn;
		if (nHitTest == HTCLOSE) {
			graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
				rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel);
		} else {
			graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
				0, 0, rc.Width(), rc.Height(), UnitPixel);
		}	
		if ( dwStyle & WS_MAXIMIZEBOX ) {	
			if (IsZoomed())
				pObjImage = m_pThemeDialog->m_pImageRestoreBtn;
			else
				pObjImage = m_pThemeDialog->m_pImageMaxBtn;
				
			GetCaptionButtonRect(rc, SC_MAXIMIZE);

			if (nHitTest == HTMAXBUTTON)
				graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
					rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel);
			else
				graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
					0, 0, rc.Width(), rc.Height(), UnitPixel);
		}
		if ( dwStyle & WS_MINIMIZEBOX ) {
			pObjImage = m_pThemeDialog->m_pImageMinBtn;
			GetCaptionButtonRect(rc, SC_MINIMIZE);
			if (nHitTest == HTMINBUTTON)
				graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
					rc.Width()*nButtonState, 0, rc.Width(), rc.Height(), UnitPixel);
			else
				graph.DrawImage(pObjImage, RectF(rc.left, rc.top, rc.Width(), rc.Height()), 
					0, 0, rc.Width(), rc.Height(), UnitPixel);
		}
	}
	graph.ReleaseHDC(pDC->m_hDC);
}
Ejemplo n.º 20
0
void CPieView::DrawText(CDC* pDc)
{

    CRect rectArea;

    GetClientRect(&rectArea);

    rectArea.top = rectArea.top + DEFAULT_MARGIN;
    rectArea.right = rectArea.right - DEFAULT_MARGIN;
    rectArea.left = rectArea.left + DEFAULT_MARGIN;
    rectArea.bottom = rectArea.bottom - rectArea.Height()*3/5 - DEFAULT_MARGIN;

    CRect Line1, Line2, Line3, Line4, Line5, Line6;
    Line1 = Line2 = Line3 = Line4 =Line5=Line6= rectArea;
    Line1.bottom = rectArea.top + rectArea.Height()/3;
    Line2.top = Line1.bottom;
    Line2.bottom = rectArea.bottom - rectArea.Height()/3;
    Line3.top = Line2.bottom;
    Line4.top=Line3.bottom;
    Line5.top=rectArea.bottom + rectArea.Height()/5;
    Line6.top=Line5.bottom + rectArea.Height()-85;


    CFont FontTitle;
    FontTitle.CreateFont(15, 0, 0, 0, 0, FALSE,FALSE, 0,
                         ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                         DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, _T("Arial"));

    CFont* pOldFont=(CFont*) pDc->SelectObject(&FontTitle);

    CString Title;
    ULARGE_INTEGER temp= {0};

    if (pCapacity.QuadPart > 1024.0*1024.0*1024)
        Title.Format(_T("Capacity: %2.2f GB"), pCapacity.QuadPart/1024.0/1024.0/1024.0);
    else if (pCapacity.QuadPart > 1024.0*1024.0)
        Title.Format(_T("Capacity: %2.2f MB"), pCapacity.QuadPart/1024.0/1024.0);
    else
        Title.Format(_T("Capacity: %2.2f KB"), pCapacity.QuadPart/1024.0);

    pDc->TextOut(Line1.left + DEFAULT_MARGIN + 4.5,
                 Line1.top + DEFAULT_MARGIN,
                 Title);

    if (pUsed.QuadPart > 1024.0*1024.0*1024)
        Title.Format(_T("Used: %2.2f GB"), pUsed.QuadPart/1024.0/1024.0/1024.0);
    else if (pUsed.QuadPart > 1024.0*1024.0)
        Title.Format(_T("Used: %2.2f MB"), pUsed.QuadPart/1024.0/1024.0);
    else
        Title.Format(_T("Used: %2.2f KB"), pUsed.QuadPart/1024.0);

    pDc->TextOut(Line2.left + Line2.Width()/20,
                 Line2.top,
                 Title);

    if (pFree.QuadPart > 1024.0*1024.0*1024)
        Title.Format(_T("Free: %2.2f GB"), pFree.QuadPart/1024.0/1024.0/1024.0);
    else if (pFree.QuadPart > 1024.0*1024.0)
        Title.Format(_T("Free: %2.2f MB"), pFree.QuadPart/1024.0/1024.0);
    else
        Title.Format(_T("Free: %2.2f KB"), pFree.QuadPart/1024.0);

    pDc->TextOut(Line3.left + Line3.Width()/20,
                 Line3.top - DEFAULT_MARGIN,
                 Title);

    if (pOther.QuadPart > 1024.0*1024.0*1024)
        Title.Format(_T("Folder Size: %2.2f GB"), pOther.QuadPart/1024.0/1024.0/1024.0);
    else if (pOther.QuadPart > 1024.0*1024.0)
        Title.Format(_T("Folder Size: %2.2f MB"), pOther.QuadPart/1024.0/1024.0);
    else
        Title.Format(_T("Folder Size: %2.2f KB"), pOther.QuadPart/1024.0);

    pDc->TextOut(Line4.left + Line4.Width()/20,
                 Line4.top - DEFAULT_MARGIN,
                 Title);

    Title.Format(_T("# of folders: %d"), folderCount);
    pDc->TextOut(Line5.left + Line5.Width()/20,
                 Line5.top,
                 Title);

    Title.Format(_T("# of files: %d"), fileCount);
    pDc->TextOut(Line6.left + Line6.Width()/20,
                 Line6.top,
                 Title);

    pDc->SelectObject(pOldFont);

    CBrush UsedBrush, FreeBrush, FolderBrush;
    CRect FreeRect, UsedRect, FolderRect;

    //kockice
    UsedRect.top=Line2.top;
    UsedRect.left=Line2.left + DEFAULT_MARGIN * 2;
    UsedRect.right=UsedRect.left + DEFAULT_MARGIN * 3 - 2;
    UsedRect.bottom=UsedRect.top + DEFAULT_MARGIN * 3 - 2;
    UsedBrush.CreateSolidBrush(USED_RGB);
    pDc->FillRect(&UsedRect,&UsedBrush);

    FreeRect.top=Line3.top - DEFAULT_MARGIN;
    FreeRect.left=Line3.left + DEFAULT_MARGIN * 2;
    FreeRect.right=FreeRect.left + DEFAULT_MARGIN * 3 - 2;
    FreeRect.bottom=FreeRect.top + DEFAULT_MARGIN * 3 - 2;
    FreeBrush.CreateSolidBrush(FREE_RGB);
    pDc->FillRect(&FreeRect,&FreeBrush);

    FolderRect.top=Line4.top - DEFAULT_MARGIN;
    FolderRect.left=Line4.left + DEFAULT_MARGIN * 2;
    FolderRect.right=FolderRect.left + DEFAULT_MARGIN * 3 - 2;
    FolderRect.bottom=FolderRect.top + DEFAULT_MARGIN * 3 - 2;
    FolderBrush.CreateSolidBrush(THIS_RGB);
    pDc->FillRect(&FolderRect,&FolderBrush);
}
Ejemplo n.º 21
0
BOOL CServerWnd::OnInitDialog()
{
	if (theApp.m_fontLog.m_hObject == NULL)
	{
		CFont* pFont = GetDlgItem(IDC_SSTATIC)->GetFont();
		LOGFONT lf;
		pFont->GetObject(sizeof lf, &lf);
		theApp.m_fontLog.CreateFontIndirect(&lf);
	}

	ReplaceRichEditCtrl(GetDlgItem(IDC_MYINFOLIST), this, GetDlgItem(IDC_SSTATIC)->GetFont());
	CResizableDialog::OnInitDialog();

	// using ES_NOHIDESEL is actually not needed, but it helps to get around a tricky window update problem!
	// If that style is not specified there are troubles with right clicking into the control for the very first time!?
#define	LOG_PANE_RICHEDIT_STYLES WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL
	CRect rect;

	GetDlgItem(IDC_SERVMSG)->GetWindowRect(rect);
	GetDlgItem(IDC_SERVMSG)->DestroyWindow();
	::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);
	if (servermsgbox->Create(LOG_PANE_RICHEDIT_STYLES, rect, this, IDC_SERVMSG)){
		servermsgbox->SetProfileSkinKey(_T("ServerInfoLog"));
		servermsgbox->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED);
		servermsgbox->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
		servermsgbox->SetEventMask(servermsgbox->GetEventMask() | ENM_LINK);
		servermsgbox->SetFont(&theApp.m_fontHyperText);
		servermsgbox->ApplySkin();
		servermsgbox->SetTitle(GetResString(IDS_SV_SERVERINFO));

		servermsgbox->AppendText(_T("eMule v") + theApp.m_strCurVersionLong + _T("\n"));
		// MOD Note: Do not remove this part - Merkur
		m_strClickNewVersion = GetResString(IDS_EMULEW) + _T(" ") + GetResString(IDS_EMULEW3) + _T(" ") + GetResString(IDS_EMULEW2);
		servermsgbox->AppendHyperLink(_T(""), _T(""), m_strClickNewVersion, _T(""));
		// MOD Note: end
		servermsgbox->AppendText(_T("\n\n"));
	}

	GetDlgItem(IDC_LOGBOX)->GetWindowRect(rect);
	GetDlgItem(IDC_LOGBOX)->DestroyWindow();
	::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);
	if (logbox->Create(LOG_PANE_RICHEDIT_STYLES, rect, this, IDC_LOGBOX)){
		logbox->SetProfileSkinKey(_T("Log"));
		logbox->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED);
		logbox->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
		if (theApp.m_fontLog.m_hObject)
			logbox->SetFont(&theApp.m_fontLog);
		logbox->ApplySkin();
		logbox->SetTitle(GetResString(IDS_SV_LOG));
		logbox->SetAutoURLDetect(FALSE);
	}

	GetDlgItem(IDC_DEBUG_LOG)->GetWindowRect(rect);
	GetDlgItem(IDC_DEBUG_LOG)->DestroyWindow();
	::MapWindowPoints(NULL, m_hWnd, (LPPOINT)&rect, 2);
	if (debuglog->Create(LOG_PANE_RICHEDIT_STYLES, rect, this, IDC_DEBUG_LOG)){
		debuglog->SetProfileSkinKey(_T("VerboseLog"));
		debuglog->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED);
		debuglog->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
		if (theApp.m_fontLog.m_hObject)
			debuglog->SetFont(&theApp.m_fontLog);
		debuglog->ApplySkin();
		debuglog->SetTitle(SZ_DEBUG_LOG_TITLE);
		debuglog->SetAutoURLDetect(FALSE);
	}

	SetAllIcons();
	Localize();
	serverlistctrl.Init();

	((CEdit*)GetDlgItem(IDC_SPORT))->SetLimitText(5);
	GetDlgItem(IDC_SPORT)->SetWindowText(_T("4661"));

	TCITEM newitem;
	CString name;
	name = GetResString(IDS_SV_SERVERINFO);
	name.Replace(_T("&"), _T("&&"));
	newitem.mask = TCIF_TEXT | TCIF_IMAGE;
	newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name);
	newitem.iImage = 1;
	VERIFY( StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneServerInfo );

	name = GetResString(IDS_SV_LOG);
	name.Replace(_T("&"), _T("&&"));
	newitem.mask = TCIF_TEXT | TCIF_IMAGE;
	newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name);
	newitem.iImage = 0;
	VERIFY( StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneLog );

	name = SZ_DEBUG_LOG_TITLE;
	name.Replace(_T("&"), _T("&&"));
	newitem.mask = TCIF_TEXT | TCIF_IMAGE;
	newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name);
	newitem.iImage = 0;
	VERIFY( StatusSelector.InsertItem(StatusSelector.GetItemCount(), &newitem) == PaneVerboseLog );

	AddAnchor(IDC_SERVLST_ICO, TOP_LEFT);
	AddAnchor(IDC_SERVLIST_TEXT, TOP_LEFT);
	AddAnchor(serverlistctrl, TOP_LEFT, MIDDLE_RIGHT);
	AddAnchor(m_ctrlNewServerFrm, TOP_RIGHT);
	AddAnchor(IDC_SSTATIC4, TOP_RIGHT);
	AddAnchor(IDC_SSTATIC7, TOP_RIGHT);
	AddAnchor(IDC_IPADDRESS, TOP_RIGHT);
	AddAnchor(IDC_SSTATIC3, TOP_RIGHT);
	AddAnchor(IDC_SNAME, TOP_RIGHT);
	AddAnchor(IDC_ADDSERVER, TOP_RIGHT);
	AddAnchor(IDC_SSTATIC5, TOP_RIGHT);
	AddAnchor(m_ctrlMyInfoFrm, TOP_RIGHT, BOTTOM_RIGHT);
	AddAnchor(m_MyInfo, TOP_RIGHT, BOTTOM_RIGHT);
	AddAnchor(IDC_SPORT, TOP_RIGHT);
	AddAnchor(m_ctrlUpdateServerFrm, TOP_RIGHT);
	AddAnchor(IDC_SERVERMETURL, TOP_RIGHT);
	AddAnchor(IDC_UPDATESERVERMETFROMURL, TOP_RIGHT);
	AddAnchor(StatusSelector, MIDDLE_LEFT, BOTTOM_RIGHT);
	AddAnchor(IDC_LOGRESET, MIDDLE_RIGHT); // avoid resizing GUI glitches with the tab control by adding this control as the last one (Z-order)
	AddAnchor(IDC_ED2KCONNECT, TOP_RIGHT);
	AddAnchor(IDC_DD, TOP_RIGHT);
	// The resizing of those log controls (rich edit controls) works 'better' when added as last anchors (?)
	AddAnchor(*servermsgbox, MIDDLE_LEFT, BOTTOM_RIGHT);
	AddAnchor(*logbox, MIDDLE_LEFT, BOTTOM_RIGHT);
	AddAnchor(*debuglog, MIDDLE_LEFT, BOTTOM_RIGHT);

	// Set the tab control to the bottom of the z-order. This solves a lot of strange repainting problems with
	// the rich edit controls (the log panes).
	::SetWindowPos(StatusSelector, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOSIZE);

	debug = true;
	ToggleDebugWindow();

	debuglog->ShowWindow(SW_HIDE);
	logbox->ShowWindow(SW_HIDE);
	servermsgbox->ShowWindow(SW_SHOW);

	// optional: restore last used log pane
	if (thePrefs.GetRestoreLastLogPane())
	{
		if (thePrefs.GetLastLogPaneID() >= 0 && thePrefs.GetLastLogPaneID() < StatusSelector.GetItemCount())
		{
			int iCurSel = StatusSelector.GetCurSel();
			StatusSelector.SetCurSel(thePrefs.GetLastLogPaneID());
			if (thePrefs.GetLastLogPaneID() == StatusSelector.GetCurSel())
				UpdateLogTabSelection();
			else
				StatusSelector.SetCurSel(iCurSel);
		}
	}

	m_MyInfo.SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
	m_MyInfo.SetAutoURLDetect();
	m_MyInfo.SetEventMask(m_MyInfo.GetEventMask() | ENM_LINK);

	PARAFORMAT pf = {0};
	pf.cbSize = sizeof pf;
	if (m_MyInfo.GetParaFormat(pf)){
		pf.dwMask |= PFM_TABSTOPS;
		pf.cTabCount = 4;
		pf.rgxTabs[0] = 900;
		pf.rgxTabs[1] = 1000;
		pf.rgxTabs[2] = 1100;
		pf.rgxTabs[3] = 1200;
		m_MyInfo.SetParaFormat(pf);
	}

	m_cfDef.cbSize = sizeof m_cfDef;
	if (m_MyInfo.GetSelectionCharFormat(m_cfDef)){
		m_cfBold = m_cfDef;
		m_cfBold.dwMask |= CFM_BOLD;
		m_cfBold.dwEffects |= CFE_BOLD;
	}

	if (thePrefs.GetUseAutocompletion()){
		m_pacServerMetURL = new CCustomAutoComplete();
		m_pacServerMetURL->AddRef();
		if (m_pacServerMetURL->Bind(::GetDlgItem(m_hWnd, IDC_SERVERMETURL), ACO_UPDOWNKEYDROPSLIST | ACO_AUTOSUGGEST | ACO_FILTERPREFIXES ))
			m_pacServerMetURL->LoadList(thePrefs.GetMuleDirectory(EMULE_CONFIGDIR) + SERVERMET_STRINGS_PROFILE);
		if (theApp.m_fontSymbol.m_hObject){
			GetDlgItem(IDC_DD)->SetFont(&theApp.m_fontSymbol);
			GetDlgItem(IDC_DD)->SetWindowText(_T("6")); // show a down-arrow
		}
	}
	else
		GetDlgItem(IDC_DD)->ShowWindow(SW_HIDE);

	InitWindowStyles(this);

	// splitter
	CRect rcSpl;
	rcSpl.left = 55;
	rcSpl.right = 300;//rcDlgItem.right;
	rcSpl.top = 55;
	rcSpl.bottom = rcSpl.top + SVWND_SPLITTER_HEIGHT;
	m_wndSplitter.Create(WS_CHILD | WS_VISIBLE, rcSpl, this, IDC_SPLITTER_SERVER);
	m_wndSplitter.SetDrawBorder(true);
	InitSplitter();

	return true;
}
Ejemplo n.º 22
0
void CSkinHeaderCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CRect					rect, rectItem, clientRect;

	GetClientRect(&rect);
	GetClientRect(&clientRect);

	CMemDC					memDC(&dc, rect);
	CDC						bitmapDC;

	bitmapDC.CreateCompatibleDC(&dc);
	
	memDC.FillSolidRect(&rect, RGB(76,85,118));

	CBitmap					bitmapSpan;

	bitmapSpan.LoadBitmap(IDB_COLUMNHEADER_SPAN);

	CBitmap					*pOldBitmapSpan = bitmapDC.SelectObject(&bitmapSpan);

	memDC.StretchBlt(2, 0, rect.Width(), 40, &bitmapDC, 0, 0, 1, 40, SRCCOPY);

	bitmapDC.SelectObject(pOldBitmapSpan);
	bitmapSpan.DeleteObject();
	
	int						nItems = GetItemCount();

	CBitmap					bitmap3;
	
	bitmap3.LoadBitmap(IDB_COLUMNHEADER_END);

	for(int i = 0; i <nItems; i++)
	{		
		TCHAR					buf1[256];
		HD_ITEM					hditem1;
		
		hditem1.mask = HDI_TEXT | HDI_FORMAT | HDI_ORDER;
		hditem1.pszText = buf1;
		hditem1.cchTextMax = 255;

		GetItem(i, &hditem1);
		
		GetItemRect(i, &rect);
		
/*		CBitmap* pOldBitmap = NULL;
		
		//make sure we draw the start piece
		//on the first item so it has a left border

		//For the following items we will just use the
		//right border of the previous items as the left
		//border
		if(hditem1.iOrder==0)
		{
			pOldBitmap = bitmapDC.SelectObject(&bitmap);
			memDC.BitBlt(rect.left,rect.top,2,12,&bitmapDC,0,0,SRCCOPY);
		}
		else
		{
			memDC.BitBlt(rect.left-1,rect.top,2,12,&bitmapDC,0,0,SRCCOPY);
			pOldBitmap = bitmapDC.SelectObject(&bitmap2);
			memDC.BitBlt(rect.left+1,rect.top,1,12,&bitmapDC,0,0,SRCCOPY);
		}

		bitmapDC.SelectObject(pOldBitmap);
		
		//span the bitmap for the width of the column header item
		int nWidth = rect.Width() - 4;
		
		CBitmap* pOldBitmap2 = bitmapDC.SelectObject(&bitmap2);
		
		memDC.StretchBlt(rect.left+2, 0, nWidth, 1, &bitmapDC, 0,0, 1, 12, SRCCOPY);

		bitmapDC.SelectObject(pOldBitmap2);
*/		
		
		//draw the end piece of the column header
		CBitmap					*pOldBitmap3 = bitmapDC.SelectObject(&bitmap3);

		//memDC.BitBlt((rect.right - 2), 0, 2, 12, &bitmapDC, 0, 0, SRCCOPY);
		memDC.StretchBlt((rect.right-1), 0, 2, 40, &bitmapDC, 0, 0,2,40, SRCCOPY);

		bitmapDC.SelectObject(pOldBitmap3);
		
		//Get all the info for the current
		//item so we can draw the text to it
		//in the desired font and style
		DRAWITEMSTRUCT			DrawItemStruct;

		GetItemRect(i, &rectItem);
				
		DrawItemStruct.CtlType = 100;
		DrawItemStruct.hDC = dc.GetSafeHdc();
		DrawItemStruct.itemAction = ODA_DRAWENTIRE; 
		DrawItemStruct.hwndItem = GetSafeHwnd(); 
		DrawItemStruct.rcItem = rectItem;
		DrawItemStruct.itemID = i;

		DrawItem(&DrawItemStruct);
		
		UINT					uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_TOP |DT_CENTER;
						
		CFont					font;
		LOGFONT					lf;

		memset(&lf, 0, sizeof(LOGFONT));
		
		//폰트의 속성 지정.
		lf.lfHeight = 22;
		lf.lfWeight = FW_BOLD;
		//strcpy(lf.lfFaceName, "Sevenet 7");

		font.CreateFontIndirect(&lf);

		CFont					*def_font = memDC.SelectObject(&font);
		
		memDC.SetBkMode(TRANSPARENT);
		memDC.SetTextColor(RGB(128, 128, 0));

		// 폰트의 세로 맞춤.
		//rectItem.DeflateRect(2, 2, 2, 2);
		rectItem.DeflateRect(2, 2, 2, 2);
		
		TCHAR					buf[256];
		HD_ITEM					hditem;
		
		hditem.mask = HDI_TEXT | HDI_FORMAT | HDI_ORDER;
		hditem.pszText = buf;
		hditem.cchTextMax = 255;

		GetItem(DrawItemStruct.itemID, &hditem);

		memDC.DrawText(buf, &rectItem, uFormat);

		memDC.SelectObject(def_font);
		font.DeleteObject();
	}		
}
Ejemplo n.º 23
0
/***************************************************
StartDropList
	This internal function is used to parse out 
	the label string, which contains the items to 
	show in the list.  Also this function will
	show the list box in the proper location on the
	screen.
Params:
	<none>
Return:
	UG_ERROR	- the list is already visible.
	UG_SUCCESS	- everything went smoothly, the drop
				  list was shown
***************************************************/
int CUGDropListType::StartDropList()
{
	RECT		rect;
	RECT		clientRect;
	int			dif,len,pos,startpos;
	CFont *		font = NULL;
	LOGFONT		lf;
	CFont *		cfont;
	CStringList list;	  //lists of strings for the list are assembed here
	CString *	items;	  //points to the string used to assemble the list

	//return false if it is already up
	if(	m_listBox->m_HasFocus)
		return UG_ERROR;

	CUGCell cell;
	m_ctrl->GetCellIndirect(m_btnCol,m_btnRow,&cell);

	// make sure that the read only cells do not show droplist
	if ( cell.GetReadOnly() == TRUE )
		return UG_SUCCESS;

	//get the current row and col
	m_btnCol  = m_ctrl->GetCurrentCol();
	m_btnRow = m_ctrl->GetCurrentRow();

	//add the strings to the CStringList
	CString string;
	cell.GetLabelText(&string);
	items = &string;
	len = items->GetLength();
	pos =0;
	startpos =0;
	while(pos <len){
		if(items->GetAt(pos)== _T('\n')){
			list.AddTail(items->Mid(startpos,pos-startpos));
			startpos = pos+1;
		}
		pos++;
	}

	//notify the user of the list, so it can be modified if needed
	if ( OnCellTypeNotify(m_ID,m_btnCol,m_btnRow,UGCT_DROPLISTSTART,(LONG_PTR)&list) == FALSE )
		// if FALSE was returned from OnCellTypeNotify call, than the developer does not
		// wish to show the drop list at the moment.
		return UG_ERROR;
	
	// set default font height
	lf.lfHeight = 12;

	//get the font
	if(cell.IsPropertySet(UGCELL_FONT_SET))
		font = cell.GetFont();
	else if(m_ctrl->m_GI->m_defFont != NULL)
		font = m_ctrl->m_GI->m_defFont;
	
	if(font == NULL)
		font = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FONT));

	if(font != NULL)
	{
		//find the height of the font
		cfont = font;
		cfont->GetLogFont(&lf); 	// lf.lfHeight

		if( lf.lfHeight < 0 ){
			HDC hDC = CreateCompatibleDC(NULL);
			lf.lfHeight = -MulDiv(lf.lfHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);
			DeleteDC(hDC);
		}
	}

	//get the rectangle for the listbox
	m_ctrl->GetCellRect(m_btnCol,m_btnRow,&rect);
	rect.top = rect.bottom;
	rect.left+=10;
	rect.right+=10;
	len = (int)list.GetCount();
	if(len >15)
		len = 15;
	rect.bottom += lf.lfHeight * len + 6;
	
	m_ctrl->m_CUGGrid->GetClientRect(&clientRect);
	if(rect.bottom > clientRect.bottom){
		dif = rect.bottom - clientRect.bottom;
		rect.bottom -= dif;
		rect.top -= dif;
		if(rect.top <0)
			rect.top = 0;
	}
	if(rect.right > clientRect.right){
		dif = rect.right - clientRect.right;
		rect.right -= dif;
		rect.left -= dif;
		if(rect.left <0)
			rect.left = 0;
	}

	//create the CListBox
	m_listBox->m_ctrl = m_ctrl;
	m_listBox->m_cellType = this;
	m_listBox->m_cellTypeId = m_ID;
	m_listBox->Create(WS_CHILD|WS_BORDER|WS_VSCROLL,rect,m_ctrl->m_CUGGrid,123);
	
	//set up the font
	if(font != NULL)
		m_listBox->SetFont(font);

	// v7.2 - update 03 - this works to eliminate blank lines that 
	// can occur with odd sized fonts/number of items. Fix courtesy Gerbrand 
	// .start
	int itHeight = m_listBox->GetItemHeight(0);   
	if (len > 15)      
		len = 15;   
	rect.bottom = rect.top + len * itHeight + 6;   
	if(rect.bottom > clientRect.bottom){      
		dif = rect.bottom - clientRect.bottom;      
		rect.bottom -= dif;      
		rect.top -= dif;      
		if(rect.top <0)         
			rect.top = 0;   
	}   
	
	// v7.2 - update 03 - Adjust the rect width to accomodate the largest string
	//			Allen Shiels
	dif = GetMaxStringWidth(list) - (rect.right-rect.left);	
	if (dif > 0) {		
		if (len >= 15) // add a scroll bar width if max items in list
			dif += GetSystemMetrics(SM_CXVSCROLL);		
		rect.right += dif;	
	}

	if(rect.right > clientRect.right){      
		dif = rect.right - clientRect.right;      
		rect.right -= dif;      
		rect.left -= dif;      
		if(rect.left <0)         
			rect.left = 0;   
	}
	// .end
	
	//resize the window again since a new font is being used
	m_listBox->MoveWindow(&rect,FALSE);

	//add the items to the list
	len = (int)list.GetCount();
	POSITION position = list.GetHeadPosition();
	pos =0;
	while(pos < len){
		m_listBox->AddString(list.GetAt(position));
		pos++;
		if(pos < len)
			list.GetNext(position);
	}

	//give the list box pointers to the cell
	m_listBox->m_col = &m_btnCol;
	m_listBox->m_row = &m_btnRow;

	m_listBox->ShowWindow(SW_SHOW);
	m_listBox->SetFocus();
	
	m_btnDown = FALSE;
	m_ctrl->RedrawCell(m_btnCol,m_btnRow);

	return UG_SUCCESS;
}
Ejemplo n.º 24
0
BOOL CAucma_HeaterDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	// 载入图标到图片句柄
	m_bmpHeatFastOn.LoadBitmap(IDB_HEATFAST_ON);
	m_bmpHeatFastOff.LoadBitmap(IDB_HEATFAST_OFF);
	m_bmpWinterOn.LoadBitmap(IDB_WINTER_ON);
	m_bmpWinterOff.LoadBitmap(IDB_WINTER_OFF);
	m_bmpHelperOn.LoadBitmap(IDB_HELPER_ON);
	m_bmpHelperOff.LoadBitmap(IDB_HELPER_OFF);
	m_bmpWashHandOn.LoadBitmap(IDB_WASHHAND_ON);
	m_bmpWashHandOff.LoadBitmap(IDB_WASHHAND_OFF);
	m_bmpNightModeOn.LoadBitmap(IDB_NIGHT_ON);
	m_bmpNightModeOff.LoadBitmap(IDB_NIGHT_OFF);
	m_bmpTempOff.LoadBitmap(IDB_TEMP_OFF);
	m_bmpTempInsulation.LoadBitmap(IDB_TEMP_INSULATION);
	m_bmpTempHeat1.LoadBitmap(IDB_TEMP_HEAT_1);
	m_bmpTempHeat2.LoadBitmap(IDB_TEMP_HEAT_2);
	m_bmpTempHeat3.LoadBitmap(IDB_TEMP_HEAT_3);
	m_bmpPowerOn.LoadBitmap(IDB_POWER_ON);
	m_bmpPowerOff.LoadBitmap(IDB_POWER_OFF);
	for (int i=0; i<10; i++)
	{
		m_bmpTempShow[i].LoadBitmap(IDB_TEMP_0 + i);
		m_bmpTempSet[i].LoadBitmap(IDB_TEMP_LIGHT_0 + i);
		m_bmpTimeShow[i].LoadBitmap(IDB_TIME_0 + i);
		m_bmpTimeSet[i].LoadBitmap(IDB_TIME_LIGHT_0 + i);
	}
	m_bmpAdd.LoadBitmap(IDB_ADD);
	m_bmpReduce.LoadBitmap(IDB_REDUCE);
	m_bmpTimeLabel.LoadBitmap(IDB_TIME_LABEL);
	// 创建背景刷子
	m_brushBk.CreateSolidBrush(DialogBkColor);

	CFont* pfont = NULL;
	LOGFONT logFont;
	LONG lfHeight = 0;
	pfont = GetDC()->GetCurrentFont();
	memset(&logFont, 0, sizeof(LOGFONT));
	pfont->GetLogFont(&logFont);
	lfHeight = logFont.lfHeight;
	VERIFY(m_FontDefault.CreateFontIndirect(&logFont));
	logFont.lfHeight = lfHeight * 6 / 7;
	VERIFY(m_FontWinter.CreateFontIndirect(&logFont));
	logFont.lfHeight = lfHeight * 3 / 2;
	VERIFY(m_FontTemp.CreateFontIndirect(&logFont));
	// 对话框最大化显示
//	ShowWindow(SW_SHOWMAXIMIZED);
	int iFullWidth = GetSystemMetrics(SM_CXSCREEN);
	int iFullHeight = GetSystemMetrics(SM_CYSCREEN);
	::SetWindowPos(this->m_hWnd, HWND_TOPMOST, 0, 0, iFullWidth, iFullHeight, SWP_NOOWNERZORDER|SWP_SHOWWINDOW);
	
	CRect rect;
	GetClientRect(rect);
	m_rectHeatFastPic = OnSetRect(40, 10, 48, 48);
	m_rectHeatFastText = OnSetRect(40, 58, 48, 14);
	m_rectWinterPic = OnSetRect(92, 34, 24, 24);
	m_rectWinterText = OnSetRect(92, 58, 24, 12);
	m_rectHelperPic = OnSetRect(40, 82, 48, 48);
	m_rectHelperText = OnSetRect(40, 130, 48, 14);
	m_rectWashHandPic = OnSetRect(40, 154, 48, 48);
	m_rectWashHandText = OnSetRect(40, 202, 48, 14);
	m_rectNightModePic = OnSetRect(390, 10, 48, 48);
	m_rectNightModeText = OnSetRect(390, 58, 48, 14);
	m_rectTempPic = OnSetRect(402, 82, 24, 48);
	m_rectTempInsulationText = OnSetRect(384, 130, 24, 14);
	m_rectTempHeatText = OnSetRect(420, 130, 24, 14);
	m_rectPowerPic = OnSetRect(390, 160, 48, 48);
	m_rectTempHighPic = OnSetRect(179, 10, 72, 108);
	m_rectTempLowPic = OnSetRect(255, 10, 72, 108);
	m_rectTemp = OnSetRect(179, 10, 148, 108);
	m_rectTempLabelText = OnSetRect(327, 10, 20, 20);
	m_rectAdd = OnSetRect(227, 122, 24, 24);
	m_rectReduce = OnSetRect(255, 122, 24, 24);
	m_rectTimeLabelPic = OnSetRect(245, 154, 16, 48);
	m_rectHourHighPic = OnSetRect(179, 154, 32, 48);
	m_rectHourLowPic = OnSetRect(213, 154, 32, 48);
	m_rectMinHighPic = OnSetRect(261, 154, 32, 48);
	m_rectMinLowPic = OnSetRect(295, 154, 32, 48);
	m_rectTime = OnSetRect(179, 154, 148, 48);
	m_CurrTime = CTime::GetCurrentTime();
	SetTimer(ShowTimeTimerEvent, ShowTimeTimeSet, NULL);
	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
}
Ejemplo n.º 25
0
void CPropertiesWnd::InitPropList()
{
	SetPropListFont();

	m_wndPropList.EnableHeaderCtrl(FALSE);
	m_wndPropList.EnableDescriptionArea();
	m_wndPropList.SetVSDotNetLook();
	m_wndPropList.MarkModifiedProperties();

	CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("Appearance"));

	pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the window's font will be non-bold and controls will have a 3D border")));

	CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame"));
	pProp->AddOption(_T("None"));
	pProp->AddOption(_T("Thin"));
	pProp->AddOption(_T("Resizable"));
	pProp->AddOption(_T("Dialog Frame"));
	pProp->AllowEdit(FALSE);

	pGroup1->AddSubItem(pProp);
	pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the window's title bar")));

	m_wndPropList.AddProperty(pGroup1);

	CMFCPropertyGridProperty* pSize = new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE);

	pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the window's height"));
	pProp->EnableSpinControl(TRUE, 50, 300);
	pSize->AddSubItem(pProp);

	pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the window's width"));
	pProp->EnableSpinControl(TRUE, 50, 200);
	pSize->AddSubItem(pProp);

	m_wndPropList.AddProperty(pSize);

	CMFCPropertyGridProperty* pGroup2 = new CMFCPropertyGridProperty(_T("Font"));

	LOGFONT lf;
	CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
	font->GetLogFont(&lf);

	lstrcpy(lf.lfFaceName, _T("Arial"));

	pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the window")));
	pGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the window uses MS Shell Dlg font")));

	m_wndPropList.AddProperty(pGroup2);

	CMFCPropertyGridProperty* pGroup3 = new CMFCPropertyGridProperty(_T("Misc"));
	pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("Application"));
	pProp->Enable(FALSE);
	pGroup3->AddSubItem(pProp);

	CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default window color"));
	pColorProp->EnableOtherButton(_T("Other..."));
	pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
	pGroup3->AddSubItem(pColorProp);

	static const TCHAR szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||");
	pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the window icon")));

	pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\")));

	m_wndPropList.AddProperty(pGroup3);

	CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("Hierarchy"));

	CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level"));
	pGroup4->AddSubItem(pGroup41);

	CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level"));
	pGroup41->AddSubItem(pGroup411);

	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description")));
	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description")));
	pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description")));

	pGroup4->Expand(FALSE);
	m_wndPropList.AddProperty(pGroup4);
}
Ejemplo n.º 26
0
bool CChildView::GLLoadFont()
{
	CFont    ThisFont;
	CFont*   pOldFont;

	int l;

	CPaintDC dc(this); // device context for painting
	HDC hDC = dc.m_hDC;
	wglMakeCurrent(dc.m_hDC,m_hRC);

	CFont TempFont;
	LOGFONT lf;
 
	if(!TempFont.CreatePointFont(85, "Courier New"))
	{
//		AfxMessageBox("Font Courrier New is not present\n switching to Courier Font");
		if(!TempFont.CreatePointFont(85, "Courier"))
		{
//			AfxMessageBox("Couldn't find Courier font either. Exiting...");
		TempFont.CreateFont(
			12,                        // nHeight
			8,                         // nWidth
			0,                         // nEscapement
			0,                         // nOrientation
			FW_NORMAL,                 // nWeight
			FALSE,                     // bItalic
			FALSE,                     // bUnderline
			0,                         // cStrikeOut
			ANSI_CHARSET,              // nCharSet
			OUT_DEFAULT_PRECIS,        // nOutPrecision
			CLIP_DEFAULT_PRECIS,       // nClipPrecision
			DEFAULT_QUALITY,           // nQuality
			FIXED_PITCH | FF_MODERN,  // nPitchAndFamily
			"DefaultFont");                 // lpszFacename
		}
	}

	TempFont.GetLogFont(&lf);
	lf.lfHeight = m_WndLogFont.lfHeight;
	if(!ThisFont.CreateFontIndirect(&lf))
	{
		AfxMessageBox("Couldn't create indirect Font. Exiting...");
		return false;
	}
	pOldFont = dc.SelectObject(&ThisFont);


	if(!wglUseFontBitmaps(hDC, 0,255, GLF_START_LIST))
	{
		AfxMessageBox("Couldn't create GL Font Bitmaps. Exiting...");
		return false;
	}

	MAT2 m2 = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; 
	GLYPHMETRICS gm;

	m_LetterWidth = 0;
	DWORD res;
	for (l=42; l<122; l++)
	{
		res = dc.GetGlyphOutline(l, 0, &gm, 0, NULL, &m2);
		if(res==-1)
		{
			AfxMessageBox("Couldn't create GL Glyph Outline. Exiting...");
			return false;
		}
		m_LetterWidth = max (m_LetterWidth,(int)(gm.gmBlackBoxX));
	}

	dc.SelectObject(pOldFont);
	wglMakeCurrent(dc.m_hDC,NULL);
	return true;
}
Ejemplo n.º 27
0
LRESULT CSVGElementListView::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	CPaintDC dc(m_hWnd);

	long scrollposY; m_vert->get_pos(&scrollposY);

	if (dc.IntersectClipRect(&m_areaRect) > NULLREGION)
	{
		dc.SetViewportOrg(m_areaRect.left, m_areaRect.top -scrollposY);

		HFONT hOldFont = dc.GetCurrentFont();

		CFont font = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		LOGFONT lf;
		font.GetLogFont(&lf);
		lf.lfWeight = FW_BOLD;

		CFont boldFont;
		boldFont.CreateFontIndirect(&lf);

		dc.SetBkMode(TRANSPARENT);

		int itemHeight = (m_view == 0 || m_view == 2)? SMALL: LARGE;

		int ncolumns = m_areaRect.Width()/itemHeight;
		if (ncolumns == 0) ncolumns = 1;

		for (int i = 0; i < m_items.GetSize(); i++)
		{
			int x, y;
			int x2, y2;
			int twidth, theight;

			if (m_view == 0 || m_view == 1)	// Small/Large Thumbnails
			{
				x = i%ncolumns *itemHeight;
				y = i/ncolumns *itemHeight;

				x2 = x+3;
				y2 = y+3;

				twidth = itemHeight-6;
				theight = itemHeight-6;
			}
			else	// Small/Large ListView
			{
				x = 0;
				y = i*itemHeight;

				x2 = x+3;
				y2 = y+3;

				twidth = itemHeight-6;
				theight = itemHeight-6;
			}

			bool bSelected = IsItemSelected(m_items[i]);

			_bstr_t id;
			/*
			if (m_items[i]->m_element)
			{
				BSTR bid;
				m_items[i]->m_element->getAttribute(L"id", &bid);
				id = _bstr_t(bid, false);
			}
			else
				*/
			{
				id = m_items[i]->m_name;
			}

			if (m_view == 2 || m_view == 3)	// Small/Large Listview, display id
			{
				dc.MoveTo(0, y);
				dc.LineTo(m_areaRect.Width(), y);

				dc.FillSolidRect(0, y+1, m_areaRect.Width(), itemHeight-1, GetSysColor(COLOR_WINDOW));

				dc.Draw3dRect(x2-1, y2-1, twidth+2, theight+2, RGB(0, 0, 0), RGB(0, 0, 0));

				if (bSelected)
				{
					dc.SelectFont(boldFont);
					dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
					dc.SetBkColor(GetSysColor(COLOR_HIGHLIGHT));

					dc.FillSolidRect(0, y+2, m_areaRect.Width(), itemHeight-3, dc.GetBkColor());
				}
				else
				{
					dc.SelectFont(font);
					dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
					dc.SetBkColor(GetSysColor(COLOR_WINDOW));
				}

				CRect trect(itemHeight+2, y+3, m_areaRect.Width(), y+itemHeight-3);
				dc.DrawText(id, id.length(), &trect, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS);
			}
			else	// Thumbnails
			{
				dc.Draw3dRect(x, y, itemHeight, itemHeight, RGB(0, 0, 0), RGB(0, 0, 0));

				if (bSelected)
				{
					dc.Draw3dRect(x+2, y+2, itemHeight-4, itemHeight-4, RGB(0,0,0), RGB(0,0,0));
				}
			}

			DRAWITEMSTRUCT dis;
			dis.hDC = dc.m_hDC;
			dis.rcItem = CRect(x2, y2, x2+twidth, y2+theight);
			dis.itemData = (ULONG_PTR)m_items[i];
			::SendMessage(GetParent(), WM_DRAWITEM, 0, (LPARAM)&dis);
		}

		dc.SelectFont(hOldFont);
	}

	return 0;
}
Ejemplo n.º 28
0
void CTScreenDevice::TwipsCacheFlushL()
	{
	RWsSession session;
	CWsScreenDevice* device;
	CFont* font;
	CFont* font2;
	const TFontSpec fontspec(KTestFontTypefaceName,250);
	TPixelsTwipsAndRotation sizeAndRotation;

	// create a CWsScreenDevice instance
	User::LeaveIfError(session.Connect());
	device=new(ELeave) CWsScreenDevice(session);
	device->Construct(iTest->iScreenNumber);

	// Record a font height for use by latter tests
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
	const TInt height0=font->HeightInPixels();
	device->ReleaseFont(font);

	// 1. find font with best-matching height in twips,
	// 2. change twips size of the screen (leaving pixel-size same),
	// 3. find font with best-matching height in twips,
	// 4. make sure that the newly found font is not the same as previous and has the different height in pixels
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
#if defined(EXTRA_LOGGING)
	_LIT(KLog1,"Font height: %d for unchanged device.   pixels=%d,%d  twips=%d,%d");
	LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
						,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
#endif
	sizeAndRotation.iTwipsSize.iHeight=2000;
	sizeAndRotation.iTwipsSize.iWidth =3000;
	device->SetScreenSizeAndRotation(sizeAndRotation);

	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
	TInt height=font->HeightInPixels();
#if defined(EXTRA_LOGGING)
	_LIT(KLog2,"Font height: %d for device with twips set to 2000x3000");
	LOG_MESSAGE2(KLog2,height);
#endif
	TFontSpec returnedSpec=font->FontSpecInTwips();

	sizeAndRotation.iTwipsSize.iHeight=4000;
	sizeAndRotation.iTwipsSize.iWidth =6000;
	device->SetScreenSizeAndRotation(sizeAndRotation);

	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
	TInt height2=font2->HeightInPixels();
	TFontSpec returnedSpec2 = font2->FontSpecInTwips();
#if defined(EXTRA_LOGGING)
	_LIT(KLog3,"Font height: %d for device with twips set to 4000x6000");
	LOG_MESSAGE2(KLog3,height2);
#endif

	TEST(font!=font2);
	TEST(height!=height2);
	_LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d");
	if (height==height2)
		INFO_PRINTF2(KLogErrM,height);

	device->ReleaseFont(font2);
	device->ReleaseFont(font);

	// 1. find font with best-matching height in twips,
	// 2. change pixel size of the screen (leaving twip-size same),
	// 3. find font with best-matching height in twips,
	// 4. make sure that the newly found font is not the same as previous and has the different height in pixels
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
	sizeAndRotation.iPixelSize.iHeight=240;
	sizeAndRotation.iPixelSize.iWidth =640;
	device->SetScreenSizeAndRotation(sizeAndRotation);

	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
	height=font->HeightInPixels();
	returnedSpec=font->FontSpecInTwips();
#if defined(EXTRA_LOGGING)
	_LIT(KLog4,"Font height: %d for device with pixels set to 240x640   twips=%d,%d");
	LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
#endif

	sizeAndRotation.iPixelSize.iHeight=480;
	sizeAndRotation.iPixelSize.iWidth =1280;
	device->SetScreenSizeAndRotation(sizeAndRotation);

	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
	height2=font2->HeightInPixels();
	returnedSpec2=font2->FontSpecInTwips();
#if defined(EXTRA_LOGGING)
	_LIT(KLog5,"Font height: %d for device with pixels set to 480x1280");
	LOG_MESSAGE2(KLog5,height2);
#endif

	TEST(font!=font2);
	TEST(height!=height2);
	if (height==height2)
		INFO_PRINTF2(KLogErrM,height);

	device->ReleaseFont(font2);
	device->ReleaseFont(font);

	// 1. double the width and height of screen in both pixels and twips
	// 2. find font with best-matching height in twips,
	// 3. make sure that the newly found font is the same as previous and has the same height in pixels
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
	device->SetScreenSizeAndRotation(sizeAndRotation);
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
	sizeAndRotation.iPixelSize.iHeight*=2;
	sizeAndRotation.iPixelSize.iWidth *=2;
	sizeAndRotation.iTwipsSize.iHeight*=2;
	sizeAndRotation.iTwipsSize.iWidth *=2;
	device->SetScreenSizeAndRotation(sizeAndRotation);

	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
	height2=font2->HeightInPixels();
#if defined(EXTRA_LOGGING)
	_LIT(KLog6,"Font height: %d for device doubled size.   pixels=%d,%d  twips=%d,%d");
	LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
							,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
#endif

	TEST(font==font2);
	TEST(height0==height2);
	_LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d");
	if (height0!=height2)
		INFO_PRINTF3(KLogErrD,height0,height2);

	device->ReleaseFont(font2);
	device->ReleaseFont(font);

	// 1. swap width and height sizes of screen for both pixels and twips
	// 2. find font with best-matching height in twips,
	// 3. make sure that the newly found font is the same as previous and has the same height in pixels
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
	device->SetScreenSizeAndRotation(sizeAndRotation);
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
	TInt swap=sizeAndRotation.iPixelSize.iHeight;
	sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth;
	sizeAndRotation.iPixelSize.iWidth =swap;
	swap=sizeAndRotation.iTwipsSize.iHeight;
	sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth;
	sizeAndRotation.iTwipsSize.iWidth =swap;
	device->SetScreenSizeAndRotation(sizeAndRotation);
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
	height2 = font2->HeightInPixels();
#if defined(EXTRA_LOGGING)
	_LIT(KLog7,"Font height: %d for device rotated size.   pixels=%d,%d  twips=%d,%d");
	LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
							,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
#endif

	TEST(font==font2);
	TEST(height0==height2);
	if (height0!=height2)
		INFO_PRINTF3(KLogErrD,height0,height2);

	device->ReleaseFont(font2);
	device->ReleaseFont(font);

	delete device;
	session.Close();
	}
Ejemplo n.º 29
0
/*
================
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();
}
Ejemplo n.º 30
0
BOOL CMFCControlsDlg::OnInitDialog()
{
	CFont* pFont = GetFont();

	LOGFONT logfont;

	pFont->GetLogFont(&logfont);

	logfont.lfWeight = 700;

	CFont myFont;
	myFont.CreateFontIndirect(&logfont);

	SetFont(&myFont,TRUE);

	myFont.Detach();

	CDialog::OnInitDialog();
	
	// Add "About..." menu item to system menu.
	
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);
	
	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}
	
	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// Setup demo controls - no more skinning-specific code in this method
    for (int i = 0; i < 5; i ++)
    {
        TCHAR szTab[20] = {0};
        _stprintf(szTab, _T("Tab %d"), (i+1));
        m_Tab.InsertItem(i, szTab); 
    }
	
    for (int j = 0; j < 10; j++) {
        m_List.InsertString(j, _T("SkinMagic Toolkit!"));
    }
	
    m_bPlaying = TRUE;
    
    m_Progress.SetRange(0, 1000);
    m_Progress.SetPos(0);
    m_VertScroll.SetScrollRange(0, 1000, TRUE);
    m_HorzScroll.SetScrollRange(0, 1000, TRUE);
    SendDlgItemMessage(IDC_RADIO3, BM_SETCHECK, 1, 0);
    SendDlgItemMessage(IDC_CHECK3, BM_SETCHECK, 1, 0);
	
    m_Slider1.SetRange(0,100,0);
    m_Slider2.SetRange(0,100,0);
    m_Slider3.SetRange(0,100,0);
    m_Slider4.SetRange(0,100,0);
    m_Slider5.SetRange(0,100,0);
    m_Slider6.SetRange(0,100,0);
	
    m_Slider1.SetPos(0);
    m_Slider2.SetPos(50);
    m_Slider3.SetPos(100);
    m_Slider4.SetPos(0);
    m_Slider5.SetPos(50);
    m_Slider6.SetPos(100);
	
    // Set a timer to update
    //SetTimer(1000, 250, NULL);


	
	return TRUE;  // return TRUE  unless you set the focus to a control
}