Source for file WTextLayoutEditor.class.php

Documentation is available at WTextLayoutEditor.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: WTextLayoutEditor.class.php,v 1.4 2007/09/19 14:04:45 adamfranco Exp $
  10. */
  11.  
  12.  
  13.  
  14. /**
  15. * This class allows for the modification of the layout 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: WTextLayoutEditor.class.php,v 1.4 2007/09/19 14:04:45 adamfranco Exp $
  24. */
  25.  
  26. class WTextLayoutEditor
  27. extends WMoreOptions
  28. {
  29.  
  30. var $_callBack;
  31. var $_collectionName;
  32. var $_thingsToApplyCollectionTo;
  33.  
  34. /**
  35. * It is important to know that the $thingsToApplyCollectionTo is an array
  36. * of arrays. Each array should have two elements--an index at 'index', and
  37. * a type at 'type.' types might be MENU, BLOCK, HEADING and so forth.
  38. */
  39. function WTextLayoutEditor ($callBack, $collectionName, $thingsToApplyCollectionTo) {
  40.  
  41. $this->init();
  42. $this->_callBack =$callBack;
  43. $this->_collectionName =$collectionName;
  44. $this->_thingsToApplyCollectionTo = $thingsToApplyCollectionTo;
  45. $this->rebuildContent();
  46. }
  47. /**
  48. * Make everything
  49. */
  50. function rebuildContent(){
  51. $callBack = $this->_callBack;
  52. $collectionName = $this->_collectionName;
  53. $thingsToApplyCollectionTo = $this->_thingsToApplyCollectionTo;
  54. //get the theme
  55. eval('$theme = '.$callBack."();");
  56.  
  57.  
  58. if(!is_object($theme)){
  59. return;
  60. }
  61. $align = GUIComponentUtility::makeAlignArray();
  62. $textSpacing = GUIComponentUtility::makeSpacingArray();
  63. $lineSpacing = GUIComponentUtility::makeLineSpacingArray();
  64. $marginArray = GUIComponentUtility::makeMarginAndPaddingArray();
  65.  
  66. $collectionSelector1 = "*.".$collectionName;
  67.  
  68. //first style collection
  69. if(!$theme->getStyleCollection($collectionSelector1)){
  70. $styleCollection1 = new StyleCollection($collectionSelector1, $collectionName,"Text Properties", "How would you like your text to look?".$collectionName);
  71. foreach($thingsToApplyCollectionTo as $arr){
  72. $theme->addStyleForComponentType($styleCollection1,$arr['type'],$arr['index']);
  73. }
  74. }
  75.  
  76.  
  77. //first style collection GUI elements
  78. $comp = new WGUISelectList($callBack, $collectionSelector1,new TextAlignSP("left"),"TextAlignSC",$align,"text-align");
  79. $this->addComponent('align',$comp);
  80. $comp = new WGUISelectList($callBack, $collectionSelector1,new LetterSpacingSP("normal"),"TextSpacingSC",$textSpacing,"letter-spacing");
  81. $this->addComponent('letterSpace',$comp);
  82. $comp = new WGUISelectList($callBack, $collectionSelector1,new WordSpacingSP("normal"),"TextSpacingSC",$textSpacing,false);
  83. $this->addComponent('wordSpace',$comp);
  84. $comp = new WGUISelectList($callBack, $collectionSelector1,new LineHeightSP("normal"),"LineHeightSC",$lineSpacing,false);
  85. $this->addComponent('lineSpace',$comp);
  86.  
  87. $comp = new WGUISelectList($callBack, $collectionSelector1,new PaddingTopSP("0px"),"LengthSC",$marginArray,false);
  88. $this->addComponent('p_top',$comp);
  89. $comp = new WGUISelectList($callBack, $collectionSelector1,new PaddingBottomSP("0px"),"LengthSC",$marginArray,false);
  90. $this->addComponent('p_bottom',$comp);
  91. $comp = new WGUISelectList($callBack, $collectionSelector1,new PaddingLeftSP("0px"),"LengthSC",$marginArray,false);
  92. $this->addComponent('p_left',$comp);
  93. $comp = new WGUISelectList($callBack, $collectionSelector1,new PaddingRightSP("0px"),"LengthSC",$marginArray,false);
  94. $this->addComponent('p_right',$comp);
  95.  
  96. }
  97. /**
  98. * Returns a block of XHTML-valid code that contains markup for this specific
  99. * component.
  100. * @param string $fieldName The field name to use when outputting form data or
  101. * similar parameters/information.
  102. * @access public
  103. * @return string
  104. */
  105. function getMarkup ($fieldName) {
  106. //make sure we're current with the theme
  107. $this->rebuildContent();
  108. $s="";
  109.  
  110. $s.="\n<table border='1' width='100%'>";
  111. $s.="\n\t<tr><td>";
  112.  
  113.  
  114.  
  115. $s.="\n<table border='0' width='100%' cellpadding='5'>";
  116. $s.="\n\t<tr>";
  117. $s.="\t\t<td>Text Align: ";
  118. $comp =$this->getChild($name = 'align');
  119. $s.="\n\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  120. $s.="\t\t<td>Line Spacing: ";
  121. $comp =$this->getChild($name = 'lineSpace');
  122. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  123. $s.="\n\t\t<td>More Text layout options: ".$this->getCheckboxMarkup($fieldName)."</td>";
  124.  
  125.  
  126.  
  127.  
  128.  
  129. $s.="\n\t</tr>";
  130. $s.="\n</table>";
  131.  
  132. $s.="\n\t</td></tr><tr><td>";
  133.  
  134. $s.= $this->getOptionalComponentsMarkup($fieldName);
  135.  
  136. $s.="\n\t</td></tr></table>";
  137.  
  138.  
  139.  
  140. return $s;
  141. }
  142.  
  143.  
  144. /**
  145. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  146. * options.
  147. * @param string $fieldName The field name to use when outputting form data or
  148. * similar parameters/information.
  149. * @access public
  150. * @return string
  151. */
  152. function advancedMarkup ($fieldName) {
  153. $s="";
  154.  
  155. $s.="\n<table border='0' width='100%' cellpadding='5'>";
  156. $s.="\n\t<tr>";
  157. $s.="\t\t<td width>Space between letters: ";
  158. $comp =$this->getChild($name = 'letterSpace');
  159. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  160. $s.="\t\t<td width>Space between words: ";
  161. $comp =$this->getChild($name = 'wordSpace');
  162. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  163. $s.="\n\t</tr><tr>";
  164. $s.="\t\t<td>Top Padding: ";
  165. $comp =$this->getChild($name = 'p_top');
  166. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  167. $s.="\t\t<td>Bottom Padding: ";
  168. $comp =$this->getChild($name = 'p_bottom');
  169. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  170. $s.="\n\t</tr><tr>";
  171. $s.="\t\t<td>Left Padding: ";
  172. $comp =$this->getChild($name = 'p_left');
  173. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  174. $s.="\t\t<td>Right Padding: ";
  175. $comp =$this->getChild($name = 'p_right');
  176. $s.="\t\t".$comp->getMarkup($fieldName."_".$name)."</td>";
  177. $s.="\n\t</tr><tr>";
  178. $s.="\n\t</tr>";
  179. $s.="\n</table>";
  180.  
  181.  
  182.  
  183.  
  184.  
  185. return $s;
  186. }
  187.  
  188.  
  189. }
  190.  
  191. ?>

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