CControlUI* CVideoFrame::FindChild( CContainerUI* pContainer, LPCTSTR strName ) { if (!pContainer) return NULL; if (_tcsicmp(strName, pContainer->GetName()) == 0) { return pContainer; } for (int i = 0; ; i ++) { CControlUI* pControl = pContainer->GetItemAt(i); if (pControl == NULL) return NULL; if ( _tcsicmp(strName ,pControl->GetName()) == 0) { return pControl; } CContainerUI* pContainerSub = dynamic_cast<CContainerUI*>(pControl); if (pContainerSub) { CControlUI* p = FindChild(pContainerSub, strName); if (p) return p; } } return NULL; }
void CMenuNotify::Notify(TNotifyUI& msg) { if( msg.sType == DUI_MSGTYPE_ITEMCLICK) { CMenuElementUI *pMenuElement = (CMenuElementUI*)msg.pSender; CPaintManagerUI *m_pm = pMenuElement->GetManager(); if (m_pm != NULL) { CControlUI *pRootControl = m_pm->GetRoot(); if (pRootControl != NULL) { CDuiString szMenuName = pRootControl->GetName(); //if (szMenuName == _T("workstation_menu")) //{ CDuiString szText = pMenuElement->GetText(); int index = pMenuElement->GetIndex(); bool bTickStatus = false; switch (index) { case 0: PostMessage(pMainFrame->m_hWnd,WM_CLICKABOUT,0,0); break; } //} } } } }
virtual void Notify(TNotifyUI& msg) { //TRACE(_T("class:%s,Id:%s,event:%s"),msg.pSender->GetClass(),msg.pSender->GetName().GetData(),msg.sType.GetData()); if(0 != msg.sType.Compare(_T("click"))) return; CControlUI * pSender = msg.pSender; if(_tcscmp(pSender->GetName(),_T("closebtn"))==0 || _tcscmp(pSender->GetName(),_T("cancel"))==0) { Close(MBRT_CANCEL); } else if(_tcscmp(pSender->GetName(),_T("yes"))==0 || _tcscmp(pSender->GetName(),_T("ok"))==0) { CCheckBoxUI* pCheckBox= static_cast<CCheckBoxUI*>(GetPaintMgr()->FindControl(_T("checkbox"))); ASSERT(pCheckBox); pCheckBox->IsSelected() ? Close(MBRT_OKCHECKED) : Close(MBRT_OK); } }
CUICommandElement::CUICommandElement(CArray<CControlUI*,CControlUI*>& arrSelected, BOOL bModify) : m_pElementXml(NULL) { TiXmlNode* pNode; m_pElementXml = new TiXmlElement("UIHistory"); for(int i=0; i<arrSelected.GetSize(); i++) { CLayoutManager::SaveProperties(arrSelected[i], m_pElementXml, !bModify); if(i == 0) pNode = m_pElementXml->FirstChild(); else pNode = pNode->NextSibling(); CControlUI* pControl = arrSelected[i]; ASSERT(pNode && pControl); pNode->ToElement()->SetAttribute("myname", StringConvertor::WideToUtf8(pControl->GetName())); CControlUI* pParent = arrSelected[i]->GetParent(); ASSERT(pNode && pParent); pNode->ToElement()->SetAttribute("parentname", StringConvertor::WideToUtf8(pParent->GetName())); } }
LRESULT CRichListWnd::OnMouseHover(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; CControlUI* pHover = m_PaintManager.FindControl(pt); if( pHover == NULL ) return 0; /*演示悬停在下载列表的图标上时,动态变换下载图标状态显示*/ if(pHover->GetName() == _T("down_ico")) { MessageBox(NULL, _T("鼠标在某控件例如按钮上悬停后,对目标控件操作,这里改变了状态图标大小"), _T("DUILIB DEMO"), MB_OK); ((CButtonUI *)pHover)->ApplyAttributeList( _T("normalimage=\"file='downlist_pause.png' dest='15,9,32,26'\"")); } return 0; }
// wchar* ViCbGetName(VApiHandle hWnd) SQInteger ViCbGetName(HSQUIRRELVM v) { SQInteger nargs = sq_gettop(v); SQInteger Handle = 0; CControlUI* pCtrl = NULL; CStdString sName; 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_;} sName = pCtrl->GetName(); _Exit_: sq_pushstring(v, sName.GetData(), sName.GetLength()); return 1; }
static bool OnButtonEvent(void* event) { if (((TEventUI*)event)->Type == UIEVENT_BUTTONDOWN) { CControlUI* pButton = ((TEventUI*)event)->pSender; if (pButton != NULL) { CListContainerElementUI* pListElement = (CListContainerElementUI*)(pButton->GetTag()); if (pButton->GetName() == kcreatGroupControlName) { //创建讨论组 std::string sid; module::getGroupListModule()->onCreateDiscussionGrpDialog(sid); } else { if (pListElement != NULL) pListElement->DoEvent(*(TEventUI*)event); } } } return true; }
void CPropertiesWnd::SetUIValue(CMFCPropertyGridProperty* pProp,int nTag) { CControlUI* pControl = m_wndUIProperties.GetCurUI(); if(pControl == NULL) return; int nUpdate=UPDATE_REDRAW_CONTROL; CString strName=pProp->GetName(); strName.MakeLower(); CString strNewVal; CString strOldVal; strNewVal = pProp->FormatProperty(); strOldVal = m_wndUIProperties.FormatOrigProperty(pProp); if(nTag!=tagName && nTag!=tagText && strName.Find(_T("image"))==-1) { strNewVal.MakeLower(); strOldVal.MakeLower(); } switch(nTag) { case tagName: { CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager(); if(strNewVal.IsEmpty() || pManager->FindControl(strNewVal)) { if(!strNewVal.IsEmpty()) MessageBox(strNewVal + _T(" 名称已被其他控件使用!")); pProp->SetValue((_variant_t)pControl->GetName()); return; } else pManager->ReapObjects(pControl); g_pClassView->RenameUITreeItem(pControl, strNewVal); break; } case tagPos: case tagPadding: SetPropValue(pControl,tagSize); nUpdate=UPDATE_POS; break; case tagSize: case tagMinSize: case tagMaxSize: case tagMinMax: SetUIValue(pProp->GetSubItem(0),-1); SetUIValue(pProp->GetSubItem(1),-1); SetPropValue(pControl,tagPos); nUpdate=UPDATE_POS; break; case tagFloat: case tagColumns: nUpdate=UPDATE_POS; break; case tagVisible: nUpdate=UPDATE_REDRAW_PARENT; break; case tagListHeader: if (strNewVal.Compare(_T("false"))==0) { strNewVal = _T("hidden"); } break; case tagAlpha: { int alpha=_ttoi(strNewVal); if (alpha<0) { strNewVal=_T("0"); pProp->SetValue((_variant_t)(LONG)0); } else { strNewVal=_T("255"); pProp->SetValue((_variant_t)(LONG)255); } break; } } CUIDesignerView* pUIView=g_pMainFrame->GetActiveUIView(); ASSERT(pUIView); TNotifyUI Msg; UIAttribute oldAttrib = {strName, strOldVal}; Msg.pSender=pControl; Msg.sType=_T("PropertyBeginChanged"); Msg.wParam=0; Msg.lParam=(LPARAM)&oldAttrib; pUIView->Notify(Msg); pControl->SetAttribute(strName,strNewVal); pProp->SetOriginalValue(pProp->GetValue()); UIAttribute newAttrib = {strName, strNewVal}; Msg.sType = _T("PropertyEndChanged"); Msg.lParam = (LPARAM)&newAttrib; pUIView->Notify(Msg); if(nTag==tagWindowSize) { Msg.sType=_T("formsize"); Msg.lParam = NULL; pUIView->Notify(Msg); } else if(nTag == tagName) { CPaintManagerUI* pManager = pUIView->GetPaintManager(); pManager->InitControls(pControl); } CControlUI* pParent=pControl->GetParent(); if(pParent==NULL) pParent=pControl; switch(nUpdate) { case UPDATE_POS: pParent->SetPos(pParent->GetPos()); break; case UPDATE_REDRAW_CONTROL: pControl->NeedUpdate(); break; case UPDATE_REDRAW_PARENT: pParent->NeedUpdate(); } }
void YSkinWindow::Notify(TNotifyUI& msg) { CControlUI* pUI = msg.pSender; YTrace_(_T("YSkinWindow::Notify class:%s,event:%s,name:%s"),pUI ? pUI->GetClass():_T(""),msg.sType.GetData(),pUI?pUI->GetName().GetData():_T("")); if (0 == msg.sType.Compare(kClick)) OnClick(msg); else if(0 == msg.sType.Compare(kSelectChanged)) { // if (pUI->IsName(_T("tab1"))) // { // _pSkinLayout->SelectItem(0); // } // else if (pUI->IsName(_T("tab2"))) // { // _pSkinLayout->SelectItem(1); // } _pSkinLayout->SelectItem(msg.pSender->GetTag()); } }