From 0a40bca6deb8ee25fe9380c071d49b8234da76f2 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 15 Jan 2006 00:37:31 +0000 Subject: Fixed style merging problem. --- framework/Web/UI/WebControls/TFont.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'framework/Web/UI/WebControls/TFont.php') diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php index 37a08546..61b43b27 100644 --- a/framework/Web/UI/WebControls/TFont.php +++ b/framework/Web/UI/WebControls/TFont.php @@ -209,26 +209,27 @@ class TFont extends TComponent /** * Merges the font with a new one. - * The fields in the new font will overwrite the current ones. + * If a style field is not set in the current style but set in the new style + * it will take the value from the new style. * @param TFont the new font */ public function mergeWith($font) { if($font===null || $font->_flags===0) return; - if($font->_flags & self::IS_SET_BOLD) + if(($font->_flags & self::IS_SET_BOLD) && !($this->_flags & self::IS_SET_BOLD)) $this->setBold($font->getBold()); - if($font->_flags & self::IS_SET_ITALIC) + if(($font->_flags & self::IS_SET_ITALIC) && !($font->_flags & self::IS_SET_ITALIC)) $this->setItalic($font->getItalic()); - if($font->_flags & self::IS_SET_OVERLINE) + if(($font->_flags & self::IS_SET_OVERLINE) && !($font->_flags & self::IS_SET_OVERLINE)) $this->setOverline($font->getOverline()); - if($font->_flags & self::IS_SET_STRIKEOUT) + if(($font->_flags & self::IS_SET_STRIKEOUT) && !($font->_flags & self::IS_SET_STRIKEOUT)) $this->setStrikeout($font->getStrikeout()); - if($font->_flags & self::IS_SET_UNDERLINE) + if(($font->_flags & self::IS_SET_UNDERLINE) && !($font->_flags & self::IS_SET_UNDERLINE)) $this->setUnderline($font->getUnderline()); - if($font->_flags & self::IS_SET_SIZE) + if(($font->_flags & self::IS_SET_SIZE) && !($this->_flags & self::IS_SET_SIZE)) $this->setSize($font->getSize()); - if($font->_flags & self::IS_SET_NAME) + if(($font->_flags & self::IS_SET_NAME) && !($this->_flags & self::IS_SET_NAME)) $this->setName($font->getName()); } @@ -239,8 +240,9 @@ class TFont extends TComponent */ public function copyFrom($font) { - $this->reset(); - $this->mergeWith($font); + $this->_flags=$font->_flags; + $this->_name=$font->_name; + $this->_size=$font->_size; } /** -- cgit v1.2.3