Source for file WColorWheel.class.php

Documentation is available at WColorWheel.class.php

  1. <?php
  2. /**
  3. * @since Jul 21, 2005
  4. * @package polyphony.wizard.components
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. * @license This is distributed under the BY-NC-SA licence(http://creativecommons.org/licenses/by-nc-sa/2.0/). License for commercial use is not possible
  9. *
  10. * @version $Id: WColorWheel.class.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  11. */
  12.  
  13. require_once(POLYPHONY.'/main/library/Wizard/WizardComponent.abstract.php');
  14.  
  15. /**
  16. * This class allows for the creation of a ColorWheel color management tool.
  17. *
  18. * @since Jul 21, 2005
  19. * @package polyphony.wizard.components
  20. *
  21. * @copyright Copyright &copy; 2005, Middlebury College
  22. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  23. * @license This is distributed under the BY-NC-SA licence(http://creativecommons.org/licenses/by-nc-sa/2.0/). License for commercial use is not possible
  24. *
  25. * @version $Id: WColorWheel.class.php,v 1.4 2007/09/19 14:04:51 adamfranco Exp $
  26. */
  27. class WColorWheel
  28. extends WizardComponent
  29. {
  30.  
  31. var $_value;
  32. var $_settings='';
  33. var $_style = null;
  34. /**
  35. * Constructor
  36. * @access public
  37. * @return WSelectList
  38. */
  39. function WColorWheel () {
  40. // do nothing
  41. }
  42. /**
  43. * sets the CSS style for the labels of the radio buttons.
  44. * @param string $style
  45. * @access public
  46. * @return void
  47. */
  48. function setStyle ($style) {
  49. $this->_style = $style;
  50. }
  51. /**
  52. * Sets the value of this ColorWheel object.
  53. * The value is a string containing the hex
  54. * representation of the selected colors.
  55. * Colors come in groups of 4:first is the base
  56. * color and then follow three variations. Some
  57. * schemata give more than one group of colors.
  58. * Thus, the string starts with the number of
  59. * color groups returned by the ColorWheel and
  60. * then follow the colors themselves(in hex) all
  61. * separated by a semicolon. So an example could
  62. * be:
  63. * 1;#007D48;#BFFFE4;#80FFC9;#00B366;
  64. * where you are given 1 group of 4 colors.
  65. *
  66. * @param string $value
  67. * @access public
  68. * @return void
  69. */
  70. function setValue ($value) {
  71. $this->_value = $value;
  72. }
  73. /**
  74. * Gets the current Settings of the ColorWheel
  75. * object. The settings are returned as a string
  76. * with the attributes separated by semicolons.
  77. * The order is:
  78. * mainColor;preset;slider-value;safecolor;shift1;shift2;shift3;shift4;schema;
  79. * @access public
  80. * @return string settings
  81. */
  82. function getSettings(){
  83. return $this->_settings;
  84. }
  85. /**
  86. * Tells the wizard component to update itself - this may include getting
  87. * form post data or validation - whatever this particular component wants to
  88. * do every pageload.
  89. * @param string $fieldName The field name to use when outputting form data or
  90. * similar parameters/information.
  91. * @access public
  92. * @return boolean - TRUE if everything is OK
  93. */
  94. function update ($fieldName) {
  95. $val = RequestContext::value($fieldName.'_colors');
  96. if ($val) $this->_value = $val;
  97. $settings = RequestContext::value($fieldName.'_settings');
  98. if($settings) $this->_settings = $settings;
  99. }
  100. /**
  101. * Returns the values of wizard-components. Should return an array if children are involved,
  102. * otherwise a whatever type of object is expected.
  103. * @access public
  104. * @return mixed
  105. */
  106. function getAllValues () {
  107. return $this->_value;
  108. }
  109. /**
  110. * Returns a block of XHTML-valid code that contains markup for this specific
  111. * component.
  112. * @param string $fieldName The field name to use when outputting form data or
  113. * similar parameters/information.
  114. * @access public
  115. * @return string
  116. */
  117. function getMarkup ($fieldName) {
  118. $guimanager = Services::getService("GUIManager");
  119. $name = RequestContext::name($fieldName);
  120. $value = $this->_value;
  121. $settings = $this->_settings;
  122. $colorwheelurl = "http://slug.middlebury.edu/~nstamato/polyphony/main/library/Wizard/Components/WColorWheelFiles/";
  123.  
  124.  
  125. $style = '';
  126. if ($this->_style) $style = " style=\"".addslashes($this->_style)."\"";
  127. $guimanager->setHead($guimanager->getHead()."\n<link rel=\"stylesheet\"
  128. href='".$colorwheelurl."colorwheel.css' type=\"text/css\">".
  129. "\n<script type=\"text/javascript\" src='".$colorwheelurl."colorblind.js'></script>".
  130. "\n<script type=\"text/javascript\" src='".$colorwheelurl."colorwheel.js'></script>"
  131. );
  132.  
  133. $m ="<br /><div id=\"maindiv\" style='position:relative; border:1px solid #000; height:500px; width:800px; font:11px/1.2 verdana,sans-serif;'>
  134. <div id=\"maincolorsample\"></div>
  135. <div id='image'>
  136. <div id=\"wheelarea\"></div>
  137. <div id=\"pointer0\"></div>
  138. <div id=\"pointer1\"></div>
  139. <div id=\"pointer2\"></div>
  140. <div id=\"pointer3\"></div>
  141. </div>
  142. <div id=\"maincolorhue\"></div>
  143. <div id='scheme-select'>
  144. <img id=\"previmg-mono\" src=".$colorwheelurl."prev_mono.gif\" alt=\"\" width=\"41\" height=\"52\" onclick=\"selectScheme('mono')\">
  145. <img id=\"previmg-compl\" class='previmg' src=".$colorwheelurl."prev_compl.gif\" alt=\"\" width=\"41\" height=\"52\" onclick=\"selectScheme('compl')\">
  146. <img id=\"previmg-triad\" class='previmg' src=".$colorwheelurl."prev_triad.gif\" alt=\"\" width=\"41\" height=\"52\" onclick=\"selectScheme('triad')\">
  147. <img id=\"previmg-tetrad\" class='previmg' src=".$colorwheelurl."prev_tetrad.gif\" alt=\"\" width=\"41\" height=\"52\" onclick=\"selectScheme('tetrad')\">
  148. <img id=\"previmg-analog\" class='previmg' src=".$colorwheelurl."prev_analog.gif\" alt=\"\" width=\"41\" height=\"52\" onclick=\"selectScheme('analog')\">
  149. </div>
  150. <div id=\"scheme-slider\">
  151. <div id=\"pointer-slider\"></div>
  152. </div>
  153. <div id=\"scheme-addcompl\">
  154. <input type=\"checkbox\" id=\"analogCompl\" onchange=\"createScheme(false)\" onclick=\"createScheme(false)\"> <label for=\"analogCompl\">add the complement</label>
  155. </div>
  156. <div id=\"scheme-searchrgb\">
  157. <a href=\"#\" onclick=\"searchRGB(false)\">Enter RGB</a> (rough conversion)
  158. </div>
  159. <div id=\"colsample\">
  160. <div id=\"color0\" class=\"col\">
  161. <div id=\"color0-0\" class=\"col-0\" onclick=\"drawVar(0,0)\"></div>
  162. <div id=\"color0-1\" class=\"col-1\" onclick=\"drawVar(0,1)\"></div>
  163. <div id=\"color0-2\" class=\"col-2\" onclick=\"drawVar(0,2)\"></div>
  164. <div id=\"color0-3\" class=\"col-3\" onclick=\"drawVar(0,3)\"></div>
  165. </div>
  166. <div id=\"color1\" class=\"col\">
  167. <div id=\"color1-0\" class=\"col-0\" onclick=\"drawVar(1,0)\"></div>
  168. <div id=\"color1-1\" class=\"col-1\" onclick=\"drawVar(1,1)\"></div>
  169. <div id=\"color1-2\" class=\"col-2\" onclick=\"drawVar(1,2)\"></div>
  170. <div id=\"color1-3\" class=\"col-3\" onclick=\"drawVar(1,3)\"></div>
  171. </div>
  172. <div id=\"color2\" class=\"col\">
  173. <div id=\"color2-0\" class=\"col-0\" onclick=\"drawVar(2,0)\"></div>
  174. <div id=\"color2-1\" class=\"col-1\" onclick=\"drawVar(2,1)\"></div>
  175. <div id=\"color2-2\" class=\"col-2\" onclick=\"drawVar(2,2)\"></div>
  176. <div id=\"color2-3\" class=\"col-3\" onclick=\"drawVar(2,3)\"></div>
  177. </div>
  178. <div id=\"color3\" class=\"col\">
  179. <div id=\"color3-0\" class=\"col-0\" onclick=\"drawVar(3,0)\"></div>
  180. <div id=\"color3-1\" class=\"col-1\" onclick=\"drawVar(3,1)\"></div>
  181. <div id=\"color3-2\" class=\"col-2\" onclick=\"drawVar(3,2)\"></div>
  182. <div id=\"color3-3\" class=\"col-3\" onclick=\"drawVar(3,3)\"></div>
  183. </div>
  184. <div id=\"textBlack\">Lorem ipsum <strong>dolor sit amet</strong></div>
  185. <div id=\"textWhite\"><strong>Lorem ipsum</strong> dolor sit amet</div>
  186. </div>
  187. <div id=\"coltable\"></div>
  188. <div id=\"websnapswitch\">
  189. <input type=\"checkbox\" id=\"websnapper\" onclick=\"switchWebSnap(this.checked)\" onchange=\"switchWebSnap(this.checked)\"> <label for=\"websnapper\">Reduce to \"safe\" colors (WebColors)</label>
  190. </div>
  191. <div id=\"presetswitch\">
  192. Variations:
  193. <a href=\"\" id=\"preset-default\" class=\"btn\" onclick=\"switchPreset('default');return false\">Default</a>
  194. <a href=\"\" id=\"preset-pastel\" class=\"btn\" onclick=\"switchPreset('pastel');return false\">Pastel</a>
  195. <a href=\"\" id=\"preset-soft\" class=\"btn\" onclick=\"switchPreset('soft');return false\">Dark pastel</a>
  196. <a href=\"\" id=\"preset-light\" class=\"btn\" onclick=\"switchPreset('light');return false\">Light pastel</a>
  197. <a href=\"\" id=\"preset-hard\" class=\"btn\" onclick=\"switchPreset('hard');return false\">Contrast</a>
  198. <a href=\"\" id=\"preset-pale\" class=\"btn\" onclick=\"switchPreset('pale');return false\">Pale</a>
  199. </div>
  200. <a id=\"url\" href=\"index.html\">URL of this scheme</a>
  201. <div style='position:absolute; left:300px; top:385px; height:100; width: 450px; text-align: right;'>
  202. <select id=\"cbmodeswitcher\" onchange=\"switchBlindlessMode()\">
  203. <option value=\"\">Normal vision (cca 85,5 % of population)</option>
  204. <option value=\"1\">Protanopy (1 % of men)</option>
  205. <option value=\"2\">Deuteranopy (1 % of men)</option>
  206. <option value=\"3\">Tritanopy (cca 0,003 % of population)</option>
  207. <option value=\"4\">Protanomaly (1 % of men)</option>
  208. <option value=\"5\">Deuteranomaly (5 % of men, 0.4 % of women)</option>
  209. <option value=\"6\">Tritanomaly (almost 0 %)</option>
  210. <option value=\"7\">Full colorblindness (0,005% of population)</option>
  211. <option value=\"8\">Atypical monochromatism</option>
  212. </select>
  213. </div>
  214. <div id=\"colsamplevarsswitch\"><div class=\"bottomaligner\">
  215. <a href=\"\" class=\"btn\" id=\"cancelsamplevars\" onclick=\"drawSample();return false\">Back</a>
  216. </div></div>
  217. <div id=\"colsamplevars\"></div>
  218. <p id=\"info\">
  219. <a href=\"http://www.wellstyled.com\">Wellstyled.com</a> &rarr;
  220. <strong>Color schemes generator 2</strong> &bull;
  221. Please read <a id=\"helptext\" href=".$colorwheelurl."help.html>more info &amp; help</a><br>
  222. &bull; Copyright <a href=\"http://www.pixy.cz\">pixy</a> &copy; 2002, 2004
  223. </p></div>";
  224. $m.="<div id=\"display\">
  225. <input type='hidden' name='".$name."_colors' id='wizardColorWheelColors' value='$value' /></div>";
  226. $m.="<div id=\"settings\">
  227. <input type='hidden' name='".$name."_settings' id='settingsdata' value='$settings' /></div>";
  228.  
  229. return $m;
  230. }
  231. }
  232.  
  233. ?>

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