defaults.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.drawing.defaults"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.drawing.defaults"] = true;
  8. dojo.provide("dojox.drawing.defaults");
  9. dojox.drawing.defaults = {
  10. // summary:
  11. // Styles and defaults used for Drawing stencils and text.
  12. // description:
  13. // This object contains defaults for objects used in Drawing.
  14. // To change one item's style, use item.attr();
  15. // To change all these styles, create a copy of this file
  16. // and point to it in the Drawing properties:
  17. // | <div dojoType="dojox.drawing.Drawing" id="drawing" defaults="MyCustom.defaults"></div>
  18. // See:
  19. // Drawing.changeDefaults
  20. //
  21. // Determines whether in draw or edit mode (whether stencils
  22. // are clickable. If clickMode is false, the original
  23. // functionality of silently switching between select modes
  24. // is enabled. If clickMode is true, it allows powerpoint-
  25. // like functionality. Clickable is used by powerpoint to
  26. // distinguish when things can be selected and when they can't
  27. clickMode:true,
  28. clickable:true,
  29. // current: Object
  30. // current will point to either null or selected
  31. current:null,
  32. // currentHit: Object
  33. // currentHit will point to either hitNorm or hitSelected
  34. currentHit:null,
  35. // angleSnap: Number
  36. // Line, arrows, vector and axes will all snap to this angle on mouse up
  37. // shown angle also reflects the snap
  38. // currently cannot accept less than 1 degree
  39. angleSnap:1,
  40. // zAxis: Boolean
  41. // If true, draw current object in z-direction.
  42. // zAxisEnabled: Boolean
  43. // If true, render axes with Z-axis included, allow objects drawn in z-direction.
  44. // If false the z-axis button will not show up.
  45. zAxis: false,
  46. zAxisEnabled: true,
  47. zAngle: 225,
  48. // renderHitLines: Boolean
  49. // If true, renders a second, larger layer for lines to make
  50. // them more easily clickable.
  51. renderHitLines: true,
  52. //
  53. // renderHitLayer:
  54. // If true, renders a second layer for each Stencil, one
  55. // acting as a 'hit' object for a wider mouse-click area.
  56. // It also doubles as a hilight. If true, overrides
  57. // renderHitLines setting.
  58. renderHitLayer:true,
  59. // labelSameColor:
  60. // If true, the label text color will be the same as the
  61. // Stencil's line color.
  62. labelSameColor:false,
  63. //
  64. useSelectedStyle: true,
  65. norm:{
  66. // summary:
  67. // Normal style of all shapes
  68. // will get overridden by
  69. // above andes styles
  70. width:1,
  71. color:"#000000",
  72. style:"Solid",
  73. cap:"round", // square, butt, round
  74. fill:"#CCCCCC"
  75. },
  76. selected:{
  77. // summary:
  78. // Selected style of all shapes
  79. // styles not shown will used from
  80. // norm
  81. width:6,
  82. color:"#00FF00"
  83. },
  84. highlighted:{
  85. // summary:
  86. // Highlighted style of all shapes
  87. // NOT CURRENTLY BEING USED
  88. width:6,
  89. color:"#FF00FF",
  90. style:"Solid",
  91. cap:"round",
  92. fill:"#E11EBB"
  93. },
  94. disabled:{
  95. // summary:
  96. // Disabled or "locked" or "fade" style of all shapes
  97. width:1,
  98. color:"#666666",
  99. style:"solid",
  100. cap:"round",
  101. fill:"#cccccc"
  102. },
  103. // "hit" refers to the hidden object below the shape
  104. // that is usually larger than the object to give a
  105. // larger 'target' to click upon. These hit objects
  106. // double as highlights.
  107. //
  108. hitNorm:{
  109. // summary:
  110. // Normal style of a hit area
  111. width:6,
  112. color:{r:0, g:255, b:255, a:0},
  113. style:"Solid",
  114. cap:"round",
  115. fill:{r:255, g:255, b:255, a:0}
  116. },
  117. hitSelected:{
  118. // summary:
  119. // Selected style of a hit area
  120. width:6,
  121. color:"#FF9900",
  122. style:"Solid",
  123. cap:"round",
  124. fill:{r:255, g:255, b:255, a:0}
  125. },
  126. hitHighlighted:{
  127. // summary:
  128. // Highlighted style of a hit area
  129. width:6,
  130. color:"#FFFF00",
  131. style:"Solid",
  132. cap:"round",
  133. fill:{r:255, g:255, b:255, a:0}
  134. },
  135. anchors:{
  136. // summary:
  137. // Style for the anchor resize-points
  138. size:10,
  139. width:2,
  140. color:"#999",
  141. style:"solid",
  142. fill:"#fff",
  143. cap:"square",
  144. minSize:10,
  145. marginZero:5 // not really an anchor prop
  146. },
  147. arrows:{
  148. // summary:
  149. // Size of arrows on vectors.
  150. // length is in pixels
  151. // width is actually an angle
  152. // but is close to pixels in size
  153. length:30,
  154. width:16
  155. },
  156. text:{
  157. // summary:
  158. // Style of text
  159. minWidth:100,
  160. deleteEmptyCreate:true,
  161. deleteEmptyModify:true,
  162. pad:3,
  163. size:"18px",
  164. family:"sans-serif",
  165. weight:"normal",
  166. color:"#000000"
  167. },
  168. textDisabled:{
  169. // summary:
  170. // Style of disabled text
  171. size:"18px",
  172. family:"sans-serif",
  173. weight:"normal",
  174. color:"#cccccc"
  175. },
  176. textMode:{
  177. // summary:
  178. // These styles apply to the containing
  179. // text box (edit mode), and not the text itself
  180. create:{
  181. width:2,
  182. style:"dotted",
  183. color:"#666666",
  184. fill:null
  185. },
  186. edit:{
  187. width:1,
  188. style:"dashed",
  189. color:"#666",
  190. fill:null
  191. }
  192. },
  193. button:{
  194. norm:{
  195. "color": "#cccccc",
  196. "fill": {
  197. type:"linear",
  198. x1:0, x2:0, y1:0, y2:100,
  199. colors:[
  200. {offset:.5, color:"#ffffff"},
  201. {offset:1, color:"#e5e5e5"}
  202. ]
  203. }
  204. },
  205. over:{
  206. "fill": {
  207. type:"linear",
  208. x1:0, x2:0, y1:0, y2:100,
  209. colors:[{offset:.5, color:"#ffffff"}, {offset:1, color:"#e1eaf5"}]
  210. },
  211. "color": "#92a0b3"
  212. },
  213. down:{
  214. "fill": {
  215. type:"linear",
  216. x1:0, x2:0, y1:0, y2:100,
  217. colors:[{offset:0, color:"#e1eaf5"}, {offset:1, color:"#ffffff"}]
  218. },
  219. "color": "#92a0b3"
  220. },
  221. selected:{
  222. "fill": {
  223. type:"linear",
  224. x1:0, x2:0, y1:0, y2:100,
  225. colors:[{offset:0, color:"#97b4bf"}, {offset:1, color:"#c8dae1"}]
  226. },
  227. "color": "#92a0b3"
  228. },
  229. icon:{
  230. norm:{
  231. fill:null,
  232. color:"#92a0b3"
  233. },
  234. selected:{
  235. fill:"#ffffff",
  236. color:"#92a0b3"
  237. }
  238. }
  239. },
  240. copy: function(){
  241. // summary
  242. // Each shape gets its own copy
  243. // of these styles so that instances
  244. // do not change each other's styles
  245. //
  246. var cpy = function(obj){
  247. if(typeof(obj)!="object" || obj===null || obj===undefined){
  248. return obj;
  249. }
  250. var o;
  251. if(obj.push){
  252. o = [];
  253. for(var i=0; i<obj.length;i++){
  254. o.push(cpy(obj[i]))
  255. }
  256. return o;
  257. }
  258. o = {};
  259. for(var nm in obj){
  260. if(nm!="copy"){
  261. if(typeof(obj[nm])=="object"){
  262. o[nm] = cpy(obj[nm]);
  263. }else{
  264. o[nm] = obj[nm]
  265. }
  266. }
  267. }
  268. return o;
  269. }
  270. var o = cpy(this);
  271. o.current = o.norm;
  272. o.currentHit = o.hitNorm;
  273. o.currentText = o.text;
  274. return o;
  275. }
  276. };
  277. }