gwenhywfar  4.3.1
htmlprops.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  begin       : Sat Feb 20 2010
00003  copyright   : (C) 2010 by Martin Preuss
00004  email       : martin@libchipcard.de
00005 
00006  ***************************************************************************
00007  *          Please see toplevel file COPYING for license details           *
00008  ***************************************************************************/
00009 
00010 #ifdef HAVE_CONFIG_H
00011 # include <config.h>
00012 #endif
00013 
00014 #define DISABLE_DEBUGLOG
00015 
00016 
00017 #include "htmlprops_p.h"
00018 
00019 #include <gwenhywfar/misc.h>
00020 
00021 #include <assert.h>
00022 
00023 
00024 
00025 
00026 HTML_PROPS *HtmlProps_new(void) {
00027   HTML_PROPS *pr;
00028 
00029   GWEN_NEW_OBJECT(HTML_PROPS, pr);
00030   pr->refCount=1;
00031   pr->foregroundColor=HTML_PROPS_NOCOLOR;
00032   pr->backgroundColor=HTML_PROPS_NOCOLOR;
00033 
00034   return pr;
00035 }
00036 
00037 
00038 
00039 void HtmlProps_free(HTML_PROPS *pr) {
00040   if (pr) {
00041     assert(pr->refCount);
00042     if (pr->refCount>1) {
00043       pr->refCount--;
00044     }
00045     else {
00046       HtmlFont_free(pr->font);
00047       pr->refCount=0;
00048       GWEN_FREE_OBJECT(pr);
00049     }
00050   }
00051 }
00052 
00053 
00054 
00055 HTML_PROPS *HtmlProps_dup(const HTML_PROPS *pro) {
00056   HTML_PROPS *pr;
00057 
00058   pr=HtmlProps_new();
00059   pr->font=pro->font;
00060   if (pr->font)
00061     HtmlFont_Attach(pr->font);
00062   pr->foregroundColor=pro->foregroundColor;
00063   pr->backgroundColor=pro->backgroundColor;
00064 
00065   return pr;
00066 }
00067 
00068 
00069 
00070 void HtmlProps_Attach(HTML_PROPS *pr) {
00071   assert(pr);
00072   assert(pr->refCount);
00073   pr->refCount++;
00074 }
00075 
00076 
00077 
00078 HTML_FONT *HtmlProps_GetFont(const HTML_PROPS *pr) {
00079   assert(pr);
00080   assert(pr->refCount);
00081   return pr->font;
00082 }
00083 
00084 
00085 
00086 void HtmlProps_SetFont(HTML_PROPS *pr, HTML_FONT *fnt) {
00087   assert(pr);
00088   assert(pr->refCount);
00089   HtmlFont_Attach(fnt);
00090   HtmlFont_free(pr->font);
00091   pr->font=fnt;
00092 }
00093 
00094 
00095 
00096 uint32_t HtmlProps_GetForegroundColor(const HTML_PROPS *pr) {
00097   assert(pr);
00098   assert(pr->refCount);
00099   return pr->foregroundColor;
00100 }
00101 
00102 
00103 
00104 void HtmlProps_SetForegroundColor(HTML_PROPS *pr, uint32_t c) {
00105   assert(pr);
00106   assert(pr->refCount);
00107   pr->foregroundColor=c;
00108 }
00109 
00110 
00111 
00112 uint32_t HtmlProps_GetBackgroundColor(const HTML_PROPS *pr) {
00113   assert(pr);
00114   assert(pr->refCount);
00115   return pr->backgroundColor;
00116 }
00117 
00118 
00119 
00120 void HtmlProps_SetBackgroundColor(HTML_PROPS *pr, uint32_t c) {
00121   assert(pr);
00122   assert(pr->refCount);
00123   pr->backgroundColor=c;
00124 }
00125 
00126 
00127 
00128 
00129 
00130 
00131