mxMockupForms.js 75 KB

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