mxMockupForms.js 72 KB

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