soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SGradient.h
1#ifndef _SGRADIENT_H_
2#define _SGRADIENT_H_
3
4#include <interface/SGradient-i.h>
5#include <sobject/Sobject.hpp>
6#include <helper/obj-ref-impl.hpp>
7#include <souicoll.h>
8
9SNSBEGIN
10
11/**
12 * @class SGradient
13 * @brief Gradient management class
14 *
15 * @details This class manages gradient data, including loading and retrieving gradient items.
16 * It implements the `IGradient` interface and provides methods to handle gradient attributes.
17 */
18class SOUI_EXP SGradient : public TObjRefImpl<SObjectImpl<IGradient>> {
19 DEF_SOBJECT(SObjectImpl<IGradient>, L"gradient")
20
21 public:
22 /**
23 * @brief Constructor
24 *
25 * @details Initializes the gradient object.
26 */
27 SGradient();
28
29 public:
30 /**
31 * @brief Gets the gradient data
32 * @return Pointer to the gradient data
33 *
34 * @details Returns a pointer to the array of gradient items.
35 */
36 STDMETHOD_(const GradientItem *, GetGradientData)(CTHIS) SCONST OVERRIDE;
37
38 /**
39 * @brief Gets the length of the gradient
40 * @return Number of gradient items
41 *
42 * @details Returns the number of gradient items in the gradient data.
43 */
44 STDMETHOD_(int, GetGradientLength)(CTHIS) SCONST OVERRIDE;
45
46 protected:
47 /**
48 * @brief Initializes the object after loading from XML
49 * @param pNode Pointer to the XML node
50 * @return HRESULT indicating success or failure
51 *
52 * @details Initializes the gradient object after it has been loaded from an XML node.
53 */
54 STDMETHOD_(void, OnInitFinished)(THIS_ IXmlNode *pNode) OVERRIDE;
55
56 public:
57 SOUI_ATTRS_BEGIN()
58 ATTR_CUSTOM(L"colors", OnAttrColors)
59 SOUI_ATTRS_END()
60
61 protected:
62 /**
63 * @brief Handles the "colors" attribute
64 * @param value Attribute value
65 * @param bLoading TRUE if loading, FALSE otherwise
66 * @return HRESULT indicating success or failure
67 *
68 * @details Processes the "colors" attribute to load gradient colors from the provided value.
69 */
70 HRESULT OnAttrColors(const SStringW &value, BOOL bLoading);
71
72 /**
73 * @brief Loads the color table from an XML node
74 * @param xmlNode Pointer to the XML node
75 * @return Number of colors loaded
76 *
77 * @details Loads the color table from the specified XML node and returns the number of colors loaded.
78 */
79 int LoadColorTable(IXmlNode *xmlNode);
80
81 protected:
82 SArray<GradientItem> m_arrGradient; /**< Array of gradient items. */
83};
84
85SNSEND
86
87#endif // _SGRADIENT_H_
const GradientItem * GetGradientData() SCONST OVERRIDE
Gets the gradient data.
Definition SGradient.cpp:9
int GetGradientLength() SCONST OVERRIDE
Gets the length of the gradient.
Definition SGradient.cpp:14
SArray< GradientItem > m_arrGradient
Definition SGradient.h:82
HRESULT OnAttrColors(const SStringW &value, BOOL bLoading)
Handles the "colors" attribute.
Definition SGradient.cpp:62
SGradient()
Constructor.
Definition SGradient.cpp:5
int LoadColorTable(IXmlNode *xmlNode)
Loads the color table from an XML node.
Definition SGradient.cpp:73
void OnInitFinished(IXmlNode *pNode) OVERRIDE
Initializes the object after loading from XML.
Definition SGradient.cpp:68
A class representing an ASCII string.
Definition sstringw.h:96
Interface for XML nodes.
Definition sxml-i.h:128