123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #include "stdafx.h"
- #include "StabtypeControl.h"
- #include "SRadioBox2.h"
- namespace SOUI
- {
- StabtypeControl::StabtypeControl()
- {
- m_evtSet.addEvent(EVENTID(EventTabtypeControl));
- }
- StabtypeControl::~StabtypeControl()
- {
- }
- void StabtypeControl::DestroyWindowcon()
- {
- SOUI::SWindow * wins = FindChildByName2<SOUI::SWindow>(L"con");
- if (wins)
- {
- //remove all children at first.
- SWindow *pChild = wins->GetWindow(GSW_FIRSTCHILD);
- while (pChild)
- {
- SWindow *pNext = pChild->GetWindow(GSW_NEXTSIBLING);
- pChild->DestroyWindow();
- pChild = pNext;
- }
- }
- }
- void StabtypeControl::ItemCreateChildren(int id, SStringW title,bool checked)
- {
-
- //font = \"adding:12,bold:1\"\
-
- SOUI::SWindow * win = FindChildByName2<SOUI::SWindow>(L"con");
- if (win)
- {
- //font=\"face:微软雅黑, size : 16\"
- SOUI::SStringW strXmlName;
- if (checked)
- {
- //<radio2 size="0,-1" name="" colorTextPush="#D8D8D8" colorText="#D8D8D844" font="adding:12,bold:1" checked="1" skin="skin_tyteselection" align="center" weight="1" extend="0,0,0,0" >US</radio2>
- strXmlName.Format(L"<radio2 id=\"%d\" \
- size=\"0, -1\" \
- cursor=\"hand\" \
- colorText=\"#ffffff\"\
- colorTextPush=\"#ffffff\"\
- align=\"center\"\
- cursor=\"hand\"\
- extend=\"0,0,0,0\" \
- tip=\"%s\" \
- animate=\"1\" \
- skin=\"skin_tyteselection\" \
- name=\"%d\" \
- weight=\"1\"\
- checked=\"1\"> \
- %s</radio2>", id, title, id, title);
- }
- else
- {
- strXmlName.Format(L"<radio2 id=\"%d\" \
- size=\"0, -1\" \
- cursor=\"hand\" \
- colorText=\"#ffffff\"\
- colorTextPush=\"#ffffff\"\
- align=\"center\"\
- cursor=\"hand\"\
- extend=\"5,0,0,0\" \
- tip=\"%s\" \
- animate=\"1\" \
- skin=\"skin_tyteselection\" \
- name=\"%d\" \
- weight=\"1\"\
- checked=\"0\"> \
- %s</radio2>", id, title, id, title);
- }
- win->CreateChildren(strXmlName);
- SOUI::SStringW strbutto;
- strbutto.Format(L"%d", id);
- SOUI::SRadioBox2* pButton =
- FindChildByName2<SOUI::SRadioBox2>(strbutto);
- pButton->GetEventSet()->subscribeEvent(SOUI::EVT_CMD,
- Subscriber(&StabtypeControl::OnBtnClick, this));
- }
- }
- // 创建控件:初始化 xml,绑定事件等等
- int StabtypeControl::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- pugi::xml_document xmlDoc;
- SOUI::SStringW strXml = L"tabtype_control";
- if (!LOADXML(xmlDoc, strXml, L"LAYOUT")) {
- return E_FAIL;
- }
- pugi::xml_node itemXmlNode = xmlDoc.child(L"tabtypecontrol");
- if (!itemXmlNode) {
- return E_FAIL;
- }
- this->CreateChildren(itemXmlNode);
-
- return 0;
- }
- // 按钮点击响应
- bool StabtypeControl::OnBtnClick(SOUI::EventArgs* pEvt)
- {
- // 获取按钮名称,获取后缀数字
- SOUI::SWindow* pButton =
- SOUI::sobj_cast<SOUI::SWindow>(pEvt->sender);
- SOUI::SStringW strName = pButton->GetName();
- //SOUI::SStringW strIndex = strName.Right(1);
- INT nIndex = _wtoi(strName);
- // 发送全局的自定义消息
- EventTabtypeControl evt(this);
- evt.nIndex = nIndex;
- FireEvent(evt); // 激活事件 Fire!!!
- return true;
- }
- }
|