#pragma once
|
|
#include <helper/SAdapterBase.h>
|
#include "IFontAdapterCallback.h"
|
|
class CFontFaceAdapter : public SAdapterBase
|
{
|
public:
|
|
|
private:
|
SArray<SStringT> m_arrFontFace;
|
IFontFaceAdapterCallback* m_pCB;
|
|
public:
|
CFontFaceAdapter(IFontFaceAdapterCallback* pCB){
|
m_pCB = pCB;
|
}
|
~CFontFaceAdapter(){}
|
|
virtual int getCount()
|
{
|
return m_arrFontFace.GetCount();
|
}
|
|
virtual void getView(int position, SWindow * pItem, pugi::xml_node xmlTemplate)
|
{
|
if (pItem->GetChildrenCount() == 0)
|
pItem->InitFromXml(xmlTemplate);
|
|
SWindow* pFontFace = pItem->FindChildByID(1);
|
SStringT wstrSelSize = m_arrFontFace.GetAt(position).m_strFontFace;
|
pFontFace->SetWindowText(wstrSelSize);
|
|
pItem->SetUserData(position);
|
pItem->GetEventSet()->subscribeEvent(EventItemPanelClick::EventID, Subscriber(&CFontFaceAdapter::OnItemClick, this));
|
}
|
|
SStringT getItemDesc(int position)
|
{
|
return m_arrFontFace.GetAt(position).m_strFontFace;
|
}
|
|
bool OnItemClick(EventArgs *pEvt)
|
{
|
EventItemPanelClick* pEvt_ItemPanel = sobj_cast<EventItemPanelClick>(pEvt);
|
SASSERT(pEvt_ItemPanel);
|
SWindow* pPanel = sobj_cast<SWindow>(pEvt_ItemPanel->sender);
|
SOUI::CPoint pt(GET_X_LPARAM(pEvt_ItemPanel->lParam), GET_Y_LPARAM(pEvt_ItemPanel->lParam));
|
SWND swnd = pPanel->SwndFromPoint(pt, FALSE);
|
SWindow *pClicked = NULL;
|
if (swnd)
|
{
|
pClicked = SWindowMgr::GetWindow(swnd);
|
}
|
|
int nIndex = pPanel->GetUserData();
|
m_pCB->OnClickFontFaceItem(nIndex,GetFontFace(nIndex));
|
|
return true;
|
}
|
|
fontFace getItem(int position)
|
{
|
SASSERT(position >= 0 && position < (int)m_arrFontFace.GetCount());
|
return m_arrFontFace[position];
|
}
|
|
void AddFontFace(const SStringT& strFontFace)
|
{
|
if (L"" != strFontFace)
|
{
|
fontFace fontFace;
|
fontFace.m_strFontFace = strFontFace;
|
m_arrFontFace.Add(fontFace);
|
this->notifyDataSetChanged();
|
}
|
}
|
SStringT GetFontFace(int position)
|
{
|
SASSERT(position >= 0 && position < (int)m_arrFontFace.GetCount());
|
return m_arrFontFace[position].m_strFontFace;
|
}
|
};
|