/includes/qcodo/_core/qform/QListItemStyle.class.php

https://github.com/quinta/qcodo · PHP · 350 lines · 289 code · 31 blank · 30 comment · 45 complexity · a50a1051fac3cb9ba2910b4261c27d30 MD5 · raw file

  1. <?php
  2. /* Qcodo Development Framework for PHP
  3. * http://www.qcodo.com/
  4. *
  5. * Copyright (C) 2006
  6. * Hunter Jensen - Barefoot Solutions - http://www.barefootsolutions.com/
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. */
  22. // This defines the style for an Item for a ListBox
  23. // All the appearance properties should be self-explanatory.
  24. // For more information about ListItem appearance, please see QListItem.class.php
  25. class QListItemStyle extends QBaseClass {
  26. protected $strBackColor = null;
  27. protected $strBorderColor = null;
  28. protected $strBorderStyle = QBorderStyle::NotSet;
  29. protected $strBorderWidth = null;
  30. protected $strCssClass = null;
  31. protected $blnFontBold = false;
  32. protected $blnFontItalic = false;
  33. protected $strFontNames = null;
  34. protected $blnFontOverline = false;
  35. protected $strFontSize = null;
  36. protected $blnFontStrikeout = false;
  37. protected $blnFontUnderline = false;
  38. protected $strForeColor = null;
  39. protected $strHeight = null;
  40. protected $strWidth = null;
  41. protected $strAltText = null;
  42. protected $strToolTip = null;
  43. public function ApplyOverride(QListItemStyle $objOverrideStyle) {
  44. $objNewStyle = clone $this;
  45. if ($objOverrideStyle->Height)
  46. $objNewStyle->Height = $objOverrideStyle->Height;
  47. if ($objOverrideStyle->CssClass)
  48. $objNewStyle->CssClass = $objOverrideStyle->CssClass;
  49. if ($objOverrideStyle->ForeColor)
  50. $objNewStyle->ForeColor = $objOverrideStyle->ForeColor;
  51. if ($objOverrideStyle->BackColor)
  52. $objNewStyle->BackColor = $objOverrideStyle->BackColor;
  53. if ($objOverrideStyle->BorderColor)
  54. $objNewStyle->BorderColor = $objOverrideStyle->BorderColor;
  55. if ($objOverrideStyle->BorderWidth)
  56. $objNewStyle->BorderWidth = $objOverrideStyle->BorderWidth;
  57. if (($objOverrideStyle->BorderStyle) && ($objOverrideStyle->BorderStyle != QBorderStyle::NotSet))
  58. $objNewStyle->BorderStyle = $objOverrideStyle->BorderStyle;
  59. if ($objOverrideStyle->FontNames)
  60. $objNewStyle->FontNames = $objOverrideStyle->FontNames;
  61. if ($objOverrideStyle->FontSize)
  62. $objNewStyle->FontSize = $objOverrideStyle->FontSize;
  63. if ($objOverrideStyle->FontBold)
  64. $objNewStyle->FontBold = true;
  65. if ($objOverrideStyle->FontItalic)
  66. $objNewStyle->FontItalic = true;
  67. if ($objOverrideStyle->FontUnderline)
  68. $objNewStyle->FontUnderline = true;
  69. if ($objOverrideStyle->FontOverline)
  70. $objNewStyle->FontOverline = true;
  71. if ($objOverrideStyle->FontStrikeout)
  72. $objNewStyle->FontStrikeout = true;
  73. return $objNewStyle;
  74. }
  75. public function GetAttributes($blnIncludeCustom = true, $blnIncludeAction = true) {
  76. $strToReturn = "";
  77. if ($this->strCssClass)
  78. $strToReturn .= sprintf('class="%s" ', $this->strCssClass);
  79. $strStyle = "";
  80. if ($this->strHeight)
  81. $strStyle .= sprintf("height:%s;", $this->strHeight);
  82. if ($this->strWidth)
  83. $strStyle .= sprintf("width:%s;", $this->strWidth);
  84. if ($this->strForeColor)
  85. $strStyle .= sprintf("color:%s;", $this->strForeColor);
  86. if ($this->strBackColor)
  87. $strStyle .= sprintf("background-color:%s;", $this->strBackColor);
  88. if ($this->strBorderColor)
  89. $strStyle .= sprintf("border-color:%s;", $this->strBorderColor);
  90. if ($this->strBorderWidth) {
  91. $strStyle .= sprintf("border-width:%s;", $this->strBorderWidth);
  92. if ((!$this->strBorderStyle) || ($this->strBorderStyle == QBorderStyle::NotSet))
  93. // For "No Border Style" -- apply a "solid" style because width is set
  94. $strStyle .= "border-style:solid;";
  95. }
  96. if (($this->strBorderStyle) && ($this->strBorderStyle != QBorderStyle::NotSet))
  97. $strStyle .= sprintf("border-style:%s;", $this->strBorderStyle);
  98. if ($this->strFontNames)
  99. $strStyle .= sprintf("font-family:%s;", $this->strFontNames);
  100. if ($this->strFontSize)
  101. $strStyle .= sprintf("font-size:%s;", $this->strFontSize);
  102. if ($this->blnFontBold)
  103. $strStyle .= "font-weight:bold;";
  104. if ($this->blnFontItalic)
  105. $strStyle .= "font-style:italic;";
  106. $strTextDecoration = "";
  107. if ($this->blnFontUnderline)
  108. $strTextDecoration .= "underline ";
  109. if ($this->blnFontOverline)
  110. $strTextDecoration .= "overline ";
  111. if ($this->blnFontStrikeout)
  112. $strTextDecoration .= "line-through ";
  113. if ($strTextDecoration) {
  114. $strTextDecoration = trim($strTextDecoration);
  115. $strStyle .= sprintf("text-decoration:%s;", $strTextDecoration);
  116. }
  117. if ($strStyle)
  118. $strToReturn .= sprintf('style="%s" ', $strStyle);
  119. if ($this->strToolTip)
  120. $strToReturn .= sprintf('title="%s" ', QApplication::HtmlEntities($this->strToolTip));
  121. if ($this->strAltText)
  122. $strToReturn .= sprintf('alt="%s" ', QApplication::HtmlEntities($this->strAltText));
  123. return ' ' . $strToReturn;
  124. }
  125. public function GetNonStyleAttributes() {
  126. $strToReturn = null;
  127. if ($this->strToolTip)
  128. $strToReturn .= sprintf('title="%s" ', QApplication::HtmlEntities($this->strToolTip));
  129. if ($this->strAltText)
  130. $strToReturn .= sprintf('alt="%s" ', QApplication::HtmlEntities($this->strAltText));
  131. if ($strToReturn)
  132. return ' ' . $strToReturn;
  133. else
  134. return null;
  135. }
  136. /////////////////////////
  137. // Public Properties: GET
  138. /////////////////////////
  139. public function __get($strName) {
  140. switch ($strName) {
  141. case "BackColor": return $this->strBackColor;
  142. case "BorderColor": return $this->strBorderColor;
  143. case "BorderStyle": return $this->strBorderStyle;
  144. case "BorderWidth": return $this->strBorderWidth;
  145. case "CssClass": return $this->strCssClass;
  146. case "FontBold": return $this->blnFontBold;
  147. case "FontItalic": return $this->blnFontItalic;
  148. case "FontNames": return $this->strFontNames;
  149. case "FontOverline": return $this->blnFontOverline;
  150. case "FontSize": return $this->strFontSize;
  151. case "FontStrikeout": return $this->blnFontStrikeout;
  152. case "FontUnderline": return $this->blnFontUnderline;
  153. case "ForeColor": return $this->strForeColor;
  154. case "Height": return $this->strHeight;
  155. case "Width": return $this->strWidth;
  156. case "AltText": return $this->strAltText;
  157. case "ToolTip": return $this->strToolTip;
  158. default:
  159. try {
  160. return parent::__get($strName);
  161. } catch (QCallerException $objExc) {
  162. $objExc->IncrementOffset();
  163. throw $objExc;
  164. }
  165. }
  166. }
  167. /////////////////////////
  168. // Public Properties: SET
  169. /////////////////////////
  170. public function __set($strName, $mixValue) {
  171. switch ($strName) {
  172. case "BackColor":
  173. try {
  174. $this->strBackColor = QType::Cast($mixValue, QType::String);
  175. break;
  176. } catch (QInvalidCastException $objExc) {
  177. $objExc->IncrementOffset();
  178. throw $objExc;
  179. }
  180. case "BorderColor":
  181. try {
  182. $this->strBorderColor = QType::Cast($mixValue, QType::String);
  183. break;
  184. } catch (QInvalidCastException $objExc) {
  185. $objExc->IncrementOffset();
  186. throw $objExc;
  187. }
  188. case "BorderStyle":
  189. try {
  190. $this->strBorderStyle = QType::Cast($mixValue, QType::String);
  191. break;
  192. } catch (QInvalidCastException $objExc) {
  193. $objExc->IncrementOffset();
  194. throw $objExc;
  195. }
  196. case "BorderWidth":
  197. try {
  198. $this->strBorderWidth = QType::Cast($mixValue, QType::String);
  199. break;
  200. } catch (QInvalidCastException $objExc) {
  201. $objExc->IncrementOffset();
  202. throw $objExc;
  203. }
  204. case "CssClass":
  205. try {
  206. $this->strCssClass = QType::Cast($mixValue, QType::String);
  207. break;
  208. } catch (QInvalidCastException $objExc) {
  209. $objExc->IncrementOffset();
  210. throw $objExc;
  211. }
  212. case "FontBold":
  213. try {
  214. $this->blnFontBold = QType::Cast($mixValue, QType::Boolean);
  215. break;
  216. } catch (QInvalidCastException $objExc) {
  217. $objExc->IncrementOffset();
  218. throw $objExc;
  219. }
  220. case "FontItalic":
  221. try {
  222. $this->blnFontItalic = QType::Cast($mixValue, QType::Boolean);
  223. break;
  224. } catch (QInvalidCastException $objExc) {
  225. $objExc->IncrementOffset();
  226. throw $objExc;
  227. }
  228. case "FontNames":
  229. try {
  230. $this->strFontNames = QType::Cast($mixValue, QType::String);
  231. break;
  232. } catch (QInvalidCastException $objExc) {
  233. $objExc->IncrementOffset();
  234. throw $objExc;
  235. }
  236. case "FontOverline":
  237. try {
  238. $this->blnFontOverline = QType::Cast($mixValue, QType::Boolean);
  239. break;
  240. } catch (QInvalidCastException $objExc) {
  241. $objExc->IncrementOffset();
  242. throw $objExc;
  243. }
  244. case "FontSize":
  245. try {
  246. $this->strFontSize = QType::Cast($mixValue, QType::String);
  247. break;
  248. } catch (QInvalidCastException $objExc) {
  249. $objExc->IncrementOffset();
  250. throw $objExc;
  251. }
  252. case "FontStrikeout":
  253. try {
  254. $this->blnFontStrikeout = QType::Cast($mixValue, QType::Boolean);
  255. break;
  256. } catch (QInvalidCastException $objExc) {
  257. $objExc->IncrementOffset();
  258. throw $objExc;
  259. }
  260. case "FontUnderline":
  261. try {
  262. $this->blnFontUnderline = QType::Cast($mixValue, QType::Boolean);
  263. break;
  264. } catch (QInvalidCastException $objExc) {
  265. $objExc->IncrementOffset();
  266. throw $objExc;
  267. }
  268. case "ForeColor":
  269. try {
  270. $this->strForeColor = QType::Cast($mixValue, QType::String);
  271. break;
  272. } catch (QInvalidCastException $objExc) {
  273. $objExc->IncrementOffset();
  274. throw $objExc;
  275. }
  276. case "Height":
  277. try {
  278. $this->strHeight = QType::Cast($mixValue, QType::String);
  279. break;
  280. } catch (QInvalidCastException $objExc) {
  281. $objExc->IncrementOffset();
  282. throw $objExc;
  283. }
  284. case "Width":
  285. try {
  286. $this->strWidth = QType::Cast($mixValue, QType::String);
  287. break;
  288. } catch (QInvalidCastException $objExc) {
  289. $objExc->IncrementOffset();
  290. throw $objExc;
  291. }
  292. case "AltText":
  293. try {
  294. $this->strAltText = QType::Cast($mixValue, QType::String);
  295. break;
  296. } catch (QInvalidCastException $objExc) {
  297. $objExc->IncrementOffset();
  298. throw $objExc;
  299. }
  300. case "ToolTip":
  301. try {
  302. $this->strToolTip = QType::Cast($mixValue, QType::String);
  303. break;
  304. } catch (QInvalidCastException $objExc) {
  305. $objExc->IncrementOffset();
  306. throw $objExc;
  307. }
  308. default:
  309. try {
  310. parent::__set($strName, $mixValue);
  311. break;
  312. } catch (QCallerException $objExc) {
  313. $objExc->IncrementOffset();
  314. throw $objExc;
  315. }
  316. }
  317. }
  318. }
  319. ?>