mxMockupForms.js 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503
  1. /**
  2. * $Id: mxMockupForms.js,v 1.11 2013/05/24 05:21:33 mate Exp $
  3. * Copyright (c) 2006-2010, JGraph Ltd
  4. */
  5. //**********************************************************************************************************************************************************
  6. //Checkbox Group (LEGACY)
  7. //**********************************************************************************************************************************************************
  8. /**
  9. * Extends mxShape.
  10. */
  11. function mxShapeMockupCheckboxGroup(bounds, fill, stroke, strokewidth)
  12. {
  13. mxShape.call(this);
  14. this.bounds = bounds;
  15. this.fill = fill;
  16. this.stroke = stroke;
  17. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  18. };
  19. /**
  20. * Extends mxShape.
  21. */
  22. mxUtils.extend(mxShapeMockupCheckboxGroup, mxShape);
  23. mxShapeMockupCheckboxGroup.prototype.cst = {
  24. MAIN_TEXT : 'mainText',
  25. TEXT_SIZE : 'textSize',
  26. TEXT_COLOR : 'textColor',
  27. SELECTED : '+', // must be 1 char
  28. SHAPE_CHECKBOX_GROUP : 'mxgraph.mockup.forms.checkboxGroup'
  29. };
  30. /**
  31. * Function: paintVertexShape
  32. *
  33. * Paints the vertex shape.
  34. */
  35. mxShapeMockupCheckboxGroup.prototype.paintVertexShape = function(c, x, y, w, h)
  36. {
  37. c.translate(x, y);
  38. var fontColor = mxUtils.getValue(this.style, mxShapeMockupCheckboxGroup.prototype.cst.TEXT_COLOR, '#666666,#008cff').toString().split(',');
  39. var fontSize = mxUtils.getValue(this.style, mxShapeMockupCheckboxGroup.prototype.cst.TEXT_SIZE, '17').toString();
  40. var optionText = mxUtils.getValue(this.style, mxShapeMockupCheckboxGroup.prototype.cst.MAIN_TEXT, 'Option 1').toString().split(',');
  41. var optionNum = optionText.length;
  42. var buttonSize = 15;
  43. var lineH = Math.max(fontSize * 1.5, buttonSize);
  44. var maxTextWidth = 0;
  45. var selected = -1;
  46. var labelOffset = 2.5;
  47. var minH = optionNum * lineH;
  48. var trueH = Math.max(h, minH);
  49. //get min width and selected option
  50. for (var i = 0; i < optionNum; i++)
  51. {
  52. var currText = optionText[i];
  53. if(currText.charAt(0) === mxShapeMockupCheckboxGroup.prototype.cst.SELECTED)
  54. {
  55. currText = optionText[i].substring(1);
  56. selected = i;
  57. }
  58. var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  59. if (currWidth > maxTextWidth)
  60. {
  61. maxTextWidth = currWidth;
  62. }
  63. }
  64. var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;
  65. var trueW = Math.max(w, minW);
  66. //draw the background
  67. c.rect(0, 0, trueW, trueH);
  68. c.fillAndStroke();
  69. c.setShadow(false);
  70. c.setFontSize(fontSize);
  71. for (var i = 0; i < optionNum; i++)
  72. {
  73. var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;
  74. var currText = optionText[i];
  75. if(currText.charAt(0) === mxShapeMockupCheckboxGroup.prototype.cst.SELECTED)
  76. {
  77. c.setFontColor(fontColor[1]);
  78. currText = optionText[i].substring(1);
  79. selected = i;
  80. }
  81. else
  82. {
  83. c.setFontColor(fontColor[0]);
  84. }
  85. c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  86. var iconX = buttonSize * 0.5;
  87. var iconY = currHeight - buttonSize * 0.5;
  88. c.setFillColor('#dddddd');
  89. c.setStrokeColor('#999999');
  90. if (selected === i)
  91. {
  92. c.setGradient('#aaaaaa', '#666666', iconX, iconY, buttonSize, buttonSize, mxConstants.DIRECTION_SOUTH, 1, 1);
  93. c.rect(iconX, iconY, buttonSize, buttonSize);
  94. c.fillAndStroke();
  95. c.setStrokeColor('#333333');
  96. c.begin();
  97. c.moveTo(iconX + buttonSize * 0.25, iconY + buttonSize * 0.5);
  98. c.lineTo(iconX + buttonSize * 0.5, iconY + buttonSize * 0.75);
  99. c.lineTo(iconX + buttonSize * 0.75, iconY + buttonSize * 0.25);
  100. c.stroke();
  101. }
  102. else
  103. {
  104. c.setGradient('#eeeeee', '#cccccc', iconX, iconY, buttonSize, buttonSize, mxConstants.DIRECTION_SOUTH, 1, 1);
  105. c.rect(iconX, iconY, buttonSize, buttonSize);
  106. c.fillAndStroke();
  107. }
  108. selected = -1;
  109. }
  110. };
  111. mxCellRenderer.registerShape(mxShapeMockupCheckboxGroup.prototype.cst.SHAPE_CHECKBOX_GROUP, mxShapeMockupCheckboxGroup);
  112. //**********************************************************************************************************************************************************
  113. //Radio Button Group
  114. //**********************************************************************************************************************************************************
  115. /**
  116. * Extends mxShape.
  117. */
  118. function mxShapeMockupRadioGroup(bounds, fill, stroke, strokewidth)
  119. {
  120. mxShape.call(this);
  121. this.bounds = bounds;
  122. this.fill = fill;
  123. this.stroke = stroke;
  124. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  125. };
  126. /**
  127. * Extends mxShape.
  128. */
  129. mxUtils.extend(mxShapeMockupRadioGroup, mxShape);
  130. mxShapeMockupRadioGroup.prototype.cst = {
  131. MAIN_TEXT : 'mainText',
  132. TEXT_SIZE : 'textSize',
  133. TEXT_COLOR : 'textColor',
  134. SELECTED : '+', // must be 1 char
  135. SHAPE_RADIO_GROUP : 'mxgraph.mockup.forms.radioGroup'
  136. };
  137. /**
  138. * Function: paintVertexShape
  139. *
  140. * Paints the vertex shape.
  141. */
  142. mxShapeMockupRadioGroup.prototype.paintVertexShape = function(c, x, y, w, h)
  143. {
  144. c.translate(x, y);
  145. var fontColor = mxUtils.getValue(this.style, mxShapeMockupRadioGroup.prototype.cst.TEXT_COLOR, '#666666,#008cff').toString().split(',');
  146. var fontSize = mxUtils.getValue(this.style, mxShapeMockupRadioGroup.prototype.cst.TEXT_SIZE, '17').toString();
  147. var optionText = mxUtils.getValue(this.style, mxShapeMockupRadioGroup.prototype.cst.MAIN_TEXT, 'Option 1').toString().split(',');
  148. var optionNum = optionText.length;
  149. var buttonSize = 15;
  150. var lineH = Math.max(fontSize * 1.5, buttonSize);
  151. var maxTextWidth = 0;
  152. var selected = -1;
  153. var labelOffset = 2.5;
  154. var minH = optionNum * lineH;
  155. var trueH = Math.max(h, minH);
  156. //get min width and selected option
  157. for (var i = 0; i < optionNum; i++)
  158. {
  159. var currText = optionText[i];
  160. if(currText.charAt(0) === mxShapeMockupRadioGroup.prototype.cst.SELECTED)
  161. {
  162. currText = optionText[i].substring(1);
  163. selected = i;
  164. }
  165. var currWidth = mxUtils.getSizeForString(currText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  166. if (currWidth > maxTextWidth)
  167. {
  168. maxTextWidth = currWidth;
  169. }
  170. }
  171. var minW = 2 * labelOffset + maxTextWidth + 2 * buttonSize;
  172. var trueW = Math.max(w, minW);
  173. //draw the background
  174. c.rect(0, 0, trueW, trueH);
  175. c.fillAndStroke();
  176. c.setShadow(false);
  177. c.setFontSize(fontSize);
  178. for (var i = 0; i < optionNum; i++)
  179. {
  180. var currHeight = (i * lineH + lineH * 0.5) * trueH / minH;
  181. var currText = optionText[i];
  182. if(currText.charAt(0) === mxShapeMockupRadioGroup.prototype.cst.SELECTED)
  183. {
  184. c.setFontColor(fontColor[1]);
  185. currText = optionText[i].substring(1);
  186. selected = i;
  187. }
  188. else
  189. {
  190. c.setFontColor(fontColor[0]);
  191. }
  192. c.text(buttonSize * 2 + labelOffset, currHeight, 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  193. var iconX = buttonSize * 0.5;
  194. var iconY = currHeight - buttonSize * 0.5;
  195. c.setStrokeColor('#999999');
  196. if (selected === i)
  197. {
  198. c.setGradient('#aaaaaa', '#666666', iconX, iconY, buttonSize, buttonSize, mxConstants.DIRECTION_SOUTH, 1, 1);
  199. c.ellipse(iconX, iconY, buttonSize, buttonSize);
  200. c.fillAndStroke();
  201. c.setFillColor('#333333');
  202. c.setStrokeColor('#333333');
  203. c.ellipse(iconX + buttonSize * 0.25, iconY + buttonSize * 0.25, buttonSize * 0.5, buttonSize * 0.5);
  204. c.fillAndStroke();
  205. }
  206. else
  207. {
  208. c.setGradient('#eeeeee', '#cccccc', iconX, iconY, buttonSize, buttonSize, mxConstants.DIRECTION_SOUTH, 1, 1);
  209. c.ellipse(iconX, iconY, buttonSize, buttonSize);
  210. c.fillAndStroke();
  211. }
  212. }
  213. };
  214. mxCellRenderer.registerShape(mxShapeMockupRadioGroup.prototype.cst.SHAPE_RADIO_GROUP, mxShapeMockupRadioGroup);
  215. //**********************************************************************************************************************************************************
  216. //Color Picker
  217. //**********************************************************************************************************************************************************
  218. /**
  219. * Extends mxShape.
  220. */
  221. function mxShapeMockupColorPicker(bounds, fill, stroke, strokewidth)
  222. {
  223. mxShape.call(this);
  224. this.bounds = bounds;
  225. this.fill = fill;
  226. this.stroke = stroke;
  227. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  228. };
  229. /**
  230. * Extends mxShape.
  231. */
  232. mxUtils.extend(mxShapeMockupColorPicker, mxShape);
  233. mxShapeMockupColorPicker.prototype.cst = {
  234. COLOR : 'chosenColor',
  235. SHAPE_COLOR_PICKER : 'mxgraph.mockup.forms.colorPicker'
  236. };
  237. mxShapeMockupColorPicker.prototype.customProperties = [
  238. {name: 'chosenColor', dispName: 'Current Color', type: 'color'}
  239. ];
  240. /**
  241. * Function: paintVertexShape
  242. *
  243. * Paints the vertex shape.
  244. */
  245. mxShapeMockupColorPicker.prototype.paintVertexShape = function(c, x, y, w, h)
  246. {
  247. var chosenColor = mxUtils.getValue(this.style, mxShapeMockupColorPicker.prototype.cst.COLOR, '#aaddff');
  248. c.translate(x, y);
  249. c.setStrokeColor('#999999');
  250. c.roundrect(0, 0, w, h, w * 0.05, h * 0.05);
  251. c.fillAndStroke();
  252. c.setShadow(false);
  253. c.setFillColor(chosenColor);
  254. c.rect(w * 0.1, h * 0.1, w * 0.8, h * 0.8);
  255. c.fill();
  256. c.setFillColor('#ffffff');
  257. c.begin();
  258. c.moveTo(w * 0.75, h * 0.75);
  259. c.lineTo(w * 0.75, h);
  260. c.lineTo(w * 0.95, h);
  261. c.arcTo(w * 0.05, h * 0.05, 0, 0, 0, w, h * 0.95);
  262. c.lineTo(w, h * 0.75);
  263. c.close();
  264. c.fill();
  265. c.setFillColor('#999999');
  266. c.begin();
  267. c.moveTo(w * 0.77, h * 0.77);
  268. c.lineTo(w * 0.875, h * 0.98);
  269. c.lineTo(w * 0.98, h * 0.77);
  270. c.close();
  271. c.fill();
  272. c.roundrect(0, 0, w, h, w * 0.05, h * 0.05);
  273. c.stroke();
  274. };
  275. mxCellRenderer.registerShape(mxShapeMockupColorPicker.prototype.cst.SHAPE_COLOR_PICKER, mxShapeMockupColorPicker);
  276. //**********************************************************************************************************************************************************
  277. //Combo box
  278. //**********************************************************************************************************************************************************
  279. /**
  280. * Extends mxShape.
  281. */
  282. function mxShapeMockupComboBox(bounds, fill, stroke, strokewidth)
  283. {
  284. mxShape.call(this);
  285. this.bounds = bounds;
  286. this.fill = fill;
  287. this.stroke = stroke;
  288. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  289. };
  290. /**
  291. * Extends mxShape.
  292. */
  293. mxUtils.extend(mxShapeMockupComboBox, mxShape);
  294. mxShapeMockupComboBox.prototype.cst = {
  295. MAIN_TEXT : 'mainText',
  296. FILL_COLOR2 : 'fillColor2',
  297. TEXT_COLOR : 'textColor',
  298. TEXT_SIZE : 'textSize',
  299. SHAPE_COMBO_BOX : 'mxgraph.mockup.forms.comboBox'
  300. };
  301. mxShapeMockupComboBox.prototype.customProperties = [
  302. {name: 'fillColor2', dispName: 'Fill2 Color', type: 'color'}
  303. ];
  304. /**
  305. * Function: paintVertexShape
  306. *
  307. * Paints the vertex shape.
  308. */
  309. mxShapeMockupComboBox.prototype.paintVertexShape = function(c, x, y, w, h)
  310. {
  311. c.translate(x, y);
  312. this.background(c, x, y, w, h);
  313. c.setShadow(false);
  314. this.foreground(c, x, y, w, h);
  315. this.mainText(c, x, y, w, h);
  316. };
  317. mxShapeMockupComboBox.prototype.background = function(c, x, y, w, h)
  318. {
  319. c.setFillColor('#ffffff');
  320. c.roundrect(0, 0, w, h, 5, 5);
  321. c.fillAndStroke();
  322. };
  323. mxShapeMockupComboBox.prototype.foreground = function(c, x, y, w, h)
  324. {
  325. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '').toString();
  326. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupComboBox.prototype.cst.FILL_COLOR2, '').toString();
  327. c.setGradient(fillColor, fillColor2, w - 30, 0, 30, h, mxConstants.DIRECTION_SOUTH, 1, 1);
  328. c.begin();
  329. c.moveTo(w - 30, 0);
  330. c.lineTo(w - 5, 0);
  331. c.arcTo(5, 5, 0, 0, 1, w, 5);
  332. c.lineTo(w, h - 5);
  333. c.arcTo(5, 5, 0, 0, 1, w - 5, h);
  334. c.lineTo(w - 30, h);
  335. c.close();
  336. c.fillAndStroke();
  337. c.setFillColor('#ffffff');
  338. c.begin();
  339. c.moveTo(w - 22, h * 0.5 - 5);
  340. c.lineTo(w - 15, h * 0.5 + 5);
  341. c.lineTo(w - 8, h * 0.5 - 5);
  342. c.fill();
  343. };
  344. mxShapeMockupComboBox.prototype.mainText = function(c, x, y, w, h)
  345. {
  346. var mainText = mxUtils.getValue(this.style, mxShapeMockupComboBox.prototype.cst.MAIN_TEXT, 'Main Text');
  347. var fontColor = mxUtils.getValue(this.style, mxShapeMockupComboBox.prototype.cst.TEXT_COLOR, '#666666').toString();
  348. var fontSize = mxUtils.getValue(this.style, mxShapeMockupComboBox.prototype.cst.TEXT_SIZE, '17').toString();
  349. c.begin();
  350. c.setFontSize(fontSize);
  351. c.setFontColor(fontColor);
  352. c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  353. };
  354. mxCellRenderer.registerShape(mxShapeMockupComboBox.prototype.cst.SHAPE_COMBO_BOX, mxShapeMockupComboBox);
  355. //**********************************************************************************************************************************************************
  356. //Spinner
  357. //**********************************************************************************************************************************************************
  358. /**
  359. * Extends mxShape.
  360. */
  361. function mxShapeMockupSpinner(bounds, fill, stroke, strokewidth)
  362. {
  363. mxShape.call(this);
  364. this.bounds = bounds;
  365. this.fill = fill;
  366. this.stroke = stroke;
  367. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  368. };
  369. /**
  370. * Extends mxShape.
  371. */
  372. mxUtils.extend(mxShapeMockupSpinner, mxShape);
  373. mxShapeMockupSpinner.prototype.cst = {
  374. LAYOUT : 'spinLayout',
  375. SPINNER_STYLE : 'spinStyle',
  376. ADJ_STYLE : 'adjStyle',
  377. LAYOUT_RIGHT : 'right',
  378. LAYOUT_LEFT : 'left',
  379. LAYOUT_TOP : 'top',
  380. LAYOUT_BOTTOM : 'bottom',
  381. LAYOUT_VERTICAL : 'vertical',
  382. LAYOUT_HORIZONTAL : 'horizontal',
  383. SPINNER_MERGED : 'merged',
  384. SPINNER_NORMAL : 'normal',
  385. ADJ_TRIANGLE : 'triangle',
  386. ADJ_PLUSMINUS : 'plusMinus',
  387. ADJ_ARROW : 'arrow',
  388. MAIN_TEXT : 'mainText',
  389. TEXT_COLOR : 'textColor',
  390. TEXT_SIZE : 'textSize',
  391. SHAPE_SPINNER : 'mxgraph.mockup.forms.spinner'
  392. };
  393. mxShapeMockupSpinner.prototype.customProperties = [
  394. {name: 'spinLayout', dispName: 'Layout', type: 'enum',
  395. enumList: [{val: 'right', dispName: 'Right'}, {val: 'left', dispName: 'Left'}, {val: 'top', dispName: 'Top'}, {val: 'bottom', dispName: 'Bottom'}, {val: 'vertical', dispName: 'Vertical'}, {val: 'horizontal', dispName: 'Horizontal'}]
  396. },
  397. {name: 'spinStyle', dispName: 'Spinner Style', type: 'enum',
  398. enumList: [{val: 'merged', dispName: 'Merged'}, {val: 'normal', dispName: 'Normal'}]
  399. },
  400. {name: 'adjStyle', dispName: 'Button Style', type: 'enum',
  401. enumList: [{val: 'triangle', dispName: 'Triangle'}, {val: 'plusMinus', dispName: '+/-'}, {val: 'arrow', dispName: 'Arrow'}]
  402. }
  403. ];
  404. /**
  405. * Function: paintVertexShape
  406. *
  407. * Paints the vertex shape.
  408. */
  409. mxShapeMockupSpinner.prototype.paintVertexShape = function(c, x, y, w, h)
  410. {
  411. var spinnerLayout = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.LAYOUT, mxShapeMockupSpinner.prototype.cst.LAYOUT_RIGHT);
  412. c.translate(x, y);
  413. this.background(c, w, h);
  414. c.setShadow(false);
  415. this.foreground(c, w, h, spinnerLayout);
  416. this.mainText(c, w, h, spinnerLayout);
  417. };
  418. mxShapeMockupSpinner.prototype.background = function(c, w, h)
  419. {
  420. c.setFillColor('#ffffff');
  421. c.roundrect(0, 0, w, h, 10, 10);
  422. c.fillAndStroke();
  423. };
  424. mxShapeMockupSpinner.prototype.foreground = function(c, w, h, spinnerLayout)
  425. {
  426. var spinnerStyle = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.SPINNER_STYLE, mxShapeMockupSpinner.prototype.cst.SPINNER_NORMAL);
  427. var adjStyle = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.ADJ_STYLE, mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE);
  428. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  429. c.setFillColor(fillColor);
  430. if (spinnerStyle === mxShapeMockupSpinner.prototype.cst.SPINNER_NORMAL)
  431. {
  432. if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_RIGHT)
  433. {
  434. c.begin();
  435. c.moveTo(w - 20, 0);
  436. c.lineTo(w - 20, h);
  437. c.moveTo(w - 20, h * 0.5);
  438. c.lineTo(w, h * 0.5);
  439. c.stroke();
  440. }
  441. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_LEFT)
  442. {
  443. c.begin();
  444. c.moveTo(20, 0);
  445. c.lineTo(20, h);
  446. c.moveTo(20, h * 0.5);
  447. c.lineTo(0, h * 0.5);
  448. c.stroke();
  449. }
  450. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_TOP)
  451. {
  452. c.begin();
  453. c.moveTo(0, 15);
  454. c.lineTo(w, 15);
  455. c.moveTo(w * 0.5, 15);
  456. c.lineTo(w * 0.5, 0);
  457. c.stroke();
  458. }
  459. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_BOTTOM)
  460. {
  461. c.begin();
  462. c.moveTo(0, h - 15);
  463. c.lineTo(w, h - 15);
  464. c.moveTo(w * 0.5, h - 15);
  465. c.lineTo(w * 0.5, h);
  466. c.stroke();
  467. }
  468. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_VERTICAL)
  469. {
  470. c.begin();
  471. c.moveTo(0, 15);
  472. c.lineTo(w, 15);
  473. c.moveTo(0, h - 15);
  474. c.lineTo(w, h - 15);
  475. c.stroke();
  476. }
  477. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_HORIZONTAL)
  478. {
  479. c.begin();
  480. c.moveTo(20, 0);
  481. c.lineTo(20, h);
  482. c.moveTo(w - 20, 0);
  483. c.lineTo(w - 20, h);
  484. c.stroke();
  485. }
  486. }
  487. c.setStrokeColor(fillColor);
  488. if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_RIGHT)
  489. {
  490. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  491. {
  492. c.begin();
  493. c.moveTo(w - 14, h * 0.25 + 4.5);
  494. c.lineTo(w - 10, h * 0.25 - 2.5);
  495. c.lineTo(w - 6, h * 0.25 + 4.5);
  496. c.close();
  497. c.fillAndStroke();
  498. }
  499. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  500. {
  501. c.begin();
  502. c.moveTo(w - 10, h * 0.25 - 4);
  503. c.lineTo(w - 10, h * 0.25 + 4);
  504. c.moveTo(w - 14, h * 0.25);
  505. c.lineTo(w - 6, h * 0.25);
  506. c.stroke();
  507. }
  508. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  509. {
  510. c.begin();
  511. c.moveTo(w - 14, h * 0.25 + 1.5);
  512. c.lineTo(w - 10, h * 0.25 - 2.5);
  513. c.lineTo(w - 6, h * 0.25 + 1.5);
  514. c.close();
  515. c.moveTo(w - 10, h * 0.25 + 4.5);
  516. c.lineTo(w - 10, h * 0.25 - 2.5);
  517. c.fillAndStroke();
  518. }
  519. }
  520. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_LEFT)
  521. {
  522. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  523. {
  524. c.begin();
  525. c.moveTo(14, h * 0.25 + 4.5);
  526. c.lineTo(10, h * 0.25 - 2.5);
  527. c.lineTo(6, h * 0.25 + 4.5);
  528. c.close();
  529. c.fillAndStroke();
  530. }
  531. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  532. {
  533. c.begin();
  534. c.moveTo(10, h * 0.25 - 4);
  535. c.lineTo(10, h * 0.25 + 4);
  536. c.moveTo(14, h * 0.25);
  537. c.lineTo(6, h * 0.25);
  538. c.stroke();
  539. }
  540. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  541. {
  542. c.begin();
  543. c.moveTo(14, h * 0.25 + 1.5);
  544. c.lineTo(10, h * 0.25 - 2.5);
  545. c.lineTo(6, h * 0.25 + 1.5);
  546. c.close();
  547. c.moveTo(10, h * 0.25 + 4.5);
  548. c.lineTo(10, h * 0.25 - 2.5);
  549. c.fillAndStroke();
  550. }
  551. }
  552. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_TOP)
  553. {
  554. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  555. {
  556. c.begin();
  557. c.moveTo(w * 0.75 + 4, 12);
  558. c.lineTo(w * 0.75, 5);
  559. c.lineTo(w * 0.75 - 4, 12);
  560. c.close();
  561. c.fillAndStroke();
  562. }
  563. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  564. {
  565. c.begin();
  566. c.moveTo(w * 0.75, 3.5);
  567. c.lineTo(w * 0.75, 11.5);
  568. c.moveTo(w * 0.75 + 4, 7.5);
  569. c.lineTo(w * 0.75 - 4, 7.5);
  570. c.stroke();
  571. }
  572. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  573. {
  574. c.begin();
  575. c.moveTo(w * 0.75 + 4, 9);
  576. c.lineTo(w * 0.75, 5);
  577. c.lineTo(w * 0.75 - 4, 9);
  578. c.close();
  579. c.moveTo(w * 0.75, 12);
  580. c.lineTo(w * 0.75, 5);
  581. c.fillAndStroke();
  582. }
  583. }
  584. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_BOTTOM)
  585. {
  586. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  587. {
  588. c.begin();
  589. c.moveTo(w * 0.75 + 4, h - 5);
  590. c.lineTo(w * 0.75, h - 12);
  591. c.lineTo(w * 0.75 - 4, h - 5);
  592. c.close();
  593. c.fillAndStroke();
  594. }
  595. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  596. {
  597. c.begin();
  598. c.moveTo(w * 0.75, h - 3.5);
  599. c.lineTo(w * 0.75, h - 11.5);
  600. c.moveTo(w * 0.75 + 4, h - 7.5);
  601. c.lineTo(w * 0.75 - 4, h - 7.5);
  602. c.stroke();
  603. }
  604. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  605. {
  606. c.begin();
  607. c.moveTo(w * 0.75 + 4, h - 6);
  608. c.lineTo(w * 0.75, h - 10);
  609. c.lineTo(w * 0.75 - 4, h - 6);
  610. c.close();
  611. c.moveTo(w * 0.75, h - 3);
  612. c.lineTo(w * 0.75, h - 10);
  613. c.fillAndStroke();
  614. }
  615. }
  616. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_VERTICAL)
  617. {
  618. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  619. {
  620. c.begin();
  621. c.moveTo(w * 0.5 + 4, 12);
  622. c.lineTo(w * 0.5, 5);
  623. c.lineTo(w * 0.5 - 4, 12);
  624. c.close();
  625. c.fillAndStroke();
  626. }
  627. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  628. {
  629. c.begin();
  630. c.moveTo(w * 0.5, 3.5);
  631. c.lineTo(w * 0.5, 11.5);
  632. c.moveTo(w * 0.5 + 4, 7.5);
  633. c.lineTo(w * 0.5 - 4, 7.5);
  634. c.stroke();
  635. }
  636. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  637. {
  638. c.begin();
  639. c.moveTo(w * 0.5 + 4, 9);
  640. c.lineTo(w * 0.5, 5);
  641. c.lineTo(w * 0.5 - 4, 9);
  642. c.close();
  643. c.moveTo(w * 0.5, 12);
  644. c.lineTo(w * 0.5, 5);
  645. c.fillAndStroke();
  646. }
  647. }
  648. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_HORIZONTAL)
  649. {
  650. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  651. {
  652. c.begin();
  653. c.moveTo(w - 6, h * 0.5 + 4.5);
  654. c.lineTo(w - 10, h * 0.5 - 2.5);
  655. c.lineTo(w - 14, h * 0.5 + 4.5);
  656. c.close();
  657. c.fillAndStroke();
  658. }
  659. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  660. {
  661. c.begin();
  662. c.moveTo(w - 10, h * 0.5 - 4);
  663. c.lineTo(w - 10, h * 0.5 + 4);
  664. c.moveTo(w - 14, h * 0.5);
  665. c.lineTo(w - 6, h * 0.5);
  666. c.stroke();
  667. }
  668. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  669. {
  670. c.begin();
  671. c.moveTo(w - 14, h * 0.5 + 1.5);
  672. c.lineTo(w - 10, h * 0.5 - 2.5);
  673. c.lineTo(w - 6, h * 0.5 + 1.5);
  674. c.close();
  675. c.moveTo(w - 10, h * 0.5 + 4.5);
  676. c.lineTo(w - 10, h * 0.5 - 2.5);
  677. c.fillAndStroke();
  678. }
  679. }
  680. if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_RIGHT)
  681. {
  682. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  683. {
  684. c.begin();
  685. c.moveTo(w - 14, h * 0.75 - 4.5);
  686. c.lineTo(w - 10, h * 0.75 + 2.5);
  687. c.lineTo(w - 6, h * 0.75 - 4.5);
  688. c.close();
  689. c.fillAndStroke();
  690. }
  691. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  692. {
  693. c.begin();
  694. c.moveTo(w - 14, h * 0.75);
  695. c.lineTo(w - 6, h * 0.75);
  696. c.stroke();
  697. }
  698. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  699. {
  700. c.begin();
  701. c.moveTo(w - 14, h * 0.75 - 1.5);
  702. c.lineTo(w - 10, h * 0.75 + 2.5);
  703. c.lineTo(w - 6, h * 0.75 - 1.5);
  704. c.close();
  705. c.moveTo(w - 10, h * 0.75 - 4.5);
  706. c.lineTo(w - 10, h * 0.75 + 2.5);
  707. c.fillAndStroke();
  708. }
  709. }
  710. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_LEFT)
  711. {
  712. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  713. {
  714. c.begin();
  715. c.moveTo(14, h * 0.75 - 4.5);
  716. c.lineTo(10, h * 0.75 + 2.5);
  717. c.lineTo(6, h * 0.75 - 4.5);
  718. c.close();
  719. c.fillAndStroke();
  720. }
  721. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  722. {
  723. c.begin();
  724. c.moveTo(14, h * 0.75);
  725. c.lineTo(6, h * 0.75);
  726. c.stroke();
  727. }
  728. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  729. {
  730. c.begin();
  731. c.moveTo(14, h * 0.75 - 1.5);
  732. c.lineTo(10, h * 0.75 + 2.5);
  733. c.lineTo(6, h * 0.75 - 1.5);
  734. c.close();
  735. c.moveTo(10, h * 0.75 - 4.5);
  736. c.lineTo(10, h * 0.75 + 2.5);
  737. c.fillAndStroke();
  738. }
  739. }
  740. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_TOP)
  741. {
  742. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  743. {
  744. c.begin();
  745. c.moveTo(w * 0.25 + 4, 5);
  746. c.lineTo(w * 0.25, 12);
  747. c.lineTo(w * 0.25 - 4, 5);
  748. c.close();
  749. c.fillAndStroke();
  750. }
  751. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  752. {
  753. c.begin();
  754. c.moveTo(w * 0.25 + 4, 7.5);
  755. c.lineTo(w * 0.25 - 4, 7.5);
  756. c.stroke();
  757. }
  758. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  759. {
  760. c.begin();
  761. c.moveTo(w * 0.25 + 4, 6);
  762. c.lineTo(w * 0.25, 10);
  763. c.lineTo(w * 0.25 - 4, 6);
  764. c.close();
  765. c.moveTo(w * 0.25, 3);
  766. c.lineTo(w * 0.25, 10);
  767. c.fillAndStroke();
  768. }
  769. }
  770. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_BOTTOM)
  771. {
  772. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  773. {
  774. c.begin();
  775. c.moveTo(w * 0.25 + 4, h - 12);
  776. c.lineTo(w * 0.25, h - 5);
  777. c.lineTo(w * 0.25 - 4, h - 12);
  778. c.close();
  779. c.fillAndStroke();
  780. }
  781. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  782. {
  783. c.begin();
  784. c.moveTo(w * 0.25 + 4, h - 7.5);
  785. c.lineTo(w * 0.25 - 4, h - 7.5);
  786. c.stroke();
  787. }
  788. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  789. {
  790. c.begin();
  791. c.moveTo(w * 0.25 + 4, h - 9);
  792. c.lineTo(w * 0.25, h - 5);
  793. c.lineTo(w * 0.25 - 4, h - 9);
  794. c.close();
  795. c.moveTo(w * 0.25, h - 12);
  796. c.lineTo(w * 0.25, h - 5);
  797. c.fillAndStroke();
  798. }
  799. }
  800. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_VERTICAL)
  801. {
  802. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  803. {
  804. c.begin();
  805. c.moveTo(w * 0.5 + 4, h - 12);
  806. c.lineTo(w * 0.5, h - 5);
  807. c.lineTo(w * 0.5 - 4, h - 12);
  808. c.close();
  809. c.fillAndStroke();
  810. }
  811. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  812. {
  813. c.begin();
  814. c.moveTo(w * 0.5 + 4, h - 7.5);
  815. c.lineTo(w * 0.5 - 4, h - 7.5);
  816. c.stroke();
  817. }
  818. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  819. {
  820. c.begin();
  821. c.moveTo(w * 0.5 + 4, h - 9);
  822. c.lineTo(w * 0.5, h - 5);
  823. c.lineTo(w * 0.5 - 4, h - 9);
  824. c.close();
  825. c.moveTo(w * 0.5, h - 12);
  826. c.lineTo(w * 0.5, h - 5);
  827. c.fillAndStroke();
  828. }
  829. }
  830. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_HORIZONTAL)
  831. {
  832. if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_TRIANGLE)
  833. {
  834. c.begin();
  835. c.moveTo(6, h * 0.5 - 4.5);
  836. c.lineTo(10, h * 0.5 + 2.5);
  837. c.lineTo(14, h * 0.5 - 4.5);
  838. c.close();
  839. c.fillAndStroke();
  840. }
  841. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_PLUSMINUS)
  842. {
  843. c.begin();
  844. c.moveTo(14, h * 0.5);
  845. c.lineTo(6, h * 0.5);
  846. c.stroke();
  847. }
  848. else if(adjStyle === mxShapeMockupSpinner.prototype.cst.ADJ_ARROW)
  849. {
  850. c.begin();
  851. c.moveTo(14, h * 0.5 - 1.5);
  852. c.lineTo(10, h * 0.5 + 2.5);
  853. c.lineTo(6, h * 0.5 - 1.5);
  854. c.close();
  855. c.moveTo(10, h * 0.5 - 4.5);
  856. c.lineTo(10, h * 0.5 + 2.5);
  857. c.fillAndStroke();
  858. }
  859. }
  860. };
  861. mxShapeMockupSpinner.prototype.mainText = function(c, w, h, spinnerLayout)
  862. {
  863. var spinnerText = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.MAIN_TEXT, '100').toString();
  864. var fontSize = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.TEXT_SIZE, '17');
  865. var fontColor = mxUtils.getValue(this.style, mxShapeMockupSpinner.prototype.cst.TEXT_COLOR, '#666666');
  866. c.setFontSize(fontSize);
  867. c.setFontColor(fontColor);
  868. if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_RIGHT)
  869. {
  870. c.text((w - 20) * 0.5, h * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  871. }
  872. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_LEFT)
  873. {
  874. c.text((w + 20) * 0.5, h * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  875. }
  876. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_TOP)
  877. {
  878. c.text(w * 0.5, (h + 15) * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  879. }
  880. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_BOTTOM)
  881. {
  882. c.text(w * 0.5, (h - 15) * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  883. }
  884. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_VERTICAL)
  885. {
  886. c.text(w * 0.5, h * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  887. }
  888. else if (spinnerLayout === mxShapeMockupSpinner.prototype.cst.LAYOUT_HORIZONTAL)
  889. {
  890. c.text(w * 0.5, h * 0.5, 0, 0, spinnerText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  891. }
  892. };
  893. mxCellRenderer.registerShape(mxShapeMockupSpinner.prototype.cst.SHAPE_SPINNER, mxShapeMockupSpinner);
  894. //**********************************************************************************************************************************************************
  895. //Menu Bar (LEGACY)
  896. //**********************************************************************************************************************************************************
  897. /**
  898. * Extends mxShape.
  899. */
  900. function mxShapeMockupMenuBar(bounds, fill, stroke, strokewidth)
  901. {
  902. mxShape.call(this);
  903. this.bounds = bounds;
  904. this.fill = fill;
  905. this.stroke = stroke;
  906. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  907. };
  908. /**
  909. * Extends mxShape.
  910. */
  911. mxUtils.extend(mxShapeMockupMenuBar, mxShape);
  912. mxShapeMockupMenuBar.prototype.cst = {
  913. MAIN_TEXT : 'mainText',
  914. SHAPE_MENU_BAR : 'mxgraph.mockup.forms.menuBar',
  915. TEXT_COLOR : 'textColor',
  916. TEXT_COLOR2 : 'textColor2',
  917. STROKE_COLOR2 : 'strokeColor2',
  918. FILL_COLOR2 : 'fillColor2',
  919. SELECTED : '+', //must be 1 char
  920. TEXT_SIZE : 'textSize'
  921. };
  922. /**
  923. * Function: paintVertexShape
  924. *
  925. * Paints the vertex shape.
  926. */
  927. mxShapeMockupMenuBar.prototype.paintVertexShape = function(c, x, y, w, h)
  928. {
  929. var textStrings = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.MAIN_TEXT, '+Menu 1, Menu 2, Menu 3').toString().split(',');
  930. var fontColor = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.TEXT_COLOR, '#666666');
  931. var selectedFontColor = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.TEXT_COLOR2, '#ffffff');
  932. var fontSize = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.TEXT_SIZE, '17').toString();
  933. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  934. var separatorColor = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.STROKE_COLOR2, '#c4c4c4');
  935. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  936. var selectedFillColor = mxUtils.getValue(this.style, mxShapeMockupMenuBar.prototype.cst.FILL_COLOR2, '#008cff');
  937. var buttonNum = textStrings.length;
  938. var buttonWidths = new Array(buttonNum);
  939. var buttonTotalWidth = 0;
  940. var selectedButton = -1;
  941. var rSize = 10; //rounding size
  942. var labelOffset = 5;
  943. for (var i = 0; i < buttonNum; i++)
  944. {
  945. var buttonText = textStrings[i];
  946. if(buttonText.charAt(0) === mxShapeMockupMenuBar.prototype.cst.SELECTED)
  947. {
  948. buttonText = textStrings[i].substring(1);
  949. selectedButton = i;
  950. }
  951. buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  952. buttonTotalWidth += buttonWidths[i];
  953. }
  954. var trueH = Math.max(h, fontSize * 1.5, 20);
  955. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  956. var trueW = Math.max(w, minW);
  957. c.translate(x, y);
  958. this.background(c, trueW, trueH, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton);
  959. c.setShadow(false);
  960. var currWidth = 0;
  961. for (var i = 0; i < buttonNum; i++)
  962. {
  963. if (i === selectedButton)
  964. {
  965. c.setFontColor(selectedFontColor);
  966. }
  967. else
  968. {
  969. c.setFontColor(fontColor);
  970. }
  971. currWidth = currWidth + labelOffset;
  972. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  973. currWidth = currWidth + buttonWidths[i] + labelOffset;
  974. }
  975. };
  976. mxShapeMockupMenuBar.prototype.background = function(c, w, h, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, separatorColor, bgColor, selectedFillColor, selectedButton)
  977. {
  978. //draw the frame
  979. c.setStrokeColor(frameColor);
  980. c.setFillColor(bgColor);
  981. c.rect(0, 0, w, h);
  982. c.fillAndStroke();
  983. //draw the button separators
  984. c.setStrokeColor(separatorColor);
  985. c.begin();
  986. for (var i = 1; i < buttonNum; i++)
  987. {
  988. if (i !== selectedButton && i !== (selectedButton + 1))
  989. {
  990. var currWidth = 0;
  991. for (var j = 0; j < i; j++)
  992. {
  993. currWidth += buttonWidths[j] + 2 * labelOffset;
  994. }
  995. currWidth = currWidth * w / minW;
  996. c.moveTo(currWidth, 0);
  997. c.lineTo(currWidth, h);
  998. }
  999. }
  1000. c.stroke();
  1001. //draw the selected menu
  1002. if (selectedButton !== -1)
  1003. {
  1004. var buttonLeft = 0;
  1005. c.setFillColor(selectedFillColor);
  1006. for (var i = 0; i < selectedButton; i++)
  1007. {
  1008. buttonLeft += buttonWidths[i] + 2 * labelOffset;
  1009. }
  1010. buttonLeft = buttonLeft * w / minW;
  1011. var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;
  1012. buttonRight += buttonLeft;
  1013. c.rect(buttonLeft, 0, buttonRight - buttonLeft, h);
  1014. c.fill();
  1015. }
  1016. //draw the frame again, for a nicer effect
  1017. c.setStrokeColor(frameColor);
  1018. c.setFillColor(bgColor);
  1019. c.rect(0, 0, w, h);
  1020. c.stroke();
  1021. };
  1022. mxShapeMockupMenuBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  1023. {
  1024. if(textString.charAt(0) === mxShapeMockupMenuBar.prototype.cst.SELECTED)
  1025. {
  1026. textString = textString.substring(1);
  1027. }
  1028. c.setFontSize(fontSize);
  1029. c.text((w + buttonWidth * 0.5) * trueW / minW, h * 0.5, 0, 0, textString, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1030. };
  1031. mxCellRenderer.registerShape(mxShapeMockupMenuBar.prototype.cst.SHAPE_MENU_BAR, mxShapeMockupMenuBar);
  1032. //**********************************************************************************************************************************************************
  1033. //Horizontal Slider
  1034. //**********************************************************************************************************************************************************
  1035. /**
  1036. * Extends mxShape.
  1037. */
  1038. function mxShapeMockupHorSlider(bounds, fill, stroke, strokewidth)
  1039. {
  1040. mxShape.call(this);
  1041. this.bounds = bounds;
  1042. this.fill = fill;
  1043. this.stroke = stroke;
  1044. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1045. };
  1046. /**
  1047. * Extends mxShape.
  1048. */
  1049. mxUtils.extend(mxShapeMockupHorSlider, mxShape);
  1050. mxShapeMockupHorSlider.prototype.cst = {
  1051. STYLE : 'sliderStyle',
  1052. SLIDER_BASIC : 'basic',
  1053. SLIDER_FANCY : 'fancy',
  1054. SLIDER_POS : 'sliderPos',
  1055. HANDLE_TRIANGLE : 'triangle',
  1056. HANDLE_CIRCLE : 'circle',
  1057. HANDLE_HANDLE : 'handle',
  1058. HANDLE_STYLE : 'handleStyle',
  1059. FILL_COLOR2 : 'fillColor2',
  1060. SHAPE_HOR_SLIDER : 'mxgraph.mockup.forms.horSlider'
  1061. };
  1062. mxShapeMockupHorSlider.prototype.customProperties = [
  1063. {name: 'sliderStyle', dispName: 'Slider Style', type: 'enum',
  1064. enumList: [{val: 'basic', dispName: 'Basic'}, {val: 'fancy', dispName: 'Fancy'}]
  1065. },
  1066. {name: 'handleStyle', dispName: 'Handle Style', type: 'enum',
  1067. enumList: [{val: 'triangle', dispName: 'Triangle'}, {val: 'circle', dispName: 'Circle'}, {val: 'handle', dispName: 'Handle'}]
  1068. },
  1069. {name: 'sliderPos', dispName: 'Handle Position', type: 'float'},
  1070. {name: 'fillColor2', dispName: 'Fill2 Color', type: 'color'},
  1071. ];
  1072. /**
  1073. * Function: paintVertexShape
  1074. *
  1075. * Paints the vertex shape.
  1076. */
  1077. mxShapeMockupHorSlider.prototype.paintVertexShape = function(c, x, y, w, h)
  1078. {
  1079. var sliderStyle = mxUtils.getValue(this.style, mxShapeMockupHorSlider.prototype.cst.STYLE, mxShapeMockupHorSlider.prototype.cst.SLIDER_BASIC);
  1080. var rSize = 5;
  1081. c.translate(x, y);
  1082. this.background(c, w, h, rSize, sliderStyle);
  1083. c.setShadow(false);
  1084. this.foreground(c, w, h, rSize, sliderStyle);
  1085. this.sliderPos = 20;
  1086. };
  1087. mxShapeMockupHorSlider.prototype.background = function(c, w, h, rSize, sliderStyle)
  1088. {
  1089. if (sliderStyle === mxShapeMockupHorSlider.prototype.cst.SLIDER_BASIC)
  1090. {
  1091. c.begin();
  1092. c.moveTo(0, h * 0.5);
  1093. c.lineTo(w, h * 0.5);
  1094. c.stroke();
  1095. }
  1096. else if (sliderStyle === mxShapeMockupHorSlider.prototype.cst.SLIDER_FANCY)
  1097. {
  1098. c.roundrect(0, h * 0.5 - rSize, w, 2 * rSize, rSize, rSize);
  1099. c.fillAndStroke();
  1100. }
  1101. };
  1102. mxShapeMockupHorSlider.prototype.foreground = function(c, w, h, rSize, sliderStyle)
  1103. {
  1104. var sliderPos = mxUtils.getValue(this.style, mxShapeMockupHorSlider.prototype.cst.SLIDER_POS, '20');
  1105. var handleStyle = mxUtils.getValue(this.style, mxShapeMockupHorSlider.prototype.cst.HANDLE_STYLE, mxShapeMockupHorSlider.prototype.cst.HANDLE_CIRCLE);
  1106. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  1107. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupHorSlider.prototype.cst.FILL_COLOR2, '#ddeeff');
  1108. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#999999');
  1109. sliderPos = Math.min(100, sliderPos);
  1110. sliderPos = Math.max(0, sliderPos);
  1111. if (sliderStyle === mxShapeMockupHorSlider.prototype.cst.SLIDER_BASIC)
  1112. {
  1113. c.setStrokeColor(fillColor2);
  1114. var barCenterPos = w * sliderPos / 100;
  1115. c.begin();
  1116. c.moveTo(0, h * 0.5);
  1117. c.lineTo(barCenterPos, h * 0.5);
  1118. c.stroke();
  1119. c.setStrokeColor(strokeColor);
  1120. }
  1121. else if (sliderStyle === mxShapeMockupHorSlider.prototype.cst.SLIDER_FANCY)
  1122. {
  1123. var barCenterPos = 10 + (w - 10) * sliderPos / 100;
  1124. c.setFillColor(fillColor2);
  1125. c.roundrect(0, h * 0.5 - rSize, barCenterPos, 2 * rSize, rSize, rSize);
  1126. c.fillAndStroke();
  1127. c.setFillColor(fillColor);
  1128. }
  1129. var handleCenterPos = 5 + (w - 10) * sliderPos / 100;
  1130. if (handleStyle === mxShapeMockupHorSlider.prototype.cst.HANDLE_CIRCLE)
  1131. {
  1132. c.ellipse(handleCenterPos - 10, h * 0.5 - 10, 20, 20);
  1133. c.fillAndStroke();
  1134. }
  1135. else if (handleStyle === mxShapeMockupHorSlider.prototype.cst.HANDLE_TRIANGLE)
  1136. {
  1137. c.begin();
  1138. c.moveTo(handleCenterPos - 10, h * 0.5 + 10);
  1139. c.lineTo(handleCenterPos, h * 0.5 - 10);
  1140. c.lineTo(handleCenterPos + 10, h * 0.5 + 10);
  1141. c.close();
  1142. c.fillAndStroke();
  1143. }
  1144. else if (handleStyle === mxShapeMockupHorSlider.prototype.cst.HANDLE_HANDLE)
  1145. {
  1146. c.begin();
  1147. c.moveTo(handleCenterPos - 7, h * 0.5 + 10);
  1148. c.lineTo(handleCenterPos - 7, h * 0.5);
  1149. c.lineTo(handleCenterPos, h * 0.5 - 10);
  1150. c.lineTo(handleCenterPos + 7, h * 0.5);
  1151. c.lineTo(handleCenterPos + 7, h * 0.5 + 10);
  1152. c.close();
  1153. c.fillAndStroke();
  1154. }
  1155. };
  1156. mxCellRenderer.registerShape(mxShapeMockupHorSlider.prototype.cst.SHAPE_HOR_SLIDER, mxShapeMockupHorSlider);
  1157. Graph.handleFactory[mxShapeMockupHorSlider.prototype.cst.SHAPE_HOR_SLIDER] = function(state)
  1158. {
  1159. var handles = [Graph.createHandle(state, ['sliderPos'], function(bounds)
  1160. {
  1161. var sliderPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'sliderPos', this.sliderPos))));
  1162. return new mxPoint(bounds.x + ((bounds.width - 10) * sliderPos / bounds.width) / 100 * bounds.width + 5, bounds.y + bounds.height / 2);
  1163. }, function(bounds, pt)
  1164. {
  1165. this.state.style['sliderPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  1166. })];
  1167. return handles;
  1168. }
  1169. //**********************************************************************************************************************************************************
  1170. //List Box (LEGACY)
  1171. //**********************************************************************************************************************************************************
  1172. /**
  1173. * Extends mxShape.
  1174. */
  1175. function mxShapeMockupListBox(bounds, fill, stroke, strokewidth)
  1176. {
  1177. mxShape.call(this);
  1178. this.bounds = bounds;
  1179. this.fill = fill;
  1180. this.stroke = stroke;
  1181. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1182. };
  1183. /**
  1184. * Extends mxShape.
  1185. */
  1186. mxUtils.extend(mxShapeMockupListBox, mxShape);
  1187. mxShapeMockupListBox.prototype.cst = {
  1188. MAIN_TEXT : 'mainText',
  1189. SUB_TEXT : 'subText',
  1190. BUTTON_TEXT : 'buttonText',
  1191. TEXT_SIZE : 'textSize',
  1192. TEXT_COLOR : 'textColor',
  1193. STROKE_COLOR2 : 'strokeColor2',
  1194. STROKE_COLOR3 : 'strokeColor3',
  1195. SELECTED_COLOR : 'selectedColor',
  1196. SELECTED : '+', //must be 1 char
  1197. SHAPE_LIST_BOX : 'mxgraph.mockup.forms.listBox'
  1198. };
  1199. /**
  1200. * Function: paintVertexShape
  1201. *
  1202. * Paints the vertex shape.
  1203. */
  1204. mxShapeMockupListBox.prototype.paintVertexShape = function(c, x, y, w, h)
  1205. {
  1206. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  1207. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  1208. var fontSize = mxUtils.getValue(this.style, mxShapeMockupListBox.prototype.cst.TEXT_SIZE, '17').toString();
  1209. var selectedButton = -1;
  1210. var maxShapeWidth = w;
  1211. var subText = mxUtils.getValue(this.style, mxShapeMockupListBox.prototype.cst.SUB_TEXT, 'Sub Text').toString().split(',');
  1212. for (var i = 0; i < subText.length; i++)
  1213. {
  1214. var itemText = subText[i];
  1215. if(itemText.charAt(0) === mxShapeMockupListBox.prototype.cst.SELECTED)
  1216. {
  1217. itemText = subText[i].substring(1);
  1218. selectedButton = i;
  1219. }
  1220. var currWidth = mxUtils.getSizeForString(itemText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  1221. if (currWidth > maxShapeWidth)
  1222. {
  1223. maxShapeWidth = currWidth;
  1224. }
  1225. }
  1226. c.translate(x, y);
  1227. w = Math.min(w, maxShapeWidth);
  1228. h = Math.max(h, 30 + subText.length * fontSize * 1.5);
  1229. this.background(c, w, h, bgColor, frameColor);
  1230. c.setShadow(false);
  1231. this.foreground(c, w, h, frameColor, selectedButton, subText, fontSize);
  1232. };
  1233. mxShapeMockupListBox.prototype.background = function(c, w, h, bgColor, frameColor)
  1234. {
  1235. c.setFillColor(bgColor);
  1236. c.setStrokeColor(frameColor);
  1237. c.rect(0, 0, w, h);
  1238. c.fillAndStroke();
  1239. };
  1240. mxShapeMockupListBox.prototype.foreground = function(c, w, h, frameColor, selectedButton, subText, fontSize)
  1241. {
  1242. var strokeWidth = mxUtils.getValue(this.style, mxConstants.STYLE_STROKEWIDTH, '1');
  1243. var selectedColor = mxUtils.getValue(this.style, mxShapeMockupListBox.prototype.cst.SELECTED_COLOR, '#ddeeff');
  1244. if(selectedButton !== -1)
  1245. {
  1246. c.setFillColor(selectedColor);
  1247. c.rect(0, 30 + selectedButton * fontSize * 1.5, w, fontSize * 1.5);
  1248. c.fill();
  1249. }
  1250. c.begin();
  1251. c.moveTo(0, 30);
  1252. c.lineTo(w, 30);
  1253. c.stroke();
  1254. //buttons
  1255. var windowTitle = mxUtils.getValue(this.style, mxShapeMockupListBox.prototype.cst.MAIN_TEXT, 'Window Title').toString();
  1256. var fontColor = mxUtils.getValue(this.style, mxShapeMockupListBox.prototype.cst.TEXT_COLOR, '#666666,#008cff').toString().split(',');
  1257. c.setFontColor(fontColor[1]);
  1258. c.setFontSize(fontSize);
  1259. c.text(10, 15, 0, 0, windowTitle, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1260. c.setFontColor(fontColor[0]);
  1261. for (var i = 0; i < subText.length; i++)
  1262. {
  1263. var currText = subText[i];
  1264. if(currText.charAt(0) === mxShapeMockupListBox.prototype.cst.SELECTED)
  1265. {
  1266. currText = subText[i].substring(1);
  1267. }
  1268. c.text(10, 30 + fontSize * (i * 1.5 + 0.75), 0, 0, currText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1269. }
  1270. c.rect(0, 0, w, h);
  1271. c.stroke();
  1272. };
  1273. mxCellRenderer.registerShape(mxShapeMockupListBox.prototype.cst.SHAPE_LIST_BOX, mxShapeMockupListBox);
  1274. //**********************************************************************************************************************************************************
  1275. //Password Field
  1276. //**********************************************************************************************************************************************************
  1277. /**
  1278. * Extends mxShape.
  1279. */
  1280. function mxShapeMockupPwField(bounds, fill, stroke, strokewidth)
  1281. {
  1282. mxShape.call(this);
  1283. this.bounds = bounds;
  1284. this.fill = fill;
  1285. this.stroke = stroke;
  1286. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1287. };
  1288. /**
  1289. * Extends mxShape.
  1290. */
  1291. mxUtils.extend(mxShapeMockupPwField, mxShape);
  1292. mxShapeMockupPwField.prototype.cst = {
  1293. MAIN_TEXT : 'mainText',
  1294. TEXT_COLOR : 'textColor',
  1295. TEXT_SIZE : 'textSize',
  1296. SHAPE_PW_FIELD : 'mxgraph.mockup.forms.pwField'
  1297. };
  1298. /**
  1299. * Function: paintVertexShape
  1300. *
  1301. * Paints the vertex shape.
  1302. */
  1303. mxShapeMockupPwField.prototype.paintVertexShape = function(c, x, y, w, h)
  1304. {
  1305. c.translate(x, y);
  1306. this.background(c, w, h);
  1307. c.setShadow(false);
  1308. this.foreground(c, w, h);
  1309. };
  1310. mxShapeMockupPwField.prototype.background = function(c, w, h)
  1311. {
  1312. c.rect(0, 0, w, h);
  1313. c.fillAndStroke();
  1314. };
  1315. mxShapeMockupPwField.prototype.foreground = function(c, w, h)
  1316. {
  1317. var mainText = mxUtils.getValue(this.style, mxShapeMockupPwField.prototype.cst.MAIN_TEXT, '******');
  1318. var fontColor = mxUtils.getValue(this.style, mxShapeMockupPwField.prototype.cst.TEXT_COLOR, '#666666');
  1319. var fontSize = mxUtils.getValue(this.style, mxShapeMockupPwField.prototype.cst.TEXT_SIZE, '17');
  1320. c.setFontColor(fontColor);
  1321. c.setFontSize(fontSize);
  1322. c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1323. };
  1324. mxCellRenderer.registerShape(mxShapeMockupPwField.prototype.cst.SHAPE_PW_FIELD, mxShapeMockupPwField);
  1325. //**********************************************************************************************************************************************************
  1326. //Splitter
  1327. //**********************************************************************************************************************************************************
  1328. /**
  1329. * Extends mxShape.
  1330. */
  1331. function mxShapeMockupSplitter(bounds, fill, stroke, strokewidth)
  1332. {
  1333. mxShape.call(this);
  1334. this.bounds = bounds;
  1335. this.fill = fill;
  1336. this.stroke = stroke;
  1337. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1338. };
  1339. /**
  1340. * Extends mxShape.
  1341. */
  1342. mxUtils.extend(mxShapeMockupSplitter, mxShape);
  1343. mxShapeMockupSplitter.prototype.cst = {
  1344. MAIN_TEXT : 'mainText',
  1345. TEXT_COLOR : 'textColor',
  1346. TEXT_SIZE : 'textSize',
  1347. SHAPE_SPLITTER : 'mxgraph.mockup.forms.splitter'
  1348. };
  1349. /**
  1350. * Function: paintVertexShape
  1351. *
  1352. * Paints the vertex shape.
  1353. */
  1354. mxShapeMockupSplitter.prototype.paintVertexShape = function(c, x, y, w, h)
  1355. {
  1356. w = Math.max(w, 35);
  1357. c.translate(x, y);
  1358. this.background(c, w, h);
  1359. c.setShadow(false);
  1360. this.foreground(c, w, h);
  1361. };
  1362. mxShapeMockupSplitter.prototype.background = function(c, w, h)
  1363. {
  1364. c.begin();
  1365. c.moveTo(0, h * 0.5 - 5);
  1366. c.lineTo(w, h * 0.5 - 5);
  1367. c.lineTo(w, h * 0.5 + 5);
  1368. c.lineTo(0, h * 0.5 + 5);
  1369. c.close();
  1370. c.fill();
  1371. };
  1372. mxShapeMockupSplitter.prototype.foreground = function(c, w, h)
  1373. {
  1374. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#999999');
  1375. c.begin();
  1376. c.moveTo(0, h * 0.5 - 5);
  1377. c.lineTo(w, h * 0.5 - 5);
  1378. c.moveTo(w, h * 0.5 + 5);
  1379. c.lineTo(0, h * 0.5 + 5);
  1380. c.stroke();
  1381. c.setFillColor(strokeColor);
  1382. c.ellipse(w * 0.5 - 17, h * 0.5 - 2, 4, 4);
  1383. c.fill();
  1384. c.ellipse(w * 0.5 - 2, h * 0.5 - 2, 4, 4);
  1385. c.fill();
  1386. c.ellipse(w * 0.5 + 13, h * 0.5 - 2, 4, 4);
  1387. c.fill();
  1388. };
  1389. mxCellRenderer.registerShape(mxShapeMockupSplitter.prototype.cst.SHAPE_SPLITTER, mxShapeMockupSplitter);
  1390. //**********************************************************************************************************************************************************
  1391. //Wedge Bar (LEGACY)
  1392. //**********************************************************************************************************************************************************
  1393. /**
  1394. * Extends mxShape.
  1395. */
  1396. function mxShapeMockupWedgeBar(bounds, fill, stroke, strokewidth)
  1397. {
  1398. mxShape.call(this);
  1399. this.bounds = bounds;
  1400. this.fill = fill;
  1401. this.stroke = stroke;
  1402. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1403. };
  1404. /**
  1405. * Extends mxShape.
  1406. */
  1407. mxUtils.extend(mxShapeMockupWedgeBar, mxShape);
  1408. mxShapeMockupWedgeBar.prototype.cst = {
  1409. BLOCK : 'block',
  1410. CONE : 'cone',
  1411. HALF_CONE : 'halfCone',
  1412. ROUND : 'round',
  1413. TEXT_SIZE : 'textSize',
  1414. TAB_NAMES : 'tabs',
  1415. TAB_STYLE : 'tabStyle',
  1416. STYLE_FILLCOLOR2 : 'fillColor2',
  1417. TEXT_COLOR : 'textColor',
  1418. SEL_TEXT_COLOR : 'textColor2',
  1419. SHAPE_WEDGE_BAR : 'mxgraph.mockup.forms.wedgeBar'
  1420. };
  1421. /**
  1422. * Function: paintVertexShape
  1423. *
  1424. * Paints the vertex shape.
  1425. */
  1426. mxShapeMockupWedgeBar.prototype.paintVertexShape = function(c, x, y, w, h)
  1427. {
  1428. var fontSize = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TEXT_SIZE, '17').toString();
  1429. var tabNames = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TAB_NAMES, 'Tab 1,+Tab 2,Tab 3').toString().split(',');
  1430. var tabH = fontSize * 1.5;
  1431. var startOffset = 10;
  1432. var tabOffset = 5;
  1433. var labelOffset = 10;
  1434. var tabCount = tabNames.length;
  1435. var minW = 2 * startOffset + (tabCount - 1) * tabOffset + tabCount * 2 * labelOffset;
  1436. var rSize = 5;
  1437. var labelWidths = new Array();
  1438. var selectedTab = -1;
  1439. for (var i = 0; i < tabCount; i++)
  1440. {
  1441. var currLabel = tabNames[i];
  1442. if(currLabel.charAt(0) === '+')
  1443. {
  1444. currLabel = currLabel.substring(1);
  1445. selectedTab = i;
  1446. }
  1447. var currW = mxUtils.getSizeForString(currLabel, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  1448. if (currW === 0)
  1449. {
  1450. labelWidths[i] = 42;
  1451. }
  1452. else
  1453. {
  1454. labelWidths[i] = currW;
  1455. }
  1456. minW = minW + labelWidths[i];
  1457. }
  1458. w = Math.max(w, minW);
  1459. h = Math.max(h, tabH + rSize);
  1460. c.translate(x, y);
  1461. c.setShadow(false);
  1462. this.backTabs(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1463. this.focusTab(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab);
  1464. this.tabText(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames);
  1465. };
  1466. mxShapeMockupWedgeBar.prototype.backTabs = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1467. {
  1468. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TAB_STYLE, mxShapeMockupWedgeBar.prototype.cst.BLOCK);
  1469. var currW = startOffset;
  1470. for (var i=0; i < tabCount; i++)
  1471. {
  1472. var tabW = labelWidths[i] + 2 * labelOffset;
  1473. if (selectedTab !== i)
  1474. {
  1475. if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.BLOCK)
  1476. {
  1477. c.begin();
  1478. c.moveTo(currW, tabH);
  1479. c.lineTo(currW, 0);
  1480. c.lineTo(currW + tabW, 0);
  1481. c.lineTo(currW + tabW, tabH);
  1482. }
  1483. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.CONE)
  1484. {
  1485. c.begin();
  1486. c.moveTo(currW, tabH);
  1487. c.lineTo(currW + labelOffset * 0.5, 0);
  1488. c.lineTo(currW + tabW - labelOffset * 0.5, 0);
  1489. c.lineTo(currW + tabW, tabH);
  1490. }
  1491. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.HALF_CONE)
  1492. {
  1493. c.begin();
  1494. c.moveTo(currW, tabH);
  1495. c.lineTo(currW + labelOffset * 0.5, 0);
  1496. c.lineTo(currW + tabW, 0);
  1497. c.lineTo(currW + tabW, tabH);
  1498. }
  1499. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.ROUND)
  1500. {
  1501. c.begin();
  1502. c.moveTo(currW - rSize, tabH);
  1503. c.arcTo(rSize, rSize, 0, 0, 0, currW, tabH - rSize);
  1504. c.lineTo(currW, rSize);
  1505. c.arcTo(rSize, rSize, 0, 0, 1, currW + rSize, 0);
  1506. c.lineTo(currW + tabW - rSize, 0);
  1507. c.arcTo(rSize, rSize, 0, 0, 1, currW + tabW, rSize);
  1508. c.lineTo(currW + tabW, tabH - rSize);
  1509. c.arcTo(rSize, rSize, 0, 0, 0, currW + tabW + rSize, tabH);
  1510. }
  1511. c.fillAndStroke();
  1512. }
  1513. currW = currW + tabW + tabOffset;
  1514. }
  1515. };
  1516. mxShapeMockupWedgeBar.prototype.focusTab = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab)
  1517. {
  1518. var tabStyle = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TAB_STYLE, mxShapeMockupWedgeBar.prototype.cst.BLOCK);
  1519. var selectedFill = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.STYLE_FILLCOLOR2, '#008cff');
  1520. var currW = startOffset;
  1521. c.setStrokeColor(selectedFill);
  1522. c.setFillColor(selectedFill);
  1523. for (var i=0; i <= selectedTab; i++)
  1524. {
  1525. var tabW = labelWidths[i] + 2 * labelOffset;
  1526. if (selectedTab === i)
  1527. {
  1528. if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.BLOCK)
  1529. {
  1530. c.begin();
  1531. c.moveTo(currW, tabH);
  1532. c.lineTo(currW, 0);
  1533. c.lineTo(currW + tabW, 0);
  1534. c.lineTo(currW + tabW, tabH);
  1535. }
  1536. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.CONE)
  1537. {
  1538. c.begin();
  1539. c.moveTo(currW, tabH);
  1540. c.lineTo(currW + labelOffset * 0.5, 0);
  1541. c.lineTo(currW + tabW - labelOffset * 0.5, 0);
  1542. c.lineTo(currW + tabW, tabH);
  1543. }
  1544. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.HALF_CONE)
  1545. {
  1546. c.begin();
  1547. c.moveTo(currW, tabH);
  1548. c.lineTo(currW + labelOffset * 0.5, 0);
  1549. c.lineTo(currW + tabW, 0);
  1550. c.lineTo(currW + tabW, tabH);
  1551. }
  1552. else if (tabStyle === mxShapeMockupWedgeBar.prototype.cst.ROUND)
  1553. {
  1554. c.begin();
  1555. c.moveTo(currW - rSize, tabH);
  1556. c.arcTo(rSize, rSize, 0, 0, 0, currW, tabH - rSize);
  1557. c.lineTo(currW, rSize);
  1558. c.arcTo(rSize, rSize, 0, 0, 1, currW + rSize, 0);
  1559. c.lineTo(currW + tabW - rSize, 0);
  1560. c.arcTo(rSize, rSize, 0, 0, 1, currW + tabW, rSize);
  1561. c.lineTo(currW + tabW, tabH - rSize);
  1562. c.arcTo(rSize, rSize, 0, 0, 0, currW + tabW + rSize, tabH);
  1563. }
  1564. c.fillAndStroke();
  1565. }
  1566. currW = currW + tabW + tabOffset;
  1567. }
  1568. };
  1569. mxShapeMockupWedgeBar.prototype.tabText = function(c, w, h, rSize, tabH, startOffset, tabOffset, labelOffset, tabCount, labelWidths, selectedTab, tabNames)
  1570. {
  1571. var fontColor = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TEXT_COLOR, '#666666');
  1572. var selFontColor = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.SEL_TEXT_COLOR, '#ffffff');
  1573. var fontSize = mxUtils.getValue(this.style, mxShapeMockupWedgeBar.prototype.cst.TEXT_SIZE, '17').toString();
  1574. c.setFontColor(fontColor);
  1575. c.setFontSize(fontSize);
  1576. var currW = startOffset;
  1577. for (var i=0; i < tabCount; i++)
  1578. {
  1579. var currLabel = tabNames[i];
  1580. if (i === selectedTab)
  1581. {
  1582. c.setFontColor(selFontColor);
  1583. }
  1584. if (currLabel.charAt(0) === '+')
  1585. {
  1586. currLabel = currLabel.substring(1);
  1587. }
  1588. var tabW = labelWidths[i] + 2 * labelOffset;
  1589. c.text(currW + labelOffset, tabH * 0.5, 0, 0, currLabel, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1590. currW = currW + tabW + tabOffset;
  1591. if (i === selectedTab)
  1592. {
  1593. c.setFontColor(fontColor);
  1594. }
  1595. }
  1596. };
  1597. mxCellRenderer.registerShape(mxShapeMockupWedgeBar.prototype.cst.SHAPE_WEDGE_BAR, mxShapeMockupWedgeBar);
  1598. //**********************************************************************************************************************************************************
  1599. //Search Box
  1600. //**********************************************************************************************************************************************************
  1601. /**
  1602. * Extends mxShape.
  1603. */
  1604. function mxShapeMockupSearchBox(bounds, fill, stroke, strokewidth)
  1605. {
  1606. mxShape.call(this);
  1607. this.bounds = bounds;
  1608. this.fill = fill;
  1609. this.stroke = stroke;
  1610. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1611. };
  1612. /**
  1613. * Extends mxShape.
  1614. */
  1615. mxUtils.extend(mxShapeMockupSearchBox, mxShape);
  1616. mxShapeMockupSearchBox.prototype.cst = {
  1617. MAIN_TEXT : 'mainText',
  1618. TEXT_COLOR : 'textColor',
  1619. TEXT_SIZE : 'textSize',
  1620. STROKE_COLOR2 : 'strokeColor2',
  1621. SHAPE_SEARCH_BOX : 'mxgraph.mockup.forms.searchBox'
  1622. };
  1623. mxShapeMockupSearchBox.prototype.customProperties = [
  1624. {name: 'strokeColor2', dispName: 'Icon Color', type: 'color'},
  1625. ];
  1626. /**
  1627. * Function: paintVertexShape
  1628. *
  1629. * Paints the vertex shape.
  1630. */
  1631. mxShapeMockupSearchBox.prototype.paintVertexShape = function(c, x, y, w, h)
  1632. {
  1633. c.translate(x, y);
  1634. this.background(c, w, h);
  1635. c.setShadow(false);
  1636. this.foreground(c, w, h);
  1637. };
  1638. mxShapeMockupSearchBox.prototype.background = function(c, w, h)
  1639. {
  1640. c.rect(0, 0, w, h);
  1641. c.fillAndStroke();
  1642. };
  1643. mxShapeMockupSearchBox.prototype.foreground = function(c, w, h)
  1644. {
  1645. var mainText = mxUtils.getValue(this.style, mxShapeMockupSearchBox.prototype.cst.MAIN_TEXT, 'Search');
  1646. var fontColor = mxUtils.getValue(this.style, mxShapeMockupSearchBox.prototype.cst.TEXT_COLOR, '#666666');
  1647. var strokeColor2 = mxUtils.getValue(this.style, mxShapeMockupSearchBox.prototype.cst.STROKE_COLOR2, '#008cff');
  1648. var fontSize = mxUtils.getValue(this.style, mxShapeMockupSearchBox.prototype.cst.TEXT_SIZE, '17');
  1649. c.setFontColor(fontColor);
  1650. c.setFontSize(fontSize);
  1651. c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1652. c.setStrokeColor(strokeColor2);
  1653. c.ellipse(w - 15, h * 0.5 - 8, 10, 10);
  1654. c.stroke();
  1655. c.begin();
  1656. c.moveTo(w - 19, h * 0.5 + 9);
  1657. c.lineTo(w - 13, h * 0.5 + 1);
  1658. c.stroke();
  1659. };
  1660. mxCellRenderer.registerShape(mxShapeMockupSearchBox.prototype.cst.SHAPE_SEARCH_BOX, mxShapeMockupSearchBox);
  1661. //**********************************************************************************************************************************************************
  1662. //Sign In (LEGACY)
  1663. //**********************************************************************************************************************************************************
  1664. /**
  1665. * Extends mxShape.
  1666. */
  1667. function mxShapeMockupSignIn(bounds, fill, stroke, strokewidth)
  1668. {
  1669. mxShape.call(this);
  1670. this.bounds = bounds;
  1671. this.fill = fill;
  1672. this.stroke = stroke;
  1673. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1674. };
  1675. /**
  1676. * Extends mxShape.
  1677. */
  1678. mxUtils.extend(mxShapeMockupSignIn, mxShape);
  1679. mxShapeMockupSignIn.prototype.cst = {
  1680. MAIN_TEXT : 'mainText',
  1681. TEXT_COLOR : 'textColor',
  1682. TEXT_COLOR2 : 'textColor2',
  1683. TEXT_SIZE : 'textSize',
  1684. TEXT_SIZE2 : 'textSize2',
  1685. STROKE_COLOR2 : 'strokeColor2',
  1686. FILL_COLOR2 : 'fillColor2',
  1687. SHAPE_SIGN_IN : 'mxgraph.mockup.forms.signIn'
  1688. };
  1689. /**
  1690. * Function: paintVertexShape
  1691. *
  1692. * Paints the vertex shape.
  1693. */
  1694. mxShapeMockupSignIn.prototype.paintVertexShape = function(c, x, y, w, h)
  1695. {
  1696. c.translate(x, y);
  1697. this.background(c, w, h);
  1698. c.setShadow(false);
  1699. this.foreground(c, w, h);
  1700. };
  1701. mxShapeMockupSignIn.prototype.background = function(c, w, h)
  1702. {
  1703. c.rect(0, 0, w, h);
  1704. c.fillAndStroke();
  1705. };
  1706. mxShapeMockupSignIn.prototype.foreground = function(c, w, h)
  1707. {
  1708. var mainText = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.MAIN_TEXT, 'Sign In,User Name:,johndoe,Password:,********,Forgot Password?,New User,SIGN IN,SIGN UP').toString().split(',');
  1709. var fontColor = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.TEXT_COLOR, '#666666');
  1710. var fontColor2 = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.TEXT_COLOR2, '#ffffff');
  1711. var fontSize = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.TEXT_SIZE, '12');
  1712. var fontSize2 = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.TEXT_SIZE2, '15');
  1713. var strokeColor2 = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.STROKE_COLOR2, '#ddeeff');
  1714. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupSignIn.prototype.cst.FILL_COLOR2, '#66bbff');
  1715. c.setFillColor(fillColor2);
  1716. c.roundrect(w * 0.09, h * 0.52, w * 0.36, h * 0.09, 5, 5);
  1717. c.fill();
  1718. c.roundrect(w * 0.09, h * 0.84, w * 0.36, h * 0.09, 5, 5);
  1719. c.fill();
  1720. c.rect(w * 0.05, h * 0.22, w * 0.75, h * 0.08);
  1721. c.stroke();
  1722. c.rect(w * 0.05, h * 0.4, w * 0.75, h * 0.08);
  1723. c.stroke();
  1724. c.setStrokeColor(strokeColor2);
  1725. c.setStrokeWidth(2);
  1726. c.begin();
  1727. c.moveTo(w * 0.05, h * 0.12);
  1728. c.lineTo(w * 0.95, h * 0.12);
  1729. c.moveTo(w * 0.05, h * 0.72);
  1730. c.lineTo(w * 0.95, h * 0.72);
  1731. c.stroke();
  1732. c.setFontColor(fontColor);
  1733. c.setFontSize(fontSize);
  1734. c.text(w * 0.05, h * 0.1, 0, 0, mainText[0], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_BOTTOM, 0, null, 0, 0, 0);
  1735. c.text(w * 0.05, h * 0.2, 0, 0, mainText[1], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_BOTTOM, 0, null, 0, 0, 0);
  1736. c.text(w * 0.075, h * 0.26, 0, 0, mainText[2], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1737. c.text(w * 0.05, h * 0.38, 0, 0, mainText[3], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_BOTTOM, 0, null, 0, 0, 0);
  1738. c.text(w * 0.075, h * 0.44, 0, 0, mainText[4], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1739. c.text(w * 0.05, h * 0.8, 0, 0, mainText[6], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1740. c.setStrokeWidth(1);
  1741. c.setFontColor('#9999ff');
  1742. c.setStrokeColor('#9999ff');
  1743. var forgotW = mxUtils.getSizeForString(mainText[5], fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  1744. c.text(w * 0.05, h * 0.7, 0, 0, mainText[5], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_BOTTOM, 0, null, 0, 0, 0);
  1745. c.begin();
  1746. c.moveTo(w * 0.05, h * 0.7);
  1747. c.lineTo(w * 0.05 + forgotW, h * 0.7);
  1748. c.stroke();
  1749. c.setFontColor(fontColor2);
  1750. c.setFontStyle(mxConstants.FONT_BOLD);
  1751. c.setFontSize(fontSize2);
  1752. c.text(w * 0.27, h * 0.565, 0, 0, mainText[7], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1753. c.text(w * 0.27, h * 0.885, 0, 0, mainText[8], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1754. };
  1755. mxCellRenderer.registerShape(mxShapeMockupSignIn.prototype.cst.SHAPE_SIGN_IN, mxShapeMockupSignIn);
  1756. //**********************************************************************************************************************************************************
  1757. //Calendar (LEGACY)
  1758. //**********************************************************************************************************************************************************
  1759. /**
  1760. * Extends mxShape.
  1761. */
  1762. function mxShapeMockupCalendar(bounds, fill, stroke, strokewidth)
  1763. {
  1764. mxShape.call(this);
  1765. this.bounds = bounds;
  1766. this.fill = fill;
  1767. this.stroke = stroke;
  1768. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1769. };
  1770. /**
  1771. * Extends mxShape.
  1772. */
  1773. mxUtils.extend(mxShapeMockupCalendar, mxShape);
  1774. mxShapeMockupCalendar.prototype.cst = {
  1775. SHAPE_CALENDAR : 'mxgraph.mockup.forms.calendar',
  1776. DAYS : 'days',
  1777. SELECTED_DAY : 'selDay',
  1778. PREV_DAYS : 'prevDays',
  1779. FIRST_DAY : 'firstDay',
  1780. START_ON : 'startOn',
  1781. DAY_NAMES : 'dayNames',
  1782. MAIN_TEXT : 'mainText',
  1783. TEXT_SIZE : 'textSize',
  1784. TEXT_COLOR : 'textColor',
  1785. TEXT_COLOR2 : 'textColor2',
  1786. STROKE_COLOR2 : 'strokeColor2',
  1787. FILL_COLOR2 : 'fillColor2'
  1788. };
  1789. /**
  1790. * Function: paintVertexShape
  1791. *
  1792. * Paints the vertex shape.
  1793. */
  1794. mxShapeMockupCalendar.prototype.paintVertexShape = function(c, x, y, w, h)
  1795. {
  1796. c.translate(x, y);
  1797. this.background(c, w, h);
  1798. c.setShadow(false);
  1799. this.foreground(c, w, h);
  1800. };
  1801. mxShapeMockupCalendar.prototype.background = function(c, w, h)
  1802. {
  1803. c.roundrect(0, 0, w, h, w * 0.0312, h * 0.0286);
  1804. c.fillAndStroke();
  1805. };
  1806. mxShapeMockupCalendar.prototype.foreground = function(c, w, h)
  1807. {
  1808. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#999999');
  1809. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  1810. var strokeColor2 = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.STROKE_COLOR2, '#008cff');
  1811. var fillColor2 = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.FILL_COLOR2, '#ddeeff');
  1812. var mainText = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.MAIN_TEXT, '');
  1813. var textSize = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.TEXT_SIZE, '15');
  1814. var textColor = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.TEXT_COLOR, '#999999');
  1815. var textColor2 = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.TEXT_COLOR2, '#ffffff');
  1816. var days = parseInt(mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.DAYS, '30'), 10);
  1817. var prevDays = parseInt(mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.PREV_DAYS, '31'), 10);
  1818. //month starts on Monday
  1819. var firstDay = parseInt(mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.FIRST_DAY, '0'), 10);
  1820. //week starts with Monday
  1821. var startOn = parseInt(mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.START_ON, '6', 10));
  1822. var dayNames = mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.DAY_NAMES, 'Mo,Tu,We,Th,Fr,Sa,Su').toString().split(',');
  1823. var selDay = parseInt(mxUtils.getValue(this.style, mxShapeMockupCalendar.prototype.cst.SELECTED_DAY, '24'), 10);
  1824. fistDay = Math.max(firstDay, 0);
  1825. startOn = Math.max(startOn, 0);
  1826. fistDay = Math.min(firstDay, 6);
  1827. startOn = Math.min(startOn, 6);
  1828. //buttons
  1829. c.roundrect(w * 0.05, h * 0.0457, w * 0.1438, h * 0.1029, w * 0.025, h * 0.0229);
  1830. c.stroke();
  1831. c.roundrect(w * 0.8125, h * 0.0457, w * 0.1438, h * 0.1029, w * 0.025, h * 0.0229);
  1832. c.stroke();
  1833. //button markers
  1834. c.setStrokeWidth(2);
  1835. c.setStrokeColor(strokeColor2);
  1836. c.begin();
  1837. c.moveTo(w * 0.1438, h * 0.0743);
  1838. c.lineTo(w * 0.1, h * 0.0971);
  1839. c.lineTo(w * 0.1438, h * 0.12);
  1840. c.moveTo(w * 0.8625, h * 0.0743);
  1841. c.lineTo(w * 0.9062, h * 0.0971);
  1842. c.lineTo(w * 0.8625, h * 0.12);
  1843. c.stroke();
  1844. c.setFontSize(textSize);
  1845. c.setFontColor(textColor);
  1846. c.text(w * 0.5, h * 0.0971, 0, 0, mainText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1847. //write day names
  1848. var range = w * 0.875;
  1849. var cellSize = range / 7;
  1850. for (var i = 0; i < 7; i++)
  1851. {
  1852. var currX = w * 0.0625 + cellSize * 0.5 + i * cellSize;
  1853. var j = i + startOn;
  1854. if (j > 6)
  1855. {
  1856. j = j - 7;
  1857. }
  1858. c.text(currX, h * 0.2114, 0, 0, dayNames[j], mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1859. }
  1860. c.setStrokeWidth(1);
  1861. //1st day is on first weekday as default
  1862. var x = 0;
  1863. var selX = -1;
  1864. var selY = -1;
  1865. //check if we need to write days from previous month
  1866. if (firstDay !== startOn)
  1867. {
  1868. c.setStrokeColor(strokeColor);
  1869. c.setFillColor(fillColor2);
  1870. var diff = firstDay - startOn;
  1871. if (diff < 0)
  1872. {
  1873. diff = diff + 7;
  1874. }
  1875. for (var i = 0; i < diff; i++)
  1876. {
  1877. var currX = w * 0.0625 + i * cellSize;
  1878. c.rect(currX, h * 0.2686, cellSize, h * 0.1143);
  1879. c.fillAndStroke();
  1880. var tmp = prevDays - diff + i + 1;
  1881. c.text(currX + cellSize * 0.5, h * 0.2686 + cellSize * 0.5, 0, 0, tmp.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1882. }
  1883. x = diff;
  1884. }
  1885. //now we need to write the actual month days...
  1886. c.setFillColor(fillColor);
  1887. c.setStrokeColor(strokeColor);
  1888. //week begins in first row
  1889. var y = 0;
  1890. for (var i = 0; i < days; i++)
  1891. {
  1892. var d = i + 1;
  1893. var currX = w * 0.0625 + x * cellSize;
  1894. var currY = h * 0.2686 + y * h * 0.1143;
  1895. if (d === selDay)
  1896. {
  1897. selX = currX;
  1898. selY = currY;
  1899. }
  1900. else
  1901. {
  1902. c.rect(currX, currY, cellSize, h * 0.1143);
  1903. c.fillAndStroke();
  1904. c.text(currX + cellSize * 0.5, currY + cellSize * 0.5, 0, 0, d.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1905. }
  1906. if (x < 6)
  1907. {
  1908. x++;
  1909. }
  1910. else
  1911. {
  1912. x = 0;
  1913. y++;
  1914. }
  1915. }
  1916. var i = 1;
  1917. c.setFillColor(fillColor2);
  1918. while (y < 6)
  1919. {
  1920. var currX = w * 0.0625 + x * cellSize;
  1921. var currY = h * 0.2686 + y * h * 0.1143;
  1922. c.rect(currX, currY, cellSize, h * 0.1143);
  1923. c.fillAndStroke();
  1924. c.text(currX + cellSize * 0.5, currY + cellSize * 0.5, 0, 0, i.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1925. if (x < 6)
  1926. {
  1927. x++;
  1928. }
  1929. else
  1930. {
  1931. x = 0;
  1932. y++;
  1933. }
  1934. i++;
  1935. }
  1936. if (selX >= 0)
  1937. {
  1938. c.setStrokeColor('#ff0000');
  1939. c.setStrokeWidth(2);
  1940. c.setFillColor(strokeColor2);
  1941. c.setFontColor(textColor2);
  1942. c.rect(selX, selY, cellSize, h * 0.1143);
  1943. c.fillAndStroke();
  1944. c.text(selX + cellSize * 0.5, selY + cellSize * 0.5, 0, 0, selDay.toString(), mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  1945. }
  1946. };
  1947. mxCellRenderer.registerShape(mxShapeMockupCalendar.prototype.cst.SHAPE_CALENDAR, mxShapeMockupCalendar);
  1948. //**********************************************************************************************************************************************************
  1949. //Email Form
  1950. //**********************************************************************************************************************************************************
  1951. /**
  1952. * Extends mxShape.
  1953. */
  1954. function mxShapeMockupEmailForm(bounds, fill, stroke, strokewidth)
  1955. {
  1956. mxShape.call(this);
  1957. this.bounds = bounds;
  1958. this.fill = fill;
  1959. this.stroke = stroke;
  1960. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1961. };
  1962. /**
  1963. * Extends mxShape.
  1964. */
  1965. mxUtils.extend(mxShapeMockupEmailForm, mxShape);
  1966. mxShapeMockupEmailForm.prototype.cst = {
  1967. MAIN_TEXT : 'mainText',
  1968. TEXT_COLOR : 'textColor',
  1969. SHOW_CC : 'showCC',
  1970. SHOW_BCC : 'showBCC',
  1971. TEXT_SIZE : 'textSize',
  1972. SHAPE_EMAIL_FORM : 'mxgraph.mockup.forms.emailForm'
  1973. };
  1974. /**
  1975. * Function: paintVertexShape
  1976. *
  1977. * Paints the vertex shape.
  1978. */
  1979. mxShapeMockupEmailForm.prototype.paintVertexShape = function(c, x, y, w, h)
  1980. {
  1981. var fontSize = mxUtils.getValue(this.style, mxShapeMockupEmailForm.prototype.cst.TEXT_SIZE, '12');
  1982. var showCC = mxUtils.getValue(this.style, mxShapeMockupEmailForm.prototype.cst.SHOW_CC, 'true');
  1983. var showBCC = mxUtils.getValue(this.style, mxShapeMockupEmailForm.prototype.cst.SHOW_BCC, 'true');
  1984. var tabX = fontSize * 4;
  1985. var optCount = 0;
  1986. if (showCC === 'true')
  1987. {
  1988. optCount++;
  1989. }
  1990. if (showBCC === 'true')
  1991. {
  1992. optCount++;
  1993. }
  1994. w = Math.max(w, fontSize * 5);
  1995. h = Math.max(h, fontSize * 10.5 + optCount * fontSize * 3);
  1996. c.translate(x, y);
  1997. this.background(c, w, h, fontSize, tabX, showCC, showBCC);
  1998. c.setShadow(false);
  1999. this.foreground(c, w, h, fontSize, tabX, showCC, showBCC);
  2000. };
  2001. mxShapeMockupEmailForm.prototype.background = function(c, w, h, fontSize, tabX, showCC, showBCC)
  2002. {
  2003. var messX = fontSize * 9;
  2004. if (showCC === 'true')
  2005. {
  2006. messX = messX + fontSize * 3;
  2007. c.rect(tabX, fontSize * 9, w - tabX, fontSize * 1.5);
  2008. c.fillAndStroke();
  2009. }
  2010. if (showBCC === 'true')
  2011. {
  2012. c.rect(tabX, messX, w - tabX, fontSize * 1.5);
  2013. messX = messX + fontSize * 3;
  2014. c.fillAndStroke();
  2015. }
  2016. c.rect(tabX, 0, w - tabX, fontSize * 1.5);
  2017. c.fillAndStroke();
  2018. c.rect(tabX, fontSize * 3, w - tabX, fontSize * 1.5);
  2019. c.fillAndStroke();
  2020. c.rect(tabX, fontSize * 6, w - tabX, fontSize * 1.5);
  2021. c.fillAndStroke();
  2022. c.rect(0, messX, w, h - messX);
  2023. c.fillAndStroke();
  2024. };
  2025. mxShapeMockupEmailForm.prototype.foreground = function(c, w, h, fontSize, tabX, showCC, showBCC)
  2026. {
  2027. var mainText = mxUtils.getValue(this.style, mxShapeMockupEmailForm.prototype.cst.MAIN_TEXT, 'john@jgraph.com,Greeting,fred@jgraph.com,,,Lorem ipsum').toString().split(',');
  2028. var fontColor = mxUtils.getValue(this.style, mxShapeMockupEmailForm.prototype.cst.TEXT_COLOR, '#666666');
  2029. c.setFontColor(fontColor);
  2030. c.setFontSize(fontSize);
  2031. c.text(tabX - fontSize * 0.5, fontSize * 0.75, 0, 0, 'From', mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2032. c.text(tabX - fontSize * 0.5, fontSize * 3.75, 0, 0, 'Subject', mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2033. c.text(tabX - fontSize * 0.5, fontSize * 6.75, 0, 0, 'To', mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2034. c.text(tabX + fontSize * 0.5, fontSize * 0.75, 0, 0, mainText[0], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2035. c.text(tabX + fontSize * 0.5, fontSize * 3.75, 0, 0, mainText[1], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2036. c.text(tabX + fontSize * 0.5, fontSize * 6.75, 0, 0, mainText[2], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2037. var messX = fontSize * 9;
  2038. if (showCC === 'true')
  2039. {
  2040. messX = messX + fontSize * 3;
  2041. c.text(tabX - fontSize * 0.5, fontSize * 9.75, 0, 0, 'CC', mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2042. c.text(tabX + fontSize * 0.5, fontSize * 9.75, 0, 0, mainText[3], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2043. }
  2044. if (showBCC === 'true')
  2045. {
  2046. c.text(tabX - fontSize * 0.5, messX + fontSize * 0.75, 0, 0, 'BCC', mxConstants.ALIGN_RIGHT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2047. c.text(tabX + fontSize * 0.5, messX + fontSize * 0.75, 0, 0, mainText[4], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2048. messX = messX + fontSize * 3;
  2049. }
  2050. c.text(fontSize * 0.5, messX + fontSize * 0.75, 0, 0, mainText[5], mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  2051. };
  2052. mxCellRenderer.registerShape(mxShapeMockupEmailForm.prototype.cst.SHAPE_EMAIL_FORM, mxShapeMockupEmailForm);
  2053. //**********************************************************************************************************************************************************
  2054. //Rounded rectangle (adjustable rounding)
  2055. //**********************************************************************************************************************************************************
  2056. /**
  2057. * Extends mxShape.
  2058. */
  2059. function mxShapeMockupFormsRRect(bounds, fill, stroke, strokewidth)
  2060. {
  2061. mxShape.call(this);
  2062. this.bounds = bounds;
  2063. this.fill = fill;
  2064. this.stroke = stroke;
  2065. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2066. };
  2067. /**
  2068. * Extends mxShape.
  2069. */
  2070. mxUtils.extend(mxShapeMockupFormsRRect, mxShape);
  2071. mxShapeMockupFormsRRect.prototype.cst = {
  2072. RRECT : 'mxgraph.mockup.forms.rrect',
  2073. R_SIZE : 'rSize'
  2074. };
  2075. mxShapeMockupFormsRRect.prototype.customProperties = [
  2076. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:10},
  2077. ];
  2078. /**
  2079. * Function: paintVertexShape
  2080. *
  2081. * Paints the vertex shape.
  2082. */
  2083. mxShapeMockupFormsRRect.prototype.paintVertexShape = function(c, x, y, w, h)
  2084. {
  2085. c.translate(x, y);
  2086. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeMockupFormsRRect.prototype.cst.R_SIZE, '10'));
  2087. c.roundrect(0, 0, w, h, rSize);
  2088. c.fillAndStroke();
  2089. };
  2090. mxCellRenderer.registerShape(mxShapeMockupFormsRRect.prototype.cst.RRECT, mxShapeMockupFormsRRect);
  2091. //**********************************************************************************************************************************************************
  2092. //Anchor (a dummy shape without visuals used for anchoring)
  2093. //**********************************************************************************************************************************************************
  2094. /**
  2095. * Extends mxShape.
  2096. */
  2097. function mxShapeMockupFormsAnchor(bounds, fill, stroke, strokewidth)
  2098. {
  2099. mxShape.call(this);
  2100. this.bounds = bounds;
  2101. };
  2102. /**
  2103. * Extends mxShape.
  2104. */
  2105. mxUtils.extend(mxShapeMockupFormsAnchor, mxShape);
  2106. mxShapeMockupFormsAnchor.prototype.cst = {
  2107. ANCHOR : 'mxgraph.mockup.forms.anchor'
  2108. };
  2109. /**
  2110. * Function: paintVertexShape
  2111. *
  2112. * Paints the vertex shape.
  2113. */
  2114. mxShapeMockupFormsAnchor.prototype.paintVertexShape = function(c, x, y, w, h)
  2115. {
  2116. };
  2117. mxCellRenderer.registerShape(mxShapeMockupFormsAnchor.prototype.cst.ANCHOR, mxShapeMockupFormsAnchor);
  2118. //**********************************************************************************************************************************************************
  2119. //Checkbox
  2120. //**********************************************************************************************************************************************************
  2121. /**
  2122. * Extends mxShape.
  2123. */
  2124. function mxShapeMockupFormsCheckbox(bounds, fill, stroke, strokewidth)
  2125. {
  2126. mxShape.call(this);
  2127. this.bounds = bounds;
  2128. this.fill = fill;
  2129. this.stroke = stroke;
  2130. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2131. };
  2132. /**
  2133. * Extends mxShape.
  2134. */
  2135. mxUtils.extend(mxShapeMockupFormsCheckbox, mxShape);
  2136. mxShapeMockupFormsCheckbox.prototype.cst = {
  2137. CHECKBOX : 'mxgraph.mockup.forms.checkbox'
  2138. };
  2139. /**
  2140. * Function: paintVertexShape
  2141. *
  2142. * Paints the vertex shape.
  2143. */
  2144. mxShapeMockupFormsCheckbox.prototype.paintVertexShape = function(c, x, y, w, h)
  2145. {
  2146. c.translate(x, y);
  2147. c.rect(0, 0, w, h);
  2148. c.fillAndStroke();
  2149. c.begin();
  2150. c.moveTo(w * 0.8, h * 0.2);
  2151. c.lineTo(w * 0.4, h * 0.8);
  2152. c.lineTo(w * 0.25, h * 0.6);
  2153. c.stroke();
  2154. };
  2155. mxCellRenderer.registerShape(mxShapeMockupFormsCheckbox.prototype.cst.CHECKBOX, mxShapeMockupFormsCheckbox);
  2156. //**********************************************************************************************************************************************************
  2157. //U Rect
  2158. //**********************************************************************************************************************************************************
  2159. /**
  2160. * Extends mxShape.
  2161. */
  2162. function mxShapeMockupFormsURect(bounds, fill, stroke, strokewidth)
  2163. {
  2164. mxShape.call(this);
  2165. this.bounds = bounds;
  2166. this.fill = fill;
  2167. this.stroke = stroke;
  2168. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  2169. };
  2170. /**
  2171. * Extends mxShape.
  2172. */
  2173. mxUtils.extend(mxShapeMockupFormsURect, mxShape);
  2174. mxShapeMockupFormsURect.prototype.cst = {
  2175. U_RECT : 'mxgraph.mockup.forms.uRect'
  2176. };
  2177. /**
  2178. * Function: paintVertexShape
  2179. *
  2180. * Paints the vertex shape.
  2181. */
  2182. mxShapeMockupFormsURect.prototype.paintVertexShape = function(c, x, y, w, h)
  2183. {
  2184. c.translate(x, y);
  2185. c.begin();
  2186. c.moveTo(0, h);
  2187. c.lineTo(0, 0);
  2188. c.lineTo(w, 0);
  2189. c.lineTo(w, h);
  2190. c.fillAndStroke();
  2191. };
  2192. mxCellRenderer.registerShape(mxShapeMockupFormsURect.prototype.cst.U_RECT, mxShapeMockupFormsURect);