void CheckPointListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {  
  ItemData *data = (ItemData *)lpDrawItemStruct->itemData;
  if (data == NULL || data == (ItemData *)-1) {
    return;
  }
  CDC *dc = CDC::FromHandle(lpDrawItemStruct->hDC);
  CRect rectItem(lpDrawItemStruct->rcItem);
  dc->FillSolidRect(rectItem, RGB(255, 255, 255));
  rectItem.DeflateRect(32, 0, 32, 0);
  int index = lpDrawItemStruct->itemID;
  CFont *oldFont = dc->SelectObject(GuiResources::GetInstance()->GetFont(GuiResources::FONT_BIG));  
  
  dc->SetBkMode(TRANSPARENT);

  int x = rectItem.right - 32 - 4;
  int y = rectItem.top + (rectItem.Height() - 32) / 2;
  if (imageList_ != NULL && data->state != -1) {
    imageList_->Draw(dc, data->state, CPoint(x, y), ILD_NORMAL);
  }

  dc->SetTextColor(RGB(0,0,0));

  if (imageList_ != NULL && data->icon != -1) {
    imageList_->Draw(dc, data->icon, CPoint(rectItem.left + 10, y), ILD_NORMAL);
  }

  CRect rectText(rectItem);
  rectText.left = rectItem.left + 32 + spacing_;
  dc->DrawText(data->text, rectText, DT_SINGLELINE | DT_VCENTER);

  dc->SelectObject(oldFont);

  dc->Draw3dRect(CRect(rectText.left, rectItem.bottom - 1, rectItem.right, rectItem.bottom),
      RGB(221,221,221), RGB(221,221,221));
}
void wxJigsawInputParameter::Draw(wxDC & dc, const wxPoint & pos, const wxSize & offset, double scale, wxColour color)
{
	wxPoint realPosition(
		pos.x + offset.GetWidth(), 
		pos.y /*+ offset.GetHeight()*/);
	/*wxLogTrace(wxTraceMask(), _("ParameterPos = %i,%i; Offset=%i, %i"),
		realPosition.x, realPosition.y, offset.x, offset.y);*/
	wxSize labelSize;
	wxSize size = GetSize(dc, scale);
	dc.GetTextExtent(m_Label, &labelSize.x, &labelSize.y, 0, 0, (wxFont *)&dc.GetFont());

	//Draw the text with bevel
	wxRect rectText(realPosition, size);
	rectText.x++;
	rectText.y++;
	dc.SetTextForeground(*wxBLACK);
	dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);

	rectText.x--;
	rectText.y--;
	dc.SetTextForeground(*wxWHITE);
	dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);

	
	wxPoint shapePos;
	wxSize shapeSize;
	if(m_Shape)
	{
		shapeSize = m_Shape->GetSize(dc, scale);
		shapePos = wxPoint(
			pos.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, 
			pos.y + (size.GetHeight()-shapeSize.GetHeight())/2);
		m_Shape->SetPosition(shapePos.x, 
			shapePos.y + (size.GetHeight()-shapeSize.GetHeight())*scale/2 - offset.GetHeight());
		m_Shape->Draw(dc, offset, scale);
	}
	else
	{
		dc.SetPen(*wxBLACK_PEN);

		wxBrush paramBrush(wxColour(color.Red()*.9,color.Green()*.9,color.Blue()*.9)); 
		dc.SetBrush(paramBrush);
		//dc.SetBrush(*wxWHITE_BRUSH);

		shapeSize = wxJigsawInputParameter::GetDefaultParameterSize();
		shapeSize.x *= scale;
		shapeSize.y *= scale;
		shapePos = wxPoint(
			realPosition.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, 
			realPosition.y + (size.GetHeight()-shapeSize.GetHeight())/2);
		wxJigsawShape::DrawShapeHeader(dc, shapePos, 
			shapeSize, GetStyle());
	}
	//dc.SetBrush(*wxTRANSPARENT_BRUSH);
	//dc.SetPen(*wxBLACK_PEN);
	//dc.DrawRectangle(realPosition, size);
}
Exemple #3
0
void wxMarkupText::Render(wxDC& dc, const wxRect& rect, int flags)
{
    // We want to center the above-baseline parts of the letter vertically, so
    // we use the visible height and not the total height (which includes
    // descent and internal leading) here.
    int visibleHeight;
    wxRect rectText(rect.GetPosition(), Measure(dc, &visibleHeight));
    rectText.height = visibleHeight;

    wxMarkupParserRenderOutput out(dc, rectText.CentreIn(rect), flags);
    wxMarkupParser parser(out);
    parser.Parse(m_markup);
}
void
CNdasMenuBitmapHandler::
OnDrawStatusText(
	LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDCHandle dc = lpDrawItemStruct->hDC;
	CRect rect(&lpDrawItemStruct->rcItem);
	rect.bottom -= 2;

	COLORREF oldBkColor = dc.SetBkColor(RGB(255,255,225));

	CBrush brush = ::CreateSolidBrush(RGB(255,255,225));
	
	CPen pen = ::CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DDKSHADOW)); 

	HBRUSH hOldBrush = dc.SelectBrush(brush);
	HPEN hOldPen = dc.SelectPen(pen);

//	dc.Rectangle(rect);

	dc.RoundRect(rect,CPoint(rect.Height() /4, rect.Height() / 4));

	(void) dc.SelectPen(hOldPen);
	(void) dc.SelectBrush(hOldBrush);

	CRect rectText(rect);
	rectText.left += GetSystemMetrics(SM_CXMENUCHECK) + 2;

	CString strStatus;
	ATLVERIFY(strStatus.LoadString(static_cast<UINT>(lpDrawItemStruct->itemData)));

	CFontHandle curFont = dc.GetCurrentFont();
	LOGFONT logFont;
	curFont.GetLogFont(&logFont);
	logFont.lfWeight = FW_BOLD;
	CFont newFont = ::CreateFontIndirect(&logFont);
	CFontHandle oldFont = dc.SelectFont(newFont);

//	COLORREF oldTextColor = dc.SetTextColor(RGB(40,40,233));

	dc.DrawText(
		strStatus,
		strStatus.GetLength(),
		&rectText,
		DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_NOPREFIX | 
		DT_VCENTER);

	dc.SelectFont(oldFont);
//	dc.SetTextColor(oldTextColor);
	dc.SetBkColor(oldBkColor);
}
Exemple #5
0
LRESULT CVideoViewControl::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	PAINTSTRUCT ps = { 0 };
	CDCHandle cdc(BeginPaint(&ps));

	if (m_bPlayerStarted && m_strLastErrorMsg.IsEmpty())
	{
		::SendMessage(m_hWndPlayer, WM_PLAYER_UPDATE, 0, 0);
	}
	else
	{
		CRect rect;
		GetClientRect(&rect);

		static DWORD dwBrushColor = 0;
		static DWORD dwTextColor = 0;
		if (!dwBrushColor)
		{
			CComPtr<IThemeColorMap> pThemeColorMap;
			ASSERT_IF_FAILED(m_pTheme->GetColorMap(&pThemeColorMap));
			ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::BrushBackground, &dwBrushColor));
			ASSERT_IF_FAILED(pThemeColorMap->GetColor(Twitter::Metadata::Drawing::PictureWindowText, &dwTextColor));
		}

		cdc.SetBkMode(TRANSPARENT);
		cdc.SetTextColor(dwTextColor);

		cdc.FillSolidRect(&rect, dwBrushColor);

		CComBSTR str = L"Launching video player...";
		if (!m_strLastErrorMsg.IsEmpty())
			str = m_strLastErrorMsg;

		CSize size;
		CRect rect1 = rect;
		cdc.DrawTextEx(str, str.Length(), &rect1, DT_WORDBREAK | DT_CENTER | DT_CALCRECT, NULL);
		size.cx = rect1.Width();
		size.cy = rect1.Height();

		auto x = (rect.right - rect.left) / 2 - (size.cx / 2);
		auto y = (rect.bottom - rect.top) / 2 - (size.cy / 2);

		CRect rectText(x, y, x + size.cx, y + size.cy);
		DrawRoundedRect(cdc, rectText, false);
		cdc.DrawTextEx(str, str.Length(), &rectText, DT_WORDBREAK | DT_CENTER, NULL);
	}
	EndPaint(&ps);
	return 0;
}
Exemple #6
0
void CHSListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	int itemID = lpDrawItemStruct->itemID;
	RECT &r = lpDrawItemStruct->rcItem;

	// use our font and pen
	CFont *oldFont = (CFont *)pDC->SelectObject(GetFontForIndex(itemID));
	CPen *oldPen = (CPen *)pDC->SelectObject(&m_penSelectionBorder);

	// do all this on selection change or redraw
	if (lpDrawItemStruct->itemAction == ODA_SELECT ||
		lpDrawItemStruct->itemAction == ODA_DRAWENTIRE)
	{
		// clear background -- XXX: is this required?
		pDC->FillSolidRect(&r, RGB(255,255,255));

		// draw selection rect
		if (lpDrawItemStruct->itemState & ODS_SELECTED)
		{
			// draw selection rectangle
			pDC->Rectangle(r.left+2, r.top+2, r.right-1, r.bottom-1);
		}

		// draw text:

		// get rectangle to draw it in
		CRect rectText(r);
		rectText.DeflateRect(4, 4);
		// get the style
		const HeadingStyle& hs = m_refPrintTemplate.headings[itemID];
		// make flags
		UINT flags = DT_LEFT;
		if (hs.justify == HeadingStyle::JFY_CENTER)
			flags = DT_CENTER;
		else if (hs.justify == HeadingStyle::JFY_RIGHT)
			flags = DT_RIGHT;
		// set the color
		pDC->SetTextColor(hs.fontColor);
		// actually draw it
		pDC->DrawText(GetTextForIndex(itemID), &rectText, flags);
	}

	// put back old pen and font
	pDC->SelectObject(oldPen);
	pDC->SelectObject(oldFont);
}
QSize QColorTabWidget::calcTabSize( QPainter& p, const TabInfo& ti )
{
    p.setFont(m_fntTab);

    QRectF rectText(0,0,0,0);

    if( isHorzTab() )
    {
        rectText.setHeight((float)m_sizeTabHeader.height());
    }
    else
    {
        rectText.setWidth((float)m_sizeTabHeader.width());
    }

    QString strCaption = ti.strCaption;
    int flags = Qt::AlignLeft|Qt::AlignVCenter|Qt::TextSingleLine;

    QRectF rectBB = p.boundingRect( rectText, flags, strCaption );
    //p.drawText( rectText, flags, strCaption, &rectBB );

    float fImageOffset = 0.f;
    if( ti.pIconImage )
    {
        fImageOffset = ti.pIconImage->width() + 5.f;
    }

    if( isHorzTab() )
    {
        rectBB.setWidth( rectBB.width() + fImageOffset + 15.f );
    }
    else
    {
        rectBB.setWidth( rectBB.width() + fImageOffset );
        rectBB.setHeight( rectBB.height() + 15.f );
    }


    return QSize( (int)(rectBB.width() + .5f), (int)(rectBB.height() + .5f) );
}
Exemple #8
0
void COXItemTip::NeedItemTip(LPNEEDITEMTIPINFO pnitInfo)
{
	ASSERT(::IsWindow(m_hWndHooked));
	ASSERT(m_hWndHooked==m_pAttachedCtrl->m_hWnd);

	// Make sure that the ListCtrl is in report view
	if((m_pAttachedCtrl->GetStyle()&LVS_TYPEMASK)!=LVS_REPORT)
	{
		pnitInfo->result=ID_NIT_WRONGFORMAT;
		return;
	}

	// check if list control has any items
	if(m_pAttachedCtrl->GetItemCount()==0)
	{
		//changed 12/15/99
		pnitInfo->result=ID_NIT_OUTOFCONTROLBORDER;//ID_NIT_NOTHIDDEN;
		return;
	}


	CPoint point;
	point.x=pnitInfo->point.x;
	point.y=pnitInfo->point.y;

	CRect rectItem=pnitInfo->rectItem;

	// Get the top and bottom row visible
	int nTopRow=m_pAttachedCtrl->GetTopIndex();
	int nBottomRow=nTopRow+m_pAttachedCtrl->GetCountPerPage();
	if(nBottomRow>=m_pAttachedCtrl->GetItemCount())
	{
		nBottomRow=m_pAttachedCtrl->GetItemCount()-1;
	}

	int nRow=nTopRow;
	while(TRUE)
	{
		ASSERT(nRow<m_pAttachedCtrl->GetItemCount());

		m_pAttachedCtrl->GetItemRect(nRow,&rectItem,LVIR_BOUNDS);
		if(rectItem.PtInRect(point))
		{
			break;
		}
		nRow++;

		if(nRow>nBottomRow)
		{
			pnitInfo->result=ID_NIT_OUTOFCONTROLBORDER;
			return;
		}
	}
	pnitInfo->row=nRow;

	int nCol=0;
	int nColReal=0;
	while(TRUE)
	{
		nColReal=GetRealColumn(nCol);
		int nColWidth=m_pAttachedCtrl->GetColumnWidth(nColReal);
		if(nColWidth<0)
		{
			pnitInfo->result=ID_NIT_OUTOFCONTROLBORDER;
			return;
		}

		rectItem.right=rectItem.left+nColWidth;
		if(rectItem.PtInRect(point))
		{
			break;
		}
		rectItem.left=rectItem.right;
		nCol++;
	}
	pnitInfo->col=nColReal;

	if(nColReal==0)
	{
		CRect rcLabel;
		m_pAttachedCtrl->GetItemRect(nRow, &rcLabel, LVIR_LABEL);

		rectItem=rcLabel;
		rectItem.InflateRect(1,0);
		if(!rectItem.PtInRect(point))
		{
			pnitInfo->result=ID_NIT_OUTOFITEMBORDER;
			return;
		}
	}

	int nOffset=(nColReal==0 ? pnitInfo->offset/2 : pnitInfo->offset);
	rectItem.DeflateRect(nOffset,0);

	CString sText=m_pAttachedCtrl->GetItemText(nRow,nColReal);
	if(sText.IsEmpty())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}
	lstrcpyn(pnitInfo->itemText,sText,pnitInfo->sizeText);

	CClientDC dc(m_pAttachedCtrl);
	CFont* pOldFont=pnitInfo->pFont==NULL ? NULL : 
		dc.SelectObject((CFont*)pnitInfo->pFont);
	CRect rectText(0, 0, 0, 0);
	dc.DrawText(sText,&rectText,DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
	if(pOldFont)
	{
		dc.SelectObject(pOldFont);
	}

	CRect rectClient;
	m_pAttachedCtrl->GetClientRect(&rectClient);

	LV_COLUMN lvc;
	memset(&lvc,0,sizeof(LV_COLUMN));
	lvc.mask=LVCF_FMT;
	VERIFY(m_pAttachedCtrl->GetColumn(nColReal, &lvc));

	int fmt=lvc.fmt&LVCFMT_JUSTIFYMASK;
	int nTextWidth=rectText.Width();
	switch(fmt)
	{
	case LVCFMT_LEFT:
		{
			rectText.left=rectItem.left;
			rectText.right=rectText.left+nTextWidth;
			pnitInfo->alignment=DT_LEFT;
			break;
		}
	case LVCFMT_RIGHT:
		{
			rectText.right=rectItem.right;
			rectText.left=rectText.right-nTextWidth;
			pnitInfo->alignment=DT_RIGHT;
			break;
		}
	case LVCFMT_CENTER:
		{
			int nCenter=rectItem.left+(rectItem.right-rectItem.left)/2;
			rectText.left=nCenter-nTextWidth/2;
			rectText.right=nCenter+nTextWidth/2;
			pnitInfo->alignment=DT_CENTER;
			break;
		}
	default:
		ASSERT(FALSE);
	}

	CRect rectItemWindow=rectItem;
	m_pAttachedCtrl->ClientToScreen(rectItemWindow);
	CWnd* pParentWnd=m_pAttachedCtrl->GetParent();
	BOOL bTopMostParent=FALSE;
	while(pParentWnd!=NULL)
	{
		if(pParentWnd->GetExStyle() & WS_EX_TOPMOST)
		{
			bTopMostParent=TRUE;
			break;
		}
		pParentWnd=pParentWnd->GetParent();
	}
	// check if item rectangle fits into the screen
	DWORD dwMessagePos=::GetMessagePos();
	CPoint ptHitTest(GET_X_LPARAM(dwMessagePos),GET_Y_LPARAM(dwMessagePos));
	CRect rectDisplay=COXItemTipWnd::GetMonitorRectFromPoint(ptHitTest,!bTopMostParent);

	if(rectText.Width()<=rectItem.Width() && 
		rectText.right<=rectClient.right && 
		rectText.left>=rectClient.left &&
		rectItemWindow.right<=rectDisplay.right &&
		rectItemWindow.left>=rectDisplay.left)
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}

	if(rectItem.Width()<rectText.Width())
	{
		rectItem.right=rectItem.left+rectText.Width();
	}
	rectItem.InflateRect(nOffset,0);

	pnitInfo->rectItem.left=rectItem.left;
	pnitInfo->rectItem.right=rectItem.left+__min(rectItem.Width(),rectText.Width());
	pnitInfo->rectItem.top=rectItem.top;
	pnitInfo->rectItem.bottom=rectItem.bottom;

	pnitInfo->offset=nOffset;

	BOOL bSelected=(m_pAttachedCtrl->GetItemState(pnitInfo->row,LVIS_SELECTED)==
		LVIS_SELECTED);
	if(pnitInfo->clrText==ID_OX_COLOR_NONE)
	{
		pnitInfo->clrText=(bSelected ? ::GetSysColor(COLOR_HIGHLIGHTTEXT) : 
			m_pAttachedCtrl->GetTextColor());
	}
	if(pnitInfo->clrBackground==ID_OX_COLOR_NONE)
	{
		pnitInfo->clrBackground=(bSelected ? ::GetSysColor(COLOR_HIGHLIGHT) : 
			pnitInfo->clrBackground);
	}


	pnitInfo->result=ID_NIT_SUCCESS;
}
Exemple #9
0
//***************************************************************************
//
//
//***************************************************************************
BOOL DrawVerticalText
( 
	CDC* pDC, 
	const CRect& rectWindow, 
	CString szcText, 
	const DWORD dwStyle 
)
{
	int nSavedDC = pDC->SaveDC();

	//
    // Start by getting this control's font, and then tweak it a bit.
	//

	LOGFONT lf;
	CFont *pTmpFont = pDC->GetCurrentFont();

	if( NULL == pTmpFont )
	{
		ASSERT( pTmpFont );  // Font not selected in DC!
		return FALSE;
	}

	pTmpFont->GetObject( sizeof(LOGFONT), &lf );
	
	//
    // Text will be rotated counter-clockwise 90 degrees.
	//
	lf.lfOrientation = lf.lfEscapement = 900;

	//
    // We need a TrueType font to get rotated text.  MS Sans Serif
    // won't cut it!  Opps!  A hard coded string!  
	//
    lstrcpy( lf.lfFaceName, _T("Tahoma") );

	//
	// Create a font with the tweaked attributes.
	//
    CFont font;
    if( FALSE == font.CreateFontIndirect( &lf ) )
	{
		TRACE2("Error creating font! Line: %d, File: %s\n", __LINE__, __FILE__ );
		return FALSE;
	}

	CFont *pfontOld = pDC->SelectObject( &font );


	CRect rectText( rectWindow );

	//
	// Compute size of horizontal oriented string
	//
	pDC->DrawText ( CString(szcText), 
		            rectText,
                    DT_LEFT 
				   |DT_TOP 
				   |DT_CALCRECT 
				   |DT_SINGLELINE );

	//
    // Dependence on format flags, compute offset of text rectangle
	// Horizontal offset is constant for all formats
	// Vertical offset depend on format
	//
	CSize szOffset(0,0);
    if ( dwStyle & SS_CENTER )
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              -(rectWindow.Height()-rectText.Width())/2+rectText.Height() );
	}
    else if ( dwStyle & SS_RIGHT )
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              -rectWindow.Height()+rectText.Width()+rectText.Height() );
	}
    else
	{
	    szOffset = CSize( (rectWindow.Width()-rectText.Height())/2, 
			              rectText.Height() );
	}
	
	//
	// Convert dimensions of horizontal oriented rectangle 
	// to dimensions of vertical oriented rectangle 
	// (swap horizontal and vertical sizes)
	// rectText.SetRect( rectWindow.left, 0, rectWindow.left + rectText.Height(), rectWindow.Height());
	// rectText.SetRect( rectWindow.left, rectWindow.top, rectText.right, rectWindow.Height());
	//

	rectText.top    = rectWindow.top;
	rectText.bottom = rectWindow.bottom;
	
	//
    // Offset text rectangle
	//
	rectText.OffsetRect(szOffset);
	rectText.top = 0;

	if( rectWindow.Height() < rectText.Width() )
		rectText.right -= ((rectText.Width() - rectWindow.Height())/2);

	pDC->SetBkMode( TRANSPARENT );
	pDC->DrawText( szcText, 
		           rectText,
                   DT_LEFT 
				  |DT_BOTTOM 
				  |DT_SINGLELINE 
				  |DT_END_ELLIPSIS );
    pDC->SelectObject ( pfontOld );
	pDC->RestoreDC( nSavedDC );
    
	return TRUE;
}
Exemple #10
0
void CDuiTabCtrl::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	int nHeight = m_rc.Height();

	if(!m_bUpdate)
	{
		UpdateMemDC(dc, nWidth, nHeight * 3);

		Graphics graphics(m_memDC);

		BSTR bsFont = m_strFont.AllocSysString();
		FontFamily fontFamily(bsFont);
		Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
		::SysFreeString(bsFont);

		SolidBrush solidBrush(m_clrText);			// 正常文字画刷

		graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );

		// 文字的对齐方式
		StringFormat strFormat;
		strFormat.SetAlignment(StringAlignmentCenter);		// 水平方向中间对齐
		strFormat.SetLineAlignment(StringAlignmentCenter);	// 垂直方向中间对齐
		//strFormat.SetFormatFlags( StringFormatFlagsNoClip | StringFormatFlagsMeasureTrailingSpaces);
		
		for(int i = 0; i < 3; i++)
		{
			m_memDC.BitBlt(0, i * nHeight, nWidth, nHeight, &dc, m_rc.left ,m_rc.top, SRCCOPY);

			int nXPos = 0;
			int nYPos = i * nHeight;
			for(size_t j = 0; j < m_vecItemInfo.size(); j++)
			{
				TabItemInfo &itemInfo = m_vecItemInfo.at(j);
				
				if(!itemInfo.bVisible)
				{
					continue;
				}

				if(itemInfo.pImage != NULL)	// 使用tab页指定的图片
				{
					int nImageIndex = i;
					if(itemInfo.nImageCount == 1)
					{
						nImageIndex = 0;
					}
					int nX = (itemInfo.rc.Width() - itemInfo.sizeImage.cx) / 2;
					graphics.DrawImage(itemInfo.pImage, Rect(nXPos + nX, nYPos,  itemInfo.sizeImage.cx, itemInfo.sizeImage.cy),
						itemInfo.sizeImage.cx * nImageIndex, 0, itemInfo.sizeImage.cx, itemInfo.sizeImage.cy, UnitPixel);
				}else
				if((m_pImage != NULL) && (itemInfo.nImageIndex != -1))	// 使用tabctrl的索引图片
				{
					// 画底图
					int nX = (itemInfo.rc.Width() - itemInfo.sizeImage.cx) / 2;
					graphics.DrawImage(m_pImage, Rect(nXPos + nX, nYPos,  itemInfo.sizeImage.cx, itemInfo.sizeImage.cy),
						itemInfo.sizeImage.cx * itemInfo.nImageIndex, 0, itemInfo.sizeImage.cx, itemInfo.sizeImage.cy, UnitPixel);
				}

				// 画热点图(如果存在tabctrl设置的热点图的话)
				if((m_pImageHover != NULL) && (i > 0))
				{
					int nX = (itemInfo.rc.Width() - m_sizeHover.cx) / 2;
					if(nX < 0)
					{
						nX = 0;
					}
					graphics.DrawImage(m_pImageHover, Rect(nXPos + nX, nYPos,  m_sizeHover.cx, m_sizeHover.cy),
						m_sizeHover.cx * (i-1), 0, m_sizeHover.cx, m_sizeHover.cy, UnitPixel);
				}

				// 文字
				if(!itemInfo.strText.IsEmpty())
				{
					RectF rectText((Gdiplus::REAL)nXPos, (Gdiplus::REAL)(nYPos + itemInfo.sizeImage.cy + 1), (Gdiplus::REAL)itemInfo.rc.Width(),(Gdiplus::REAL)(m_nTabCtrlHeight - itemInfo.sizeImage.cy - 1));
					if(m_nTabCtrlHeight <= itemInfo.sizeImage.cy)
					{
						// 如果tabctrl高度小于图片高度,则文字直接居中显示
						rectText.Y = (Gdiplus::REAL)nYPos;
						rectText.Height = (Gdiplus::REAL)m_nTabCtrlHeight;
					}
					BSTR bsText = itemInfo.strText.AllocSysString();
					graphics.DrawString(bsText, (INT)wcslen(bsText), &font, rectText, &strFormat, &solidBrush);
					::SysFreeString(bsText);
				}

				nXPos += itemInfo.rc.Width();

				// 画分隔图片(采用拉伸方式)
				if(j < m_vecItemInfo.size() - 1 && m_pImageSeperator != NULL)
				{
					CRect &rc = m_vecRcSeperator.at(j);
					int nSepHeight = itemInfo.rc.Height();	// m_sizeSeperator.cy
					graphics.DrawImage(m_pImageSeperator, Rect(nXPos, nYPos, m_sizeSeperator.cx, nSepHeight),
						0, 0, m_sizeSeperator.cx, m_sizeSeperator.cy, UnitPixel);

					nXPos += m_sizeSeperator.cx;
				}
			}
		}
	}

	dc.BitBlt(m_rc.left,m_rc.top, m_rc.Width(), m_rc.Height(), &m_memDC, 0, 0, SRCCOPY);

	if((m_nHoverItem != -1) && (m_nHoverItem < (int)m_vecItemInfo.size()))
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(m_nHoverItem);

		dc.BitBlt(itemInfo.rc.left,itemInfo.rc.top, itemInfo.rc.Width(), itemInfo.rc.Height(), &m_memDC, itemInfo.rc.left - m_rc.left,itemInfo.rc.top - m_rc.top + m_rc.Height(), SRCCOPY);
	}

	if((m_nDownItem != -1) && (m_nDownItem < (int)m_vecItemInfo.size()))
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(m_nDownItem);

		dc.BitBlt(itemInfo.rc.left,itemInfo.rc.top, itemInfo.rc.Width(), itemInfo.rc.Height(), &m_memDC, itemInfo.rc.left - m_rc.left,itemInfo.rc.top - m_rc.top + m_rc.Height() * 2, SRCCOPY);
	}
}
Exemple #11
0
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION:	  DrawItem
//
// DESCRIPTION:	Called in response to draw the button
//
// NOTES:
//
// MAINTENANCE:
// Name:		  Date:	  Version:	Notes:
// NT ALMOND	210100	1.0			  Origin
//
////////////////////////////////////////////////////////////////////////////////
void CCoolBtn::DrawItem(DRAWITEMSTRUCT* lpDIS)
{
    if (lpDIS->CtlType != ODT_BUTTON)
        return;

    CFont *pFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));

    CDC dcMem;
    CBitmap bmp;

    CRect btnRect(lpDIS->rcItem);
    CRect trueRect(btnRect);

    CDC *pDC = CDC::FromHandle(lpDIS->hDC);

    ////////////////////////////////////////
    // Button Background                  //
    ////////////////////////////////////////

    pDC->FillRect(trueRect,&CBrush(GetSysColor(COLOR_BTNFACE)));

    BOOL bDisabled = ODS_DISABLED & lpDIS->itemState;

    if (m_bDefaultBtn)
        btnRect.DeflateRect(1,1);

    CRect rectFocus(btnRect);

    rectFocus.DeflateRect(4,4);

    if (!m_bMenuPushed)
        rectFocus.OffsetRect(m_bPushed,m_bPushed);

    rectFocus.right -= nDropBtnWidth;

    ////////////////////////////////////////
    // Button in a normal state           //
    ////////////////////////////////////////
    if (!m_bPushed || m_bMenuPushed)
    {
#ifdef _VISUALSTYLE_XP_H_
        if (g_xpStyle.IsAppThemed())
        {
            HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
            g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                          BP_PUSHBUTTON, PBS_NORMAL, &btnRect, 0);
            g_xpStyle.CloseThemeData(hTheme);
        }
        else
        {
#endif
            pDC->DrawFrameControl(&btnRect,DFC_BUTTON,DFCS_BUTTONPUSH);
#ifdef _VISUALSTYLE_XP_H_
        }
#endif
    }


    ////////////////////////////////////////
    // Default Button State               //
    ////////////////////////////////////////
    if ((m_bDefaultBtn || m_bPushed) && !bDisabled)
    {

        if (m_bPushed && !m_bMenuPushed)
        {
#ifdef _VISUALSTYLE_XP_H_
            if (g_xpStyle.IsAppThemed())
            {
                HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
                g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                              BP_PUSHBUTTON, PBS_PRESSED, &btnRect, 0);
                g_xpStyle.CloseThemeData(hTheme);
            }
            else
            {
#endif
                pDC->FrameRect(&lpDIS->rcItem,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
                pDC->FrameRect(&btnRect,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
#ifdef _VISUALSTYLE_XP_H_
            }
#endif
        }
    }
    ////////////////////////////////////////
    // State Hover                        //
    ////////////////////////////////////////
    if (m_bOverControl /*lpDIS->itemState & ODS_HOTLIGHT*/)
        if (!m_bMenuPushed)
        {
#ifdef _VISUALSTYLE_XP_H_
            if (g_xpStyle.IsAppThemed())
            {
                HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
                g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                              BP_PUSHBUTTON, PBS_HOT, &btnRect, 0);
                g_xpStyle.CloseThemeData(hTheme);
            }
#endif
        }

    ////////////////////////////////////////
    // State Focus                        //
    ////////////////////////////////////////
    if (lpDIS->itemState & ODS_FOCUS || m_bPushed)
        if (!m_bMenuPushed)
            pDC->DrawFocusRect(&rectFocus);


    ////////////////////////////////////////
    // Action Focus                       //
    ////////////////////////////////////////
    if ((lpDIS->itemAction & ODA_FOCUS))
        if (!m_bMenuPushed)
            pDC->DrawFocusRect(&rectFocus);


    ////////////////////////////////////////
    // Draw out bitmap                    //
    ////////////////////////////////////////

    // Draw out bitmap
    if (m_bLoaded)
    {
        if (!bDisabled)
        {
            m_IL.DrawIndirect(pDC,0,CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), CPoint(0,0),ILD_NORMAL);
        }
        else
        {
            pDC->DrawState(CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), m_hbmpDisabled, DST_BITMAP | DSS_DISABLED);
        }
    }


    ////////////////////////////////////////
    // Draw out text                      //
    ////////////////////////////////////////
    pDC->SelectObject(pFont);
    CRect rectText(rectFocus);
    rectFocus.left += m_bm.bmWidth + 2;

    CString strCaption;
    GetWindowText(strCaption);
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));

    if (ODS_DISABLED & lpDIS->itemState)
    {
        rectFocus.OffsetRect(1,1);
        pDC->SetTextColor(GetSysColor(COLOR_WINDOW));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

        rectFocus.OffsetRect(-1,-1);
        pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    }
    else
    {
        pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    }


    CRect rectSplit(btnRect);
    rectSplit.DeflateRect(2,2);
    rectSplit.right -= nDropBtnWidth;


    ////////////////////////////////////////
    // Drop down split                    //
    ////////////////////////////////////////
    CPen brFace(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW));
    pDC->SelectObject(&brFace);
    pDC->MoveTo(rectSplit.right, rectSplit.top);
    pDC->LineTo(rectSplit.right, rectSplit.bottom);


    CPen brLite(PS_SOLID,1,GetSysColor(COLOR_3DHILIGHT));
    pDC->SelectObject(&brLite);
    pDC->MoveTo(rectSplit.right+1 , rectSplit.top);
    pDC->LineTo(rectSplit.right+1, rectSplit.bottom);


    rectSplit.left = rectSplit.right;
    rectSplit.right += nDropBtnWidth;

    CPoint pt(rectSplit.CenterPoint());
    pt += CPoint(m_bPushed,m_bPushed);

    CPen penBlack(PS_SOLID, 1, bDisabled ? GetSysColor(COLOR_GRAYTEXT) : GetSysColor(COLOR_WINDOWTEXT));
    pDC->SelectObject(&penBlack);
    DrawArrow(pDC,pt);

    ////////////////////////////////////////
    // Drop down state                    //
    ////////////////////////////////////////
    if (m_bMenuPushed && !bDisabled)
    {
#ifdef _VISUALSTYLE_XP_H_
        rectSplit.DeflateRect(1,1);
#else
        rectSplit.InflateRect(1,1);
#endif
        pDC->DrawEdge(rectSplit,BDR_SUNKENOUTER, BF_RECT);
    }
}
void COwnMenu::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{


  CRect rectFull(lpDrawItemStruct->rcItem); 
  CRect rectIcon(rectFull.left,rectFull.top,rectFull.left+20,rectFull.top+20);
  CRect rectText(rectIcon.right,rectFull.top,rectFull.right,rectFull.bottom);

  COLORREF IconRectLeft = COLORREF(RGB(246,245,244));
  COLORREF IconRectRight = COLORREF(RGB(0,209,201));
  COLORREF TextRect = COLORREF(RGB(249, 248, 247));
  CRect rectBorder = rectFull;
  //rectBorder.left -= 3;
  rectBorder.right -= 1;
  CRect rectFill = rectBorder;
  rectFill.left += 1;
  rectFill.right -= 1;
  rectFill.top += 1;
  rectFill.bottom -= 1;

  if(((MenuObject*)lpDrawItemStruct->itemData)->bFirstMenu)
  {
	  ZeroMemory(&rectIcon, sizeof(CRect));
	  rectText = rectFull;
	  TextRect = GetSysColor(COLOR_BTNFACE);// COLORREF(RGB(192,192,192));
  }

  CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
  FillFluentRect(pDC->GetSafeHdc(),
	  rectIcon, 246,245,244,213,209,201);
  //::FillRect(pDC->GetSafeHdc(), &rectIcon, 
         //         CreateSolidBrush(IconRectRight));

  pDC->FillSolidRect(&rectText, 
                     TextRect);





  //if the menu item is selected
  if ((lpDrawItemStruct->itemState & ODS_SELECTED) &&
    (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
  {
	  //draw XP Rect
	  TextRect = COLORREF(RGB(182, 189, 210));
	  pDC->FillSolidRect(&rectBorder, COLORREF(RGB(10, 36, 106)));
	  pDC->FillSolidRect(&rectFill, TextRect);
  }





  pDC->SetBkColor(TextRect);
  rectText.left += 5;
  rectText.top += 1;
  rectText.bottom += 1;
  pDC->TextOut(rectText.left,
                  rectText.top, ((MenuObject*)lpDrawItemStruct->itemData)->m_strCaption);

}
Exemple #13
0
// 画控件
void CDuiTabCtrl::DrawControl(CDC &dc, CRect rcUpdate)
{
	int nWidth = m_rc.Width();
	//int nHeight = m_rc.Height();	// 纵向内存DC的高度是整个tabctrl的高度,不只是页签部分高度
	int nTabHeight = m_nTabCtrlHeight;	// 纵向内存DC高度改为tabctrl部分高度

	if(!m_bUpdate)
	{
		// 创建内存DC,纵向分为6层:
		// 1.tab页签图片-原图
		// 2.tab页签图片-鼠标热点
		// 3.tab页签图片-鼠标按下
		// 4,5,6层是上面3层的备份
		UpdateMemDC(dc, nWidth, nTabHeight * 3 * 2);

		Graphics graphics(m_memDC);

		BSTR bsFont = m_strFont.AllocSysString();
		FontFamily fontFamily(bsFont);
		Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
		::SysFreeString(bsFont);

		//SolidBrush solidBrush(m_clrText);			// 正常文字画刷

		graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );

		// 设置tab页签文字的水平和垂直对齐方式
		DUI_STRING_ALIGN_DEFINE();
		strFormat.SetFormatFlags( StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);
		
		// 画内存DC的3个层的内容
		for(int i = 0; i < 3; i++)
		{
			// 将背景内容拷贝到内存DC
			m_memDC.BitBlt(0, i * nTabHeight, nWidth, nTabHeight, &dc, m_rc.left, m_rc.top, SRCCOPY);

			// 画tab页签
			int nXPos = m_nTabLeftPading;
			int nYPos = i * nTabHeight;
			for(size_t j = 0; j < m_vecItemInfo.size(); j++)
			{
				TabItemInfo &itemInfo = m_vecItemInfo.at(j);
				
				if(!itemInfo.bVisible)
				{
					continue;
				}

				// 图片位置(根据对齐方式进行计算)
				CPoint point = GetOriginPoint(m_nTabItemWidth, m_nTabCtrlHeight, itemInfo.sizeImage.cx, itemInfo.sizeImage.cy,
						GetGDIAlignment(m_uAlignment), GetGDIVAlignment(m_uVAlignment));
				// 如果有图片和文字,则图片的垂直对齐按照上对齐方式
				if(!itemInfo.strText.IsEmpty())
				{
					point.y = 0;
				}

				// 画tab页签底图
				if(itemInfo.pImage != NULL)	// 如果页签设置了图片,则使用tab页签指定的图片
				{
					int nImageIndex = i;
					if(itemInfo.nImageCount == 1)
					{
						nImageIndex = 0;
					}
					graphics.DrawImage(itemInfo.pImage, Rect(nXPos + point.x, nYPos + point.y,  itemInfo.sizeImage.cx, itemInfo.sizeImage.cy),
						itemInfo.sizeImage.cx * nImageIndex, 0, itemInfo.sizeImage.cx, itemInfo.sizeImage.cy, UnitPixel);
				}else
				if((m_pImage != NULL) && (itemInfo.nImageIndex != -1))	// 如果设置了页签图片索引,使用tabctrl图片的索引图片
				{
					if(m_enTabImageMode == enTIMNormal)	// 普通模式
					{
						graphics.DrawImage(m_pImage, Rect(nXPos + point.x, nYPos + point.y,  itemInfo.sizeImage.cx, itemInfo.sizeImage.cy),
							itemInfo.sizeImage.cx * itemInfo.nImageIndex, 0, itemInfo.sizeImage.cx, itemInfo.sizeImage.cy, UnitPixel);
					}else
					if(m_enTabImageMode == enTIMMID)	// 九宫格模式
					{
						CRect rcTemp(nXPos, nYPos, nXPos+m_nTabItemWidth, nYPos+m_nTabCtrlHeight);
						DrawImageFrameMID(graphics, m_pImage, rcTemp, m_sizeImage.cx * i, 0, m_sizeImage.cx, m_sizeImage.cy,
							m_nWLT, m_nHLT, m_nWRB, m_nHRB);
					}
				}

				// 画tab页签热点图(如果存在tabctrl设置的热点图的话)
				if((m_pImageHover != NULL) && (i > 0))
				{
					int nX = (itemInfo.rc.Width() - m_sizeHover.cx) / 2;
					if(nX < 0)
					{
						nX = 0;
					}
					graphics.DrawImage(m_pImageHover, Rect(nXPos + nX, nYPos,  m_sizeHover.cx, m_sizeHover.cy),
						m_sizeHover.cx * (i-1), 0, m_sizeHover.cx, m_sizeHover.cy, UnitPixel);
				}

				// 画tab页签文字
				if(!itemInfo.strText.IsEmpty())
				{
					// 设置页签文字颜色
					SolidBrush solidBrushItem(m_clrText);
					if((m_nHoverItem == j) && (m_clrTextHover.GetValue() != Color(0, 0, 0, 0).GetValue()))	// 设置了鼠标移动颜色,则使用
					{
						solidBrushItem.SetColor(m_clrTextHover);
					}else
					if((m_nDownItem == j) && (m_clrTextDown.GetValue() != Color(0, 0, 0, 0).GetValue()))	// 设置了鼠标按下颜色,则使用
					{
						solidBrushItem.SetColor(m_clrTextDown);
					}

					RectF rectText((Gdiplus::REAL)nXPos,
							(Gdiplus::REAL)(nYPos + itemInfo.sizeImage.cy + 1),
							(Gdiplus::REAL)((m_pImageTabBtn != NULL) ? (itemInfo.rc.Width()-m_sizeTabBtn.cx) : itemInfo.rc.Width()),
							(Gdiplus::REAL)(m_nTabCtrlHeight - itemInfo.sizeImage.cy - 1));
					if(m_nTabCtrlHeight <= itemInfo.sizeImage.cy)
					{
						// 如果tabctrl高度小于图片高度,则文字直接居中显示
						rectText.Y = (Gdiplus::REAL)nYPos;
						rectText.Height = (Gdiplus::REAL)m_nTabCtrlHeight;
					}

					// 计算是否需要显示tip
					itemInfo.bNeedTextTip = rectText.Width < GetTextBounds(font, itemInfo.strText).Width;

					BSTR bsText = itemInfo.strText.AllocSysString();
					graphics.DrawString(bsText, (INT)wcslen(bsText), &font, rectText, &strFormat, &solidBrushItem);
					::SysFreeString(bsText);
				}

				nXPos += itemInfo.rc.Width();

				// 画tab页签之间的分隔图片(采用拉伸方式)
				if(j < m_vecItemInfo.size() - 1 && m_pImageSeperator != NULL)
				{
					CRect &rc = m_vecRcSeperator.at(j);
					int nSepHeight = itemInfo.rc.Height();	// m_sizeSeperator.cy
					graphics.DrawImage(m_pImageSeperator, Rect(nXPos, nYPos, m_sizeSeperator.cx, nSepHeight),
						0, 0, m_sizeSeperator.cx, m_sizeSeperator.cy, UnitPixel);

					nXPos += m_sizeSeperator.cx;
				}
			}
		}

		// 内存dc复制一份进行备份
		m_memDC.BitBlt(0, nTabHeight * 3, nWidth, nTabHeight * 3, &m_memDC, 0, 0, SRCCOPY);
	}

	// 画Tab页签按钮到内存dc
	if(m_pImageTabBtn != NULL)
	{
		// 现将备份的内存dc整体进行恢复,避免页签按钮叠加之后的影响
		m_memDC.BitBlt(0, 0, nWidth, nTabHeight * 3, &m_memDC, 0, nTabHeight * 3, SRCCOPY);

		Graphics graphics(m_memDC);
		for(int i = 0; i < 3; i++)
		{
			for(size_t j = 0; j < m_vecItemInfo.size(); j++)
			{
				TabItemInfo &itemInfo = m_vecItemInfo.at(j);
				graphics.DrawImage(m_pImageTabBtn,
					RectF((Gdiplus::REAL)itemInfo.rcButton.left, (Gdiplus::REAL)(nTabHeight * i + itemInfo.rcButton.top),
					(Gdiplus::REAL)itemInfo.rcButton.Width(), (Gdiplus::REAL)itemInfo.rcButton.Height()),
					(Gdiplus::REAL)(itemInfo.buttonState * m_sizeTabBtn.cx), 0,
					(Gdiplus::REAL)m_sizeTabBtn.cx, (Gdiplus::REAL)m_sizeTabBtn.cy,
					UnitPixel); 
			}
		}
	}

	// 内存dc输出到dc
	// 1.画原图
	dc.BitBlt(m_rc.left,m_rc.top, nWidth, nTabHeight, &m_memDC, 0, 0, SRCCOPY);

	// 2.画鼠标热点的Tab页签
	if((m_nHoverItem != -1) && (m_nHoverItem < (int)m_vecItemInfo.size()))
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(m_nHoverItem);

		dc.BitBlt(itemInfo.rc.left, itemInfo.rc.top, itemInfo.rc.Width(), itemInfo.rc.Height(), &m_memDC,
			itemInfo.rc.left - m_rc.left, itemInfo.rc.top - m_rc.top + nTabHeight, SRCCOPY);
	}

	// 3.画鼠标按下的Tab页签
	if((m_nDownItem != -1) && (m_nDownItem < (int)m_vecItemInfo.size()))
	{
		TabItemInfo &itemInfo = m_vecItemInfo.at(m_nDownItem);

		dc.BitBlt(itemInfo.rc.left, itemInfo.rc.top, itemInfo.rc.Width(), itemInfo.rc.Height(), &m_memDC,
			itemInfo.rc.left - m_rc.left, itemInfo.rc.top - m_rc.top + nTabHeight * 2, SRCCOPY);
	}
}
Exemple #14
0
void COXComboBoxTip::NeedItemTip(LPNEEDITEMTIPINFO pnitInfo)
{
	ASSERT(::IsWindow(m_hWndHooked));
	ASSERT(m_hWndHooked==m_pAttachedCtrl->m_hWnd);

	DWORD dwStyle=m_pAttachedCtrl->GetStyle();
	// Make sure that the combo box control has dropdown style
	if((dwStyle&CBS_DROPDOWNLIST)!=CBS_DROPDOWNLIST)
	{
		pnitInfo->result=ID_NIT_WRONGFORMAT;
		return;
	}

	CPoint ptTest(pnitInfo->point);
	CRect rectItem;
	m_pAttachedCtrl->GetClientRect(rectItem);
	rectItem.right-=::GetSystemMetrics(SM_CXVSCROLL);
	if(!rectItem.PtInRect(ptTest))
	{
		pnitInfo->result=ID_NIT_OUTOFITEMBORDER;
		return;
	}


	CString sText;
	m_pAttachedCtrl->GetWindowText(sText);
	if(sText.IsEmpty())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}

	pnitInfo->offset=ID_ITEMTIP_XOFFSET_COMBOBOX;

	CClientDC dc(m_pAttachedCtrl);
	CFont* pOldFont=pnitInfo->pFont==NULL ? NULL : 
		dc.SelectObject((CFont*)pnitInfo->pFont);
	CRect rectText(0, 0, 0, 0);
	dc.DrawText(sText,&rectText,DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
	if(pOldFont)
	{
		dc.SelectObject(pOldFont);
	}
	rectText.InflateRect(pnitInfo->offset,0);
	if(rectText.Width()<=rectItem.Width() && rectText.Height()<=rectItem.Height())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}
	rectItem.right=rectItem.left+rectText.Width();
	rectItem.bottom=rectItem.top+__max(rectText.Height(),rectItem.Height());

	pnitInfo->alignment=DT_LEFT;

	pnitInfo->rectItem.left=rectItem.left;
	pnitInfo->rectItem.top=rectItem.top;
	pnitInfo->rectItem.right=rectItem.right;
	pnitInfo->rectItem.bottom=rectItem.bottom;

	lstrcpyn(pnitInfo->itemText,sText,pnitInfo->sizeText);

	if(pnitInfo->clrText==ID_OX_COLOR_NONE)
	{
		pnitInfo->clrText=::GetSysColor(COLOR_WINDOWTEXT);
	}

	pnitInfo->result=ID_NIT_SUCCESS;
}
Exemple #15
0
void COXListBoxTip::NeedItemTip(LPNEEDITEMTIPINFO pnitInfo)
{
	ASSERT(::IsWindow(m_hWndHooked));
	ASSERT(m_hWndHooked==m_pAttachedCtrl->m_hWnd);

	CPoint ptTest(pnitInfo->point);
	BOOL bOutside=TRUE;
	int nItemIndex=m_pAttachedCtrl->ItemFromPoint(ptTest,bOutside);
	if(nItemIndex<0 || nItemIndex>=m_pAttachedCtrl->GetCount() || bOutside)
	{
		pnitInfo->result=ID_NIT_OUTOFCONTROLBORDER;
		return;
	}


	CString sText;
	m_pAttachedCtrl->GetText(nItemIndex,sText);
	if(sText.IsEmpty())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}


	CRect rectItem;
	m_pAttachedCtrl->GetItemRect(nItemIndex,rectItem);

	pnitInfo->offset=ID_ITEMTIP_XOFFSET_LISTBOX;

	if(!rectItem.PtInRect(ptTest))
	{
		pnitInfo->result=ID_NIT_OUTOFITEMBORDER;
		return;
	}

	pnitInfo->row=nItemIndex;

	CClientDC dc(m_pAttachedCtrl);
	CFont* pOldFont=pnitInfo->pFont==NULL ? NULL : 
		dc.SelectObject((CFont*)pnitInfo->pFont);
	CRect rectText(0, 0, 0, 0);
	dc.DrawText(sText,&rectText,DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
	if(pOldFont)
	{
		dc.SelectObject(pOldFont);
	}
	rectText.InflateRect(pnitInfo->offset,0);
	if(rectText.Width()<=rectItem.Width() && rectText.Height()<=rectItem.Height())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}
	rectItem.right=rectItem.left+rectText.Width();
	rectItem.bottom=rectItem.top+__max(rectText.Height(),rectItem.Height());

	pnitInfo->alignment=DT_LEFT;

	pnitInfo->rectItem.left=rectItem.left;
	pnitInfo->rectItem.top=rectItem.top;
	pnitInfo->rectItem.right=rectItem.right;
	pnitInfo->rectItem.bottom=rectItem.bottom;

	lstrcpyn(pnitInfo->itemText,sText,pnitInfo->sizeText);

	BOOL bSelected=(m_pAttachedCtrl->GetSel(pnitInfo->row)!=0);
	if(pnitInfo->clrText==ID_OX_COLOR_NONE)
	{
		pnitInfo->clrText=(bSelected ? ::GetSysColor(COLOR_HIGHLIGHTTEXT) : 
			::GetSysColor(COLOR_WINDOWTEXT));
	}
	if(pnitInfo->clrBackground==ID_OX_COLOR_NONE)
	{
		pnitInfo->clrBackground=(bSelected ? ::GetSysColor(COLOR_HIGHLIGHT) : 
			pnitInfo->clrBackground);
	}

	pnitInfo->result=ID_NIT_SUCCESS;
}
Exemple #16
0
bool CPrintFolder::DrawImage(CDCHandle dc, CPoint point, IW::Image &image, IW::FolderItem *pItem)
{
	HFONT hOldFont = dc.SelectFont(m_font);
	UINT uTextStyle =  DT_NOPREFIX | DT_EDITCONTROL;
	if (m_bCenter) uTextStyle |= DT_CENTER;
	if (!m_bWrap) uTextStyle |= DT_WORD_ELLIPSIS; else uTextStyle |= DT_WORDBREAK;

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

	int i, nHeightText = 0;

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

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

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

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

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

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

			if (bRotate)
			{
				IW::Image imageRotate;

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

				image = imageRotate;
			}
		}	

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

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

		const CRect rectBounding = image.GetBoundingRect();

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

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

		const CRect rectPrint(pt, sizeImage);

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

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

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

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

	

	return true;
}
Exemple #17
0
void COXEditTip::NeedItemTip(LPNEEDITEMTIPINFO pnitInfo)
{
	ASSERT(::IsWindow(m_hWndHooked));
	ASSERT(m_hWndHooked==m_pAttachedCtrl->m_hWnd);

	// we already been there so we don't need to show the tip again
	if(IsMouseOver())
	{
		pnitInfo->result=ID_NIT_CUSTOMREJECT;
		return;
	}

	DWORD dwStyle=m_pAttachedCtrl->GetStyle();
	// Make sure that the Edit control has single line style
	if((dwStyle&ES_MULTILINE)==ES_MULTILINE)
	{
		pnitInfo->result=ID_NIT_WRONGFORMAT;
		return;
	}

	CString sText;
	m_pAttachedCtrl->GetWindowText(sText);
	if(sText.IsEmpty())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}
	if(sText.GetLength()>pnitInfo->sizeText)
	{
		pnitInfo->result=ID_NIT_WRONGFORMAT;
		return;
	}

	CRect rectItem;
	m_pAttachedCtrl->GetRect(rectItem);
	CRect rectClient;
	m_pAttachedCtrl->GetClientRect(rectClient);
	CRect rectWindow;
	m_pAttachedCtrl->GetWindowRect(rectWindow);
	m_pAttachedCtrl->ScreenToClient(rectWindow);

	pnitInfo->offset=rectItem.left-rectWindow.left;

	CClientDC dc(m_pAttachedCtrl);
	CFont* pOldFont=pnitInfo->pFont==NULL ? NULL : 
		dc.SelectObject((CFont*)pnitInfo->pFont);
	CRect rectText(0, 0, 0, 0);
	dc.DrawText(sText,&rectText,DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
	if(pOldFont)
	{
		dc.SelectObject(pOldFont);
	}

	if(rectText.Width()<=rectItem.Width() && rectText.Height()<=rectItem.Height())
	{
		pnitInfo->result=ID_NIT_NOTHIDDEN;
		return;
	}
	rectItem.right=rectItem.left+rectText.Width();
	rectItem.bottom=rectItem.top+rectText.Height();

	if((dwStyle&ES_CENTER)==ES_CENTER)
		pnitInfo->alignment=DT_CENTER;
	else if((dwStyle&ES_RIGHT)==ES_RIGHT)
		pnitInfo->alignment=DT_RIGHT;
	else
		pnitInfo->alignment=DT_LEFT;

	pnitInfo->rectItem.left=rectWindow.left;
	pnitInfo->rectItem.top=rectWindow.top;
	pnitInfo->rectItem.right=rectWindow.left+rectItem.Width();
	pnitInfo->rectItem.bottom=rectWindow.bottom;

	lstrcpyn(pnitInfo->itemText,sText,pnitInfo->sizeText);

	if(pnitInfo->clrText==ID_OX_COLOR_NONE)
		pnitInfo->clrText=::GetSysColor(COLOR_WINDOWTEXT);

	pnitInfo->result=ID_NIT_SUCCESS;
}