1 /***************************************************************************
2  begin       : Sat Feb 20 2010
3  copyright   : (C) 2010 by Martin Preuss
4  email       : martin@libchipcard.de
5 
6  ***************************************************************************
7  *          Please see toplevel file COPYING for license details           *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 
14 #define DISABLE_DEBUGLOG
15 
16 
17 #include "htmlprops_p.h"
18 
19 #include <gwenhywfar/misc.h>
20 
21 #include <assert.h>
22 
23 
24 
25 
HtmlProps_new(void)26 HTML_PROPS *HtmlProps_new(void)
27 {
28   HTML_PROPS *pr;
29 
30   GWEN_NEW_OBJECT(HTML_PROPS, pr);
31   pr->refCount=1;
32   pr->foregroundColor=HTML_PROPS_NOCOLOR;
33   pr->backgroundColor=HTML_PROPS_NOCOLOR;
34 
35   return pr;
36 }
37 
38 
39 
HtmlProps_free(HTML_PROPS * pr)40 void HtmlProps_free(HTML_PROPS *pr)
41 {
42   if (pr) {
43     assert(pr->refCount);
44     if (pr->refCount>1) {
45       pr->refCount--;
46     }
47     else {
48       HtmlFont_free(pr->font);
49       pr->refCount=0;
50       GWEN_FREE_OBJECT(pr);
51     }
52   }
53 }
54 
55 
56 
HtmlProps_dup(const HTML_PROPS * pro)57 HTML_PROPS *HtmlProps_dup(const HTML_PROPS *pro)
58 {
59   HTML_PROPS *pr;
60 
61   pr=HtmlProps_new();
62   pr->font=pro->font;
63   if (pr->font)
64     HtmlFont_Attach(pr->font);
65   pr->foregroundColor=pro->foregroundColor;
66   pr->backgroundColor=pro->backgroundColor;
67 
68   return pr;
69 }
70 
71 
72 
HtmlProps_Attach(HTML_PROPS * pr)73 void HtmlProps_Attach(HTML_PROPS *pr)
74 {
75   assert(pr);
76   assert(pr->refCount);
77   pr->refCount++;
78 }
79 
80 
81 
HtmlProps_GetFont(const HTML_PROPS * pr)82 HTML_FONT *HtmlProps_GetFont(const HTML_PROPS *pr)
83 {
84   assert(pr);
85   assert(pr->refCount);
86   return pr->font;
87 }
88 
89 
90 
HtmlProps_SetFont(HTML_PROPS * pr,HTML_FONT * fnt)91 void HtmlProps_SetFont(HTML_PROPS *pr, HTML_FONT *fnt)
92 {
93   assert(pr);
94   assert(pr->refCount);
95   HtmlFont_Attach(fnt);
96   HtmlFont_free(pr->font);
97   pr->font=fnt;
98 }
99 
100 
101 
HtmlProps_GetForegroundColor(const HTML_PROPS * pr)102 uint32_t HtmlProps_GetForegroundColor(const HTML_PROPS *pr)
103 {
104   assert(pr);
105   assert(pr->refCount);
106   return pr->foregroundColor;
107 }
108 
109 
110 
HtmlProps_SetForegroundColor(HTML_PROPS * pr,uint32_t c)111 void HtmlProps_SetForegroundColor(HTML_PROPS *pr, uint32_t c)
112 {
113   assert(pr);
114   assert(pr->refCount);
115   pr->foregroundColor=c;
116 }
117 
118 
119 
HtmlProps_GetBackgroundColor(const HTML_PROPS * pr)120 uint32_t HtmlProps_GetBackgroundColor(const HTML_PROPS *pr)
121 {
122   assert(pr);
123   assert(pr->refCount);
124   return pr->backgroundColor;
125 }
126 
127 
128 
HtmlProps_SetBackgroundColor(HTML_PROPS * pr,uint32_t c)129 void HtmlProps_SetBackgroundColor(HTML_PROPS *pr, uint32_t c)
130 {
131   assert(pr);
132   assert(pr->refCount);
133   pr->backgroundColor=c;
134 }
135 
136 
137 
138 
139 
140 
141 
142