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.3 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.3 2007/09/19 14:04:45 adamfranco Exp $
  24. */
  25.  
  26. class WTextLayoutEditor
  27. extends WMoreOptions
  28. {
  29.  
  30.  
  31. function WFontEditor ($callBack, $collectionName, $type, $index) {
  32.  
  33. //get the theme
  34. eval('$theme = '.$callBack."();");
  35.  
  36.  
  37. $fonts = $this->makeFontArray();
  38. $fontSize =$this->makeFontSizeArray();
  39.  
  40.  
  41. $collectionSelector1 = "*.".$collectionName;
  42.  
  43. //first style collection
  44. if(!$theme->getStyleCollection($collectionSelector1)){
  45. $styleCollection1 = new StyleCollection($collectionSelector1, $collectionName,"Font Properties", "Font choice with selector ".$collectionName);
  46. $theme->addStyleForComponentType($styleCollection1,$type,$index);
  47. }
  48.  
  49.  
  50. //first style collection GUI elements
  51. $comp = new WGUISelectList($callBack, $collectionSelector1,new ColorSP("#000000"),"ColorSC",$color['options'],$color['styles']);
  52. $this->addComponent('color',$comp);
  53.  
  54. $prop = new FontSP('serif',"12pt","normal","normal","normal");
  55. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"FontFamilySC",$fonts,"font-family");
  56. $this->addComponent('font',$comp);
  57. $comp = new WGUISelectList($callBack, $collectionSelector1,$prop,"FontSizeSC",$fontSize,"font-size");
  58. $this->addComponent('fontSize',$comp);
  59. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontWeightSC","bold","normal");
  60. $this->addComponent('boldBox',$comp);
  61. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontStyleSC","italic","normal");
  62. $this->addComponent('italicsBox',$comp);
  63. $comp = new WGUICheckBox($callBack, $collectionSelector1,$prop,"FontVariantSC","small-caps","normal");
  64. $this->addComponent('smallcapsBox',$comp);
  65.  
  66.  
  67.  
  68. }
  69.  
  70. /**
  71. *
  72. * Make an array of colors complete with styles. The colors are arranged by hue families.
  73. *
  74. * @param int slices The number of families. 6-15 is probably good.
  75. * @param int trisize The size of each family.
  76. * @return array an array with the values at 'options' and styles in 'styles'
  77. */
  78. function makeBorderSizeArrays(){
  79. $arr = array("0px","1px","2px","3px","4px","5px","6px","8px","10px","14px");
  80. foreach($arr as $option){
  81. $options[$option]=$option;
  82. $styles[$option]="border-width: ".$option."; margin 3; padding 3;";
  83. }
  84. $ret = array('options'=>$options,'styles'=>$styles);
  85. return $ret;
  86. }
  87. function makeBorderSizeArrays(){
  88. $arr = array("0px","1px","2px","3px","4px","5px","6px","8px","10px","14px");
  89. foreach($arr as $option){
  90. $options[$option]=$option;
  91. $styles[$option]="border-width: ".$option."; margin 3; padding 3;";
  92. }
  93. $ret = array('options'=>$options,'styles'=>$styles);
  94. return $ret;
  95. }
  96. function makeBorderSizeArrays(){
  97. $arr = array("0px","1px","2px","3px","4px","5px","6px","8px","10px","14px");
  98. foreach($arr as $option){
  99. $options[$option]=$option;
  100. $styles[$option]="border-width: ".$option."; margin 3; padding 3;";
  101. }
  102. $ret = array('options'=>$options,'styles'=>$styles);
  103. return $ret;
  104. }
  105. function makeBorderSizeArrays(){
  106. $arr = array("0px","1px","2px","3px","4px","5px","6px","8px","10px","14px");
  107. foreach($arr as $option){
  108. $options[$option]=$option;
  109. $styles[$option]="border-width: ".$option."; margin 3; padding 3;";
  110. }
  111. $ret = array('options'=>$options,'styles'=>$styles);
  112. return $ret;
  113. }
  114.  
  115.  
  116. /**
  117. * Returns a block of XHTML-valid code that contains markup for this specific
  118. * component.
  119. * @param string $fieldName The field name to use when outputting form data or
  120. * similar parameters/information.
  121. * @access public
  122. * @return string
  123. */
  124. function getMarkup ($fieldName) {
  125. $s="";
  126.  
  127. $s.="\n<table border='0'>";
  128. $s.="\n\t<tr><td>";
  129.  
  130.  
  131.  
  132. $s.="\n<table border='1' width='100%'>";
  133. $s.="\n\t<tr>";
  134. $s.="\t\t<td>Text Color:</td>";
  135. $comp =$this->getChild($name = 'color');
  136. $s.="\t\t<td>".$comp->getMarkup($fieldName."_".$name)."</td>";
  137.  
  138. $s.="\t\t<td>Text Size:</td>";
  139. $comp =$this->getChild($name = 'fontSize');
  140. $s.="\t\t<td>".$comp->getMarkup($fieldName."_".$name)."</td>";
  141.  
  142. $s.="\t\t<td>More font options: ".$this->getCheckboxMarkup($fieldName)."</td>";
  143.  
  144.  
  145.  
  146.  
  147. $s.="\n\t</tr>";
  148. $s.="\n</table>";
  149.  
  150. $s.="\n\t</td></tr><tr><td>";
  151.  
  152. $s.= $this->getOptionalComponentsMarkup($fieldName);
  153.  
  154. $s.="\n\t</td></tr></table>";
  155.  
  156.  
  157.  
  158. return $s;
  159. }
  160.  
  161.  
  162. /**
  163. * Returns a block of XHTML-valid code that contains markup for the "advanced"
  164. * options.
  165. * @param string $fieldName The field name to use when outputting form data or
  166. * similar parameters/information.
  167. * @access public
  168. * @return string
  169. */
  170. function advancedMarkup ($fieldName) {
  171. $s="";
  172.  
  173. $s.="\n<table border='1' width='100%'>";
  174. $s.="\n\t<tr>";
  175. $s.="\t\t<td>Font:</td>";
  176. $comp =$this->getChild($name = 'font');
  177. $s.="\t\t<td>".$comp->getMarkup($fieldName."_".$name)."</td>";
  178. $comp =$this->getChild($name = 'boldBox');
  179. $s.="\t\t<td>Bold".$comp->getMarkup($fieldName."_".$name)."</td>";
  180. $comp =$this->getChild($name = 'italicsBox');
  181. $s.="\t\t<td>Italics".$comp->getMarkup($fieldName."_".$name)."</td>";
  182. $comp =$this->getChild($name = 'smallcapsBox');
  183. $s.="\t\t<td>Smallcaps".$comp->getMarkup($fieldName."_".$name)."</td>";
  184. $s.="\n\t</tr>";
  185. $s.="\n</table>";
  186.  
  187.  
  188.  
  189.  
  190.  
  191. return $s;
  192. }
  193.  
  194.  
  195. }
  196.  
  197. ?>

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