diff options
Diffstat (limited to 'framework/Web/UI')
| -rw-r--r-- | framework/Web/UI/WebControls/TDataGrid.php | 77 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TDataList.php | 73 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TFont.php | 18 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TStyle.php | 42 | 
4 files changed, 116 insertions, 94 deletions
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php index 81fe2ce1..f8dd0b17 100644 --- a/framework/Web/UI/WebControls/TDataGrid.php +++ b/framework/Web/UI/WebControls/TDataGrid.php @@ -442,11 +442,11 @@ class TDataGrid extends TBaseDataList  	}
  	/**
 -	 * @return boolean whether datagrid columns should be automatically generated Defaults to false.
 +	 * @return boolean whether datagrid columns should be automatically generated. Defaults to true.
  	 */
  	public function getAutoGenerateColumns()
  	{
 -		return $this->getViewState('AutoGenerateColumns',false);
 +		return $this->getViewState('AutoGenerateColumns',true);
  	}
  	/**
 @@ -454,7 +454,7 @@ class TDataGrid extends TBaseDataList  	 */
  	public function setAutoGenerateColumns($value)
  	{
 -		$this->setViewState('AutoGenerateColumns',TPropertyValue::ensureBoolean($value),false);
 +		$this->setViewState('AutoGenerateColumns',TPropertyValue::ensureBoolean($value),true);
  	}
  	/**
 @@ -1157,33 +1157,22 @@ class TDataGrid extends TBaseDataList  	 */
  	protected function applyItemStyles()
  	{
 +		$itemStyle=$this->getViewState('ItemStyle',null);
 +
 +		$alternatingItemStyle=new TTableItemStyle($itemStyle);
 +		if(($style=$this->getViewState('AlternatingItemStyle',null))!==null)
 +			$alternatingItemStyle->mergeWith($style);
 +
 +		$selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
 +
 +		$editItemStyle=new TTableItemStyle($selectedItemStyle);
 +		if(($style=$this->getViewState('EditItemStyle',null))!==null)
 +			$editItemStyle->copyFrom($style);
 +
  		$headerStyle=$this->getViewState('HeaderStyle',null);
  		$footerStyle=$this->getViewState('FooterStyle',null);
  		$pagerStyle=$this->getViewState('PagerStyle',null);
  		$separatorStyle=$this->getViewState('SeparatorStyle',null);
 -		$itemStyle=$this->getViewState('ItemStyle',null);
 -		$alternatingItemStyle=$this->getViewState('AlternatingItemStyle',null);
 -		if($itemStyle!==null)
 -		{
 -			if($alternatingItemStyle===null)
 -				$alternatingItemStyle=$itemStyle;
 -			else
 -				$alternatingItemStyle->mergeWith($itemStyle);
 -		}
 -		$selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
 -		if($alternatingItemStyle!==null)
 -		{
 -			if($selectedItemStyle===null)
 -				$selectedItemStyle=new TTableItemStyle;
 -			$selectedItemStyle->mergeWith($alternatingItemStyle);
 -		}
 -		$editItemStyle=$this->getViewState('EditItemStyle',null);
 -		if($selectedItemStyle!==null)
 -		{
 -			if($editItemStyle===null)
 -				$editItemStyle=new TTableItemStyle;
 -			$editItemStyle->mergeWith($selectedItemStyle);
 -		}
  		foreach($this->getControls() as $index=>$item)
  		{
 @@ -1215,10 +1204,30 @@ class TDataGrid extends TBaseDataList  						$item->getStyle()->mergeWith($alternatingItemStyle);
  					break;
  				case 'SelectedItem':
 +					if($index % 2==1)
 +					{
 +						if($itemStyle)
 +							$item->getStyle()->mergeWith($itemStyle);
 +					}
 +					else
 +					{
 +						if($alternatingItemStyle)
 +							$item->getStyle()->mergeWith($alternatingItemStyle);
 +					}
  					if($selectedItemStyle)
  						$item->getStyle()->mergeWith($selectedItemStyle);
  					break;
  				case 'EditItem':
 +					if($index % 2==1)
 +					{
 +						if($itemStyle)
 +							$item->getStyle()->mergeWith($itemStyle);
 +					}
 +					else
 +					{
 +						if($alternatingItemStyle)
 +							$item->getStyle()->mergeWith($alternatingItemStyle);
 +					}
  					if($editItemStyle)
  						$item->getStyle()->mergeWith($editItemStyle);
  					break;
 @@ -1761,8 +1770,8 @@ class TDataGridPagerStyle extends TTableItemStyle  	/**
  	 * Merges with a style.
 -	 * 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.
 +	 * If a style field is set in the new style, the current style field
 +	 * will be overwritten.
  	 * This method overrides the parent implementation by
  	 * merging with additional TDataGridPagerStyle specific attributes.
  	 * @param TStyle the new style
 @@ -1772,17 +1781,17 @@ class TDataGridPagerStyle extends TTableItemStyle  		parent::mergeWith($style);
  		if($style instanceof TDataGridPagerStyle)
  		{
 -			if($style->_visible!==null && $this->_visible===null)
 +			if($style->_visible!==null)
  				$this->_visible=$style->_visible;
 -			if($style->_position!==null && $this->_position===null)
 +			if($style->_position!==null)
  				$this->_position=$style->_position;
 -			if($style->_buttonCount!==null && $this->_buttonCount===null)
 +			if($style->_buttonCount!==null)
  				$this->_buttonCount=$style->_buttonCount;
 -			if($style->_prevText!==null && $this->_prevText===null)
 +			if($style->_prevText!==null)
  				$this->_prevText=$style->_prevText;
 -			if($style->_nextText!==null && $this->_nextText===null)
 +			if($style->_nextText!==null)
  				$this->_nextText=$style->_nextText;
 -			if($style->_mode!==null && $this->_mode===null)
 +			if($style->_mode!==null)
  				$this->_mode=$style->_mode;
  		}
  	}
 diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php index d04acdaf..0bdeb4a4 100644 --- a/framework/Web/UI/WebControls/TDataList.php +++ b/framework/Web/UI/WebControls/TDataList.php @@ -902,63 +902,74 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs  	 */
  	protected function applyItemStyles()
  	{
 +		$itemStyle=$this->getViewState('ItemStyle',null);
 +
 +		$alternatingItemStyle=new TTableItemStyle($itemStyle);
 +		if(($style=$this->getViewState('AlternatingItemStyle',null))!==null)
 +			$alternatingItemStyle->mergeWith($style);
 +
 +		$selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
 +
 +		$editItemStyle=new TTableItemStyle($selectedItemStyle);
 +		if(($style=$this->getViewState('EditItemStyle',null))!==null)
 +			$editItemStyle->copyFrom($style);
 +
  		$headerStyle=$this->getViewState('HeaderStyle',null);
  		$footerStyle=$this->getViewState('FooterStyle',null);
 +		$pagerStyle=$this->getViewState('PagerStyle',null);
  		$separatorStyle=$this->getViewState('SeparatorStyle',null);
 -		$itemStyle=$this->getViewState('ItemStyle',null);
 -		$alternatingItemStyle=$this->getViewState('AlternatingItemStyle',null);
 -		if($itemStyle!==null)
 -		{
 -			if($alternatingItemStyle===null)
 -				$alternatingItemStyle=new TTableItemStyle;
 -			$alternatingItemStyle->mergeWith($itemStyle);
 -		}
 -		$selectedItemStyle=$this->getViewState('SelectedItemStyle',null);
 -		if($alternatingItemStyle!==null)
 -		{
 -			if($selectedItemStyle===null)
 -				$selectedItemStyle=new TTableItemStyle;
 -			$selectedItemStyle->mergeWith($alternatingItemStyle);
 -		}
 -		$editItemStyle=$this->getViewState('EditItemStyle',null);
 -		if($selectedItemStyle!==null)
 -		{
 -			if($editItemStyle===null)
 -				$editItemStyle=new TTableItemStyle;
 -			$editItemStyle->mergeWith($selectedItemStyle);
 -		}
 -		foreach($this->getControls() as $control)
 +		foreach($this->getControls() as $index=>$item)
  		{
 -			switch($control->getItemType())
 +			switch($item->getItemType())
  			{
  				case 'Header':
  					if($headerStyle)
 -						$control->getStyle()->mergeWith($headerStyle);
 +						$item->getStyle()->mergeWith($headerStyle);
  					break;
  				case 'Footer':
  					if($footerStyle)
 -						$control->getStyle()->mergeWith($footerStyle);
 +						$item->getStyle()->mergeWith($footerStyle);
  					break;
  				case 'Separator':
  					if($separatorStyle)
 -						$control->getStyle()->mergeWith($separatorStyle);
 +						$item->getStyle()->mergeWith($separatorStyle);
  					break;
  				case 'Item':
  					if($itemStyle)
 -						$control->getStyle()->mergeWith($itemStyle);
 +						$item->getStyle()->mergeWith($itemStyle);
  					break;
  				case 'AlternatingItem':
  					if($alternatingItemStyle)
 -						$control->getStyle()->mergeWith($alternatingItemStyle);
 +						$item->getStyle()->mergeWith($alternatingItemStyle);
  					break;
  				case 'SelectedItem':
 +					if($index % 2==1)
 +					{
 +						if($itemStyle)
 +							$item->getStyle()->mergeWith($itemStyle);
 +					}
 +					else
 +					{
 +						if($alternatingItemStyle)
 +							$item->getStyle()->mergeWith($alternatingItemStyle);
 +					}
  					if($selectedItemStyle)
 -						$control->getStyle()->mergeWith($selectedItemStyle);
 +						$item->getStyle()->mergeWith($selectedItemStyle);
  					break;
  				case 'EditItem':
 +					if($index % 2==1)
 +					{
 +						if($itemStyle)
 +							$item->getStyle()->mergeWith($itemStyle);
 +					}
 +					else
 +					{
 +						if($alternatingItemStyle)
 +							$item->getStyle()->mergeWith($alternatingItemStyle);
 +					}
  					if($editItemStyle)
 -						$control->getStyle()->mergeWith($editItemStyle);
 +						$item->getStyle()->mergeWith($editItemStyle);
  					break;
  				default:
  					break;
 diff --git a/framework/Web/UI/WebControls/TFont.php b/framework/Web/UI/WebControls/TFont.php index d958c0ee..51d864c3 100644 --- a/framework/Web/UI/WebControls/TFont.php +++ b/framework/Web/UI/WebControls/TFont.php @@ -209,27 +209,27 @@ class TFont extends TComponent  	/**
  	 * Merges the font with a new one.
 -	 * 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.
 +	 * If a font field is set in the new font, the current font field
 +	 * will be overwritten.
  	 * @param TFont the new font
  	 */
  	public function mergeWith($font)
  	{
  		if($font===null || $font->_flags===0)
  			return;
 -		if(($font->_flags & self::IS_SET_BOLD) && !($this->_flags & self::IS_SET_BOLD))
 +		if($font->_flags & self::IS_SET_BOLD)
  			$this->setBold($font->getBold());
 -		if(($font->_flags & self::IS_SET_ITALIC) && !($this->_flags & self::IS_SET_ITALIC))
 +		if($font->_flags & self::IS_SET_ITALIC)
  			$this->setItalic($font->getItalic());
 -		if(($font->_flags & self::IS_SET_OVERLINE) && !($this->_flags & self::IS_SET_OVERLINE))
 +		if($font->_flags & self::IS_SET_OVERLINE)
  			$this->setOverline($font->getOverline());
 -		if(($font->_flags & self::IS_SET_STRIKEOUT) && !($this->_flags & self::IS_SET_STRIKEOUT))
 +		if($font->_flags & self::IS_SET_STRIKEOUT)
  			$this->setStrikeout($font->getStrikeout());
 -		if(($font->_flags & self::IS_SET_UNDERLINE) && !($this->_flags & self::IS_SET_UNDERLINE))
 +		if($font->_flags & self::IS_SET_UNDERLINE)
  			$this->setUnderline($font->getUnderline());
 -		if(($font->_flags & self::IS_SET_SIZE) && !($this->_flags & self::IS_SET_SIZE))
 +		if($font->_flags & self::IS_SET_SIZE)
  			$this->setSize($font->getSize());
 -		if(($font->_flags & self::IS_SET_NAME) && !($this->_flags & self::IS_SET_NAME))
 +		if($font->_flags & self::IS_SET_NAME)
  			$this->setName($font->getName());
  	}
 diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index fa3bcb28..dac862a6 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -50,7 +50,8 @@ class TStyle extends TComponent  	 */
  	public function __construct($style=null)
  	{
 -		$this->copyFrom($style);
 +		if($style!==null)
 +			$this->copyFrom($style);
  	}
  	/**
 @@ -295,21 +296,20 @@ class TStyle extends TComponent  	/**
  	 * Merges with a style.
 -	 * 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.
 +	 * If a style field is set in the new style, the current style field
 +	 * will be overwritten.
  	 * @param TStyle the new style
  	 */
  	public function mergeWith($style)
  	{
  		if($style!==null)
  		{
 -			//$this->_fields=array_merge($this->_fields,$style->_fields);
 -			$this->_fields=array_merge($style->_fields,$this->_fields);
 -			if($this->_class===null)
 +			$this->_fields=array_merge($this->_fields,$style->_fields);
 +			if($style->_class!==null)
  				$this->_class=$style->_class;
 -			if($this->_customStyle===null)
 +			if($style->_customStyle!==null)
  				$this->_customStyle=$style->_customStyle;
 -			if($this->_font===null && $style->_font!==null)
 +			if($style->_font!==null)
  				$this->getFont()->mergeWith($style->_font);
  		}
  	}
 @@ -405,8 +405,9 @@ class TTableStyle extends TStyle  	/**
  	 * Merges with a style.
 -	 * 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.
 +	 * Merges with a style.
 +	 * If a style field is set in the new style, the current style field
 +	 * will be overwritten.
  	 * This method overrides the parent implementation by
  	 * merging with additional TTableStyle specific attributes.
  	 * @param TStyle the new style
 @@ -416,15 +417,15 @@ class TTableStyle extends TStyle  		parent::mergeWith($style);
  		if($style instanceof TTableStyle)
  		{
 -			if($style->_backImageUrl!==null && $this->_backImageUrl===null)
 +			if($style->_backImageUrl!==null)
  				$this->_backImageUrl=$style->_backImageUrl;
 -			if($style->_horizontalAlign!==null && $this->_horizontalAlign===null)
 +			if($style->_horizontalAlign!==null)
  				$this->_horizontalAlign=$style->_horizontalAlign;
 -			if($style->_cellPadding!==null && $this->_cellPadding===null)
 +			if($style->_cellPadding!==null)
  				$this->_cellPadding=$style->_cellPadding;
 -			if($style->_cellSpacing!==null && $this->_cellSpacing===null)
 +			if($style->_cellSpacing!==null)
  				$this->_cellSpacing=$style->_cellSpacing;
 -			if($style->_gridLines!==null && $this->_gridLines===null)
 +			if($style->_gridLines!==null)
  				$this->_gridLines=$style->_gridLines;
  		}
  	}
 @@ -615,8 +616,9 @@ class TTableItemStyle extends TStyle  	/**
  	 * Merges with a style.
 -	 * 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.
 +	 * Merges with a style.
 +	 * If a style field is set in the new style, the current style field
 +	 * will be overwritten.
  	 * This method overrides the parent implementation by
  	 * merging with additional TTableItemStyle specific attributes.
  	 * @param TStyle the new style
 @@ -626,11 +628,11 @@ class TTableItemStyle extends TStyle  		parent::mergeWith($style);
  		if($style instanceof TTableItemStyle)
  		{
 -			if($style->_verticalAlign!==null && $this->_verticalAlign===null)
 +			if($style->_verticalAlign!==null)
  				$this->_verticalAlign=$style->_verticalAlign;
 -			if($style->_horizontalAlign!==null && $this->_horizontalAlign===null)
 +			if($style->_horizontalAlign!==null)
  				$this->_horizontalAlign=$style->_horizontalAlign;
 -			if($style->_wrap!==null && $this->_wrap===null)
 +			if($style->_wrap!==null)
  				$this->_wrap=$style->_wrap;
  		}
  	}
  | 
