void CControlUI::SetPos(RECT rc, bool bNeedInvalidate) { if( rc.right < rc.left ) rc.right = rc.left; if( rc.bottom < rc.top ) rc.bottom = rc.top; CDuiRect invalidateRc = m_rcItem; if( ::IsRectEmpty(&invalidateRc) ) invalidateRc = rc; if( m_bFloat ) { CControlUI* pParent = GetParent(); if( pParent != NULL ) { RECT rcParentPos = pParent->GetPos(); RECT rcCtrl = {rcParentPos.left + rc.left, rcParentPos.top + rc.top, rcParentPos.left + rc.right, rcParentPos.top + rc.bottom}; m_rcItem = rcCtrl; LONG width = rcParentPos.right - rcParentPos.left; LONG height = rcParentPos.bottom - rcParentPos.top; RECT rcPercent = {(LONG)(width*m_piFloatPercent.left), (LONG)(height*m_piFloatPercent.top), (LONG)(width*m_piFloatPercent.right), (LONG)(height*m_piFloatPercent.bottom)}; m_cXY.cx = rc.left - rcPercent.left; m_cXY.cy = rc.top - rcPercent.top; m_cxyFixed.cx = rc.right - rcPercent.right - m_cXY.cx; m_cxyFixed.cy = rc.bottom - rcPercent.bottom - m_cXY.cy; } } else { m_rcItem = rc; } if( m_pManager == NULL ) return; if( !m_bSetPos ) { m_bSetPos = true; if( OnSize ) OnSize(this); m_bSetPos = false; } m_bUpdateNeeded = false; if( bNeedInvalidate && IsVisible() ) { invalidateRc.Join(m_rcItem); CControlUI* pParent = this; RECT rcTemp; RECT rcParent; while( pParent = pParent->GetParent() ) { if( !pParent->IsVisible() ) return; rcTemp = invalidateRc; rcParent = pParent->GetPos(); if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) return; } m_pManager->Invalidate(invalidateRc); } }
void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode) { TiXmlElement* pElement = pNode->ToElement(); CStringA strName = pElement->Attribute("myname"); pElement->RemoveAttribute("myname"); if(strName.IsEmpty()) return; CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName)); TiXmlAttribute* pAttrib = pElement->FirstAttribute(); if(pControl == NULL) return; while(pAttrib) { if(strcmp(pAttrib->Name(), "name") == 0) { pManager->ReapObjects(pControl); g_pClassView->RenameUITreeItem(pControl, StringConvertor::Utf8ToWide(pAttrib->Value())); pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pManager->InitControls(pControl); } else pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name()) , StringConvertor::Utf8ToWide(pAttrib->Value())); pAttrib = pAttrib->Next(); } CControlUI* pParent = pControl->GetParent(); if(pParent == NULL) pParent = pControl; pParent->SetPos(pParent->GetPos()); }
void CContainerUI::DoPaint(HDC hDC, const RECT& rcPaint) { RECT rcTemp = { 0 }; if( !::IntersectRect(&rcTemp, &rcPaint, &m_rcItem) ) return; CRenderClip clip; CBlueRenderEngineUI::GenerateClip(hDC, m_rcItem, clip); for( int it = 0; it < m_items.GetSize(); it++ ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[it]); if( !pControl->IsVisible() ) continue; if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue; if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue; pControl->DoPaint(hDC, rcPaint); } }
void CDialogLayoutUI::RecalcArea() { if( !m_bFirstResize ) return; // Add the remaining control to the list // Controls that have specific stretching needs will define them in the XML resource // and by calling SetStretchMode(). Other controls needs to be added as well now... for( int it = 0; it < m_items.GetSize(); it++ ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[it]); bool bFound = false; for( int i = 0; !bFound && i < m_aModes.GetSize(); i++ ) { if( static_cast<STRETCHMODE*>(m_aModes[i])->pControl == pControl ) bFound = true; } if( !bFound ) { STRETCHMODE mode; mode.pControl = pControl; mode.uMode = UISTRETCH_NEWGROUP; mode.rcItem = pControl->GetPos(); m_aModes.Add(&mode); } } // Figure out the actual size of the dialog so we can add proper scrollbars later CRect rcDialog(9999, 9999, 0,0); for( int i = 0; i < m_items.GetSize(); i++ ) { const RECT& rcPos = static_cast<CControlUI*>(m_items[i])->GetPos(); rcDialog.Join(rcPos); } for( int j = 0; j < m_aModes.GetSize(); j++ ) { RECT& rcPos = static_cast<STRETCHMODE*>(m_aModes[j])->rcItem; ::OffsetRect(&rcPos, -rcDialog.left, -rcDialog.top); } m_rcDialog = rcDialog; // We're done with initialization m_bFirstResize = false; }
RECT CControlUI::GetRelativePos() const { CControlUI* pParent = GetParent(); if( pParent != NULL ) { RECT rcParentPos = pParent->GetPos(); CDuiRect rcRelativePos(m_rcItem); rcRelativePos.Offset(-rcParentPos.left, -rcParentPos.top); return rcRelativePos; } else { return CDuiRect(0, 0, 0, 0); } }
LRESULT CRichListWnd::OnMouseWheel( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled ) { // 解决ie控件收不到滚动消息的问题 POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; ::ScreenToClient(m_PaintManager.GetPaintWindow(), &pt); CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(_T("ie"))); if( pControl && pControl->IsVisible() ) { RECT rc = pControl->GetPos(); if( ::PtInRect(&rc, pt) ) { return CWindowWnd::HandleMessage(uMsg, wParam, lParam); } } bHandled = FALSE; return 0; }
//************************************ // 函数名称: Invalidate // 返回类型: void // 函数说明: //************************************ void CTreeNodeUI::Invalidate() { if( !IsVisible() ) return; if( GetParent() ) { CContainerUI* pParentContainer = static_cast<CContainerUI*>(GetParent()->GetInterface(_T("Container"))); if( pParentContainer ) { RECT rc = pParentContainer->GetPos(); RECT rcInset = pParentContainer->GetInset(); rc.left += rcInset.left; rc.top += rcInset.top; rc.right -= rcInset.right; rc.bottom -= rcInset.bottom; CScrollBarUI* pVerticalScrollBar = pParentContainer->GetVerticalScrollBar(); if( pVerticalScrollBar && pVerticalScrollBar->IsVisible() ) rc.right -= pVerticalScrollBar->GetFixedWidth(); CScrollBarUI* pHorizontalScrollBar = pParentContainer->GetHorizontalScrollBar(); if( pHorizontalScrollBar && pHorizontalScrollBar->IsVisible() ) rc.bottom -= pHorizontalScrollBar->GetFixedHeight(); RECT invalidateRc = m_rcItem; if( !::IntersectRect(&invalidateRc, &m_rcItem, &rc) ) return; CControlUI* pParent = GetParent(); RECT rcTemp; RECT rcParent; while( pParent = pParent->GetParent() ) { rcTemp = invalidateRc; rcParent = pParent->GetPos(); if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) return; } if( m_pManager != NULL ) m_pManager->Invalidate(invalidateRc); } else { CContainerUI::Invalidate(); } } else { CContainerUI::Invalidate(); } }
void CContainerUI::SetScrollPos(SIZE szPos, bool bMsg) { int cx = 0; int cy = 0; if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) { int iLastScrollPos = m_pVerticalScrollBar->GetScrollPos(); m_pVerticalScrollBar->SetScrollPos(szPos.cy); cy = m_pVerticalScrollBar->GetScrollPos() - iLastScrollPos; } if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) { int iLastScrollPos = m_pHorizontalScrollBar->GetScrollPos(); m_pHorizontalScrollBar->SetScrollPos(szPos.cx); cx = m_pHorizontalScrollBar->GetScrollPos() - iLastScrollPos; } if( cx == 0 && cy == 0 ) return; RECT rcPos; for( int it2 = 0; it2 < m_items.GetSize(); it2++ ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[it2]); if( !pControl->IsVisible() ) continue; if( pControl->IsFloat() ) continue; rcPos = pControl->GetPos(); rcPos.left -= cx; rcPos.right -= cx; rcPos.top -= cy; rcPos.bottom -= cy; pControl->SetPos(rcPos); } Invalidate(); if(m_pVerticalScrollBar) { // 发送滚动消息 if( m_pManager != NULL && bMsg ) { int nPage = (m_pVerticalScrollBar->GetScrollPos() + m_pVerticalScrollBar->GetLineSize()) / m_pVerticalScrollBar->GetLineSize(); m_pManager->SendNotify(this, DUI_MSGTYPE_SCROLL, (WPARAM)nPage); } } }
// int ViCbGetPosHight(VApiHandle hWnd) SQInteger ViCbGetPosHight(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger Handle = 0; CControlUI* pCtrl = NULL; SQInteger nRet = 0; RECT rc = {0}; if (!v || 1 + 1 != nargs) {goto _Exit_;} if (OT_INTEGER != sq_gettype(v, 2)) {goto _Exit_;} sq_getinteger(v, 2, &Handle); pCtrl = QiHwHandleToCtrl(Handle); if (!pCtrl) {goto _Exit_;} rc = pCtrl->GetPos(); nRet = rc.bottom - rc.top; _Exit_: sq_pushinteger(v, nRet); return 1; }
void CControlUI::Invalidate() { if( !IsVisible() ) return; RECT invalidateRc = m_rcItem; CControlUI* pParent = this; RECT rcTemp; RECT rcParent; while( pParent = pParent->GetParent() ) { rcTemp = invalidateRc; rcParent = pParent->GetPos(); if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) { return; } } if( m_pManager != NULL ) m_pManager->Invalidate(invalidateRc); }
void CComboBoxUI::PaintText(HDC hDC) { RECT rcText = m_rcItem; rcText.left += m_rcTextPadding.left; rcText.right -= m_rcTextPadding.right; rcText.top += m_rcTextPadding.top; rcText.bottom -= m_rcTextPadding.bottom; rcText.right -= m_nArrowWidth; // add this line than CComboUI::PaintText(HDC hDC) if( m_iCurSel >= 0 ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); IListItemUI* pElement = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pElement != NULL ) { pElement->DrawItemText(hDC, rcText); } else { RECT rcOldPos = pControl->GetPos(); pControl->SetPos(rcText); pControl->DoPaint(hDC, rcText); pControl->SetPos(rcOldPos); } } }
void CDropDownUI::DoPaint(HDC hDC, const RECT& rcPaint) { // Paint the nice frame int cy = m_rcItem.bottom - m_rcItem.top; ::SetRect(&m_rcButton, m_rcItem.right - cy, m_rcItem.top, m_rcItem.right, m_rcItem.bottom); RECT rcText = { m_rcItem.left, m_rcItem.top, m_rcButton.left + 1, m_rcItem.bottom }; if( !IsEnabled() ) { CBlueRenderEngineUI::DoPaintFrame(hDC, m_pManager, rcText, UICOLOR_CONTROL_BORDER_DISABLED, UICOLOR__INVALID, UICOLOR__INVALID); } else { CBlueRenderEngineUI::DoPaintFrame(hDC, m_pManager, rcText, UICOLOR_CONTROL_BORDER_NORMAL, UICOLOR_CONTROL_BORDER_NORMAL, UICOLOR__INVALID); } // Paint dropdown edit box ::InflateRect(&rcText, -1, -1); if( m_iCurSel >= 0 ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[m_iCurSel]); IListItemUI* pElement = static_cast<IListItemUI*>(pControl->GetInterface(_T("ListItem"))); if( pElement != NULL ) { // Render item with specific draw-style pElement->DrawItem(hDC, rcText, UIDRAWSTYLE_INPLACE | (m_bFocused ? UIDRAWSTYLE_FOCUS : 0)); } else { // Allow non-listitems to render as well. RECT rcOldPos = pControl->GetPos(); pControl->SetPos(rcText); pControl->DoPaint(hDC, rcText); pControl->SetPos(rcOldPos); } } else { CBlueRenderEngineUI::DoFillRect(hDC, m_pManager, rcText, UICOLOR_CONTROL_BACKGROUND_NORMAL); } // Paint dropdown button RECT rcPadding = { 0 }; CBlueRenderEngineUI::DoPaintButton(hDC, m_pManager, m_rcButton, _T("<i 6>"), rcPadding, m_uButtonState, 0); }
void CMainDialog::OnClick( CControlUI* pSender) { if (pSender->GetName() == TEXT ("btnExit")) { PostQuitMessage(0); return; } else if (pSender->GetName() == _T ("btnTip")) { CControlUI* pbtnTip = static_cast <CControlUI*> (m_pm.FindControl(_T ("btnTip"))); if (pbtnTip) { pbtnTip->SetVisible(false); } CEditUI* peditSearch = static_cast <CEditUI*> (m_pm.FindControl(_T ("editSearch"))); if (peditSearch != NULL) { peditSearch->SetFocus(); } } else if (pSender->GetName() == _T ("lstDelButton")) { int iIndex = 0; CMyList* pParent = static_cast <CMyList*> (pSender->GetParent()->GetParent()); if (pParent) { iIndex = pParent->GetItemIndex(pSender->GetParent()); } CDuiString str; str.Format(_T ("您要删除 %d 项"), iIndex); if (IDNO == MessageBox (GetHWND (), str, NULL, MB_OK | MB_YESNO)) return; CMyList* pList = static_cast <CMyList*> (m_pm.FindControl(_T ("lstControl"))); ASSERT(pList); if (pList) { pList->RemoveAt(iIndex); CControlUI* pItem = pList->GetItemAt(iIndex+5); if (pItem) { const RECT& rc = pItem->GetPos(); SIZE sz = {0, rc.top}; pList->SetScrollPos(sz); } } } else if (pSender->GetName() == _T ("btnAddComboItem")) { CComboUI* pcbx = static_cast <CComboUI*> (m_pm.FindControl(_T ("combo1"))); assert (pcbx); if (pcbx) { CListLabelElementUI* pItem = new CListLabelElementUI (); pItem->SetText(_T ("{b}{i}新加项{/i}{/b}")); pcbx->Add(pItem); } AddComboboxItem(); CComboUI* pcbx2 = static_cast <CComboUI*> (m_pm.FindControl(_T ("combo2"))); } else if (pSender->GetName() == _T ("btnGoIe")) { CActiveXUI* pActiveXUI = static_cast<CActiveXUI*>(m_pm.FindControl(_T("ie"))); if( pActiveXUI ) { IWebBrowser2* pWebBrowser = NULL; pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser); if( pWebBrowser != NULL ) { CEditUI* pEdit = static_cast <CEditUI*> (m_pm.FindControl(_T ("editIePath"))); ASSERT (pEdit); CDuiString strIePath = _T ("www.baidu.com"); if (pEdit) { strIePath = pEdit->GetText(); } WCHAR szPath [1024] = {0}; #if defined(_UNICODE) || defined(UNICODE) lstrcpyW (szPath, strIePath); #else ::MultiByteToWideChar(CP_ACP, 0, strIePath, -1, szPath, 1023); #endif pWebBrowser->Navigate(szPath,NULL,NULL,NULL,NULL); pWebBrowser->Release(); } } } }
LRESULT CMainWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam) { IImageOle * pNewImageOle = NULL; RECT rc = {0}; POINT pt = {LOWORD(lParam), HIWORD(lParam)}; CControlUI * pControl = this->paint_manager_.FindControl(pt); if (pControl != NULL) { if (pControl == m_pSendEdit || pControl == m_pRecvEdit) { ITextServices * pTextServices = ((CRichEditUI *)pControl)->GetTextServices(); IImageOle * pImageOle = NULL; BOOL bRet = RichEdit_GetImageOle(pTextServices, pt, &pImageOle); if (bRet && pImageOle != NULL) { pNewImageOle = pImageOle; pImageOle->GetObjectRect(&rc); } if (pImageOle != NULL) pImageOle->Release(); pTextServices->Release(); } } if (m_pLastImageOle != pNewImageOle) { m_pLastImageOle = pNewImageOle; if (m_pLastImageOle != NULL) { m_ptRBtnDown = pt; if (!::IsWindow((HWND)m_PicBarDlg)) { m_PicBarDlg.Create(m_hWnd, NULL, WS_CHILD|WS_POPUP, WS_EX_TOOLWINDOW); RECT rcPos = {0}; ::GetClientRect((HWND)m_PicBarDlg, &rcPos); m_cxPicBarDlg = rcPos.right-rcPos.left; m_cyPicBarDlg = rcPos.bottom-rcPos.top; } m_PicBarDlg.SetCallBackCtrl(pControl); RECT rc2 = pControl->GetPos(); POINT pt = {rc.right, rc.bottom-m_cyPicBarDlg}; if (pt.x < rc2.left) pt.x = rc2.left; if (pt.x > rc2.right) pt.x = rc2.right; if (pt.y > rc2.bottom-m_cyPicBarDlg) pt.y = rc2.bottom-m_cyPicBarDlg; ::ClientToScreen(m_hWnd, &pt); ::SetWindowPos((HWND)m_PicBarDlg, NULL, pt.x, pt.y, m_cxPicBarDlg, m_cyPicBarDlg, SWP_NOACTIVATE|SWP_SHOWWINDOW); } else { ::ShowWindow((HWND)m_PicBarDlg, SW_HIDE); } } return 0; }
void CDuilib3dFrame::Notify(TNotifyUI& msg) { CStdString strName = msg.pSender->GetName(); if(msg.sType == _T("windowinit")) { } else if (msg.sType == _T("click")) { if (strName == _T("closebtn")) { //Close(); m_cls.Create(m_hWnd,230,false,SW_MINIMIZE,CCloseAnimation::STYLE_CLOSE_ICON); } else if (strName == _T("scanbtn")) { CControlUI* pControl = m_PaintManager.FindControl(_T("testanibtn")); RECT rc = pControl->GetPos(); rc.right = rc.left+64; rc.bottom = rc.top+64; POINT ptCenter = {rc.left+32,rc.top+32}; POINT ptTrans = {-120,100}; CAnimJobUI anim(0,500,ptCenter,ptTrans,1.0f,1.0f); anim.SetTextureFromFile(_T("../bin/skin/texture.png")); m_PaintManager.AddAnimJob(anim); } else if (strName == _T("common") || strName == _T("mumaoption") || strName == _T("shaduoption") || strName == _T("wangdunoption") || strName == _T("fdhoption") || strName == _T("rjgjoption")) { RECT rc = msg.pSender->GetPos(); POINT ptStartCenter = {rc.left+(rc.right-rc.left)/2,rc.top+(rc.bottom-rc.top)/2}; POINT ptTrans = {200,0}; CAnimJobUI anim(0,500,ptStartCenter,ptTrans,1.0f,1.0f,false,false,rc,rc); anim.SetSpeedType(SPEED_LINEAR); m_PaintManager.AddAnimJob(anim); } else if (strName == _T("testanibtn")) { } } else if(msg.sType==_T("selectchanged")) { CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(m_PaintManager.FindControl(_T("switch"))); RECT rcSrc = pControl->GetPos(); RECT rcClip = {rcSrc.left+1,rcSrc.top+1,rcSrc.right-1,rcSrc.bottom};; long rcWidth = rcClip.right - rcClip.left; long rcHeight = rcClip.bottom - rcClip.top; CStdString stdString[8] = {_T("examine"),_T("trojan"),_T("plugins"),_T("vulnerability"),_T("rubbish"),_T("cleanup"),_T("fix"),_T("tool")}; POINT ptStartCenter = {rcClip.left+rcWidth/2,rcClip.top+rcHeight/2}; POINT ptTrans = {-rcWidth,0}; for (int i=0;i<8;++i) { if (strName == stdString[i]) { CAnimJobUI anim(0,500,ptStartCenter,ptTrans,1.0f,1.0f,true,true,rcClip,rcClip); m_PaintManager.AddAnimJob(anim); pControl->SelectItem(i); ptStartCenter.x += rcWidth; CAnimJobUI animTmp(0,500,ptStartCenter,ptTrans,1.0f,1.0f,true,true,rcClip,rcClip,WM_USER+1,pControl); if (m_PaintManager.AddAnimJob(animTmp)) { pControl->SetVisible(false); } } } } else if (msg.sType == _T("tabselect")) { } }
void CMainDialog::OnNotify( TNotifyUI& msg ) { if (msg.sType == _T ("itemactivate")) { if (_tcsicmp (msg.pSender->GetClass(), _T("ListUI")) == 0) { CListUI* pList = static_cast <CListUI*> (m_pm.FindControl(_T ("lstNormal"))); ASSERT(pList); if (pList) { CDuiString str; str.Format(_T ("双击或回车了 %d 项"), pList->GetCurSel()); MessageBox (GetHWND(), str, NULL, MB_OK); } } else if (msg.pSender && msg.pSender->GetParent () && msg.pSender->GetParent ()->GetParent () && _tcsicmp (msg.pSender->GetParent ()->GetParent ()->GetClass(), _T("Tree")) == 0) { CDuiTreeView* pTree1 = static_cast<CDuiTreeView*>(m_pm.FindControl(_T("Tree1"))); if( pTree1 != NULL && pTree1->GetItemIndex(msg.pSender) != -1 ) { if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) { CDuiTreeView::Node* node = (CDuiTreeView::Node*)msg.pSender->GetTag(); pTree1->SetChildVisible(node, !node->data()._child_visible); } } } } if( msg.sType == _T("itemclick") ) { if (msg.pSender && msg.pSender->GetParent () && msg.pSender->GetParent ()->GetParent () && _tcsicmp (msg.pSender->GetParent ()->GetParent ()->GetClass(), _T("Tree")) == 0) { CDuiTreeView* pTree1 = static_cast<CDuiTreeView*>(m_pm.FindControl(_T("Tree1"))); if( pTree1 && pTree1->GetItemIndex(msg.pSender) != -1 ) { if( _tcscmp(msg.pSender->GetClass(), _T("ListLabelElementUI")) == 0 ) { CDuiTreeView::Node* node = (CDuiTreeView::Node*)msg.pSender->GetTag(); POINT pt = { 0 }; ::GetCursorPos(&pt); ::ScreenToClient(m_pm.GetPaintWindow(), &pt); pt.x -= msg.pSender->GetX(); SIZE sz = pTree1->GetExpanderSizeX(node); if( pt.x >= sz.cx && pt.x < sz.cy ) pTree1->SetChildVisible(node, !node->data()._child_visible); } } } } if (_tcscmp(msg.pSender->GetClass(), _T("ListHeaderItemUI")) == 0 && msg.sType == _T ("headerclick")) { CListUI* pList = static_cast <CListUI*> (m_pm.FindControl(_T ("lstNormal"))); ASSERT(pList); if (pList) { CListHeaderUI* pHeader = pList->GetHeader(); ASSERT(pHeader); if (pHeader) { for (int i = 0; i < pHeader->GetCount(); ++i) { CControlUI* pItem = pHeader->GetItemAt (i); ASSERT(pItem); if (pItem) { if (PtInRect (&pItem->GetPos(), msg.ptMouse)) { CDuiString str; str.Format(_T ("单击了头 %d 项"), i); MessageBox (GetHWND(), str, NULL, MB_OK); } } } } } } CDuiDialog::OnNotify(msg); }
void CContainerUI::DoPaint(HDC hDC, const RECT& rcPaint) { RECT rcTemp = { 0 }; if( !::IntersectRect(&rcTemp, &rcPaint, &m_rcItem) ) return; CRenderClip clip; CRenderClip::GenerateClip(hDC, rcTemp, clip); CControlUI::DoPaint(hDC, rcPaint); if( m_items.GetSize() > 0 ) { RECT rc = m_rcItem; rc.left += m_rcInset.left; rc.top += m_rcInset.top; rc.right -= m_rcInset.right; rc.bottom -= m_rcInset.bottom; if( m_pVerticalScrollBar && m_pVerticalScrollBar->IsVisible() ) rc.right -= m_pVerticalScrollBar->GetFixedWidth(); if( m_pHorizontalScrollBar && m_pHorizontalScrollBar->IsVisible() ) rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight(); if( !::IntersectRect(&rcTemp, &rcPaint, &rc) ) { for( int it = 0; it < m_items.GetSize(); it++ ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[it]); if( !pControl->IsVisible() ) continue; if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue; if( pControl ->IsFloat() ) { if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue; pControl->DoPaint(hDC, rcPaint); } } } else { CRenderClip childClip; CRenderClip::GenerateClip(hDC, rcTemp, childClip); for( int it = 0; it < m_items.GetSize(); it++ ) { CControlUI* pControl = static_cast<CControlUI*>(m_items[it]); if( !pControl->IsVisible() ) continue; if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue; if( pControl ->IsFloat() ) { if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue; CRenderClip::UseOldClipBegin(hDC, childClip); pControl->DoPaint(hDC, rcPaint); CRenderClip::UseOldClipEnd(hDC, childClip); } else { if( !::IntersectRect(&rcTemp, &rc, &pControl->GetPos()) ) continue; pControl->DoPaint(hDC, rcPaint); } } } } if( m_pVerticalScrollBar != NULL && m_pVerticalScrollBar->IsVisible() ) { if( ::IntersectRect(&rcTemp, &rcPaint, &m_pVerticalScrollBar->GetPos()) ) { m_pVerticalScrollBar->DoPaint(hDC, rcPaint); } } if( m_pHorizontalScrollBar != NULL && m_pHorizontalScrollBar->IsVisible() ) { if( ::IntersectRect(&rcTemp, &rcPaint, &m_pHorizontalScrollBar->GetPos()) ) { m_pHorizontalScrollBar->DoPaint(hDC, rcPaint); } } }