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

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

	_ResizeWindow();
	_RepositionWindow();
	RedrawWindow();
}
Exemple #3
0
void CdlTxtView::OnSetSize(NMHDR* pNMHDR, LRESULT* pRes)
{
	
	CFont cfont;
	cfont.CreateFontW(-((CHARNMHDR*)pNMHDR)->cf.yHeight/20,                        // nHeight
					0,                         // nWidth
				  0,                         // nEscapement
				  0,                         // nOrientation
				  400,                 // nWeight
				  FALSE,                     // bItalic
				  FALSE,                     // bUnderline
				  0,                         // cStrikeOut
				  ANSI_CHARSET,              // nCharSet
				  OUT_DEFAULT_PRECIS,        // nOutPrecision
				  CLIP_DEFAULT_PRECIS,       // nClipPrecision
				  DEFAULT_QUALITY,           // nQuality
				  DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
				  _T("Arial"));
	GetRichEditCtrl().SetFont(&cfont);

	*pRes =1;
}
Exemple #4
0
void CClosableTabCtrl::OnPaint(){
	//CTabCtrl::OnPaint();
	ModifyStyle(0, WS_CLIPCHILDREN);
	if( !m_pSpinCtrl )
    {
      CWnd * pWnd = FindWindowEx( GetSafeHwnd(), 0, _T("msctls_updown32"), 0 );
      if( pWnd )
      {
        m_pSpinCtrl = new CSpinButtonCtrl;
        m_pSpinCtrl->Attach(pWnd->GetSafeHwnd());
      }
    }

	BOOL aero=false;
	HMODULE hm=LoadLibrary(L"dwmapi.dll");
	if(hm){
		DWMISCOMPOSITIONENABLED* ic=(DWMISCOMPOSITIONENABLED*)GetProcAddress(hm, "DwmIsCompositionEnabled");
		(ic)(&aero);
		FreeLibrary(hm);
	}

	RECT wrect;
	GetWindowRect(&wrect);
	int w=wrect.right-wrect.left;
	int h=TAB_HEIGHT+TAB_TOP_MARGIN;
	CPaintDC _dc(this);
	if(!_dc.m_hDC)return;
	CDC dc;
	dc.CreateCompatibleDC(&_dc);
	if(!dc.m_hDC){
		ReleaseDC(&_dc);
		return;
	}
	CBitmap bmp;
	bmp.CreateCompatibleBitmap(&_dc, w, h);
	if(!bmp.m_hObject){
		ReleaseDC(&_dc);
		ReleaseDC(&dc);
		return;
	}
	CBitmap* obmp=dc.SelectObject(&bmp);

	
	CFont fnt;
	fnt.CreateFontW(-11, 0, 0, 0, 0, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, L"Tahoma"); 
	CFont* ofnt=dc.SelectObject(&fnt);
	
	

	dc.SetBkMode(TRANSPARENT);

	//skin.tabbarBG.bmp.DrawStretched(&dc, 0, 0, w, 20, 0, 0, 0, 0);
	if(!aero){
		COLORREF bgcol=IsTopParentActive()?GetSysColor(COLOR_ACTIVECAPTION):GetSysColor(COLOR_INACTIVECAPTION);
		dc.FillSolidRect(0, 0, w, h, bgcol);
	}

	int offset=5;

	if(m_pSpinCtrl){
		int p=LOWORD(m_pSpinCtrl->GetPos());
		for(int i=0;i<p;i++){
			offset-=itemWidths[i];
		}
	}

	itemWidths.clear();
	int totalWidth=5;

	for(int i=0;i<GetItemCount();i++){
		TC_ITEM item;
		memset(&item, 0, sizeof(TC_ITEM));
		item.mask=TCIF_TEXT|TCIF_IMAGE|TCIF_PARAM;
		item.pszText=new wchar_t[512];
		item.cchTextMax=512;
		GetItem(i, &item);
		int tw=dc.GetTextExtent(item.pszText, wcslen(item.pszText)).cx+40;
		RECT rect;
		rect.top=TAB_TOP_MARGIN;
		rect.bottom=h;
		rect.left=offset;
		rect.right=offset+tw;
		CTalkTab* tab=(CTalkTab*)item.lParam;

		totalWidth+=tw;

		if(i==this->GetCurSel()){
			skin.tabActive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			dc.SetTextColor(skin.tabActiveTextColor);
		}else if(over_idx==i){
			skin.tabOver.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabOverTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}else{
			skin.tabInactive.bmp.DrawStretched(&dc, offset, TAB_TOP_MARGIN, tw, TAB_HEIGHT, 0, 0, 0, 0);
			//dc.SetTextColor(skin.tabIncativeTextColor);
			dc.SetTextColor(IsTopParentActive()?GetSysColor(COLOR_CAPTIONTEXT):GetSysColor(COLOR_INACTIVECAPTIONTEXT));
		}

		HICON hIcon=skin.iconUnknown;

		bool newmsg=false;
		if(tab){
			newmsg=tab->hasNewMsg;
			if(newmsg){
				hIcon=skin.iconNewMsg;
			}
		}

		if(item.iImage>0 && !newmsg){
			bool inList=false;
			for(int j=0;j<con.clDlg->friendList.items.size();j++){
				if(con.clDlg->friendList.items[j].uid==item.iImage){
					inList=true;
					break;
				}
			}
			if(inList){
				if(con.clDlg->friendList.items[con.clDlg->friendList.GetItemByUID(item.iImage)].online){
					hIcon=skin.iconOnline;
				}else{
					hIcon=skin.iconOffline;
				}
			}
		}

		if(tab){
			if(tab->tabProxy)tab->tabProxy->SetIcon(hIcon, false);
		}

		DrawIconEx(dc.GetSafeHdc(), offset+2, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, hIcon, 16, 16, 0, NULL, DI_NORMAL);

		if(i==this->GetCurSel()){
			skin.tabCloseAct.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}else{
			skin.tabCloseInact.DrawUnscaled(&dc, offset+tw-18, TAB_HEIGHT/2+TAB_TOP_MARGIN-8, 15, 15, 0, 0);
		}

		if(!aero){
		dc.DrawText(item.pszText, wcslen(item.pszText), &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		}else{
			if(i==this->GetCurSel()){
				CUtils::DrawAeroText(rect, &dc, 0, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}else{
				CUtils::DrawAeroText(rect, &dc, 3, DT_CENTER|DT_VCENTER|DT_SINGLELINE, &fnt, item.pszText);
			}
		}

		delete item.pszText;
		offset+=tw+TAB_SPACING;
		itemWidths.push_back(tw);
	}

	_dc.BitBlt(0, 0, w, h, &dc, 0, 0, SRCCOPY);
	dc.SelectObject(obmp);
	dc.SelectObject(ofnt);
	ReleaseDC(&dc);
	ReleaseDC(&_dc);
	SetItemSize(CSize(totalWidth/GetItemCount(), 20));
}
Exemple #5
0
//draw client area
void WeaselPanel::DoPaint(CDCHandle dc)
{
	CRect rc;
	GetClientRect(&rc);

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

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

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

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

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

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

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

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

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

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

	dc.SelectFont(oldFont);	
}
void CConfigAppearance::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// Do not call CPropertyPage::OnPaint() for painting messages

	CRect Rect, ParentRect;
	GetWindowRect(ParentRect);

	CWnd *pWnd = GetDlgItem(IDC_COL_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	CBrush BrushColor;
	BrushColor.CreateSolidBrush(m_iColors[m_iSelectedItem]);

	// Solid color box
	CBrush *pOldBrush = dc.SelectObject(&BrushColor);
	dc.Rectangle(Rect);
	dc.SelectObject(pOldBrush);

	// Preview all colors

	pWnd = GetDlgItem(IDC_PREVIEW);
	pWnd->GetWindowRect(Rect);

	Rect.top -= ParentRect.top;
	Rect.bottom -= ParentRect.top;// - 16;
	Rect.left -= ParentRect.left;
	Rect.right -= ParentRect.left;

	int WinHeight = Rect.bottom - Rect.top;

	CFont Font;		// // //
	Font.CreateFontW(-m_iFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET,
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, m_strFont.data());
	CFont *OldFont = OldFont = dc.SelectObject(&Font);

	// Background
	dc.FillSolidRect(Rect, GetColor(COL_BACKGROUND));
	dc.SetBkMode(TRANSPARENT);

	COLORREF ShadedCol = DIM(GetColor(COL_PATTERN_TEXT), .5);
	COLORREF ShadedHiCol = DIM(GetColor(COL_PATTERN_TEXT_HILITE), .5);

	int iRowSize = m_iFontSize;
	int iRows = (WinHeight - 12) / iRowSize;// 12;

	COLORREF CursorCol = GetColor(COL_CURSOR);
	COLORREF CursorShadedCol = DIM(CursorCol, .5);
	COLORREF BgCol = GetColor(COL_BACKGROUND);
	COLORREF HilightBgCol = GetColor(COL_BACKGROUND_HILITE);
	COLORREF Hilight2BgCol = GetColor(COL_BACKGROUND_HILITE2);

	const auto BAR = [&] (int x, int y) {
		dc.FillSolidRect(x + 3, y + (iRowSize / 2) + 1, 10 - 7, 1, ShadedCol);
	};

	for (int i = 0; i < iRows; ++i) {

		int OffsetTop = Rect.top + (i * iRowSize) + 6;
		int OffsetLeft = Rect.left + 9;

		if (OffsetTop > (Rect.bottom - iRowSize))
			break;

		if ((i & 3) == 0) {
			if ((i & 6) == 0)
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, Hilight2BgCol, BgCol);		// // //
			else
				GradientBar(dc, Rect.left, OffsetTop, Rect.right - Rect.left, iRowSize, HilightBgCol, BgCol);

			if (i == 0) {
				dc.SetTextColor(GetColor(COL_PATTERN_TEXT_HILITE));
				GradientBar(dc, Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, GetColor(COL_BACKGROUND));
				dc.Draw3dRect(Rect.left + 5, OffsetTop, 40, iRowSize, CursorCol, CursorShadedCol);
			}
			else
				dc.SetTextColor(ShadedHiCol);
		}
		else {
			dc.SetTextColor(ShadedCol);
		}

		if (i == 0) {
			dc.TextOutW(OffsetLeft, OffsetTop - 2, L"C");
			dc.TextOutW(OffsetLeft + 12, OffsetTop - 2, L"-");
			dc.TextOutW(OffsetLeft + 24, OffsetTop - 2, L"4");
		}
		else {
			BAR(OffsetLeft, OffsetTop - 2);
			BAR(OffsetLeft + 12, OffsetTop - 2);
			BAR(OffsetLeft + 24, OffsetTop - 2);
		}

		if ((i & 3) == 0) {
			dc.SetTextColor(ShadedHiCol);
		}
		else {
			dc.SetTextColor(ShadedCol);
		}

		BAR(OffsetLeft + 40, OffsetTop - 2);
		BAR(OffsetLeft + 52, OffsetTop - 2);
		BAR(OffsetLeft + 68, OffsetTop - 2);
		BAR(OffsetLeft + 84, OffsetTop - 2);
		BAR(OffsetLeft + 96, OffsetTop - 2);
		BAR(OffsetLeft + 108, OffsetTop - 2);
	}

	dc.SelectObject(OldFont);
}
Exemple #7
0
void CColorTree::OnPaint()
{
	CTreeCtrl::OnPaint();
	CPaintDC dc(this); // device context for painting
	HTREEITEM hItem;
	CImageList *List;
			List = GetImageList(0);

	
	hItem = GetFirstVisibleItem();
	CRect rec, recText;

	 CBrush brush0(m_colRow1);
	CBrush brush1(m_colRow2);

	int i;
	i = 0;
	CDC * pDC;
	pDC = GetDC();
	CFont Font;
	Font.CreateFontW(15,0,0,0,FW_NORMAL, FALSE, FALSE,FALSE,RUSSIAN_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_MODERN|DEFAULT_PITCH,_T("TestFont"));
	pDC->SelectObject(Font);
	while(hItem!=NULL)
	{
		GetItemRect(hItem,rec,FALSE);
		GetItemRect(hItem,recText,TRUE);
		//
		if(i % 2 == 0)
			{
				pDC->FillRect(rec,&brush0);
				pDC->SetBkColor(m_colRow1);
			}
		else
			{
				pDC->SetBkColor(m_colRow2);
				pDC->FillRect(rec,&brush1);
			}
		CString sName;
		sName = GetItemText(hItem);
		if(sName.Find(_T("\n"))>-1)
		{
			sName =  sName.Left(sName.Find(_T("\n")));
		}
		if(sName.Find(_T("\t"))>-1)
			{
				CString sVal;
				sVal = sName.Left(sName.Find(_T("\t")));
				pDC->TextOutW(recText.left-20 ,rec.top,sVal,sVal.GetLength());
				
				sVal = sName.Right(sName.GetLength()-1-sVal.GetLength());
				pDC->TextOutW(rec.left + (rec.right - rec.left)/2,rec.top,sVal,sVal.GetLength());
			}
		else
			pDC->TextOutW(recText.left - 20,rec.top,sName,sName.GetLength());


		if(GetItemState(hItem, TVIS_EXPANDED)& TVIS_EXPANDED)
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				List->Draw(pDC,1,xy,ILD_NORMAL);
			}
		}
		else
		{
			if(List!=NULL)
			{
				CPoint xy; 		
				xy =  recText.TopLeft();
				xy.x = xy.x - 40;
				if(GetChildItem(hItem)!=NULL)
					List->Draw(pDC,0, xy,ILD_NORMAL);
				else
					List->Draw(pDC,2, xy,ILD_NORMAL);
			}
		}

		hItem = GetNextVisibleItem(hItem);
		i++;
	}
}