mxIOS7Ui.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719
  1. /**
  2. * $Id: mxIOS7Ui.js,v 1.6 2013/12/04 16:48:54 mate Exp $
  3. * Copyright (c) 2006-2013, JGraph Ltd
  4. */
  5. var mxIOS7C =
  6. {
  7. MAIN_TEXT : 'mainText',
  8. SUB_TEXT : 'subText',
  9. TEXT_COLOR : 'textColor',
  10. TEXT_SIZE : 'textSize',
  11. BAR_POS : 'barPos',
  12. BUTTON_TEXT : 'buttonText',
  13. BUTTON_STATE : 'buttonState',
  14. SELECTED : '+', //has to be one character long
  15. STATE_ON : 'on',
  16. STATE_OFF : 'off',
  17. GRID_SIZE : 'gridSize',
  18. SHAPE_IOS7_APP_BAR : 'mxgraph.ios7ui.appBar',
  19. SHAPE_IOS7_ON_OFF_BUTTON : 'mxgraph.ios7ui.onOffButton',
  20. SHAPE_IOS7_SLIDER : 'mxgraph.ios7ui.slider',
  21. SHAPE_IOS7_DOWNLOAD_BAR : 'mxgraph.ios7ui.downloadBar',
  22. SHAPE_IOS7_ICON : 'mxgraph.ios7ui.icon',
  23. SHAPE_IOS7_HOR_BUTTON_BAR : 'mxgraph.ios7ui.horButtonBar',
  24. SHAPE_IOS7_PAGE_CONTROL : 'mxgraph.ios7ui.pageControl',
  25. SHAPE_IOS7_EXPAND : 'mxgraph.ios7ui.expand',
  26. SHAPE_IOS7_ICON_GRID : 'mxgraph.ios7ui.iconGrid',
  27. SHAPE_IOS7_PHONE : 'mxgraph.ios7ui.phone',
  28. SHAPE_IOS7_SEARCH_BOX : 'mxgraph.ios7ui.searchBox',
  29. SHAPE_IOS7_URL : 'mxgraph.ios7ui.url',
  30. SHAPE_IOS7_ACTION_DIALOG : 'mxgraph.ios7ui.actionDialog',
  31. STYLE_FILLCOLOR2 : 'fillColor2',
  32. STYLE_FILLCOLOR3 : 'fillColor3',
  33. STYLE_TEXTCOLOR : 'textColor',
  34. STYLE_TEXTCOLOR2 : 'textColor2',
  35. STYLE_STROKECOLOR2 : 'strokeColor2',
  36. STYLE_STROKECOLOR3 : 'strokeColor3',
  37. STYLE_TEXTSIZE : 'textSize'
  38. };
  39. //**********************************************************************************************************************************************************
  40. //iOS7 Application Bar
  41. //**********************************************************************************************************************************************************
  42. /**
  43. * Extends mxShape.
  44. */
  45. function mxShapeIOS7AppBar(bounds, fill, stroke, strokewidth)
  46. {
  47. mxShape.call(this);
  48. this.bounds = bounds;
  49. this.fill = fill;
  50. this.stroke = stroke;
  51. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  52. };
  53. /**
  54. * Extends mxShape.
  55. */
  56. mxUtils.extend(mxShapeIOS7AppBar, mxShape);
  57. mxShapeIOS7AppBar.prototype.customProperties = [
  58. {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color'}
  59. ];
  60. /**
  61. * Function: paintVertexShape
  62. *
  63. * Paints the vertex shape.
  64. */
  65. mxShapeIOS7AppBar.prototype.paintVertexShape = function(c, x, y, w, h)
  66. {
  67. c.translate(x, y);
  68. this.background(c, x, y, w, h);
  69. c.setShadow(false);
  70. this.foreground(c, x, y, w, h);
  71. };
  72. mxShapeIOS7AppBar.prototype.background = function(c, x, y, w, h)
  73. {
  74. c.rect(0, 0, w, h);
  75. c.fill();
  76. };
  77. mxShapeIOS7AppBar.prototype.foreground = function(c, x, y, w, h)
  78. {
  79. c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#222222'));
  80. c.ellipse(5, h * 0.5 - 1.5, 3, 3);
  81. c.fill();
  82. c.ellipse(9, h * 0.5 - 1.5, 3, 3);
  83. c.fill();
  84. c.ellipse(13, h * 0.5 - 1.5, 3, 3);
  85. c.fill();
  86. c.ellipse(17, h * 0.5 - 1.5, 3, 3);
  87. c.fill();
  88. c.ellipse(21, h * 0.5 - 1.5, 3, 3);
  89. c.fill();
  90. c.ellipse(54, h * 0.5 + 2, 2, 2);
  91. c.fillAndStroke();
  92. c.setStrokeWidth(2);
  93. c.begin();
  94. c.moveTo(52, h * 0.5 + 1);
  95. c.arcTo(3.5, 3.5, 0, 0, 1, 58, h * 0.5 + 1);
  96. c.stroke();
  97. c.begin();
  98. c.moveTo(50, h * 0.5 - 1);
  99. c.arcTo(6, 6, 0, 0, 1, 60, h * 0.5 - 1);
  100. c.stroke();
  101. c.begin();
  102. c.moveTo(w - 19, h * 0.5 - 2);
  103. c.lineTo(w - 6, h * 0.5 - 2);
  104. c.lineTo(w - 6, h * 0.5 + 2);
  105. c.lineTo(w - 19, h * 0.5 + 2);
  106. c.close();
  107. c.fill();
  108. c.setStrokeWidth(1);
  109. c.begin();
  110. c.moveTo(w - 44, h * 0.5 - 2.5);
  111. c.lineTo(w - 36, h * 0.5 + 2.5);
  112. c.lineTo(w - 40, h * 0.5 + 5);
  113. c.lineTo(w - 40, h * 0.5 - 5);
  114. c.lineTo(w - 36, h * 0.5 - 2.5);
  115. c.lineTo(w - 44, h * 0.5 + 2.5);
  116. c.stroke();
  117. c.begin();
  118. c.moveTo(w - 20, h * 0.5 - 3);
  119. c.lineTo(w - 5, h * 0.5 - 3);
  120. c.lineTo(w - 5, h * 0.5 - 1);
  121. c.lineTo(w - 3.5, h * 0.5 - 1);
  122. c.lineTo(w - 3.5, h * 0.5 + 1);
  123. c.lineTo(w - 5, h * 0.5 + 1);
  124. c.lineTo(w - 5, h * 0.5 + 3);
  125. c.lineTo(w - 20, h * 0.5 + 3);
  126. c.close();
  127. c.stroke();
  128. };
  129. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_APP_BAR, mxShapeIOS7AppBar);
  130. //**********************************************************************************************************************************************************
  131. //On-Off Button
  132. //**********************************************************************************************************************************************************
  133. /**
  134. * Extends mxShape.
  135. */
  136. function mxShapeIOS7OnOffButton(bounds, fill, stroke, strokewidth)
  137. {
  138. mxShape.call(this);
  139. this.bounds = bounds;
  140. this.fill = fill;
  141. this.stroke = stroke;
  142. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  143. };
  144. /**
  145. * Extends mxShape.
  146. */
  147. mxUtils.extend(mxShapeIOS7OnOffButton, mxShape);
  148. mxShapeIOS7OnOffButton.prototype.customProperties = [
  149. {name: 'buttonState', dispName: 'Button State', type: 'enum',
  150. enumList: [{val: 'on', dispName: 'On'},
  151. {val: 'off', dispName: 'Off'}]
  152. },
  153. {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color'},
  154. {name: 'fillColor2', dispName: 'Fill Color 2', type: 'color'},
  155. ];
  156. /**
  157. * Function: paintVertexShape
  158. *
  159. * Paints the vertex shape.
  160. */
  161. mxShapeIOS7OnOffButton.prototype.paintVertexShape = function(c, x, y, w, h)
  162. {
  163. c.translate(x, y);
  164. w = Math.max(w, 2 * h);
  165. var state = mxUtils.getValue(this.style, mxIOS7C.BUTTON_STATE, mxIOS7C.STATE_ON);
  166. this.background(c, x, y, w, h, state);
  167. c.setShadow(false);
  168. this.foreground(c, x, y, w, h, state);
  169. };
  170. mxShapeIOS7OnOffButton.prototype.background = function(c, x, y, w, h, state)
  171. {
  172. if (state === mxIOS7C.STATE_ON)
  173. {
  174. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  175. c.fillAndStroke();
  176. }
  177. else if (state === mxIOS7C.STATE_OFF)
  178. {
  179. c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#aaaaaa'));
  180. c.setFillColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#ffffff'));
  181. c.roundrect(0, 0, w, h, h * 0.5, h * 0.5);
  182. c.fillAndStroke();
  183. }
  184. };
  185. mxShapeIOS7OnOffButton.prototype.foreground = function(c, x, y, w, h, state)
  186. {
  187. c.setFillColor('#ffffff');
  188. if (state === mxIOS7C.STATE_ON)
  189. {
  190. c.ellipse(w - h + 1, 1, h - 2, h - 2);
  191. c.fill();
  192. }
  193. else
  194. {
  195. c.ellipse(0, 0, h, h);
  196. c.stroke();
  197. }
  198. };
  199. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ON_OFF_BUTTON, mxShapeIOS7OnOffButton);
  200. //**********************************************************************************************************************************************************
  201. //Slider
  202. //**********************************************************************************************************************************************************
  203. /**
  204. * Extends mxShape.
  205. */
  206. function mxShapeIOS7Slider(bounds, fill, stroke, strokewidth)
  207. {
  208. mxShape.call(this);
  209. this.bounds = bounds;
  210. this.fill = fill;
  211. this.stroke = stroke;
  212. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  213. this.barPos = 80;
  214. };
  215. /**
  216. * Extends mxShape.
  217. */
  218. mxUtils.extend(mxShapeIOS7Slider, mxShape);
  219. /**
  220. * Function: paintVertexShape
  221. *
  222. * Paints the vertex shape.
  223. */
  224. mxShapeIOS7Slider.prototype.paintVertexShape = function(c, x, y, w, h)
  225. {
  226. c.translate(x, y);
  227. c.setShadow(false);
  228. this.foreground(c, w, h);
  229. };
  230. mxShapeIOS7Slider.prototype.foreground = function(c, w, h)
  231. {
  232. c.setStrokeWidth(2);
  233. c.begin();
  234. c.moveTo(0, h * 0.5);
  235. c.lineTo(w, h * 0.5);
  236. c.stroke();
  237. var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
  238. barPos = Math.min(barPos, 100);
  239. barPos = Math.max(barPos, 0);
  240. var deadzone = 0;
  241. var virRange = w - 2 * deadzone;
  242. var truePos = deadzone + virRange * barPos / 100;
  243. c.setStrokeColor(mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#a0a0a0'));
  244. c.ellipse(truePos - 5, h * 0.5 - 5, 10, 10);
  245. c.fillAndStroke();
  246. };
  247. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_SLIDER, mxShapeIOS7Slider);
  248. Graph.handleFactory[mxIOS7C.SHAPE_IOS7_SLIDER] = function(state)
  249. {
  250. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  251. {
  252. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  253. return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
  254. }, function(bounds, pt)
  255. {
  256. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  257. })];
  258. return handles;
  259. }
  260. //**********************************************************************************************************************************************************
  261. //Download Bar
  262. //**********************************************************************************************************************************************************
  263. /**
  264. * Extends mxShape.
  265. */
  266. function mxShapeIOS7DownloadBar(bounds, fill, stroke, strokewidth)
  267. {
  268. mxShape.call(this);
  269. this.bounds = bounds;
  270. this.fill = fill;
  271. this.stroke = stroke;
  272. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  273. this.barPos = 80;
  274. };
  275. /**
  276. * Extends mxShape.
  277. */
  278. mxUtils.extend(mxShapeIOS7DownloadBar, mxShape);
  279. mxShapeIOS7DownloadBar.prototype.customProperties = [
  280. {name: 'barPos', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:30},
  281. {name: 'strokeColor2', dispName: 'Stroke Color 2', type: 'color'}
  282. ];
  283. /**
  284. * Function: paintVertexShape
  285. *
  286. * Paints the vertex shape.
  287. */
  288. mxShapeIOS7DownloadBar.prototype.paintVertexShape = function(c, x, y, w, h)
  289. {
  290. c.translate(x, y);
  291. this.foreground(c, w, h);
  292. };
  293. mxShapeIOS7DownloadBar.prototype.foreground = function(c, w, h)
  294. {
  295. var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
  296. c.setFontStyle(mxConstants.FONT_BOLD);
  297. c.text(w * 0.5, h * 0.2, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  298. var barPos = mxUtils.getValue(this.style, mxIOS7C.BAR_POS, '80');
  299. barPos = Math.min(barPos, 100);
  300. barPos = Math.max(barPos, 0);
  301. var truePos = w * barPos / 100;
  302. c.setStrokeWidth(2);
  303. c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, ''));
  304. c.begin();
  305. c.moveTo(0, h * 0.5);
  306. c.lineTo(w, h * 0.5);
  307. c.stroke();
  308. c.setStrokeColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
  309. c.begin();
  310. c.moveTo(0, h * 0.5);
  311. c.lineTo(truePos, h * 0.5);
  312. c.stroke();
  313. };
  314. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR, mxShapeIOS7DownloadBar);
  315. Graph.handleFactory[mxIOS7C.SHAPE_IOS7_DOWNLOAD_BAR] = function(state)
  316. {
  317. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  318. {
  319. var barPos = Math.max(0, Math.min(100, parseFloat(mxUtils.getValue(this.state.style, 'barPos', this.barPos))));
  320. return new mxPoint(bounds.x + barPos / 100 * bounds.width, bounds.y + bounds.height / 2);
  321. }, function(bounds, pt)
  322. {
  323. this.state.style['barPos'] = Math.round(1000 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 1000;
  324. })];
  325. return handles;
  326. }
  327. //**********************************************************************************************************************************************************
  328. //Icon
  329. //**********************************************************************************************************************************************************
  330. /**
  331. * Extends mxShape.
  332. */
  333. function mxShapeIOS7Icon(bounds, fill, stroke, strokewidth)
  334. {
  335. mxShape.call(this);
  336. this.bounds = bounds;
  337. this.fill = fill;
  338. this.stroke = stroke;
  339. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  340. };
  341. /**
  342. * Extends mxShape.
  343. */
  344. mxUtils.extend(mxShapeIOS7Icon, mxShape);
  345. /**
  346. * Function: paintVertexShape
  347. *
  348. * Paints the vertex shape.
  349. */
  350. mxShapeIOS7Icon.prototype.paintVertexShape = function(c, x, y, w, h)
  351. {
  352. c.translate(x, y);
  353. this.foreground(c, w, h);
  354. };
  355. mxShapeIOS7Icon.prototype.foreground = function(c, w, h)
  356. {
  357. c.setGradient('#00D0F0', '#0080F0', w * 0.325, 0, w * 0.675, h * 0.5, mxConstants.DIRECTION_SOUTH, 1, 1);
  358. c.roundrect(0, 0, w, h, w * 0.1, h * 0.1);
  359. c.fill();
  360. var fieldText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '');
  361. c.setFontColor('#ffffff');
  362. c.setFontStyle(mxConstants.FONT_BOLD);
  363. c.setFontSize(8);
  364. c.text(w * 0.5, h * 0.5, 0, 0, fieldText, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  365. };
  366. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ICON, mxShapeIOS7Icon);
  367. //**********************************************************************************************************************************************************
  368. //Horizontal Button Bar
  369. //**********************************************************************************************************************************************************
  370. /**
  371. * Extends mxShape.
  372. */
  373. function mxShapeIOS7horButtonBar(bounds, fill, stroke, strokewidth)
  374. {
  375. mxShape.call(this);
  376. this.bounds = bounds;
  377. this.fill = fill;
  378. this.stroke = stroke;
  379. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  380. };
  381. /**
  382. * Extends mxShape.
  383. */
  384. mxUtils.extend(mxShapeIOS7horButtonBar, mxShape);
  385. /**
  386. * Function: paintVertexShape
  387. *
  388. * Paints the vertex shape.
  389. */
  390. mxShapeIOS7horButtonBar.prototype.paintVertexShape = function(c, x, y, w, h)
  391. {
  392. var textStrings = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, '+Button 1, Button 2, Button 3').toString().split(',');
  393. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  394. var selectedFontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR2, '#ffffff');
  395. var fontSize = mxUtils.getValue(this.style, mxConstants.STYLE_FONTSIZE, '8.5').toString();
  396. var frameColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#666666');
  397. var bgColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#ffffff');
  398. var selectedFillColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_FILLCOLOR2, '#008cff');
  399. var buttonNum = textStrings.length;
  400. var buttonWidths = new Array(buttonNum);
  401. var buttonTotalWidth = 0;
  402. var selectedButton = -1;
  403. var rSize = 2.5; //rounding size
  404. var labelOffset = 2.5;
  405. for (var i = 0; i < buttonNum; i++)
  406. {
  407. var buttonText = textStrings[i];
  408. if(buttonText.charAt(0) === mxIOS7C.SELECTED)
  409. {
  410. buttonText = textStrings[i].substring(1);
  411. selectedButton = i;
  412. }
  413. buttonWidths[i] = mxUtils.getSizeForString(buttonText, fontSize, mxConstants.DEFAULT_FONTFAMILY).width;
  414. buttonTotalWidth += buttonWidths[i];
  415. }
  416. var trueH = Math.max(h, fontSize * 1.5, 10);
  417. var minW = 2 * labelOffset * buttonNum + buttonTotalWidth;
  418. var trueW = Math.max(w, minW);
  419. c.translate(x, y);
  420. this.background(c, trueW, trueH, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton);
  421. c.setShadow(false);
  422. var currWidth = 0;
  423. for (var i = 0; i < buttonNum; i++)
  424. {
  425. if (i === selectedButton)
  426. {
  427. c.setFontColor(selectedFontColor);
  428. }
  429. else
  430. {
  431. c.setFontColor(fontColor);
  432. }
  433. currWidth = currWidth + labelOffset;
  434. this.buttonText(c, currWidth, trueH, textStrings[i], buttonWidths[i], fontSize, minW, trueW);
  435. currWidth = currWidth + buttonWidths[i] + labelOffset;
  436. }
  437. };
  438. mxShapeIOS7horButtonBar.prototype.background = function(c, w, h, rSize, buttonNum, buttonWidths, labelOffset, minW, frameColor, bgColor, selectedFillColor, selectedButton)
  439. {
  440. c.begin();
  441. //draw the frame
  442. c.setStrokeColor(frameColor);
  443. c.setFillColor(bgColor);
  444. c.moveTo(0, rSize);
  445. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  446. c.lineTo(w - rSize, 0);
  447. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  448. c.lineTo(w, h - rSize);
  449. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  450. c.lineTo(rSize, h);
  451. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  452. c.close();
  453. c.fillAndStroke();
  454. //draw the button separators
  455. c.setStrokeColor(frameColor);
  456. c.begin();
  457. for (var i = 1; i < buttonNum; i++)
  458. {
  459. if (i !== selectedButton && i !== (selectedButton + 1))
  460. {
  461. var currWidth = 0;
  462. for (var j = 0; j < i; j++)
  463. {
  464. currWidth += buttonWidths[j] + 2 * labelOffset;
  465. }
  466. currWidth = currWidth * w / minW;
  467. c.moveTo(currWidth, 0);
  468. c.lineTo(currWidth, h);
  469. }
  470. }
  471. c.stroke();
  472. //draw the selected button
  473. var buttonLeft = 0;
  474. c.setStrokeColor(mxConstants.NONE);
  475. for (var i = 0; i < selectedButton; i++)
  476. {
  477. buttonLeft += buttonWidths[i] + 2 * labelOffset;
  478. }
  479. buttonLeft = buttonLeft * w / minW;
  480. var buttonRight = (buttonWidths[selectedButton] + 2 * labelOffset) * w / minW;
  481. buttonRight += buttonLeft;
  482. c.setFillColor('#0080F0');
  483. if (selectedButton === 0)
  484. {
  485. c.begin();
  486. // we draw a path for the first button
  487. c.moveTo(0, rSize);
  488. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  489. c.lineTo(buttonRight, 0);
  490. c.lineTo(buttonRight, h);
  491. c.lineTo(rSize, h);
  492. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  493. c.close();
  494. c.fill();
  495. }
  496. else if (selectedButton === buttonNum - 1)
  497. {
  498. c.begin();
  499. // we draw a path for the last button
  500. c.moveTo(buttonLeft, 0);
  501. c.lineTo(buttonRight - rSize, 0);
  502. c.arcTo(rSize, rSize, 0, 0, 1, buttonRight, rSize);
  503. c.lineTo(buttonRight, h - rSize);
  504. c.arcTo(rSize, rSize, 0, 0, 1, buttonRight - rSize, h);
  505. c.lineTo(buttonLeft, h);
  506. c.close();
  507. c.fill();
  508. }
  509. else if (selectedButton !== -1)
  510. {
  511. c.begin();
  512. // we draw a path rectangle for one of the buttons in the middle
  513. c.moveTo(buttonLeft, 0);
  514. c.lineTo(buttonRight, 0);
  515. c.lineTo(buttonRight, h);
  516. c.lineTo(buttonLeft, h);
  517. c.close();
  518. c.fill();
  519. }
  520. //draw the frame again, to achieve a nicer effect
  521. c.setStrokeColor(frameColor);
  522. c.setFillColor(bgColor);
  523. c.begin();
  524. c.moveTo(0, rSize);
  525. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  526. c.lineTo(w - rSize, 0);
  527. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  528. c.lineTo(w, h - rSize);
  529. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  530. c.lineTo(rSize, h);
  531. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  532. c.close();
  533. c.stroke();
  534. };
  535. mxShapeIOS7horButtonBar.prototype.buttonText = function(c, w, h, textString, buttonWidth, fontSize, minW, trueW)
  536. {
  537. if(textString.charAt(0) === mxIOS7C.SELECTED)
  538. {
  539. textString = textString.substring(1);
  540. }
  541. c.begin();
  542. c.setFontSize(fontSize);
  543. 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);
  544. };
  545. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_HOR_BUTTON_BAR, mxShapeIOS7horButtonBar);
  546. //**********************************************************************************************************************************************************
  547. //Page Control
  548. //**********************************************************************************************************************************************************
  549. /**
  550. * Extends mxShape.
  551. */
  552. function mxShapeIOS7pageControl(bounds, fill, stroke, strokewidth)
  553. {
  554. mxShape.call(this);
  555. this.bounds = bounds;
  556. this.fill = fill;
  557. this.stroke = stroke;
  558. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  559. };
  560. /**
  561. * Extends mxShape.
  562. */
  563. mxUtils.extend(mxShapeIOS7pageControl, mxShape);
  564. /**
  565. * Function: paintVertexShape
  566. *
  567. * Paints the vertex shape.
  568. */
  569. mxShapeIOS7pageControl.prototype.paintVertexShape = function(c, x, y, w, h)
  570. {
  571. c.translate(x, y);
  572. var fillColor = mxUtils.getValue(this.style, mxConstants.STYLE_FILLCOLOR, '#000000');
  573. var strokeColor = mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, '#000000');
  574. var rSize = Math.min(h * 0.5, w * 0.05);
  575. c.setFillColor(strokeColor);
  576. c.ellipse(0, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  577. c.fill();
  578. c.ellipse(w * 0.25 - rSize * 0.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  579. c.fill();
  580. c.ellipse(w * 0.5 - rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  581. c.fill();
  582. c.ellipse(w * 0.75 - rSize * 1.5, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  583. c.fill();
  584. c.setFillColor(fillColor);
  585. c.ellipse(w - 2 * rSize, h * 0.5 - rSize, 2 * rSize, 2 * rSize);
  586. c.fill();
  587. };
  588. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_PAGE_CONTROL, mxShapeIOS7pageControl);
  589. //**********************************************************************************************************************************************************
  590. //Icon Grid
  591. //**********************************************************************************************************************************************************
  592. /**
  593. * Extends mxShape.
  594. */
  595. function mxShapeIOS7iconGrid(bounds, fill, stroke, strokewidth)
  596. {
  597. mxShape.call(this);
  598. this.bounds = bounds;
  599. this.fill = fill;
  600. this.stroke = stroke;
  601. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  602. };
  603. /**
  604. * Extends mxShape.
  605. */
  606. mxUtils.extend(mxShapeIOS7iconGrid, mxShape);
  607. mxShapeIOS7iconGrid.prototype.customProperties = [
  608. {name: 'gridSize', dispName: 'Grid Size', type: 'string'},
  609. ];
  610. /**
  611. * Function: paintVertexShape
  612. *
  613. * Paints the vertex shape.
  614. */
  615. mxShapeIOS7iconGrid.prototype.paintVertexShape = function(c, x, y, w, h)
  616. {
  617. c.translate(x, y);
  618. var gridSize = decodeURIComponent(mxUtils.getValue(this.style, mxIOS7C.GRID_SIZE, '4,7').toString()).split(',');
  619. var boxSizeX = w / (parseInt(gridSize[0],10) + (gridSize[0]-1) * 0.1);
  620. var boxSizeY = h / (parseInt(gridSize[1],10) + (gridSize[1]-1) * 0.1);
  621. for (var i = 0; i < gridSize[0]; i++)
  622. {
  623. for (var j = 0; j < gridSize[1]; j++)
  624. {
  625. c.rect(boxSizeX * 1.1 * i, boxSizeY * 1.1 * j, boxSizeX, boxSizeY);
  626. c.fill();
  627. }
  628. }
  629. };
  630. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ICON_GRID, mxShapeIOS7iconGrid);
  631. //**********************************************************************************************************************************************************
  632. //iPhone Vertical
  633. //**********************************************************************************************************************************************************
  634. /**
  635. * Extends mxShape.
  636. */
  637. function mxShapeIOS7phone(bounds, fill, stroke, strokewidth)
  638. {
  639. mxShape.call(this);
  640. this.bounds = bounds;
  641. this.fill = fill;
  642. this.stroke = stroke;
  643. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  644. };
  645. /**
  646. * Extends mxShape.
  647. */
  648. mxUtils.extend(mxShapeIOS7phone, mxShape);
  649. /**
  650. * Function: paintVertexShape
  651. *
  652. * Paints the vertex shape.
  653. */
  654. mxShapeIOS7phone.prototype.paintVertexShape = function(c, x, y, w, h)
  655. {
  656. c.translate(x, y);
  657. var rSize = 25;
  658. c.roundrect(0, 0, w, h, rSize, rSize);
  659. c.fillAndStroke();
  660. c.setShadow(false);
  661. this.foreground(c, x, y, w, h, rSize);
  662. };
  663. mxShapeIOS7phone.prototype.foreground = function(c, x, y, w, h, rSize)
  664. {
  665. c.rect(w * 0.0625, h * 0.15, w * 0.875, h * 0.7);
  666. c.stroke();
  667. c.ellipse(w * 0.4875, h * 0.04125, w * 0.025, h * 0.0125);
  668. c.stroke();
  669. c.roundrect(w * 0.375, h * 0.075, w * 0.25, h * 0.01875, w * 0.02, h * 0.01);
  670. c.stroke();
  671. c.ellipse(w * 0.4, h * 0.875, w * 0.2, h * 0.1);
  672. c.stroke();
  673. c.roundrect(w * 0.4575, h * 0.905, w * 0.085, h * 0.04375, h * 0.00625, h * 0.00625);
  674. c.stroke();
  675. };
  676. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_PHONE, mxShapeIOS7phone);
  677. //**********************************************************************************************************************************************************
  678. //Search Box
  679. //**********************************************************************************************************************************************************
  680. /**
  681. * Extends mxShape.
  682. */
  683. function mxShapeIOS7searchBox(bounds, fill, stroke, strokewidth)
  684. {
  685. mxShape.call(this);
  686. this.bounds = bounds;
  687. this.fill = fill;
  688. this.stroke = stroke;
  689. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  690. };
  691. /**
  692. * Extends mxShape.
  693. */
  694. mxUtils.extend(mxShapeIOS7searchBox, mxShape);
  695. /**
  696. * Function: paintVertexShape
  697. *
  698. * Paints the vertex shape.
  699. */
  700. mxShapeIOS7searchBox.prototype.paintVertexShape = function(c, x, y, w, h)
  701. {
  702. c.translate(x, y);
  703. this.background(c, w, h);
  704. c.setShadow(false);
  705. this.foreground(c, w, h);
  706. };
  707. mxShapeIOS7searchBox.prototype.background = function(c, w, h)
  708. {
  709. c.rect(0, 0, w, h);
  710. c.fill();
  711. };
  712. mxShapeIOS7searchBox.prototype.foreground = function(c, w, h)
  713. {
  714. var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'Search');
  715. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  716. var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
  717. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  718. var rSize = Math.min(w, h) * 0.1;
  719. c.setFillColor('#ffffff');
  720. c.roundrect(w * 0.05, h * 0.15, w * 0.5, h * 0.7, rSize, rSize);
  721. c.fillAndStroke();
  722. c.setFontColor(fontColor);
  723. c.setFontSize(Math.min(h * 0.7, w * 0.1));
  724. c.text(5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  725. c.setStrokeColor(strokeColor2);
  726. c.ellipse(w * 0.05 + 3, h * 0.5 - 3, 4, 4);
  727. c.stroke();
  728. c.begin();
  729. c.moveTo(w * 0.05 + 8, h * 0.5 + 3.5);
  730. c.lineTo(w * 0.05 + 6, h * 0.5 + 0.5);
  731. c.stroke();
  732. };
  733. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_SEARCH_BOX, mxShapeIOS7searchBox);
  734. //**********************************************************************************************************************************************************
  735. //URL
  736. //**********************************************************************************************************************************************************
  737. /**
  738. * Extends mxShape.
  739. */
  740. function mxShapeIOS7URL(bounds, fill, stroke, strokewidth)
  741. {
  742. mxShape.call(this);
  743. this.bounds = bounds;
  744. this.fill = fill;
  745. this.stroke = stroke;
  746. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  747. };
  748. /**
  749. * Extends mxShape.
  750. */
  751. mxUtils.extend(mxShapeIOS7URL, mxShape);
  752. /**
  753. * Function: paintVertexShape
  754. *
  755. * Paints the vertex shape.
  756. */
  757. mxShapeIOS7URL.prototype.paintVertexShape = function(c, x, y, w, h)
  758. {
  759. c.translate(x, y);
  760. this.background(c, w, h);
  761. c.setShadow(false);
  762. this.foreground(c, w, h);
  763. };
  764. mxShapeIOS7URL.prototype.background = function(c, w, h)
  765. {
  766. c.rect(0, 0, w, h);
  767. c.fill();
  768. };
  769. mxShapeIOS7URL.prototype.foreground = function(c, w, h)
  770. {
  771. var mainText = mxUtils.getValue(this.style, mxIOS7C.BUTTON_TEXT, 'draw.io');
  772. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  773. var strokeColor2 = mxUtils.getValue(this.style, mxIOS7C.STYLE_STROKECOLOR2, '#008cff');
  774. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  775. var rSize = Math.min(w, h) * 0.1;
  776. c.setFillColor('#d8d8d8');
  777. c.roundrect(w * 0.05, h * 0.15, w * 0.9, h * 0.7, rSize, rSize);
  778. c.fill();
  779. c.setFontColor(fontColor);
  780. c.setFontSize(Math.min(h * 0.7, w * 0.1));
  781. c.text(w * 0.5, h * 0.5, 0, 0, mainText, mxConstants.ALIGN_LEFT, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  782. c.setStrokeColor(strokeColor2);
  783. c.begin();
  784. c.moveTo(w * 0.95 - 5, h * 0.5);
  785. c.arcTo(3, 3, 0, 1, 1, w * 0.95 - 8, h * 0.5 - 3);
  786. c.stroke();
  787. c.setFillColor(strokeColor2);
  788. c.begin();
  789. c.moveTo(w * 0.95 - 8, h * 0.5 - 4);
  790. c.lineTo(w * 0.95 - 6, h * 0.5 - 3);
  791. c.lineTo(w * 0.95 - 8, h * 0.5 - 2);
  792. c.close();
  793. c.fillAndStroke();
  794. };
  795. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_URL, mxShapeIOS7URL);
  796. //**********************************************************************************************************************************************************
  797. //Action Dialog
  798. //**********************************************************************************************************************************************************
  799. /**
  800. * Extends mxShape.
  801. */
  802. function mxShapeIOS7Actiondialog(bounds, fill, stroke, strokewidth)
  803. {
  804. mxShape.call(this);
  805. this.bounds = bounds;
  806. this.fill = fill;
  807. this.stroke = stroke;
  808. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  809. };
  810. /**
  811. * Extends mxShape.
  812. */
  813. mxUtils.extend(mxShapeIOS7Actiondialog, mxShape);
  814. /**
  815. * Function: paintVertexShape
  816. *
  817. * Paints the vertex shape.
  818. */
  819. mxShapeIOS7Actiondialog.prototype.paintVertexShape = function(c, x, y, w, h)
  820. {
  821. var mainText = mxUtils.getValue(this.style, mxIOS7C.MAIN_TEXT, 'Main Text');
  822. var subText = mxUtils.getValue(this.style, mxIOS7C.SUB_TEXT, 'Sub Text');
  823. var fontColor = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTCOLOR, '#666666');
  824. var fontSize = mxUtils.getValue(this.style, mxIOS7C.STYLE_TEXTSIZE, '17');
  825. c.translate(x, y);
  826. this.background(c, x, y, w, h);
  827. c.setShadow(false);
  828. c.setFillColor('#e0e0e0');
  829. c.roundrect(w * 0.05, h * 0.1, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
  830. c.fill();
  831. c.roundrect(w * 0.05, h * 0.55, w * 0.9, h * 0.35, w * 0.025, h * 0.05);
  832. c.fill();
  833. c.setFontStyle(mxConstants.FONT_BOLD);
  834. this.mainText(c, x, y, w, h, mainText, fontSize, fontColor);
  835. this.subText(c, x, y, w, h, subText, fontSize / 1.4, fontColor);
  836. };
  837. mxShapeIOS7Actiondialog.prototype.background = function(c, x, y, w, h)
  838. {
  839. c.rect(0, 0, w, h);
  840. c.fill();
  841. };
  842. mxShapeIOS7Actiondialog.prototype.mainText = function(c, x, y, w, h, text, fontSize, fontColor)
  843. {
  844. c.begin();
  845. c.setFontSize(fontSize);
  846. c.setFontColor(fontColor);
  847. c.text(w * 0.5, h * 0.4, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  848. };
  849. mxShapeIOS7Actiondialog.prototype.subText = function(c, x, y, w, h, text, fontSize, fontColor)
  850. {
  851. c.begin();
  852. c.setFontSize(fontSize);
  853. c.text(w * 0.5, h * 0.7, 0, 0, text, mxConstants.ALIGN_CENTER, mxConstants.ALIGN_MIDDLE, 0, null, 0, 0, 0);
  854. };
  855. mxCellRenderer.registerShape(mxIOS7C.SHAPE_IOS7_ACTION_DIALOG, mxShapeIOS7Actiondialog);
  856. //**********************************************************************************************************************************************************
  857. //Anchor (a dummy shape without visuals used for anchoring)
  858. //**********************************************************************************************************************************************************
  859. /**
  860. * Extends mxShape.
  861. */
  862. function mxShapeIOS7Anchor(bounds, fill, stroke, strokewidth)
  863. {
  864. mxShape.call(this);
  865. this.bounds = bounds;
  866. };
  867. /**
  868. * Extends mxShape.
  869. */
  870. mxUtils.extend(mxShapeIOS7Anchor, mxShape);
  871. mxShapeIOS7Anchor.prototype.cst = {
  872. ANCHOR : 'mxgraph.ios7ui.anchor'
  873. };
  874. /**
  875. * Function: paintVertexShape
  876. *
  877. * Paints the vertex shape.
  878. */
  879. mxShapeIOS7Anchor.prototype.paintVertexShape = function(c, x, y, w, h)
  880. {
  881. };
  882. mxCellRenderer.registerShape(mxShapeIOS7Anchor.prototype.cst.ANCHOR, mxShapeIOS7Anchor);
  883. //**********************************************************************************************************************************************************
  884. //Rounded rectangle (adjustable rounding)
  885. //**********************************************************************************************************************************************************
  886. /**
  887. * Extends mxShape.
  888. */
  889. function mxShapeIOS7RRect(bounds, fill, stroke, strokewidth)
  890. {
  891. mxShape.call(this);
  892. this.bounds = bounds;
  893. this.fill = fill;
  894. this.stroke = stroke;
  895. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  896. };
  897. /**
  898. * Extends mxShape.
  899. */
  900. mxUtils.extend(mxShapeIOS7RRect, mxShape);
  901. mxShapeIOS7RRect.prototype.cst = {
  902. RRECT : 'mxgraph.ios7ui.rrect',
  903. R_SIZE : 'rSize'
  904. };
  905. mxShapeIOS7RRect.prototype.customProperties = [
  906. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  907. ];
  908. /**
  909. * Function: paintVertexShape
  910. *
  911. * Paints the vertex shape.
  912. */
  913. mxShapeIOS7RRect.prototype.paintVertexShape = function(c, x, y, w, h)
  914. {
  915. c.translate(x, y);
  916. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RRect.prototype.cst.R_SIZE, '10'));
  917. c.roundrect(0, 0, w, h, rSize);
  918. c.fillAndStroke();
  919. };
  920. mxCellRenderer.registerShape(mxShapeIOS7RRect.prototype.cst.RRECT, mxShapeIOS7RRect);
  921. //**********************************************************************************************************************************************************
  922. //Left Button
  923. //**********************************************************************************************************************************************************
  924. /**
  925. * Extends mxShape.
  926. */
  927. function mxShapeIOS7LeftButton(bounds, fill, stroke, strokewidth)
  928. {
  929. mxShape.call(this);
  930. this.bounds = bounds;
  931. this.fill = fill;
  932. this.stroke = stroke;
  933. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  934. };
  935. /**
  936. * Extends mxShape.
  937. */
  938. mxUtils.extend(mxShapeIOS7LeftButton, mxShape);
  939. mxShapeIOS7LeftButton.prototype.cst = {
  940. LEFT_BUTTON : 'mxgraph.ios7ui.leftButton',
  941. R_SIZE : 'rSize'
  942. };
  943. mxShapeIOS7LeftButton.prototype.customProperties = [
  944. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  945. ];
  946. /**
  947. * Function: paintVertexShape
  948. *
  949. * Paints the vertex shape.
  950. */
  951. mxShapeIOS7LeftButton.prototype.paintVertexShape = function(c, x, y, w, h)
  952. {
  953. c.translate(x, y);
  954. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7LeftButton.prototype.cst.R_SIZE, '10'));
  955. c.begin();
  956. c.moveTo(w, 0);
  957. c.lineTo(w, h);
  958. c.lineTo(rSize, h);
  959. c.arcTo(rSize, rSize, 0, 0, 1, 0, h - rSize);
  960. c.lineTo(0, rSize);
  961. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  962. c.close();
  963. c.fillAndStroke();
  964. };
  965. mxCellRenderer.registerShape(mxShapeIOS7LeftButton.prototype.cst.LEFT_BUTTON, mxShapeIOS7LeftButton);
  966. //**********************************************************************************************************************************************************
  967. //Right Button
  968. //**********************************************************************************************************************************************************
  969. /**
  970. * Extends mxShape.
  971. */
  972. function mxShapeIOS7RightButton(bounds, fill, stroke, strokewidth)
  973. {
  974. mxShape.call(this);
  975. this.bounds = bounds;
  976. this.fill = fill;
  977. this.stroke = stroke;
  978. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  979. };
  980. /**
  981. * Extends mxShape.
  982. */
  983. mxUtils.extend(mxShapeIOS7RightButton, mxShape);
  984. mxShapeIOS7RightButton.prototype.cst = {
  985. RIGHT_BUTTON : 'mxgraph.ios7ui.rightButton',
  986. R_SIZE : 'rSize'
  987. };
  988. mxShapeIOS7RightButton.prototype.customProperties = [
  989. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  990. ];
  991. /**
  992. * Function: paintVertexShape
  993. *
  994. * Paints the vertex shape.
  995. */
  996. mxShapeIOS7RightButton.prototype.paintVertexShape = function(c, x, y, w, h)
  997. {
  998. c.translate(x, y);
  999. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7RightButton.prototype.cst.R_SIZE, '10'));
  1000. c.begin();
  1001. c.moveTo(0, 0);
  1002. c.lineTo(w - rSize, 0);
  1003. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  1004. c.lineTo(w, h - rSize);
  1005. c.arcTo(rSize, rSize, 0, 0, 1, w - rSize, h);
  1006. c.lineTo(0, h);
  1007. c.close();
  1008. c.fillAndStroke();
  1009. };
  1010. mxCellRenderer.registerShape(mxShapeIOS7RightButton.prototype.cst.RIGHT_BUTTON, mxShapeIOS7RightButton);
  1011. //**********************************************************************************************************************************************************
  1012. //Top Button
  1013. //**********************************************************************************************************************************************************
  1014. /**
  1015. * Extends mxShape.
  1016. */
  1017. function mxShapeIOS7TopButton(bounds, fill, stroke, strokewidth)
  1018. {
  1019. mxShape.call(this);
  1020. this.bounds = bounds;
  1021. this.fill = fill;
  1022. this.stroke = stroke;
  1023. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1024. };
  1025. /**
  1026. * Extends mxShape.
  1027. */
  1028. mxUtils.extend(mxShapeIOS7TopButton, mxShape);
  1029. mxShapeIOS7TopButton.prototype.cst = {
  1030. TOP_BUTTON : 'mxgraph.ios7ui.topButton',
  1031. R_SIZE : 'rSize'
  1032. };
  1033. mxShapeIOS7TopButton.prototype.customProperties = [
  1034. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3}
  1035. ];
  1036. /**
  1037. * Function: paintVertexShape
  1038. *
  1039. * Paints the vertex shape.
  1040. */
  1041. mxShapeIOS7TopButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1042. {
  1043. c.translate(x, y);
  1044. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7TopButton.prototype.cst.R_SIZE, '10'));
  1045. c.begin();
  1046. c.moveTo(w, h);
  1047. c.lineTo(0, h);
  1048. c.lineTo(0, rSize);
  1049. c.arcTo(rSize, rSize, 0, 0, 1, rSize, 0);
  1050. c.lineTo(w - rSize, 0);
  1051. c.arcTo(rSize, rSize, 0, 0, 1, w, rSize);
  1052. c.close();
  1053. c.fillAndStroke();
  1054. };
  1055. mxCellRenderer.registerShape(mxShapeIOS7TopButton.prototype.cst.TOP_BUTTON, mxShapeIOS7TopButton);
  1056. //**********************************************************************************************************************************************************
  1057. //Bottom Button
  1058. //**********************************************************************************************************************************************************
  1059. /**
  1060. * Extends mxShape.
  1061. */
  1062. function mxShapeIOS7BottomButton(bounds, fill, stroke, strokewidth)
  1063. {
  1064. mxShape.call(this);
  1065. this.bounds = bounds;
  1066. this.fill = fill;
  1067. this.stroke = stroke;
  1068. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1069. };
  1070. /**
  1071. * Extends mxShape.
  1072. */
  1073. mxUtils.extend(mxShapeIOS7BottomButton, mxShape);
  1074. mxShapeIOS7BottomButton.prototype.cst = {
  1075. BOTTOM_BUTTON : 'mxgraph.ios7ui.bottomButton',
  1076. R_SIZE : 'rSize'
  1077. };
  1078. mxShapeIOS7BottomButton.prototype.customProperties = [
  1079. {name: 'rSize', dispName: 'Arc Size', type: 'float', min:0, defVal:3},
  1080. ];
  1081. /**
  1082. * Function: paintVertexShape
  1083. *
  1084. * Paints the vertex shape.
  1085. */
  1086. mxShapeIOS7BottomButton.prototype.paintVertexShape = function(c, x, y, w, h)
  1087. {
  1088. c.translate(x, y);
  1089. var rSize = parseInt(mxUtils.getValue(this.style, mxShapeIOS7BottomButton.prototype.cst.R_SIZE, '10'));
  1090. c.begin();
  1091. c.moveTo(w, 0);
  1092. c.lineTo(0, 0);
  1093. c.lineTo(0, h - rSize);
  1094. c.arcTo(rSize, rSize, 0, 0, 0, rSize, h);
  1095. c.lineTo(w - rSize, h);
  1096. c.arcTo(rSize, rSize, 0, 0, 0, w, h - rSize);
  1097. c.close();
  1098. c.fillAndStroke();
  1099. };
  1100. mxCellRenderer.registerShape(mxShapeIOS7BottomButton.prototype.cst.BOTTOM_BUTTON, mxShapeIOS7BottomButton);
  1101. //**********************************************************************************************************************************************************
  1102. //Horizontal Lines
  1103. //**********************************************************************************************************************************************************
  1104. /**
  1105. * Extends mxShape.
  1106. */
  1107. function mxShapeIOS7HorLines(bounds, fill, stroke, strokewidth)
  1108. {
  1109. mxShape.call(this);
  1110. this.bounds = bounds;
  1111. this.fill = fill;
  1112. this.stroke = stroke;
  1113. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1114. };
  1115. /**
  1116. * Extends mxShape.
  1117. */
  1118. mxUtils.extend(mxShapeIOS7HorLines, mxShape);
  1119. mxShapeIOS7HorLines.prototype.cst = {
  1120. HOR_LINES : 'mxgraph.ios7ui.horLines'
  1121. };
  1122. /**
  1123. * Function: paintVertexShape
  1124. *
  1125. * Paints the vertex shape.
  1126. */
  1127. mxShapeIOS7HorLines.prototype.paintVertexShape = function(c, x, y, w, h)
  1128. {
  1129. c.translate(x, y);
  1130. c.rect(0, 0, w, h);
  1131. c.fill();
  1132. c.begin();
  1133. c.moveTo(0, 0);
  1134. c.lineTo(w, 0);
  1135. c.moveTo(0, h);
  1136. c.lineTo(w, h);
  1137. c.stroke();
  1138. };
  1139. mxCellRenderer.registerShape(mxShapeIOS7HorLines.prototype.cst.HOR_LINES, mxShapeIOS7HorLines);
  1140. //**********************************************************************************************************************************************************
  1141. //rect with margins
  1142. //**********************************************************************************************************************************************************
  1143. /**
  1144. * Extends mxShape.
  1145. */
  1146. function mxShapeIOS7MarginRect(bounds, fill, stroke, strokewidth)
  1147. {
  1148. mxShape.call(this);
  1149. this.bounds = bounds;
  1150. this.fill = fill;
  1151. this.stroke = stroke;
  1152. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1153. };
  1154. /**
  1155. * Extends mxShape.
  1156. */
  1157. mxUtils.extend(mxShapeIOS7MarginRect, mxShape);
  1158. mxShapeIOS7MarginRect.prototype.customProperties = [
  1159. {name: 'rx', dispName: 'Hor. Rounding Size', type: 'float', min:0, defVal:3},
  1160. {name: 'ry', dispName: 'Ver. Rounding Size', type: 'float', min:0, defVal:3},
  1161. {name: 'rectMargin', dispName: 'Global Margin', type: 'float', min:0, defVal:5},
  1162. {name: 'rectMarginTop', dispName: 'Top Margin', type: 'float', min:0, defVal:0},
  1163. {name: 'rectMarginLeft', dispName: 'Left Margin', type: 'float', min:0, defVal:0},
  1164. {name: 'rectMarginBottom', dispName: 'Bottom Margin', type: 'float', min:0, defVal:0},
  1165. {name: 'rectMarginRight', dispName: 'Right Margin', type: 'float', min:0, defVal:0}
  1166. ];
  1167. mxShapeIOS7MarginRect.prototype.cst = {
  1168. SHAPE_MARGIN_RECT : 'mxgraph.ios7ui.marginRect',
  1169. MARGIN : 'rectMargin',
  1170. RX : 'rx',
  1171. RY : 'ry',
  1172. MARGIN_TOP : 'rectMarginTop',
  1173. MARGIN_LEFT : 'rectMarginLeft',
  1174. MARGIN_BOTTOM : 'rectMarginBottom',
  1175. MARGIN_RIGHT : 'rectMarginRight'
  1176. };
  1177. /**
  1178. * Function: paintVertexShape
  1179. *
  1180. * Paints the vertex shape.
  1181. */
  1182. mxShapeIOS7MarginRect.prototype.paintVertexShape = function(c, x, y, w, h)
  1183. {
  1184. c.translate(x, y);
  1185. this.background(c, x, y, w, h);
  1186. };
  1187. mxShapeIOS7MarginRect.prototype.background = function(c, x, y, w, h, state)
  1188. {
  1189. var margin = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN, '0'));
  1190. var marginTop = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_TOP, '0'));
  1191. var marginLeft = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_LEFT, '0'));
  1192. var marginBottom = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_BOTTOM, '0'));
  1193. var marginRight = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.MARGIN_RIGHT, '0'));
  1194. var rx = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RX, '0'));
  1195. var ry = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7MarginRect.prototype.cst.RY, '0'));
  1196. var x1 = margin + marginLeft;
  1197. var y1 = margin + marginTop;
  1198. var w1 = w - marginRight - x1 - margin;
  1199. var h1 = h - marginBottom - y1 - margin;
  1200. if (w1 >0 && h1 > 0)
  1201. {
  1202. c.begin();
  1203. c.roundrect(x1, y1, w1, h1, rx, ry);
  1204. c.fillAndStroke();
  1205. }
  1206. };
  1207. mxCellRenderer.registerShape(mxShapeIOS7MarginRect.prototype.cst.SHAPE_MARGIN_RECT, mxShapeIOS7MarginRect);
  1208. //**********************************************************************************************************************************************************
  1209. //Callout
  1210. //**********************************************************************************************************************************************************
  1211. /**
  1212. * Extends mxShape.
  1213. */
  1214. function mxShapeIOS7Callout(bounds, fill, stroke, strokewidth)
  1215. {
  1216. mxShape.call(this);
  1217. this.bounds = bounds;
  1218. this.fill = fill;
  1219. this.stroke = stroke;
  1220. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1221. };
  1222. /**
  1223. * Extends mxShape.
  1224. */
  1225. mxUtils.extend(mxShapeIOS7Callout, mxShape);
  1226. mxShapeIOS7Callout.prototype.cst = {
  1227. SHAPE_CALLOUT : 'mxgraph.ios7ui.callout'
  1228. };
  1229. /**
  1230. * Function: paintVertexShape
  1231. *
  1232. * Paints the vertex shape.
  1233. */
  1234. mxShapeIOS7Callout.prototype.paintVertexShape = function(c, x, y, w, h)
  1235. {
  1236. c.translate(x, y);
  1237. this.background(c, x, y, w, h);
  1238. };
  1239. mxShapeIOS7Callout.prototype.background = function(c, x, y, w, h, state)
  1240. {
  1241. var r = 10;
  1242. if (w >= 30 && h >= 20)
  1243. {
  1244. c.begin();
  1245. c.moveTo(15, h - r * 0.3);
  1246. c.arcTo(r * 2, r, 0, 0, 1, 0, h);
  1247. c.arcTo(r * 1.5, r * 1.5, 0, 0, 0, 10, h - r * 1);
  1248. c.lineTo(r, r);
  1249. c.arcTo(r, r, 0, 0, 1, r * 2, 0);
  1250. c.lineTo(w - r, 0);
  1251. c.arcTo(r, r, 0, 0, 1, w, r);
  1252. c.lineTo(w, h - r);
  1253. c.arcTo(r, r, 0, 0, 1, w - r, h);
  1254. c.lineTo(r * 2, h);
  1255. c.arcTo(r, r, 0, 0, 1, r * 1.5, h - r * 0.3);
  1256. c.close();
  1257. c.fillAndStroke();
  1258. }
  1259. };
  1260. mxCellRenderer.registerShape(mxShapeIOS7Callout.prototype.cst.SHAPE_CALLOUT, mxShapeIOS7Callout);
  1261. //**********************************************************************************************************************************************************
  1262. //Select Bar
  1263. //**********************************************************************************************************************************************************
  1264. /**
  1265. * Extends mxShape.
  1266. */
  1267. function mxShapeIOS7SelectBar(bounds, fill, stroke, strokewidth)
  1268. {
  1269. mxShape.call(this);
  1270. this.bounds = bounds;
  1271. this.fill = fill;
  1272. this.stroke = stroke;
  1273. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1274. this.dy = 0.5;
  1275. this.dx = 0.5;
  1276. this.dx2 = 70;
  1277. this.size = 10;
  1278. };
  1279. /**
  1280. * Extends mxShape.
  1281. */
  1282. mxUtils.extend(mxShapeIOS7SelectBar, mxActor);
  1283. mxShapeIOS7SelectBar.prototype.cst = {
  1284. SELECT_BAR : 'mxgraph.ios7ui.selectBar'
  1285. };
  1286. mxShapeIOS7SelectBar.prototype.customProperties = [
  1287. {name: 'dx', dispName: 'Callout Position', type: 'float', min:0, defVal:120},
  1288. {name: 'dx2', dispName: 'Field Size', type: 'float', min:0, defVal: 75},
  1289. {name: 'size', dispName: 'Rounding size', type: 'float', min:0, defVal:5},
  1290. {name: 'dy', dispName: 'Callout Size', type: 'float', min:0, defVal:5}
  1291. ];
  1292. /**
  1293. * Function: paintVertexShape
  1294. *
  1295. * Paints the vertex shape.
  1296. */
  1297. mxShapeIOS7SelectBar.prototype.paintVertexShape = function(c, x, y, w, h)
  1298. {
  1299. c.translate(x, y);
  1300. var dx = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx', this.dx))));
  1301. var dx2 = Math.max(0, Math.min(w, parseFloat(mxUtils.getValue(this.style, 'dx2', this.dx2))));
  1302. var r = Math.max(0, Math.min(h, parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
  1303. var dy = Math.max(0, Math.min(h, (w - Math.max(20, r) - r) / 2, parseFloat(mxUtils.getValue(this.style, 'dy', this.dy))));
  1304. r = Math.min(h / 2, w / 2, r);
  1305. dx = Math.max(r + dy, dx);
  1306. dx = Math.min(w - r - dy, w - 20 - dy, dx);
  1307. c.begin();
  1308. c.moveTo(dx - dy, h);
  1309. c.lineTo(r, h);
  1310. c.arcTo(r, r, 0, 0, 1, 0, h - r);
  1311. c.lineTo(0, r);
  1312. c.arcTo(r, r, 0, 0, 1, r, 0);
  1313. c.lineTo(w - r, 0);
  1314. c.arcTo(r, r, 0, 0, 1, w, r);
  1315. c.lineTo(w, h - r);
  1316. c.arcTo(r, r, 0, 0, 1, w - r, h);
  1317. c.lineTo(dx + dy, h);
  1318. c.lineTo(dx, h + dy);
  1319. c.close();
  1320. c.fillAndStroke();
  1321. c.setShadow(false);
  1322. c.begin();
  1323. c.moveTo(w - Math.max(20, r), 0);
  1324. c.lineTo(w - Math.max(20, r), h);
  1325. c.stroke();
  1326. var currDx = dx2;
  1327. c.begin();
  1328. while (currDx < (w - Math.max(20, r)))
  1329. {
  1330. c.moveTo(currDx, 0);
  1331. c.lineTo(currDx, h);
  1332. currDx = currDx + dx2;
  1333. }
  1334. c.stroke();
  1335. var w1 = Math.min(Math.max(20, r), h);
  1336. var x1 = w - w1 * 0.5;
  1337. var y1 = h * 0.5;
  1338. c.setFillColor(mxUtils.getValue(this.style, mxConstants.STYLE_STROKECOLOR, ''));
  1339. c.begin();
  1340. c.moveTo(x1 - w1 * 0.15, y1 - w1 * 0.225);
  1341. c.lineTo(x1 + w1 * 0.25, y1);
  1342. c.lineTo(x1 - w1 * 0.15, y1 + w1 * 0.225);
  1343. c.close();
  1344. c.fill();
  1345. };
  1346. mxCellRenderer.registerShape(mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR, mxShapeIOS7SelectBar);
  1347. mxShapeIOS7SelectBar.prototype.constraints = null;
  1348. Graph.handleFactory[mxShapeIOS7SelectBar.prototype.cst.SELECT_BAR] = function(state)
  1349. {
  1350. var handles = [Graph.createHandle(state, ['dx'], function(bounds)
  1351. {
  1352. var dx = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx))));
  1353. return new mxPoint(bounds.x + dx, bounds.y + bounds.height);
  1354. }, function(bounds, pt)
  1355. {
  1356. var y = parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy)) * 0.6;
  1357. this.state.style['dx'] = Math.round(100 * Math.max(y, Math.min(bounds.width - y, pt.x - bounds.x))) / 100;
  1358. })];
  1359. var handle2 = Graph.createHandle(state, ['dy'], function(bounds)
  1360. {
  1361. var dy = Math.max(0, Math.min(bounds.height, parseFloat(mxUtils.getValue(this.state.style, 'dy', this.dy))));
  1362. return new mxPoint(bounds.x + parseFloat(mxUtils.getValue(this.state.style, 'dx', this.dx)), bounds.y + bounds.height + dy);
  1363. }, function(bounds, pt)
  1364. {
  1365. this.state.style['dy'] = Math.round(100 * Math.max(0, Math.min(bounds.height, pt.y - bounds.y - bounds.height))) / 100;
  1366. });
  1367. handles.push(handle2);
  1368. var handle3 = Graph.createHandle(state, ['size'], function(bounds)
  1369. {
  1370. var size = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'size', this.size))));
  1371. return new mxPoint(bounds.x + bounds.width - size, bounds.y + 10);
  1372. }, function(bounds, pt)
  1373. {
  1374. this.state.style['size'] = Math.round(100 * Math.max(0, Math.min(bounds.width / 2, bounds.height / 2, bounds.x + bounds.width - pt.x))) / 100;
  1375. });
  1376. handles.push(handle3);
  1377. var handle4 = Graph.createHandle(state, ['dx2'], function(bounds)
  1378. {
  1379. var dx2 = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'dx2', this.dx2))));
  1380. return new mxPoint(bounds.x + dx2, bounds.y + bounds.height / 2);
  1381. }, function(bounds, pt)
  1382. {
  1383. this.state.style['dx2'] = Math.round(100 * Math.max(0, Math.min(bounds.width, pt.x - bounds.x))) / 100;
  1384. });
  1385. handles.push(handle4);
  1386. return handles;
  1387. }
  1388. //**********************************************************************************************************************************************************
  1389. //slider
  1390. //**********************************************************************************************************************************************************
  1391. /**
  1392. * Extends mxShape.
  1393. */
  1394. //mxShapeIOS7SelectBar
  1395. function mxShapeIOS7Slider2(bounds, fill, stroke, strokewidth)
  1396. {
  1397. mxShape.call(this);
  1398. this.bounds = bounds;
  1399. this.fill = fill;
  1400. this.stroke = stroke;
  1401. this.strokewidth = (strokewidth != null) ? strokewidth : 1;
  1402. };
  1403. /**
  1404. * Extends mxShape.
  1405. */
  1406. mxUtils.extend(mxShapeIOS7Slider2, mxShape);
  1407. mxShapeIOS7Slider2.prototype.cst = {
  1408. SHAPE_SLIDER : 'mxgraph.ios7ui.slider',
  1409. BAR_POS : 'barPos',
  1410. HANDLE_SIZE : 'handleSize'
  1411. };
  1412. mxShapeIOS7Slider2.prototype.customProperties = [
  1413. {name: 'barPos', dispName: 'Handle Position', type: 'float', min:0, max:1, defVal:20},
  1414. {name: 'handleSize', dispName: 'Handle Size', type: 'float', min:0, defVal:10}
  1415. ];
  1416. /**
  1417. * Function: paintVertexShape
  1418. *
  1419. * Paints the vertex shape.
  1420. */
  1421. mxShapeIOS7Slider2.prototype.paintVertexShape = function(c, x, y, w, h)
  1422. {
  1423. c.translate(x, y);
  1424. this.background(c, x, y, w, h);
  1425. c.setShadow(true);
  1426. };
  1427. mxShapeIOS7Slider2.prototype.background = function(c, x, y, w, h)
  1428. {
  1429. var hSize = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.HANDLE_SIZE, '10'));
  1430. var barPos = parseFloat(mxUtils.getValue(this.style, mxShapeIOS7Slider2.prototype.cst.BAR_POS, '40')) / 100;
  1431. barPos = Math.max(0, Math.min(1, barPos));
  1432. c.save();
  1433. c.setStrokeColor('#bbbbbb');
  1434. c.begin();
  1435. c.moveTo(0, h * 0.5);
  1436. c.lineTo(w, h * 0.5);
  1437. c.fillAndStroke();
  1438. c.restore();
  1439. c.begin();
  1440. c.moveTo(0, h * 0.5);
  1441. c.lineTo(barPos * w, h * 0.5);
  1442. c.fillAndStroke();
  1443. c.setStrokeColor('#bbbbbb');
  1444. c.begin();
  1445. c.ellipse(barPos * w - hSize * 0.5, h * 0.5 - hSize * 0.5, hSize, hSize);
  1446. c.fillAndStroke();
  1447. };
  1448. mxCellRenderer.registerShape(mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER, mxShapeIOS7Slider2);
  1449. mxShapeIOS7Slider2.prototype.constraints = null;
  1450. Graph.handleFactory[mxShapeIOS7Slider2.prototype.cst.SHAPE_SLIDER] = function(state)
  1451. {
  1452. var handles = [Graph.createHandle(state, ['barPos'], function(bounds)
  1453. {
  1454. var barPos = Math.max(0, Math.min(bounds.width, parseFloat(mxUtils.getValue(this.state.style, 'barPos', 0.4))));
  1455. return new mxPoint(bounds.x + barPos * bounds.width / 100, bounds.y + bounds.height / 2);
  1456. }, function(bounds, pt)
  1457. {
  1458. this.state.style['barPos'] = Math.round(100 * Math.max(0, Math.min(100, (pt.x - bounds.x) * 100 / bounds.width))) / 100;
  1459. })];
  1460. return handles;
  1461. };