soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SUiDef.cpp
1#include "include/souistd.h"
2#include "res.mgr/SUiDef.h"
3#include "helper/SplitString.h"
4#include "helper/SAutoBuf.h"
5
6SNSBEGIN
7
8const static WCHAR KNodeUidef[] = L"uidef";
9const static WCHAR KNodeDefUnit[] = L"unit";
10const static WCHAR KNodeCaret[] = L"caret";
11const static WCHAR KNodeDefFont[] = L"deffont";
12const static WCHAR KNodeFont[] = L"font";
13const static WCHAR KNodeColor[] = L"color";
14const static WCHAR KNodeDim[] = L"dim";
15const static WCHAR KNodeSkin[] = L"skin";
16const static WCHAR KNodeString[] = L"string";
17const static WCHAR KNodeStyle[] = L"style";
18const static WCHAR KNodeTemplate[] = L"template";
19const static WCHAR KNodeObjAttr[] = L"objattr";
20const static WCHAR KNodeGradient[] = L"gradient";
21
22static SXmlNode GetSourceXmlNode(SXmlNode nodeRoot, SXmlDoc &docInit, IResProvider *pResProvider, const wchar_t *pszName)
23{
24 SXmlNode nodeData = nodeRoot.child(pszName, false);
25 if (nodeData)
26 {
27 SXmlAttr attrSrc = nodeData.attribute(L"src", false);
28 if (attrSrc)
29 { //优先从src属性里获取数据
30 if (SApplication::getSingletonPtr()->LoadXmlDocment(docInit, S_CW2T(attrSrc.as_string()), pResProvider))
31 {
32 nodeData = docInit.root().child(pszName);
33 }
34 }
35 }
36 return nodeData;
37}
38
39class SUiDefInfo : public TObjRefImpl<IUiDefInfo> {
40 friend class SUiDef;
41
42 private:
43 SUiDefInfo()
44 {
45 }
46
47 public:
48 UINT Init(IResProvider *pResProvide, LPCTSTR pszUidef) override;
49 UINT Init2(IXmlNode *pNode, BOOL bGlobalDomain, IResProvider *pResProvider = NULL) override;
50 SSkinPool *GetSkinPool() override;
51 SStylePool *GetStylePool() override;
52 STemplatePool *GetTemplatePool() override;
53 SGradientPool *GetGradientPool() override;
54 SObjDefAttr *GetObjDefAttr() override;
55 SNamedColor &GetNamedColor() override;
56 SNamedString &GetNamedString() override;
57 SNamedDimension &GetNamedDimension() override;
58 SNamedFont &GetNamedFont() override;
59 SStringW GetDefFontInfo() override;
60 SXmlNode GetCaretInfo() override;
61
62 protected:
63 SAutoRefPtr<SSkinPool> pSkinPool;
64 SAutoRefPtr<SStylePool> pStylePool;
65 SAutoRefPtr<SObjDefAttr> objDefAttr;
66 SAutoRefPtr<STemplatePool> templatePool;
67 SAutoRefPtr<SGradientPool> gradientPool;
68 SNamedColor namedColor;
69 SNamedString namedString;
70 SNamedDimension namedDim;
71 SNamedFont namedFont;
72
73 SStringW defFontInfo;
74 SXmlDoc xmlCaret;
75};
76
77UINT SUiDefInfo::Init(IResProvider *pResProvider, LPCTSTR pszUidef)
78{
79 UINT bRet = 0;
80 SStringTList strUiDef;
81 if (2 != ParseResID(pszUidef, strUiDef))
82 {
83 SSLOGW() << "warning!!!! Add ResProvider Error.";
84 }
85
86 size_t dwSize = pResProvider->GetRawBufferSize(strUiDef[0], strUiDef[1]);
87 if (dwSize == 0)
88 {
89 SSLOGW() << "warning!!!! uidef was not found in the specified resprovider";
90 }
91 else
92 {
93 SXmlDoc docInit;
94 SAutoBuf strXml;
95 strXml.Allocate(dwSize);
96
97 pResProvider->GetRawBuffer(strUiDef[0], strUiDef[1], strXml, dwSize);
98
99 bool bLoad = docInit.load_buffer(strXml, strXml.size(), xml_parse_default, enc_auto);
100
101 if (!bLoad)
102 { // load xml failed
103 SSLOGD() << "warning!!! load uidef as xml document failed";
104 }
105 else
106 { // init named objects
107 SXmlNode root = docInit.root().child(KNodeUidef, false);
108 if (!root)
109 {
110 SSLOGD() << "warning!!! \"uidef\" element is not the root element of uidef xml";
111 }
112 else
113 {
114 bRet = Init2(&root, TRUE, pResProvider);
115 }
116 }
117 }
118 return bRet;
119}
120
121UINT SUiDefInfo::Init2(IXmlNode *pNode, BOOL bGlobalDomain, IResProvider *pResProvider)
122{
123 UINT uRet = 0;
124 GETUIDEF->PushUiDefInfo(this, TRUE); // make it possible for a uidef element to ref other uidef element in the same package.
125
126 SXmlNode root(pNode);
127 if (bGlobalDomain)
128 {
129 // parse default Unit
130 SXmlNode xmlUnit;
131 xmlUnit = root.child(KNodeDefUnit);
132 if (xmlUnit)
133 {
134 SStringW strUnit = xmlUnit.attribute(L"defUnit").as_string(L"px");
136 if (unit != SLayoutSize::unknow)
137 SLayoutSize::defUnit = unit;
138 }
139
140 xmlCaret.Reset();
141 SXmlNode xmlCaretNode = root.child(KNodeCaret);
142 if (xmlCaretNode)
143 xmlCaret.root().append_copy(xmlCaretNode);
144
145 // parse default font
146 SXmlNode xmlFont;
147 xmlFont = root.child(KNodeDefFont);
148 if (xmlFont)
149 {
150 defFontInfo = xmlFont.attribute(L"value").as_string();
151 }
152 else
153 {
154 xmlFont = root.child(KNodeFont); // compatible to 4.4
155 SXmlAttr attr = xmlFont.first_attribute();
156 while (attr)
157 {
158 if (!defFontInfo.IsEmpty())
159 defFontInfo += L",";
160 if (SStringW(attr.name()).CompareNoCase(L"face") == 0)
161 {
162 defFontInfo += SStringW().Format(L"face:\'%s\'", attr.value());
163 }
164 else
165 defFontInfo += SStringW().Format(L"%s:%s", attr.name(), attr.value());
166 attr = attr.next_attribute();
167 }
168 }
169
170 // load SWindow default attribute
171 SXmlDoc docData;
172 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeObjAttr);
173 if (nodeData)
174 {
175 objDefAttr.Attach(new SObjDefAttr);
176 objDefAttr->Init(nodeData);
177 nodeData.set_userdata(1);
178 }
179
180 uRet |= UDI_GLOBAL;
181 }
182 // load named string
183 {
184 SXmlDoc docData;
185 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeString);
186 if (nodeData)
187 {
188 namedString.Init(nodeData);
189 nodeData.set_userdata(1);
190 uRet |= UDI_STRING;
191 }
192 }
193
194 // load named color
195 {
196 SXmlDoc docData;
197 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeColor);
198 if (nodeData)
199 {
200 namedColor.Init(nodeData);
201 nodeData.set_userdata(1);
202 uRet |= UDI_COLOR;
203 }
204 }
205
206 // load named color
207 {
208 SXmlDoc docData;
209 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeGradient);
210 if (nodeData)
211 {
212 gradientPool.Attach(new SGradientPool);
213 gradientPool->Init(nodeData);
214 nodeData.set_userdata(1);
215 uRet |= UDI_GRADIENT;
216 }
217 }
218 // load named dimension
219 {
220 SXmlDoc docData;
221 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeDim);
222 if (nodeData)
223 {
224 namedDim.Init(nodeData);
225 nodeData.set_userdata(1);
226 uRet |= UDI_DIMENSION;
227 }
228 }
229 // load named font
230 {
231 SXmlDoc docData;
232 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeFont);
233 if (nodeData)
234 {
235 namedFont.Init(nodeData);
236 nodeData.set_userdata(1);
237 uRet |= UDI_FONT;
238 }
239 }
240 // load named skin
241 {
242 SXmlDoc docData;
243 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeSkin);
244 if (nodeData)
245 {
246 pSkinPool.Attach(new SSkinPool(TRUE));
247 pSkinPool->LoadSkins(&nodeData);
248 nodeData.set_userdata(1);
249 uRet |= UDI_SKIN;
250 }
251 }
252 // load named style
253 {
254 SXmlDoc docData;
255 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeStyle);
256 if (nodeData)
257 {
258 pStylePool.Attach(new SStylePool);
259 pStylePool->Init(nodeData);
260 nodeData.set_userdata(1);
261 uRet |= UDI_STYLE;
262 }
263 }
264 // load named template
265 {
266 SXmlDoc docData;
267 SXmlNode nodeData = GetSourceXmlNode(root, docData, pResProvider, KNodeTemplate);
268 if (nodeData)
269 {
270 templatePool.Attach(new STemplatePool);
271 templatePool->Init(nodeData);
272 nodeData.set_userdata(1);
273 uRet |= UDI_TEMPLATE;
274 }
275 }
276 GETUIDEF->PopUiDefInfo(this, TRUE);
277
278 return uRet;
279}
280
281SSkinPool *SUiDefInfo::GetSkinPool()
282{
283 return pSkinPool;
284}
285SStylePool *SUiDefInfo::GetStylePool()
286{
287 return pStylePool;
288}
289SNamedColor &SUiDefInfo::GetNamedColor()
290{
291 return namedColor;
292}
293SNamedString &SUiDefInfo::GetNamedString()
294{
295 return namedString;
296}
297SNamedDimension &SUiDefInfo::GetNamedDimension()
298{
299 return namedDim;
300}
301
302SNamedFont &SUiDefInfo::GetNamedFont()
303{
304 return namedFont;
305}
306
307SObjDefAttr *SUiDefInfo::GetObjDefAttr()
308{
309 return objDefAttr;
310}
311SStringW SUiDefInfo::GetDefFontInfo()
312{
313 return defFontInfo;
314}
315
316SXmlNode SUiDefInfo::GetCaretInfo()
317{
318 return xmlCaret.root().child(L"caret");
319}
320
321STemplatePool *SUiDefInfo::GetTemplatePool()
322{
323 return templatePool;
324}
325
326SGradientPool *SUiDefInfo::GetGradientPool()
327{
328 return gradientPool;
329}
330//////////////////////////////////////////////////////////////////////////
332 : SFontPool(fac)
333{
334 SAutoLock autolock(m_cs);
335 IUiDefInfo *emptyUiInfo = CreateUiDefInfo();
336 SetUiDef(emptyUiInfo, false); // set empty uiinfo
337 emptyUiInfo->Release();
338
339 m_bulitinSkinPool.Attach(new SSkinPool(TRUE));
340 m_lstSkinPools.AddTail(m_bulitinSkinPool);
341 m_bulitinSkinPool->AddRef();
342}
343
345{
346 SAutoLock autolock(m_cs);
347 {
348 SPOSITION pos = m_lstUiDefInfo.GetHeadPosition();
349 while (pos)
350 {
351 IObjRef *p = m_lstUiDefInfo.GetNext(pos);
352 p->Release();
353 }
354 m_lstUiDefInfo.RemoveAll();
355 m_defUiDefInfo = NULL;
356 }
357 {
358 SPOSITION pos = m_lstSkinPools.GetHeadPosition();
359 while (pos)
360 {
361 ISkinPool *p = m_lstSkinPools.GetNext(pos);
362 p->Release();
363 }
364 m_lstSkinPools.RemoveAll();
365 m_bulitinSkinPool = NULL;
366 }
367}
368
369BOOL SUiDef::InitDefUiDef(IResProvider *pResProvider, LPCTSTR pszUiDef)
370{
371 IUiDefInfo *pRet = CreateUiDefInfo();
372 UINT uRet = pRet->Init(pResProvider, pszUiDef);
373 if (uRet == 0)
374 {
375 pRet->Release();
376 return FALSE;
377 }
378 SetUiDef(pRet, true);
379 pRet->Release();
380 return TRUE;
381}
382
384{
385 SAutoLock autolock(m_cs);
386 return m_defUiDefInfo;
387}
388
389void SUiDef::SetUiDef(IUiDefInfo *pUiDefInfo, bool bUpdateDefFont)
390{
391 SAutoLock autolock(m_cs);
392 SASSERT(pUiDefInfo);
393 if (m_defUiDefInfo)
394 {
395 SASSERT(m_lstUiDefInfo.GetHead() == m_defUiDefInfo);
396 IUiDefInfo *defUI = m_lstUiDefInfo.RemoveHead();
397 defUI->Release();
398 m_defUiDefInfo = NULL;
399 }
400 m_defUiDefInfo = pUiDefInfo;
401 // add to uidef list.
402 m_lstUiDefInfo.AddHead(pUiDefInfo);
403 pUiDefInfo->AddRef();
404
405 SetDefFontInfo(m_defUiDefInfo->GetDefFontInfo());
406}
407
408void SUiDef::PushUiDefInfo(IUiDefInfo *pUiDefInfo, BOOL bPreivate)
409{
410 SAutoLock autolock(m_cs);
411 m_lstUiDefInfo.AddTail(pUiDefInfo);
412 pUiDefInfo->AddRef();
413 if (bPreivate)
414 m_cs.Enter();
415}
416
417BOOL SUiDef::PopUiDefInfo(IUiDefInfo *pUiDefInfo, BOOL bPreivate)
418{
419 SAutoLock autolock(m_cs);
420 if (bPreivate)
421 m_cs.Leave();
422 if (!pUiDefInfo)
423 {
424 if (m_lstUiDefInfo.IsEmpty())
425 return FALSE;
426 pUiDefInfo = m_lstUiDefInfo.RemoveTail();
427 pUiDefInfo->Release();
428 return TRUE;
429 }
430 else
431 {
432 SPOSITION pos = m_lstUiDefInfo.Find(pUiDefInfo);
433 if (!pos)
434 return FALSE;
435 m_lstUiDefInfo.RemoveAt(pos);
436 pUiDefInfo->Release();
437 return TRUE;
438 }
439}
440
441void SUiDef::PushSkinPool(ISkinPool *pSkinPool)
442{
443 SAutoLock autolock(m_cs);
444 if (pSkinPool == m_bulitinSkinPool)
445 return;
446 m_lstSkinPools.AddTail(pSkinPool);
447 pSkinPool->AddRef();
448}
449
450BOOL SUiDef::PopSkinPool(ISkinPool *pSkinPool)
451{
452 SAutoLock autolock(m_cs);
453 if (pSkinPool == m_bulitinSkinPool)
454 return FALSE;
455 SPOSITION pos = m_lstSkinPools.Find(pSkinPool);
456 if (!pos)
457 return FALSE;
458
459 m_lstSkinPools.RemoveAt(pos);
460 pSkinPool->Release();
461 return TRUE;
462}
463
464ISkinObj *SUiDef::GetSkin(const SStringW &strSkinName, int nScale)
465{
466 SAutoLock autolock(m_cs);
467 {
468 SPOSITION pos = m_lstSkinPools.GetTailPosition();
469 while (pos)
470 {
471 ISkinPool *pSkinPool = m_lstSkinPools.GetPrev(pos);
472 if (ISkinObj *pSkin = pSkinPool->GetSkin(strSkinName, nScale))
473 {
474 return pSkin;
475 }
476 }
477 }
478 {
479 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
480 while (pos)
481 {
482 IUiDefInfo *pUiInfo = m_lstUiDefInfo.GetPrev(pos);
483 SSkinPool *pSkinPool = pUiInfo->GetSkinPool();
484 if (!pSkinPool)
485 continue;
486 if (ISkinObj *pSkin = pSkinPool->GetSkin(strSkinName, nScale))
487 {
488 return pSkin;
489 }
490 }
491 }
492
493 if (wcscmp(strSkinName, L"") != 0)
494 {
495 SSLOGW() << L"GetSkin[" << strSkinName.c_str() << L"] Failed!";
496 }
497 return NULL;
498}
499
500static const wchar_t *BUILDIN_SKIN_NAMES[] = {
501 L"_skin.sys.checkbox", L"_skin.sys.radio", L"_skin.sys.focuscheckbox", L"_skin.sys.focusradio", L"_skin.sys.btn.normal", L"_skin.sys.scrollbar", L"_skin.sys.border", L"_skin.sys.dropbtn", L"_skin.sys.tree.toggle", L"_skin.sys.tree.checkbox", L"_skin.sys.tree.lines", L"_skin.sys.tab.page", L"_skin.sys.header", L"_skin.sys.split.vert", L"_skin.sys.split.horz", L"_skin.sys.prog.bkgnd", L"_skin.sys.prog.bar", L"_skin.sys.vert.prog.bkgnd", L"_skin.sys.vert.prog.bar", L"_skin.sys.slider.thumb", L"_skin.sys.btn.close", L"_skin.sys.btn.minimize", L"_skin.sys.btn.maxmize", L"_skin.sys.btn.restore", L"_skin.sys.menu.check", L"_skin.sys.menu.sep", L"_skin.sys.menu.arrow", L"_skin.sys.menu.border", L"_skin.sys.menu.skin", L"_skin.sys.icons", L"_skin.sys.wnd.bkgnd", L"_skin.sys.btn.prev", L"_skin.sys.btn.next", L"_skin.sys.spin.down", L"_skin.sys.spin.up", L"_skin.sys.switch", L"_skin.sys.switch_bg",
502};
503
504ISkinObj *SUiDef::GetBuiltinSkin(SYS_SKIN uID, int nScale)
505{
506 SAutoLock autolock(m_cs);
507 return GetBuiltinSkinPool()->GetSkin(BUILDIN_SKIN_NAMES[uID], nScale);
508}
509
511{
512 SAutoLock autolock(m_cs);
513 return m_bulitinSkinPool;
514}
515
517{
518 SAutoLock autolock(m_cs);
519 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
520 while (pos)
521 {
522 IUiDefInfo *pUiInfo = m_lstUiDefInfo.GetPrev(pos);
523 SStylePool *pStylePool = pUiInfo->GetStylePool();
524 if (!pStylePool)
525 continue;
526 SXmlNode style = pStylePool->GetStyle(strName);
527 if (style)
528 return style;
529 }
530 return SXmlNode();
531}
532
534{
535 SAutoLock autolock(m_cs);
536 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
537 while (pos)
538 {
539 IUiDefInfo *pUiInfo = m_lstUiDefInfo.GetPrev(pos);
540 STemplatePool *pPool = pUiInfo->GetTemplatePool();
541 if (!pPool)
542 continue;
543 SStringW strRet = pPool->GetTemplateString(strName);
544 if (!strRet.IsEmpty())
545 return strRet;
546 }
547 return SStringW();
548}
549
550IGradient *SUiDef::GetGradient(const SStringW &strName)
551{
552 SAutoLock autolock(m_cs);
553 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
554 while (pos)
555 {
556 IUiDefInfo *pUiInfo = m_lstUiDefInfo.GetPrev(pos);
557 SGradientPool *pPool = pUiInfo->GetGradientPool();
558 if (!pPool)
559 continue;
560 IGradient *pRet = pPool->GetGradient(strName);
561 if (pRet)
562 return pRet;
563 }
564 return NULL;
565}
566
567COLORREF SUiDef::GetColor(const SStringW &strColor)
568{
569 SAutoLock autolock(m_cs);
570 COLORREF cr = CR_INVALID;
571 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
572 while (pos)
573 {
574 IUiDefInfo *pUiDefInfo = m_lstUiDefInfo.GetPrev(pos);
575 if (pUiDefInfo->GetNamedColor().Get(strColor, cr))
576 return cr;
577 }
578 return cr;
579}
580
581COLORREF SUiDef::GetColor(int idx)
582{
583 SAutoLock autolock(m_cs);
584 return GetUiDef()->GetNamedColor().Get(idx);
585}
586
588{
589 SAutoLock autolock(m_cs);
590 SStringW ret;
591 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
592 while (pos)
593 {
594 IUiDefInfo *pUiDefInfo = m_lstUiDefInfo.GetPrev(pos);
595 if (pUiDefInfo->GetNamedString().Get(strString, ret))
596 return ret;
597 }
598 ret = strString;
599 return ret;
600}
601
603{
604 SAutoLock autolock(m_cs);
605 return GetUiDef()->GetNamedString().Get(idx);
606}
607
609{
610 SAutoLock autolock(m_cs);
611 SLayoutSize ret;
612 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
613 while (pos)
614 {
615 IUiDefInfo *pUiDefInfo = m_lstUiDefInfo.GetPrev(pos);
616 if (pUiDefInfo->GetNamedDimension().Get(strSize, ret))
617 return ret;
618 }
619 return ret;
620}
621
623{
624 SAutoLock autolock(m_cs);
625 return GetUiDef()->GetNamedDimension().Get(idx);
626}
627
629{
630 SAutoLock autolock(m_cs);
631 SStringW ret;
632 SPOSITION pos = m_lstUiDefInfo.GetTailPosition();
633 while (pos)
634 {
635 IUiDefInfo *pUiDefInfo = m_lstUiDefInfo.GetPrev(pos);
636 if (pUiDefInfo->GetNamedFont().Get(strFont, ret))
637 return ret;
638 }
639 ret = strFont;
640 return ret;
641}
642
644{
645 SAutoLock autolock(m_cs);
646 return GetUiDef()->GetNamedFont().Get(idx);
647}
648
650{
651 return new SUiDefInfo();
652}
653
654ISkinPool *SUiDef::CreateSkinPool(BOOL bAutoScale)
655{
656 return new SSkinPool(bAutoScale);
657}
658
659IFontPtr SUiDef::GetFont(const SStringW &strFont, int scale)
660{
661 SAutoLock lock(m_cs);
662 return SFontPool::_GetFont(strFont, scale);
663}
664
665void SUiDef::SetDefFontInfo(const SStringW &strFontInfo)
666{
667 SAutoLock lock(m_cs);
668 SFontPool::_SetDefFontInfo(strFontInfo);
669}
670
672{
673 SAutoLock lock(m_cs);
675}
676
677SNSEND
Header file for the SAutoBuf class, a smart buffer management class.
char * Allocate(size_t nElements)
Allocates a buffer of the specified size. If a buffer is already allocated, it will be freed first.
Definition SAutoBuf.cpp:40
size_t size()
Returns the size of the managed buffer.
Definition SAutoBuf.cpp:35
Auto-lock class for managing critical sections.
const FontInfo & _GetDefFontInfo() const
Get constant reference to default font information.
SFontPool(IRenderFactory *fac)
Constructor.
Definition SFontPool.cpp:41
IFontPtr _GetFont(const SStringW &strFont, int scale)
Get IFontPtr corresponding to the specified description string.
Definition SFontPool.cpp:74
void _SetDefFontInfo(const SStringW &strFontInfo)
Set default font description string.
Manages the mapping of gradient names to IGradient objects.
IGradient * GetGradient(const SStringW &strName)
Retrieves the gradient object by its name.
布局大小类
Definition SLayoutSize.h:10
static SLayoutSize::Unit unitFromString(const SStringW &strUnit)
从字符串解析单位
Unit
布局大小单位枚举
Definition SLayoutSize.h:17
Manages named colors.
BOOL Get(const SStringW &strValue, COLORREF &cr) const
Retrieves a color value by name, automatically converting named colors.
Manages named dimensions.
BOOL Get(const SStringW &strValue, SLayoutSize &ret) const
Retrieves a dimension value by name, automatically converting named dimensions.
Manages named fonts.
BOOL Get(const SStringW &strValue, SStringW &ret) const
Retrieves a font value by name, automatically converting named fonts.
Manages named strings.
BOOL Get(const SStringW &strValue, SStringW &ret) const
Retrieves a string value by name, automatically converting named strings.
Class for managing default attributes of objects.
Definition SObjDefAttr.h:17
static SApplication * getSingletonPtr(void)
Definition SSingleton.h:73
Manages the mapping of skin names to ISkinObj objects.
Definition SSkinPool.h:135
ISkinObj * GetSkin(LPCWSTR strSkinName, int nScale) OVERRIDE
Retrieves a skin object by name and scale.
A class representing an ASCII string.
Definition sstringw.h:96
const wchar_t * c_str() SCONST
Retrieves a C-style string representation of the string.
BOOL IsEmpty() SCONST
Checks if the string is empty.
Manages the mapping of style names to XML nodes.
Definition SStylePool.h:28
SXmlNode GetStyle(const SStringW &strName)
Retrieves a style XML node by name.
Manages the mapping of template names to template strings.
Definition SStylePool.h:56
SStringW GetTemplateString(const SStringW &strName) const
Retrieves a template string by name.
~SUiDef(void)
Destructor.
Definition SUiDef.cpp:344
FontInfo GetDefFontInfo() const
Retrieves the default font information.
Definition SUiDef.cpp:671
SUiDef(IRenderFactory *fac)
Constructor.
Definition SUiDef.cpp:331
void PushUiDefInfo(IUiDefInfo *pUiDefInfo, BOOL bPreivate=FALSE)
Pushes a new UI definition information object onto the stack.
Definition SUiDef.cpp:408
IUiDefInfo * GetUiDef()
Retrieves the default UI definition.
Definition SUiDef.cpp:383
SStringW GetTemplateString(const SStringW &strName)
Retrieves a template string by name.
Definition SUiDef.cpp:533
IGradient * GetGradient(const SStringW &strName)
Retrieves a gradient object by name.
Definition SUiDef.cpp:550
ISkinObj * GetSkin(const SStringW &strSkinName, int nScale)
Retrieves a skin object by name and scale.
Definition SUiDef.cpp:464
static IUiDefInfo * CreateUiDefInfo()
Creates a new UI definition information object.
Definition SUiDef.cpp:649
void SetUiDef(IUiDefInfo *pUiDefInfo, bool bUpdateDefFont)
Sets the default UI definition.
Definition SUiDef.cpp:389
SXmlNode GetStyle(const SStringW &strName)
Retrieves a style XML node by name.
Definition SUiDef.cpp:516
SLayoutSize GetLayoutSize(const SStringW &strSize)
Retrieves a layout size from a string name.
Definition SUiDef.cpp:608
BOOL InitDefUiDef(IResProvider *pResProvider, LPCTSTR pszUiDef)
Initializes the default UI definition.
Definition SUiDef.cpp:369
void SetDefFontInfo(const SStringW &strFontInfo)
Sets the default font information.
Definition SUiDef.cpp:665
SStringW GetFontDesc(const SStringW &strFont)
Retrieves a font description from a string name.
Definition SUiDef.cpp:628
SStringW GetString(const SStringW &strString)
Retrieves a string value from a string name.
Definition SUiDef.cpp:587
ISkinObj * GetBuiltinSkin(SYS_SKIN uID, int nScale)
Retrieves a built-in skin object by ID and scale.
Definition SUiDef.cpp:504
COLORREF GetColor(const SStringW &strColor)
Retrieves a color value from a string.
Definition SUiDef.cpp:567
BOOL PopUiDefInfo(IUiDefInfo *pUiDefInfo, BOOL bPreivate=FALSE)
Pops a UI definition information object from the stack.
Definition SUiDef.cpp:417
void PushSkinPool(ISkinPool *pSkinPool)
Pushes a new skin pool onto the stack.
Definition SUiDef.cpp:441
IFontPtr GetFont(const SStringW &strFont, int scale)
Retrieves a font object by description and scale.
Definition SUiDef.cpp:659
BOOL PopSkinPool(ISkinPool *pSkinPool)
Pops a skin pool from the stack.
Definition SUiDef.cpp:450
static ISkinPool * CreateSkinPool(BOOL bAutoScale=TRUE)
Creates a new skin pool.
Definition SUiDef.cpp:654
ISkinPool * GetBuiltinSkinPool()
Retrieves the built-in skin pool.
Definition SUiDef.cpp:510
Class representing an XML attribute.
Definition SXml.h:20
SXmlAttr next_attribute() const
Gets the next attribute in the attribute list of the parent node.
Definition SXml.cpp:180
const wchar_t * name() const
Gets the attribute name.
Definition SXml.cpp:85
const wchar_t * as_string(const wchar_t *def=L"") const
Gets the attribute value as a string.
Definition SXml.cpp:95
const wchar_t * value() const
Gets the attribute value.
Definition SXml.cpp:90
Implementation of IXmlDoc.
Definition SXml.h:912
SXmlNode root() const
Retrieves the root node of the document.
Definition SXml.cpp:754
bool load_buffer(const void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer.
Definition SXml.cpp:726
Class representing an XML node.
Definition SXml.h:352
SXmlAttr first_attribute() const
Gets the first attribute of the node.
Definition SXml.cpp:373
SXmlAttr append_copy(const SXmlAttr &proto)
Adds a copy of the specified attribute.
Definition SXml.cpp:478
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
Definition SXml.cpp:428
SXmlNode root() const
Gets the root node of the DOM tree this node belongs to.
Definition SXml.cpp:418
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
BOOL set_userdata(int data) OVERRIDE
Sets user data for the node.
Definition SXml.cpp:270
Template class implementing the IObjRef interface.
Font information structure.
Definition SFontInfo.h:51
Interface for reference counting.
Definition obj-ref-i.h:19
long AddRef() PURE
Increases the reference count.
long Release() PURE
Decreases the reference count.
RenderFactory object.
Definition SRender-i.h:2018
ResProvider对象
BOOL GetRawBuffer(LPCTSTR pszType, LPCTSTR pszResName, LPVOID pBuf, size_t size) PURE
获得资源内存块
size_t GetRawBufferSize(LPCTSTR pszType, LPCTSTR pszResName) PURE
获得资源数据大小
Interface for Skin Objects.
Definition SSkinobj-i.h:29
Interface for UI definition information.
Definition SUiDef.h:35
virtual SSkinPool * GetSkinPool()=0
Retrieves the skin pool.
virtual SNamedString & GetNamedString()=0
Retrieves the named string manager.
virtual SNamedDimension & GetNamedDimension()=0
Retrieves the named dimension manager.
virtual UINT Init(IResProvider *pResProvider, LPCTSTR pszUidef)=0
Initializes the UI definition from a resource provider.
virtual SGradientPool * GetGradientPool()=0
Retrieves the gradient pool.
virtual STemplatePool * GetTemplatePool()=0
Retrieves the template pool.
virtual SStylePool * GetStylePool()=0
Retrieves the style pool.
virtual SNamedColor & GetNamedColor()=0
Retrieves the named color manager.
virtual SNamedFont & GetNamedFont()=0
Retrieves the named font manager.
Interface for XML nodes.
Definition sxml-i.h:128