Source for file WFontEditor.class.php

Documentation is available at WFontEditor.class.php

  1. <?php
  2. /**
  3. * @since 8/15/2006
  4. * @package polyphony.guiwizardcomponents
  5. *
  6. * @copyright Copyright &copy; 2006, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: WFontEditor.class.php,v 1.3 2007/09/19 14:04:45 adamfranco Exp $
  10. */
  11.  
  12.  
  13.  
  14. /**
  15. * This class allows for the modification of a font.
  16. *
  17. * @since 8/09/2006
  18. * @package polyphony.guiwizardcomponents
  19. *
  20. * @copyright Copyright &copy; 2006, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: WFontEditor.class.php,v 1.3 2007/09/19 14:04:45 adamfranco Exp $
  24. */
  25.  
  26. class WFontEditor
  27. extends WMoreOptions
  28. {
  29.  
  30. var $_callBack;
  31. var $_collectionName;
  32. var $_thingsToApplyCollectionTo;
  33.  
  34.  
  35.  
  36. function WFontEditor ($callBack, $collectionName, $thingsToApplyCollectionTo) {
  37. $this->init();
  38. $this->_callBack =$callBack;
  39. $this->_collectionName =$collectionName;
  40. $this->_thingsToApplyCollectionTo = $thingsToApplyCollectionTo;
  41. $this->rebuildContent();
  42. }
  43. /**
  44. * Make everything
  45. */
  46. function rebuildContent(){
  47. $callBack = $this->_callBack;
  48. $collectionName = $this->_collectionName;
  49. $thingsToApplyCollectionTo = $this->_thingsToApplyCollectionTo;
  50.  
  51.  
  52. //get the theme
  53. eval('$theme = '.$callBack."();");
  54.  
  55. if(!is_object($theme)){
  56. return;
  57. }
  58.  
  59. //get arrays ready
  60. $color = GUIComponentUtility::makeColorArrays(12, 5);
  61. $fonts = GUIComponentUtility::makeFontArray();
  62. $fontSize = GUIComponentUtility::makeFontSizeArray();
  63.  
  64.  
  65. $collectionSelector1 = "*.".$collectionName;
  66.  
  67. //first style collection
  68. if(!$theme->getStyleCollection($collectionSelector1)){
  69. $styleCollection1 = new StyleCollection($collectionSelector1, $collectionName,"Font Properties", "Font choice with selector ".$collectionName);
  70. foreach($thingsToApplyCollectionTo as $arr){
  71. $theme->addStyleForComponentType($styleCollection1,$arr['type'],$arr['index']);
  72. }
  73. }
  74.  
  75.  
  76. //first style collection GUI elements
  77. $comp = new WGUISelectList($callBack, $collectionSelector1,new ColorSP("#000000"),"ColorSC",$color['options'],$color['styles']);
  78. $this->addComponent('color',$comp);
  79.  
  80. $prop = new FontSP('serif',"12pt","normal","normal","normal");
  81. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"FontFamilySC",$fonts,"font-family");
  82. $this->addComponent('font',$comp);
  83. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"FontSizeSC",$fontSize,"font-size");
  84. $this->addComponent('fontSize',$comp);
  85. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontWeightSC","bold","normal");
  86. $this->addComponent('boldBox',$comp);
  87. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontStyleSC","italic","normal");
  88. $this->addComponent('italicsBox',$comp);
  89. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontVariantSC","small-caps","normal");
  90. $this->addComponent('smallcapsBox',$comp);
  91.  
  92.  
  93.  
  94. }
  95.  
  96.  
  97.  
  98. /**
  99. * Returns a block of XHTML-valid code that contains markup for this specific
  100. * component.
  101. * @param string $fieldName The field name to use when outputting form data or
  102. * similar parameters/information.
  103. * @access public
  104. * @return string
  105. */
  106. function getMarkup ($fieldName) {
  107. //make sure we're current with the theme
  108. $this->rebuildContent();
  109. $s="";
  110.  
  111. $s.="\n<table border='1' width='100%'>";
  112. $s.="\n\t<tr><td>";
  113.  
  114.  
  115.  
  116. $s.="\n<table border='0' cellpadding='5' width='100%'>";
  117. $s.="\n\t<tr>";
  118. $s.="\t\t<td>Text Color:";
  119. $comp =$this->getChild($name = 'color');
  120. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  121.  
  122. $s.="\t\t<td>Text Size: ";
  123. $comp =$this->getChild($name = 'fontSize');
  124. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  125.  
  126. $s.="\t\t<td>More font options: ".$this->getCheckboxMarkup($fieldName)."</td>";
  127.  
  128.  
  129.  
  130.  
  131. $s.="\n\t</tr>";
  132. $s.="\n</table>";
  133.  
  134. $s.="\n\t</td></tr><tr><td>";
  135.  
  136. $s.= $this->getOptionalComponentsMarkup($fieldName);
  137.  
  138. $s.="\n\t</td></tr></table>";
  139.  
  140.  
  141.  
  142. return $s;
  143. }
  144.  
  145.  
  146. /**
  147. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  148. * options.
  149. * @param string $fieldName The field name to use when outputting form data or
  150. * similar parameters/information.
  151. * @access public
  152. * @return string
  153. */
  154. function advancedMarkup ($fieldName) {
  155. $s="";
  156.  
  157. $s.="\n<table border='0' width='100%' cellpadding='5'>";
  158. $s.="\n\t<tr>";
  159. $s.="\t\t<td>Font: ";
  160. $comp =$this->getChild($name = 'font');
  161. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  162. $comp =$this->getChild($name = 'boldBox');
  163. $s.="\t\t<td>Bold".$comp->getMarkup($fieldName."_".$name)."</td>";
  164. $comp =$this->getChild($name = 'italicsBox');
  165. $s.="\t\t<td>Italics".$comp->getMarkup($fieldName."_".$name)."</td>";
  166. $comp =$this->getChild($name = 'smallcapsBox');
  167. $s.="\t\t<td>Smallcaps".$comp->getMarkup($fieldName."_".$name)."</td>";
  168. $s.="\n\t</tr>";
  169. $s.="\n</table>";
  170.  
  171.  
  172.  
  173.  
  174.  
  175. return $s;
  176. }
  177.  
  178.  
  179. }
  180.  
  181. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:59 -0400 by phpDocumentor 1.3.0RC3