| 23 | } |
| 24 | |
| 25 | BOOL SComboBox::CreateListBox( pugi::xml_node xmlNode ) |
| 26 | { |
| 27 | SASSERT(xmlNode); |
| 28 | //创建列表控件 |
| 29 | pugi::xml_node listStyle = xmlNode.child(L"listStyle"); |
| 30 | SStringW strListClass = listStyle.attribute(L"wndclass").as_string(SListBox::GetClassName()); |
| 31 | m_pListBox=sobj_cast<SListBox>(SApplication::getSingleton().CreateWindowByName(strListClass)); |
| 32 | SASSERT(m_pListBox); |
| 33 | |
| 34 | m_pListBox->SetContainer(GetContainer()); |
| 35 | m_pListBox->InitFromXml(listStyle); |
| 36 | m_pListBox->SetAttribute(L"pos", L"0,0,-0,-0", TRUE); |
| 37 | m_pListBox->SetAttribute(L"hotTrack",L"1",TRUE); |
| 38 | m_pListBox->SetOwner(this); //chain notify message to combobox |
| 39 | m_pListBox->SetID(IDC_DROPDOWN_LIST); |
| 40 | m_pListBox->SSendMessage(UM_SETSCALE, GetScale()); |
| 41 | |
| 42 | //初始化列表数据 |
| 43 | pugi::xml_node xmlNode_Items=xmlNode.child(L"items"); |
| 44 | if(xmlNode_Items) |
| 45 | { |
| 46 | pugi::xml_node xmlNode_Item=xmlNode_Items.child(L"item"); |
| 47 | while(xmlNode_Item) |
| 48 | { |
| 49 | |
| 50 | SStringW strText=xmlNode_Item.attribute(L"text").value(); |
| 51 | int iIcon=xmlNode_Item.attribute(L"icon").as_int(0); |
| 52 | LPARAM lParam=xmlNode_Item.attribute(L"data").as_int(0); |
| 53 | m_pListBox->AddString(S_CW2T(strText),iIcon,lParam); |
| 54 | xmlNode_Item=xmlNode_Item.next_sibling(L"item"); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | if(m_iInitSel!=-1) |
| 59 | { |
| 60 | SetCurSel(m_iInitSel); |
| 61 | } |
| 62 | return TRUE; |
| 63 | } |
| 64 | |
| 65 | int SComboBox::GetListBoxHeight() |
| 66 | { |
nothing calls this directly
no test coverage detected