示例#1
0
// returns 16, 24, 32 bit depth
CLIB_API int GetFirstPixel(HBITMAP hBitmap, COLORREF& firstPixel)
{
	BITMAP bmp;
	if (::GetObject(hBitmap, sizeof(bmp), &bmp) && bmp.bmBits)
	{
		if (bmp.bmBitsPixel > 16)
		{
			unsigned offset=(((bmp.bmWidth*bmp.bmBitsPixel/8)+3)/4) * 4 * (bmp.bmHeight-1);
			firstPixel = *(COLORREF*)((BYTE*)bmp.bmBits + offset);
			// in memory it is laid out as BGR, so convert to RGB...
			firstPixel = RGB(GetBValue(firstPixel), GetGValue(firstPixel), GetRValue(firstPixel));
			return bmp.bmBitsPixel;
		}
		else
		{
			ATLASSERT(bmp.bmBitsPixel==16);
			// we need a temporary memory bitmap to paint into.
			CClientDC dcc(0);
			CMemBm bmpFirstPixel(dcc, 0, 0, 0, 1, 1);
			CDCHandle hdcH = bmpFirstPixel;

			HBITMAP hbmpold=dcc.SelectBitmap(hBitmap);
			hdcH.BitBlt(0, 0, 1, 1, dcc, 0, 0, SRCCOPY);
			dcc.SelectBitmap(hbmpold);

			// get trans color 
			firstPixel = bmpFirstPixel.GetFirstPixel();
			return bmp.bmBitsPixel;
		}
	}
	return 0;
}
int CSkinManager::DrawGlowText(CDCHandle hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format, bool bGlow)
{
	const int iGlowMargin = 10;

	CDC dcMem;
	dcMem.CreateCompatibleDC(hdc);

	CBitmap bmp;
	BITMAPINFO dib = { sizeof(BITMAPINFOHEADER), lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->top - lprc->bottom, 1, 32, BI_RGB };
	bmp.CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
	dcMem.SelectBitmap(bmp);

	__DTTOPTS dto = { sizeof(__DTTOPTS) };
	dto.dwFlags = _DTT_TEXTCOLOR | _DTT_COMPOSITED | (bGlow ? _DTT_GLOWSIZE : 0);
	dto.crText = hdc.GetTextColor();
	dto.iGlowSize = 8;

	dcMem.SelectFont(hdc.GetCurrentFont());

	RECT rcText2 = { iGlowMargin, 0, lprc->right - lprc->left + iGlowMargin, lprc->bottom - lprc->top };
	int iRet = ::TuoDrawThemeTextEx(s()->GetTheme(), dcMem, 0, 0, lpchText, cchText, format, &rcText2, &dto);

	BLENDFUNCTION bf;
	bf.BlendOp = AC_SRC_OVER;
	bf.BlendFlags = 0;
	bf.SourceConstantAlpha = 0xff;
	bf.AlphaFormat = AC_SRC_ALPHA;
	::AlphaBlend(hdc, lprc->left - iGlowMargin, lprc->top, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, dcMem, 0, 0, lprc->right - lprc->left + iGlowMargin + iGlowMargin, lprc->bottom - lprc->top, bf);

	return iRet;
}
示例#3
0
void TextRenderer::Paragraph::draw(CDCHandle dc, int x, int y) const {
  bool isFirstWord = true;
  HFONT lastFont = NULL;
  COLORREF lastColor = 0;
  for (vector<Word>::const_iterator i = words.begin(); i != words.end(); ++i) {
    const Word& w = *i;
    if (!w.m_text.empty()) {
      if (isFirstWord) {
        isFirstWord = false;
        dc.SelectFont(w.m_font);
        lastFont = w.m_font;
        dc.SetTextColor(w.m_fontColor);
        lastColor = w.m_fontColor;
      }
      else {
        if (lastFont != w.m_font) {
          dc.SelectFont(w.m_font);
          lastFont = w.m_font;
        }
        if (lastColor != w.m_fontColor) {
          dc.SetTextColor(w.m_fontColor);
          lastColor = w.m_fontColor;
        }
      }
      dc.TextOut(x + w.m_location.x, y + w.m_location.y, w.m_text.c_str(), w.m_text.length());
    }
  }
}
示例#4
0
HBRUSH JHCEdit::OnCtlColorEdit(CDCHandle dc, CEdit edit)
{
	dc.SetTextColor(colorTx);
	dc.SetBkColor(colorBg);
	dc.SetDCBrushColor(colorBg);
	return HBRUSH(GetStockObject(DC_BRUSH));
}
RECT CItemData::GetRect(CDCHandle& dc)
{
	if ( NULL == m_pData )
		return RECT() ;

	if ( TIT_LINK != m_pData->dwType && TIT_TEXT != m_pData->dwType )
		return RECT() ;

	RECT rcItem = {0} ;
	wstring wsText ;
	switch(m_pData->dwType)
	{
	case TIT_LINK:
		{
			CFont font ;
			font.CreateFont(13,0,0,0,GetBold()?FW_BOLD:FW_NORMAL,0,TRUE,0,0,0,0,0,0,_T("Tahoma")) ;
			HFONT hOldFont = dc.SelectFont(font) ;
			wsText = m_pData->pData->pilLink->wsText ;
			dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
			dc.SelectFont(hOldFont) ;
		}
		break;
	case TIT_TEXT :
		wsText = m_pData->pData->pitText->wsText ;
		dc.DrawText(wsText.c_str() , wsText.size() , &rcItem , DT_CALCRECT|DT_NOPREFIX|DT_NOCLIP|DT_SINGLELINE) ;
		break ;
	}
	return rcItem ;
}
示例#6
0
void CWTLView::DoPaint( CDCHandle dc )
{
    CRect      rc;
    SYSTEMTIME st;
    CString    sTime;
 
    // Get our window's client area.
    GetClientRect ( rc );
 
    // Build the string to show in the window.
    GetLocalTime ( &st );
    sTime.Format ( _T("The time is %d:%02d:%02d"), st.wHour, st.wMinute, st.wSecond );
 
    // Set up the DC and draw the text.
    dc.SaveDC();
 
	
    dc.SetBkColor ( RGB(255,153,0) );
    dc.SetTextColor ( RGB(0,0,0) );
    dc.ExtTextOut ( 0, 0, ETO_OPAQUE, rc, sTime, sTime.GetLength(), NULL );
 
    // Restore the DC.
    dc.RestoreDC(-1);

}
示例#7
0
void CWidgetSplitter::DrawSplitterBar(CDCHandle dc)
{
TRY_CATCH

	RECT rect;
	if ( GetSplitterBarRect(&rect) )
	{
		RECT rc;
		GetClientRect(&rc);
		HRGN rgnWnd = CreateRectRgnIndirect(&rc);
		HRGN rgnBar = CreateRectRgnIndirect(&rect);
		CombineRgn(rgnWnd,rgnWnd,rgnBar,RGN_XOR);

		rc = rect;
		rc.left = rect.left + (rect.right - rect.left)/2;
		rc.right = rc.left + 1;

		HRGN rgnLine = CreateRectRgnIndirect(&rc);
		CombineRgn(rgnWnd,rgnWnd,rgnLine,RGN_OR);

		SetWindowRgn(rgnWnd,TRUE);

		DeleteObject(rgnBar);
		DeleteObject(rgnLine);
		DeleteObject(rgnWnd);

		dc.MoveTo(rc.left,rc.top);
		dc.LineTo(rc.left,rc.bottom);
	}

CATCH_THROW()
}
示例#8
0
int CListViewCtrlEx::_DrawCheckBox( CDCHandle &dc, RECT &rcItem, BOOL bChecked, DWORD dwFlags )
{
    if(rcItem.left>-16)
    {
        CDC	dcTmp;
        dcTmp.CreateCompatibleDC(dc);

        RECT rcCheckBox = _GetRectCheckBox( rcItem );
        HBITMAP hBmpOld = NULL;
        int x=rcCheckBox.left + 3, y=rcCheckBox.top, nWidth=13, nHeight=13, xSrc=bChecked ? 0 : 13, ySrc=0;

        if(dwFlags&LISTITEM_CHECKBOX)
        {
            hBmpOld	= dcTmp.SelectBitmap(m_bitmapCheck);
            dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCCOPY);
        }
        else
        {
            // Need Mask
            hBmpOld	= dcTmp.SelectBitmap(m_bitmapRadioMask);
            dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCAND);
            dcTmp.SelectBitmap(m_bitmapRadio);
            dc.BitBlt(x, y, nWidth, nHeight, dcTmp, xSrc, ySrc, SRCPAINT);
        }

        dcTmp.SelectBitmap(hBmpOld);
        dcTmp.DeleteDC();
    }
    return 3 + 13 + 3;
}
void CMenuSkin::DrawColumnSepLine(CDCHandle dc, const RECT &rcClient, int iLineX)
{
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, CSkinProperty::GetColor(Skin_Property_Menu_Vertical_Sep_Color));
	dc.SelectPen(pen);
	dc.MoveTo(iLineX, rcClient.top + GetMenuMarginDelta());
	dc.LineTo(iLineX, rcClient.bottom - GetMenuMarginDelta());
}
示例#10
0
LRESULT CPreviewWindow::OnControlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  CDCHandle dc = (HDC) wParam;

  dc.SetBkColor(RGB(174, 169, 167));
  dc.SetTextColor(RGB(0, 0, 0));

  return (LRESULT) ((HBRUSH) m_bgBrush);
}
示例#11
0
void 
CAboutDialog::OnPaint(HDC hDC)
{
	//
	// HDC hDC is not a DC
	// bug in atlcrack.h
	//

	CPaintDC dc(m_hWnd);
	SIZE sizePic = {0, 0};
	m_pix.GetSizeInPixels(sizePic);

	CRect rcWnd, rcClient;
	GetClientRect(rcClient);
	GetWindowRect(rcWnd);

	ATLTRACE(_T("Picture Size: %d, %d\n"), sizePic.cx, sizePic.cy);
	ATLTRACE(_T("Client Size: %d, %d\n"), rcClient.Width(), rcClient.Height());
	ATLTRACE(_T("Window Size: %d, %d\n"), rcWnd.Width(), rcWnd.Height());

	//
	// adjust the picture size to the same width of the dialog
	//

	SIZE sizeAdj = 
	{ 
		rcWnd.Width(), 
		MulDiv(sizePic.cy, rcWnd.Width(), sizePic.cx)
	};

	LONG lBaseUnits = GetDialogBaseUnits();
	INT baseX = LOWORD(lBaseUnits);
	INT baseY = HIWORD(lBaseUnits);
	INT tplX = MulDiv(sizePic.cx, 4, baseX);
	INT tplY = MulDiv(sizePic.cy, 4, baseY);

	ATLTRACE(_T("Adjusted Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);

	//
	// avoid distortion from a little difference
	//
	int diff = sizePic.cx - sizeAdj.cx;
	diff = (diff > 0) ? diff : -diff;
	if (diff < 30)
	{
		sizeAdj = sizePic;
	}

	ATLTRACE(_T("Using Size: %d, %d\n"), sizeAdj.cx, sizeAdj.cy);

	CRect rectPic(CPoint(0,0),sizeAdj);

	CDCHandle dcHandle;
	dcHandle.Attach((HDC)dc);
	m_pix.Render(dcHandle, rectPic);
}
示例#12
0
void CDuiColorPicker::OnPaint( CDCHandle dc )
{
	CRect rcClient;
	GetClient(&rcClient);
	ALPHAINFO ai;
	CGdiAlpha::AlphaBackup(dc,rcClient,ai);
	dc.FillSolidRect(&rcClient,m_crCur);
	dc.DrawEdge(&rcClient, BDR_RAISEDINNER, BF_RECT);
	CGdiAlpha::AlphaRestore(dc,ai);
}
示例#13
0
LRESULT CNativeToolbar::OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{
    CRect rect;
    GetClientRect(rect);

    CDCHandle hdc = (HDC)wParam;
    hdc.FillSolidRect(rect, m_rgbBackColor );

    bHandled = TRUE;
    return 1;
}
示例#14
0
void CODStaticImageImpl::DrawItem (LPDRAWITEMSTRUCT lpdis)
{
	if (!m_szImagePath.IsEmpty())
	{
		RECT rcClient;
		GetClientRect(&rcClient);
		CDCHandle dc = lpdis->hDC;
		dc.SaveDC();

		HBITMAP       hBitmap, hOldBitmap;
		HPALETTE      hPalette, hOldPalette;
		BITMAP        bm;
		if( LoadBitmapFromBMPFile( m_szImagePath.LockBuffer(), &hBitmap, &hPalette ) )
		{
			GetObject(hBitmap, sizeof(BITMAP), &bm);
			HDC hMemDC = CreateCompatibleDC(dc.m_hDC);
			hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
			hOldPalette = dc.SelectPalette(hPalette, FALSE);
			dc.RealizePalette();

			dc.StretchBlt(rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,\
				hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );

			SelectObject(hMemDC, hOldBitmap);
			DeleteObject(hBitmap);
			dc.SelectPalette(hOldPalette, FALSE);
			DeleteObject(hPalette);
		}
		m_szImagePath.UnlockBuffer();

		dc.RestoreDC(-1);
	}
	else if (m_nBitmapId > 0)
	{
		RECT rcClient;
		GetClientRect(&rcClient);
		CDCHandle dc = lpdis->hDC;
		dc.SaveDC();

		CBitmap bitmap;
		_U_STRINGorID id (m_nBitmapId);
		bitmap.LoadBitmap(id);

		CMemDC memDC(dc, &rcClient);

		memDC.SelectBitmap(bitmap.m_hBitmap);

		dc.RestoreDC(-1);
	}

	return;
}
// This function is called every time the button border needs to be painted.
// If the button is in standard (not flat) mode this function will NOT be called.
//
// Parameters:
//		[IN]	pDC
//				Pointer to a CDC object that indicates the device context.
//		[IN]	pRect
//				Pointer to a CRect object that indicates the bounds of the
//				area to be painted.
//
// Return value:
//		BTNST_OK
//			Function executed successfully.
//
DWORD CButtonST::OnDrawBorder(CDCHandle pDC, LPCRECT pRect)
{
	if (m_bIsPressed)
		{
		pDC.Draw3dRect(pRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));
		}
	else
		{
		pDC.Draw3dRect(pRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
		}

	return BTNST_OK;
} // End of OnDrawBorder
示例#16
0
// Painting helper
void CPrintFolder::DoPaint(CDCHandle dc, CRect& rc, int nCurPage)
{		
	dc.SetMapMode(MM_ANISOTROPIC);
	dc.SetWindowExt(m_rcOutput.right - m_rcOutput.left, m_rcOutput.bottom - m_rcOutput.top);
	dc.SetWindowOrg(0, 0);

	dc.SetViewportExt(rc.right - rc.left, rc.bottom - rc.top);
	dc.SetViewportOrg(rc.left, rc.top);

	PrePrintPage(nCurPage, dc);
	PrintPage(nCurPage, dc);
	PostPrintPage(nCurPage, dc);
}
示例#17
0
LRESULT CPreviewWindow::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  CDCHandle dc = (HDC) wParam;
  RECT rc;

  GetClientRect(&rc);
  rc.bottom = rc.top + 21;
  dc.FillSolidRect(&rc, RGB(174, 169, 167));

  GetClientRect(&rc);
  rc.top += 21;
  dc.Draw3dRect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, RGB(103, 99, 96), RGB(200, 199, 196));
  
  CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont());
  dc.SetTextColor(RGB(0, 0, 0));
  dc.SetBkMode(TRANSPARENT);

  const sChar *desc = "(no view item)";
  frOpGraph::opMapIt it = g_graph->m_ops.find(m_client.m_curOp);
  if (it != g_graph->m_ops.end())
    desc = it->second.plg->getDisplayName();

  dc.TextOut(176, 3, desc);
  dc.SelectFont(oldFont);
  
  return 1;
}
示例#18
0
void CDxMonthPicker::DrawButtons(CDCHandle dc)
{
    if (m_btnToday->m_bVisible)
    {
        dc.FillSolidRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE));

        CRect rcButtonX = m_btnToday->m_rcButton;
        rcButtonX.DeflateRect(1, 1, 1, 1);

        if (m_btnToday->m_bPressed)
        {
            dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNTEXT), GetSysColor(COLOR_BTNFACE));
            dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
        }
        else
        {
            dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNTEXT));
            dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW));
        }

        HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT));
        CString strCaption = _T("Today");

        dc.SetTextColor(RGB(0,0,0));
        dc.DrawText(strCaption, strCaption.GetLength(), rcButtonX, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
    }
}
示例#19
0
void WeaselPanel::_HighlightText(CDCHandle dc, CRect rc, COLORREF color)
{
	rc.InflateRect(m_style.hilite_padding, m_style.hilite_padding);
	CBrush brush;
	brush.CreateSolidBrush(color);
	CBrush oldBrush = dc.SelectBrush(brush);
	CPen pen;
	pen.CreatePen(PS_SOLID, 0, color);
	CPen oldPen = dc.SelectPen(pen);
	CPoint ptRoundCorner(m_style.round_corner, m_style.round_corner);
	dc.RoundRect(rc, ptRoundCorner);
	dc.SelectBrush(oldBrush);
	dc.SelectPen(oldPen);
}
示例#20
0
BOOL CBigFileListCtrl::OnEraseBkgnd(CDCHandle dc)
{
    CRect rcClient;
    GetClientRect(rcClient);
    dc.FillSolidRect(rcClient, RGB(0xff, 0xff, 0xff));
    return TRUE;
}
void CButtonST::DrawTheBitmap(CDCHandle pDC, bool bHasTitle, RECT &rItem, CRect &rCaption, bool bIsPressed, bool bIsDisabled)
{
	CDC				hdcBmpMem	= 0;
	CBitmapHandle	hbmOldBmp	= 0;
	CDC				hdcMem		= 0;
	CBitmapHandle	hbmT		= 0;
	BYTE			byIndex		= 0;

	// Select the bitmap to use
	if (m_bIsCheckBox)
		{
		if (bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);
			}
		}
	else
		{
		if (m_bMouseOnButton || bIsPressed)
			{
			byIndex = 0;
			}
		else
			{
			byIndex = (m_csBitmaps[1].hBitmap == NULL ? 0 : 1);
			}
		}

	CRect	rImage;

	PrepareImageRect(bHasTitle, rItem, rCaption, bIsPressed, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, rImage);
	hdcBmpMem.CreateCompatibleDC(pDC);
	hbmOldBmp = hdcBmpMem.SelectBitmap(m_csBitmaps[byIndex].hBitmap);
	hdcMem.CreateCompatibleDC(0);
	hbmT = hdcMem.SelectBitmap(m_csBitmaps[byIndex].hMask);

	pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcMem, 0, 0, SRCAND);
	pDC.BitBlt(rImage.left, rImage.top, m_csBitmaps[byIndex].dwWidth, m_csBitmaps[byIndex].dwHeight, hdcBmpMem, 0, 0, SRCPAINT);

	hdcMem.SelectBitmap(hbmT);
	hdcBmpMem.SelectBitmap(hbmOldBmp);
}
示例#22
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();
}
示例#23
0
LRESULT CDrawHeader::DoLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	POINT point;
	point.x = GET_X_LPARAM(lParam);
	point.y = GET_Y_LPARAM(lParam);

	m_ptLastLButtonDown = point;
	
	if (!m_bColumnResizing)
	{
		m_pAlmSum->SetCapture(TRUE, this);
		if (MouseOverColumnResizeArea(point))
		{
			SetCursor(m_hColDivCursor); 
			m_bColumnResizing = TRUE;
		}
		else
		{
			m_nColumnCatpture = GetColumn(point);

			CDCHandle dcHandle = m_pAlmSum->GetDC();
			DoDraw(dcHandle);
			m_pAlmSum->ReleaseDC(dcHandle);
		}
	}

	if (m_bColumnResizing)
	{
		if (!GetResizeColumn(point, m_nResizingColumn, m_nDragDivideOffset))
			return 1;
		
		CRect rect = m_pAlmSum->m_rect;
		CRect invertedRect(point.x - 1 - m_nDragDivideOffset, rect.top, 
			point.x - m_nDragDivideOffset, rect.bottom);
		
		CDCHandle dcHandle = m_pAlmSum->GetDC();
		dcHandle.InvertRect(&invertedRect);
		m_pAlmSum->ReleaseDC(dcHandle);
	}
		
	return 0;
}
示例#24
0
	void CDuiWkeWebkit::OnPaint( CDCHandle dc )
	{
		CRect rcClip;
		dc.GetClipBox(&rcClip);
		CRect rcClient;
		GetClient(&rcClient);
		CRect rcInvalid;
		rcInvalid.IntersectRect(&rcClip,&rcClient);

		m_pWebView->paint(dc,rcInvalid.left,rcInvalid.top,rcInvalid.Width(),rcInvalid.Height(),rcInvalid.left-rcClient.left,rcInvalid.top-rcClient.top,true);
	}
示例#25
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();
}
示例#26
0
void CGradient::Draw(
	CDCHandle pDC,
	int xDest,
	int yDest,
	int xSrc, 
	int ySrc, 
	int Width, 
	int Height,
	DWORD Rop)
{
	pDC.BitBlt(xDest, yDest, Width, Height, mpMemDC->m_hDC, xSrc, ySrc, Rop);
}
void CNCaptureView::PrepareDC(CDCHandle dc)
{
	ATLASSERT(m_sizeAll.cx >= 0 && m_sizeAll.cy >= 0);
	dc.SetMapMode(MM_ANISOTROPIC);
	dc.SetWindowExt(m_sizeLogAll);
	dc.SetViewportExt(m_sizeAll);
	dc.SetViewportOrg(-m_ptOffset.x, -m_ptOffset.y);

	if (m_pImage)
	{
		CRect rcPaintAll(CPoint(0), m_sizeAll);	//device unit
		if (m_sizeClient.cx > m_sizeAll.cx)
		{
			rcPaintAll.right = m_sizeClient.cx;
		}
		if (m_sizeClient.cy > m_sizeAll.cy)
		{
			rcPaintAll.bottom = m_sizeClient.cy;
		}

		dc.DPtoLP((LPPOINT)(&rcPaintAll), 2);  //change to logical
		CRect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight());
		m_rcDrawTarget = _GetPhotoRect(rcPaintAll, &(rcImage.Size()));
	}

	dc.SetWindowOrg(-m_rcDrawTarget.left, -m_rcDrawTarget.top);
}
示例#28
0
int TextRenderer::Paragraph::doLayout(CDCHandle dc, int paragraphWidth) {
  dcassert(!words.empty());
  bool isFirstWord = true;
  HFONT lastFont = NULL;
  for (vector<Word>::iterator i = words.begin(); i != words.end(); ++i) {
    Word& w = *i;
    if (isFirstWord) {
      isFirstWord = false;
      dc.SelectFont(w.m_font);
      lastFont = w.m_font;
    }
    else if (lastFont != w.m_font) {
      dc.SelectFont(w.m_font);
      lastFont = w.m_font;
    }
    if (!w.m_text.empty()) {
      dc.GetTextExtent(w.m_text.c_str(), w.m_text.length(), &w.m_textSize);
    }
    else {
      dc.GetTextExtent(_T(" "), 1, &w.m_textSize);
      w.m_textSize.cx = 0;
    }
  }
  int x = 0;
  int y = 0;
  vector<Word*> currentWords;
  for (vector<Word>::iterator i = words.begin(); i != words.end(); ++i) {
    Word* w = &*i;
    if (!currentWords.empty() && (w->m_newLine || x + w->m_textSize.cx > paragraphWidth)) {
      // начинаем новую строку
      x = 0;
      y += layoutWords(currentWords, y);
      currentWords.clear();
    }
    w->m_location.x = x;
    x += w->m_textSize.cx + m_horizontalGap;
    currentWords.push_back(w);
  }
  return y + layoutWords(currentWords, y);
}
示例#29
0
bool WeaselPanel::_DrawPreedit(Text const& text, CDCHandle dc, CRect const& rc)
{
	bool drawn = false;
	wstring const& t = text.str;
	if (!t.empty())
	{
		weasel::TextRange range;
		vector<weasel::TextAttribute> const& attrs = text.attributes;
		for (size_t j = 0; j < attrs.size(); ++j)
			if (attrs[j].type == weasel::HIGHLIGHTED)
				range = attrs[j].range;

		if (range.start < range.end)
		{
			CSize selStart, selEnd;
			dc.GetTextExtent(t.c_str(), range.start, &selStart);
			dc.GetTextExtent(t.c_str(), range.end, &selEnd);
			int x = rc.left;
			if (range.start > 0)
			{
				// zzz
				std::wstring str_before(t.substr(0, range.start));
				CRect rc_before(x, rc.top, rc.left + selStart.cx, rc.bottom);
				_TextOut(dc, x, rc.top, rc_before, str_before.c_str(), str_before.length());
				x += selStart.cx + m_style.hilite_spacing;
			}
			else
			{
				x += m_style.hilite_padding;
			}
			{
				// zzz[yyy]
				std::wstring str_highlight(t.substr(range.start, range.end - range.start));
				CRect rc_hi(x, rc.top, x + (selEnd.cx - selStart.cx), rc.bottom);
				_HighlightText(dc, rc_hi, m_style.hilited_back_color);
				dc.SetTextColor(m_style.hilited_text_color);
				dc.SetBkColor(m_style.hilited_back_color);
				_TextOut(dc, x, rc.top, rc_hi, str_highlight.c_str(), str_highlight.length());
				dc.SetTextColor(m_style.text_color);
				dc.SetBkColor(m_style.back_color);
				x += (selEnd.cx - selStart.cx);
			}
			if (range.end < static_cast<int>(t.length()))
			{
				// zzz[yyy]xxx
				x += m_style.hilite_spacing;
				std::wstring str_after(t.substr(range.end));
				CRect rc_after(x, rc.top, rc.right, rc.bottom);
				_TextOut(dc, x, rc.top, rc_after, str_after.c_str(), str_after.length());
			}
		}
		else
		{
			CRect rcText(rc.left, rc.top, rc.right, rc.bottom);
			_TextOut(dc, rc.left, rc.top, rcText, t.c_str(), t.length());
		}
		drawn = true;
	}
	return drawn;
}
示例#30
0
CSeparator::CSeparator(HWND hParent, CPoint pt, int cx, const TCHAR *p)
{
   static int height;
   if (height == 0)
   {
      CDCHandle dc = ::GetDC(NULL);

      HFONT hOldFont = dc.SelectFont(Globals::Instance().sep.font);

      CSize textSize;
      dc.GetTextExtent(L"ABC", 3, &textSize);
      dc.SelectFont(hOldFont);
      height = textSize.cy;

      ::ReleaseDC(NULL, dc);
   }

	CRect rcSep(pt.x, pt.y, pt.x+cx, pt.y + (p && *p ? height : 5));
	Create(hParent, rcSep, nullptr, SS_GRAYFRAME | WS_CHILD | WS_VISIBLE);
	SetWindowText(p);
	ShowWindow(SW_SHOW);
}