Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TWizardNavigationButtonStyle class file.
4
 *
5
 * @author Qiang Xue <qiang.xue@gmail.com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id $
10
 * @package System.Web.UI.WebControls
11
 */
12
 
13
/**
14
 * Includes TStyle class file
15
 */
16
Prado::using('System.Web.UI.WebControls.TStyle');
17
 
18
/**
19
 * TWizardNavigationButtonStyle class.
20
 * TWizardNavigationButtonStyle defines the style applied to a wizard navigation button.
21
 * The button type can be specified via {@link setButtonType ButtonType}, which
22
 * can be 'Button', 'Image' or 'Link'.
23
 * If the button is an image button, {@link setImageUrl ImageUrl} will be
24
 * used to load the image for the button.
25
 * Otherwise, {@link setButtonText ButtonText} will be displayed as the button caption.
26
 *
27
 * @author Qiang Xue <qiang.xue@gmail.com>
28
 * @version $Id: TWizardNavigationButtonStyle.php 2541 2008-10-21 15:05:13Z qiang.xue $
29
 * @package System.Web.UI.WebControls
30
 * @since 3.0
31
 */
32
class TWizardNavigationButtonStyle extends TStyle
33
{
34
	private $_imageUrl=null;
35
	private $_buttonText=null;
36
	private $_buttonType=null;
37
 
38
	/**
39
	 * Sets the style attributes to default values.
40
	 * This method overrides the parent implementation by
41
	 * resetting additional TWizardNavigationButtonStyle specific attributes.
42
	 */
43
	public function reset()
44
	{
45
		parent::reset();
46
		$this->_imageUrl=null;
47
		$this->_buttonText=null;
48
		$this->_buttonType=null;
49
	}
50
 
51
	/**
52
	 * Copies the fields in a new style to this style.
53
	 * If a style field is set in the new style, the corresponding field
54
	 * in this style will be overwritten.
55
	 * @param TStyle the new style
56
	 */
57
	public function copyFrom($style)
58
	{
59
		parent::copyFrom($style);
60
		if($style instanceof TWizardNavigationButtonStyle)
61
		{
62
			if($this->_imageUrl===null && $style->_imageUrl!==null)
63
				$this->_imageUrl=$style->_imageUrl;
64
			if($this->_buttonText===null && $style->_buttonText!==null)
65
				$this->_buttonText=$style->_buttonText;
66
			if($this->_buttonType===null && $style->_buttonType!==null)
67
				$this->_buttonType=$style->_buttonType;
68
		}
69
	}
70
 
71
	/**
72
	 * Merges the style with a new one.
73
	 * If a style field is not set in this style, it will be overwritten by
74
	 * the new one.
75
	 * @param TStyle the new style
76
	 */
77
	public function mergeWith($style)
78
	{
79
		parent::mergeWith($style);
80
		if($style instanceof TWizardNavigationButtonStyle)
81
		{
82
			if($style->_imageUrl!==null)
83
				$this->_imageUrl=$style->_imageUrl;
84
			if($style->_buttonText!==null)
85
				$this->_buttonText=$style->_buttonText;
86
			if($style->_buttonType!==null)
87
				$this->_buttonType=$style->_buttonType;
88
		}
89
	}
90
 
91
	/**
92
	 * @return string image URL for the image button
93
	 */
94
	public function getImageUrl()
95
	{
96
		return $this->_imageUrl===null?'':$this->_imageUrl;
97
	}
98
 
99
	/**
100
	 * @param string image URL for the image button
101
	 */
102
	public function setImageUrl($value)
103
	{
104
		$this->_imageUrl=$value;
105
	}
106
 
107
	/**
108
	 * @return string button caption
109
	 */
110
	public function getButtonText()
111
	{
112
		return $this->_buttonText===null?'':$this->_buttonText;
113
	}
114
 
115
	/**
116
	 * @param string button caption
117
	 */
118
	public function setButtonText($value)
119
	{
120
		$this->_buttonText=$value;
121
	}
122
 
123
	/**
124
	 * @return TWizardNavigationButtonType button type. Default to TWizardNavigationButtonType::Button.
125
	 */
126
	public function getButtonType()
127
	{
128
		return $this->_buttonType===null? TWizardNavigationButtonType::Button :$this->_buttonType;
129
	}
130
 
131
	/**
132
	 * @param TWizardNavigationButtonType button type.
133
	 */
134
	public function setButtonType($value)
135
	{
136
		$this->_buttonType=TPropertyValue::ensureEnum($value,'TWizardNavigationButtonType');
137
	}
138
 
139
	/**
140
	 * Applies this style to the specified button
141
	 * @param mixed button to be applied with this style
142
	 */
143
	public function apply($button)
144
	{
145
		if($button instanceof TImageButton)
146
		{
147
			if($button->getImageUrl()==='')
148
				$button->setImageUrl($this->getImageUrl());
149
		}
150
		if($button->getText()==='')
151
			$button->setText($this->getButtonText());
152
		$button->getStyle()->mergeWith($this);
153
	}
154
}
155