void SItemPanel::Draw(IRenderTarget *pRT,const CRect & rc) { UpdateLayout(); m_style.m_crBg=m_crBk; if((m_dwState & WndState_Hover) && m_crHover != CR_INVALID) m_style.m_crBg=m_crHover; if((m_dwState & WndState_Check) && m_crSelBk != CR_INVALID) m_style.m_crBg=m_crSelBk; //不继承宿主的字体,从系统字体开始 SPainter painter; BeforePaint(pRT,painter); CAutoRefPtr<IRegion> rgn; pRT->GetClipRegion(&rgn); pRT->OffsetViewportOrg(rc.left,rc.top); if(rgn) { rgn->Offset(-rc.TopLeft()); } BuildWndTreeZorder(); RedrawRegion(pRT,rgn); pRT->OffsetViewportOrg(-rc.left,-rc.top); AfterPaint(pRT,painter); }
void CDuiListBox::RedrawItem(int iItem) { if(!IsVisible(TRUE)) return; CRect rcClient; GetClient(&rcClient); int iFirstVisible = GetTopIndex(); int nPageItems=(rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; if(iItem>=iFirstVisible && iItem<GetCount() && iItem<iFirstVisible+nPageItems) { CRect rcItem(0,0,rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(rcClient.TopLeft()); CDCHandle dc=GetDuiDC(&rcItem,OLEDC_PAINTBKGND); DuiDCPaint duiDC; BeforePaint(dc,duiDC); DuiSendMessage(WM_ERASEBKGND,(WPARAM)(HDC)dc); DrawItem(dc,rcItem,iItem); AfterPaint(dc,duiDC); ReleaseDuiDC(dc); } }
void SScrollText::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT,painter); CRect rcClient = GetClientRect(); if(m_nScrollWidth==0) { pRT->DrawText(m_strText,m_strText.GetLength(),&rcClient,DT_SINGLELINE|DT_CENTER|DT_VCENTER); }else { pRT->PushClipRect(&rcClient); CRect rcText = rcClient; rcText.left -= m_nOffset; pRT->DrawText(m_strText,m_strText.GetLength(),&rcText,DT_SINGLELINE|DT_VCENTER); if (m_nRollType==0) { if(m_nScrollWidth - m_nOffset < rcClient.Width()) { rcText.left += m_nScrollWidth; // pRT->SetTextColor(RGBA(0,0,0,255)); pRT->DrawText(m_strText,m_strText.GetLength(),&rcText,DT_SINGLELINE|DT_VCENTER); } } pRT->PopClip(); } AfterPaint(pRT,painter); }
void SDesktopDock::OnPaint(IRenderTarget *pRT) { if (!m_Init) { m_Init = TRUE; CRect rcClient = GetClientRect(); int cx = rcClient.Width(); int cy = rcClient.Height(); double X = (cx - m_DockLen)/2; double Y = cy - m_Height - m_gap; int i; for (i = 0; i < MAX_COUNT; i++) { m_RTRect[i] = CRect(CPoint(X + m_Width * i+rcClient.left, Y), CSize(m_Width, m_Height)); m_dRate[i] = 1; } } SPainter painter; BeforePaint(pRT,painter); GetRTRect(); for (int i=0; i<MAX_COUNT; i++) { m_pSkin[i]->Draw(pRT,m_RTRect[i],FALSE); } AfterPaint(pRT,painter); }
void SOUI::SToolbox::OnPaint( IRenderTarget *pRT ) { __super::OnPaint(pRT); SPainter painter; BeforePaint(pRT, painter); if (m_pIcon) { SIZE sz = m_pIcon->GetSkinSize(); CRect rc = GetWindowRect(); rc.left += (rc.Width() - sz.cx)/2 + m_IconOffsetX; rc.top += (rc.Height() - sz.cy)/2 + m_IconOffsetY; rc.right = rc.left + sz.cx; rc.bottom = rc.top + sz.cy; m_pIcon->Draw(pRT, rc, 0); } if (!m_strText.IsEmpty()) { SIZE szChar; pRT->MeasureText(m_strText, m_strText.GetLength(), &szChar); CRect chRc = GetWindowRect(); chRc.left += (chRc.Width() - szChar.cx)/2 + m_TextOffsetX; chRc.top += (chRc.Height() - szChar.cy)/2 + m_TextOffsetY; if (GetState() & WndState_PushDown) chRc.top++; chRc.right = chRc.left + szChar.cx; chRc.bottom = chRc.top + szChar.cy; pRT->DrawText(m_strText, m_strText.GetLength(), chRc, GetTextAlign()); } AfterPaint(pRT, painter); }
void SListBoxEx::OnPaint(IRenderTarget * pRT) { SPainter duiDC; BeforePaint(pRT,duiDC); CRect rcClient; GetClientRect(&rcClient); pRT->PushClipRect(&rcClient,RGN_AND); int iFirstVisible=m_ptOrigin.y/m_nItemHei; int nPageItems=(m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; CRect rcClip,rcInter; pRT->GetClipBox(&rcClip); for(int iItem = iFirstVisible; iItem<GetItemCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); rcInter.IntersectRect(&rcClip,&rcItem); if(!rcInter.IsRectEmpty()) DrawItem(pRT,rcItem,iItem); } pRT->PopClip(); AfterPaint(pRT,duiDC); }
void CDuiHeaderCtrl::DrawDraggingState(DWORD dwDragTo) { CRect rcClient; GetClient(&rcClient); CDCHandle dc=GetDuiDC(rcClient,OLEDC_PAINTBKGND); DuiDCPaint duidc; BeforePaint(dc,duidc); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); int iDragTo=LOWORD(dwDragTo); int iDragFrom=LOWORD(m_dwHitTest); CDuiArray<int> items; for(int i=0;i<m_arrItems.GetCount();i++) { if(i!=iDragFrom) items.Add(i); } items.InsertAt(iDragTo,iDragFrom); m_pSkinItem->Draw(dc,rcClient,0); for(int i=0;i<items.GetCount();i++) { rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[items[i]].cx; if(items[i]!=iDragFrom) DrawItem(dc,rcItem,m_arrItems.GetData()+items[i]); } AfterPaint(dc,duidc); ReleaseDuiDC(dc); }
void SViewSwitch::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT,painter); CRect rcWnd = GetWindowRect(); for(int i = 0; i < (int)m_dwPageCount; i++) { ISkinObj *pSkinObj = m_pSkin[i]; if (pSkinObj !=NULL) { SIZE SkinSize =pSkinObj->GetSkinSize(); CRect rct; rct.left = (i*rcWnd.Width() - (m_iSelected * rcWnd.Width())+m_iMoveWidth) ; rct.top = rcWnd.top +2; rct.bottom = SkinSize.cy; rct.right = rct.left + SkinSize.cx; pSkinObj->Draw(pRT,rct,0); } } if (m_pSkinLightLevel) m_pSkinLightLevel->Draw(pRT,rcWnd,0); AfterPaint(pRT,painter); }
void SProgress::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT, painter); SASSERT(m_pSkinBg && m_pSkinPos); CRect rcClient; GetClientRect(&rcClient); m_pSkinBg->Draw(pRT, rcClient, WndState_Normal); CRect rcValue=rcClient; if(IsVertical()) { rcValue.bottom=rcValue.top+(int)(((__int64)rcValue.Height())*(m_nValue-m_nMinValue)/(__int64)(m_nMaxValue-m_nMinValue)); } else { rcValue.right=rcValue.left+(int)(((__int64)rcValue.Width())*(m_nValue-m_nMinValue)/(__int64)(m_nMaxValue-m_nMinValue)); } if(m_nValue>m_nMinValue) { m_pSkinPos->Draw(pRT, rcValue, WndState_Normal); } if (m_bShowPercent && !IsVertical()) { SStringT strPercent; strPercent.Format(_T("%d%%"), (int)((m_nValue-m_nMinValue) * 100/(m_nMaxValue-m_nMinValue))); pRT->DrawText(strPercent, strPercent.GetLength(), GetWindowRect(), DT_SINGLELINE | DT_CENTER | DT_VCENTER); } AfterPaint(pRT, painter); }
void STabCtrl::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT,painter); CRect rcItem,rcItemPrev; CRect rcSplit; DWORD dwState; CRect rcTitle=GetTitleRect(); pRT->PushClipRect(&rcTitle,RGN_AND); for(size_t i=0; i<GetItemCount(); i++) { dwState=WndState_Normal; if(i == m_nCurrentPage) dwState=WndState_PushDown; else if(i== m_nHoverTabItem) dwState=WndState_Hover; GetItemRect(i,rcItem); //画分隔线 if(i>0 && m_pSkinTabInter) { rcSplit=rcItem; if(m_nTabAlign==AlignLeft) { rcSplit.top=rcItemPrev.bottom; rcSplit.bottom = rcSplit.top + m_nTabInterSize; } else { rcSplit.left=rcItemPrev.right; rcSplit.right=rcSplit.left + m_nTabInterSize; } m_pSkinTabInter->Draw(pRT,rcSplit,0); } DrawItem(pRT,rcItem,i,dwState); rcItemPrev=rcItem; } pRT->PopClip(); if (m_pSkinFrame) { CRect rcPage = GetChildrenLayoutRect(); m_pSkinFrame->Draw(pRT, rcPage, WndState_Normal); } if(IsFocused() && IsFocusable() && m_bDrawFocusRect) { CRect rc; GetItemRect(m_nCurrentPage,rc); rc.DeflateRect(2,2); DrawDefFocusRect(pRT,&rc); } AfterPaint(pRT,painter); }
void CDuiHeaderCtrl::RedrawItem( int iItem ) { CRect rcItem=GetItemRect(iItem); CDCHandle dc=GetDuiDC(rcItem,OLEDC_PAINTBKGND); DuiDCPaint duiDC; BeforePaint(dc,duiDC); DrawItem(dc,rcItem,m_arrItems.GetData()+iItem); AfterPaint(dc,duiDC); ReleaseDuiDC(dc); }
void SHotKeyCtrl::OnPaint( IRenderTarget * pRT ) { SPainter painter; BeforePaint(pRT,painter); CRect rcClient; GetClientRect(&rcClient); rcClient.OffsetRect(EDIT_INSET,0); SStringT str=FormatHotkey(); pRT->DrawText(str,str.GetLength(),&rcClient,DT_LEFT|DT_VCENTER|DT_SINGLELINE); AfterPaint(pRT,painter); }
void SListBox::OnPaint(IRenderTarget * pRT) { SPainter painter; BeforePaint(pRT,painter); int iFirstVisible = GetTopIndex(); int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); DrawItem(pRT,rcItem,iItem); } AfterPaint(pRT,painter); }
void STextButton::OnPaint( IRenderTarget *pRT ) { SPainter painter; BeforePaint(pRT, painter); CRect rcText; GetTextRect(rcText); DrawText(pRT,m_strText, m_strText.GetLength(), rcText, GetTextAlign()); //draw focus rect if(IsFocused()) { DrawFocus(pRT); } AfterPaint(pRT, painter); }
void SFencesView::OnPaint( IRenderTarget * pRT ) { SPainter painter; BeforePaint(pRT, painter); CRect rcList = GetWindowRect(); pRT->PushClipRect(&rcList); // »æÖƱ³¾° COLORREF crBg(0xffffff64); CAutoRefPtr<IBrush> brush,oldBrush; pRT->CreateSolidColorBrush(crBg, &brush); pRT->SelectObject(brush,(IRenderObj**)&oldBrush); pRT->FillRectangle(rcList); pRT->SelectObject(oldBrush); pRT->PopClip(); AfterPaint(pRT, painter); }
void CDuiListBox::OnPaint(CDCHandle dc) { DuiDCPaint duiDC; BeforePaint(dc,duiDC); int iFirstVisible = GetTopIndex(); int nPageItems = (m_rcClient.Height()+m_nItemHei-1)/m_nItemHei+1; for(int iItem = iFirstVisible; iItem<GetCount() && iItem <iFirstVisible+nPageItems; iItem++) { CRect rcItem(0,0,m_rcClient.Width(),m_nItemHei); rcItem.OffsetRect(0,m_nItemHei*iItem-m_ptOrigin.y); rcItem.OffsetRect(m_rcClient.TopLeft()); DrawItem(dc,rcItem,iItem); } AfterPaint(dc,duiDC); }
void CDuiHeaderCtrl::OnPaint( CDCHandle dc ) { DuiDCPaint duiDC; BeforePaint(dc,duiDC); CRect rcClient; GetClient(&rcClient); CRect rcItem(rcClient.left,rcClient.top,rcClient.left,rcClient.bottom); for(int i=0;i<m_arrItems.GetCount();i++) { rcItem.left=rcItem.right; rcItem.right=rcItem.left+m_arrItems[i].cx; DrawItem(dc,rcItem,m_arrItems.GetData()+i); if(rcItem.right>=rcClient.right) break; } if(rcItem.right<rcClient.right) { rcItem.left=rcItem.right; rcItem.right=rcClient.right; m_pSkinItem->Draw(dc,rcItem,0); } AfterPaint(dc,duiDC); }
void SComboBase::OnPaint(IRenderTarget * pRT ) { SPainter painter; BeforePaint(pRT, painter); if(GetCurSel() != -1 && m_pEdit==NULL) { CRect rcText; GetTextRect(rcText); SStringT strText=GetWindowText(); DrawText(pRT,strText, strText.GetLength(), rcText, GetTextAlign()); } //draw focus rect if(IsFocused()) { DrawFocus(pRT); } AfterPaint(pRT, painter); CRect rcBtn; GetDropBtnRect(&rcBtn); m_pSkinBtn->Draw(pRT,rcBtn,IIF_STATE3(m_dwBtnState,WndState_Normal,WndState_Hover,WndState_PushDown)); }
void SMatrixWindow::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT,painter); CRect rc = GetClientRect(); if(!m_pBgSkin) { pRT->DrawText(_T("没有指定skin对象"),-1,rc,DT_SINGLELINE|DT_VCENTER|DT_VCENTER); }else { SMatrix m,m2; m.rotate(m_fRotate) .scale(m_fScaleX,m_fScaleY) .shear(m_fSkewX,m_fSkewY) .translate(m_fTransX,m_fTransY); pRT->SetTransform(&m,&m2); m_pBgSkin->Draw(pRT,rc,0); pRT->SetTransform(&m2); } AfterPaint(pRT,painter); }
void SSliderBar::OnPaint(IRenderTarget * pRT) { SASSERT(m_pSkinThumb && m_pSkinBg && m_pSkinPos); SPainter painter; BeforePaint(pRT, painter); CRect rcRail=GetPartRect(SC_RAILBACK); m_pSkinBg->Draw(pRT,rcRail,0); if(m_nValue!=m_nMinValue) { CRect rcSel=GetPartRect(SC_SELECT); m_pSkinPos->Draw(pRT,rcSel,0); } CRect rcThumb = GetPartRect(SC_THUMB); int nState=0;//normal if(m_bDrag) nState=2;//pushback else if(m_uHtPrev==SC_THUMB) nState=1;//hover m_pSkinThumb->Draw(pRT, rcThumb, nState); AfterPaint(pRT, painter); }
void SGroup::OnPaint(IRenderTarget *pRT) { SPainter painter; BeforePaint(pRT, painter); CSize szFnt; pRT->MeasureText(m_strText, m_strText.GetLength(),&szFnt); CRect rcText=GetWindowRect(); rcText.left+=GROUP_HEADER,rcText.right-=GROUP_HEADER; rcText.bottom=rcText.top+szFnt.cy+2; if(GetTextAlign() & DT_CENTER) { rcText.left+=(rcText.Width()-szFnt.cx)/2; rcText.right=rcText.left+szFnt.cx; } else if(GetTextAlign() & DT_RIGHT) { rcText.left=rcText.right-szFnt.cx; } else { rcText.right=rcText.left+szFnt.cx; } if(!m_strText.IsEmpty()) { CRect rcClip=rcText; rcClip.InflateRect(5,5,5,5); pRT->PushClipRect(&rcClip,RGN_DIFF); } { CRect rcGroupBox = GetWindowRect(); if(!m_strText.IsEmpty()) rcGroupBox.top+=szFnt.cy/2; rcGroupBox.DeflateRect(1,1,1,0); CAutoRefPtr<IPen> pen1,pen2,oldPen; pRT->CreatePen(PS_SOLID,m_crLine1,1,&pen1); pRT->CreatePen(PS_SOLID,m_crLine2,1,&pen2); pRT->SelectObject(pen1,(IRenderObj**)&oldPen); pRT->DrawRoundRect(&rcGroupBox,CPoint(m_nRound,m_nRound)); pRT->SelectObject(pen2); rcGroupBox.InflateRect(1,1,1,-1); pRT->DrawRoundRect(&rcGroupBox,CPoint(m_nRound,m_nRound)); pRT->SelectObject(oldPen); } if(!m_strText.IsEmpty()) { pRT->PopClip(); pRT->DrawText(m_strText, m_strText.GetLength(), rcText, DT_SINGLELINE|DT_VCENTER); } AfterPaint(pRT, painter); }