BOOL SDropdownList::Create(pugi::xml_node popupStyle) { HWND hParent = m_pOwner->GetDropDownOwner()->GetContainer()->GetHostHwnd(); HWND hWnd=CSimpleWnd::Create(NULL,WS_POPUP,WS_EX_TOPMOST|WS_EX_TOOLWINDOW,0,0,0,0,hParent,0); if(!hWnd) return FALSE; m_pOwner->OnCreateDropDown(this); if(popupStyle) { InitFromXml(popupStyle); m_pListView =FindChildByName2<SListView>(KName_ListView); m_pListView->SetOwner(m_pOwner->GetDropDownOwner()); m_pListView->SetFocus(); } return TRUE; }
SItemPanel::SItemPanel(SWindow *pFrameHost,pugi::xml_node xmlNode,IItemContainer *pItemContainer) :m_pFrmHost(pFrameHost) ,m_pItemContainer(pItemContainer) ,m_dwData(0) ,m_crBk(CR_INVALID) ,m_crHover(CR_INVALID) ,m_crSelBk(RGBA(0,0,128,255)) ,m_lpItemIndex(-1) { SASSERT(m_pFrmHost); SASSERT(m_pItemContainer); SetContainer(this); if(xmlNode) { InitFromXml(xmlNode); BuildWndTreeZorder(); } m_evtSet.addEvent(EVENTID(EventItemPanelClick)); m_evtSet.addEvent(EVENTID(EventItemPanelDbclick)); m_evtSet.addEvent(EVENTID(EventItemPanelRclick)); m_evtSet.addEvent(EVENTID(EventItemPanelHover)); m_evtSet.addEvent(EVENTID(EventItemPanelLeave)); }
void FdoPropertyDefinition::InitFromXml(FdoString* propertyTypeName, FdoSchemaXmlContext* pContext, FdoXmlAttributeCollection* attrs) { InitFromXml( pContext, attrs ); }
BOOL SMessageBoxImpl::OnInitDialog( HWND wnd, LPARAM lInitParam ) { pugi::xml_node uiRoot=s_xmlMsgTemplate.child(L"SOUI"); InitFromXml(uiRoot); UINT uType = s_MsgBoxInfo.uType&0x0F; STabCtrl *pBtnSwitch= FindChildByName2<STabCtrl>(NAME_MSGBOX_BTNSWITCH); SASSERT(pBtnSwitch); pBtnSwitch->SetCurSel(g_msgBtnText[uType].nBtns-1); SWindow *pBtnPanel=pBtnSwitch->GetItem(g_msgBtnText[uType].nBtns-1); SASSERT(pBtnPanel); pugi::xml_node nodeBtnTxt = s_xmlMsgTemplate.child(L"SOUI").child(L"buttonText"); for(int i=0; i<g_msgBtnText[uType].nBtns; i++) { SWindow *pBtn=pBtnPanel->FindChildByName(g_wcsNameOfBtns[i]); int nID = g_msgBtnText[uType].btnInfo[i].uBtnID; pBtn->SetID(nID); SStringT strText = OnGetButtonText(nID); if(strText.IsEmpty()) { const wchar_t *pBtnText = g_msgBtnText[uType].btnInfo[i].szText; //先从模板中的buttonText节点里查按钮的文字 pugi::xml_node nodeTxt = nodeBtnTxt.child(pBtnText); if(nodeTxt) pBtnText=nodeTxt.text().get(); //从翻译引擎中翻译 strText = S_CW2T(TR(pBtnText,GetTranslatorContext())); } pBtn->SetWindowText(strText); } const wchar_t *pszFrameAttr=uiRoot.attribute(L"frameSize").value(); CRect rcFrame; swscanf(pszFrameAttr,L"%d,%d,%d,%d",&rcFrame.left,&rcFrame.top,&rcFrame.right,&rcFrame.bottom); CSize szMin; const wchar_t *pszMinAttr=uiRoot.attribute(L"minSize").value(); swscanf(pszMinAttr,L"%d,%d",&szMin.cx,&szMin.cy); SWindow * pTitle= FindChildByName(NAME_MSGBOX_TITLE); SASSERT(pTitle); pTitle->SetWindowText(S_CW2T(TR(s_MsgBoxInfo.pszCaption?S_CT2W(s_MsgBoxInfo.pszCaption):L"prompt",GetTranslatorContext()))); SWindow * pMsg= FindChildByName(NAME_MSGBOX_TEXT); SASSERT(pMsg); pMsg->SetWindowText(S_CW2T(TR(S_CT2W(s_MsgBoxInfo.pszText),GetTranslatorContext()))); OnSetIcon(s_MsgBoxInfo.uType); pMsg->GetRoot()->UpdateLayout(); CSize szText = pMsg->GetDesiredSize(NULL); CRect rcText = pMsg->GetWindowRect();//获取msg的左边位置 CSize szWnd; szWnd.cx=max(szMin.cx,rcText.left + szText.cx + rcFrame.right); szWnd.cy=max(szMin.cy,rcFrame.top + szText.cy + rcFrame.bottom); SetWindowPos(0,0,0,szWnd.cx,szWnd.cy,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); pMsg->GetRoot()->UpdateLayout(); //将msg text的上下位置设置成和parent相同。 rcText = pMsg->GetWindowRect(); CRect rcTextParent = pMsg->GetParent()->GetWindowRect(); rcText.top = rcTextParent.top; rcText.bottom = rcTextParent.bottom; pMsg->Move(rcText); CenterWindow(); return 0; }