summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TFont.php
diff options
context:
space:
mode:
authorxue <>2006-02-26 18:17:40 +0000
committerxue <>2006-02-26 18:17:40 +0000
commitf6a0691f3cd3ae16dee61b86d0fcfea27a3f751b (patch)
tree920876c937c23ae1fff5a002a14d092d4bd7c9b2 /framework/Web/UI/WebControls/TFont.php
parent3129cef42098493b8a67f872a405fc8b5251da0f (diff)
Fixed an issue about style merging.
Diffstat (limited to 'framework/Web/UI/WebControls/TFont.php')
-rw-r--r--framework/Web/UI/WebControls/TFont.php42
1 files changed, 28 insertions, 14 deletions
diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php
index 2f95e2bd..3fb8bbad 100644
--- a/framework/Web/UI/WebControls/TFont.php
+++ b/framework/Web/UI/WebControls/TFont.php
@@ -209,14 +209,40 @@ class TFont extends TComponent
/**
* Merges the font with a new one.
- * If a font field is set in the new font, the current font field
- * will be overwritten.
+ * If a font field is not set in the font, it will be overwritten with
+ * the new one.
* @param TFont the new font
*/
public function mergeWith($font)
{
if($font===null || $font->_flags===0)
return;
+ if(!($this->_flags & self::IS_SET_BOLD) && ($font->_flags & self::IS_SET_BOLD))
+ $this->setBold($font->getBold());
+ if(!($this->_flags & self::IS_SET_ITALIC) && ($font->_flags & self::IS_SET_ITALIC))
+ $this->setItalic($font->getItalic());
+ if(!($this->_flags & self::IS_SET_OVERLINE) && ($font->_flags & self::IS_SET_OVERLINE))
+ $this->setOverline($font->getOverline());
+ if(!($this->_flags & self::IS_SET_STRIKEOUT) && ($font->_flags & self::IS_SET_STRIKEOUT))
+ $this->setStrikeout($font->getStrikeout());
+ if(!($this->_flags & self::IS_SET_UNDERLINE) && ($font->_flags & self::IS_SET_UNDERLINE))
+ $this->setUnderline($font->getUnderline());
+ if(!($this->_flags & self::IS_SET_SIZE) && ($font->_flags & self::IS_SET_SIZE))
+ $this->setSize($font->getSize());
+ if(!($this->_flags & self::IS_SET_NAME) && ($font->_flags & self::IS_SET_NAME))
+ $this->setName($font->getName());
+ }
+
+ /**
+ * Copies the fields in a new font to this font.
+ * If a font field is set in the new font, the corresponding field
+ * in this font will be overwritten.
+ * @param TFont the new font
+ */
+ public function copyFrom($font)
+ {
+ if($font===null || $font->_flags===0)
+ return;
if($font->_flags & self::IS_SET_BOLD)
$this->setBold($font->getBold());
if($font->_flags & self::IS_SET_ITALIC)
@@ -234,18 +260,6 @@ class TFont extends TComponent
}
/**
- * Copies the font from a new one.
- * The existing font will be cleared up first.
- * @param TFont the new font.
- */
- public function copyFrom($font)
- {
- $this->_flags=$font->_flags;
- $this->_name=$font->_name;
- $this->_size=$font->_size;
- }
-
- /**
* @return string the font in a css style string representation.
*/
public function toString()