mxIOS7Ui.js 46 KB

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