Helios-Layout.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. smalltalk.addPackage('Helios-Layout', {});
  2. smalltalk.addClass('HLContainer', smalltalk.Widget, ['splitter'], 'Helios-Layout');
  3. smalltalk.addMethod(
  4. "_renderOn_",
  5. smalltalk.method({
  6. selector: "renderOn:",
  7. category: 'rendering',
  8. fn: function (html){
  9. var self=this;
  10. var $1,$2;
  11. $1=smalltalk.send(html,"_div",[]);
  12. smalltalk.send($1,"_id_",["container"]);
  13. $2=smalltalk.send($1,"_with_",[smalltalk.send(self,"_splitter",[])]);
  14. smalltalk.send(smalltalk.send(window,"_jQuery_",[window]),"_bind_do_",["resize",(function(){
  15. return smalltalk.send(smalltalk.send(self,"_splitter",[]),"_resize",[]);
  16. })]);
  17. return self},
  18. args: ["html"],
  19. source: "renderOn: html\x0a\x09html div \x0a \x09id: 'container'; \x0a with: self splitter.\x0a \x0a (window jQuery: window) bind: 'resize' do: [ self splitter resize ]",
  20. messageSends: ["id:", "div", "with:", "splitter", "bind:do:", "resize", "jQuery:"],
  21. referencedClasses: []
  22. }),
  23. smalltalk.HLContainer);
  24. smalltalk.addMethod(
  25. "_splitter",
  26. smalltalk.method({
  27. selector: "splitter",
  28. category: 'accessing',
  29. fn: function (){
  30. var self=this;
  31. return self["@splitter"];
  32. },
  33. args: [],
  34. source: "splitter\x0a\x09^ splitter",
  35. messageSends: [],
  36. referencedClasses: []
  37. }),
  38. smalltalk.HLContainer);
  39. smalltalk.addMethod(
  40. "_splitter_",
  41. smalltalk.method({
  42. selector: "splitter:",
  43. category: 'accessing',
  44. fn: function (aSplitter){
  45. var self=this;
  46. self["@splitter"]=aSplitter;
  47. return self},
  48. args: ["aSplitter"],
  49. source: "splitter: aSplitter\x0a\x09splitter := aSplitter",
  50. messageSends: [],
  51. referencedClasses: []
  52. }),
  53. smalltalk.HLContainer);
  54. smalltalk.addMethod(
  55. "_with_",
  56. smalltalk.method({
  57. selector: "with:",
  58. category: 'instance creation',
  59. fn: function (aSplitter){
  60. var self=this;
  61. var $2,$3,$1;
  62. $2=smalltalk.send(self,"_new",[]);
  63. smalltalk.send($2,"_splitter_",[aSplitter]);
  64. $3=smalltalk.send($2,"_yourself",[]);
  65. $1=$3;
  66. return $1;
  67. },
  68. args: ["aSplitter"],
  69. source: "with: aSplitter\x0a\x09^ self new \x0a \x09splitter: aSplitter; \x0a yourself",
  70. messageSends: ["splitter:", "new", "yourself"],
  71. referencedClasses: []
  72. }),
  73. smalltalk.HLContainer.klass);
  74. smalltalk.addClass('HLPane', smalltalk.Widget, [], 'Helios-Layout');
  75. smalltalk.addClass('HLHorizontalPane', smalltalk.HLPane, [], 'Helios-Layout');
  76. smalltalk.addClass('HLVerticalPane', smalltalk.HLPane, [], 'Helios-Layout');
  77. smalltalk.addClass('HLSplitter', smalltalk.Widget, ['firstWidget', 'secondWidget', 'firstPane', 'secondPane', 'splitter'], 'Helios-Layout');
  78. smalltalk.addMethod(
  79. "_cssClass",
  80. smalltalk.method({
  81. selector: "cssClass",
  82. category: 'accessing',
  83. fn: function (){
  84. var self=this;
  85. return "splitter";
  86. },
  87. args: [],
  88. source: "cssClass\x0a\x09^ 'splitter'",
  89. messageSends: [],
  90. referencedClasses: []
  91. }),
  92. smalltalk.HLSplitter);
  93. smalltalk.addMethod(
  94. "_firstWidget",
  95. smalltalk.method({
  96. selector: "firstWidget",
  97. category: 'accessing',
  98. fn: function (){
  99. var self=this;
  100. return self["@firstWidget"];
  101. },
  102. args: [],
  103. source: "firstWidget\x0a\x09^ firstWidget",
  104. messageSends: [],
  105. referencedClasses: []
  106. }),
  107. smalltalk.HLSplitter);
  108. smalltalk.addMethod(
  109. "_firstWidget_",
  110. smalltalk.method({
  111. selector: "firstWidget:",
  112. category: 'accessing',
  113. fn: function (aWidget){
  114. var self=this;
  115. self["@firstWidget"]=aWidget;
  116. return self},
  117. args: ["aWidget"],
  118. source: "firstWidget: aWidget\x0a\x09firstWidget := aWidget",
  119. messageSends: [],
  120. referencedClasses: []
  121. }),
  122. smalltalk.HLSplitter);
  123. smalltalk.addMethod(
  124. "_isHeliosSplitter",
  125. smalltalk.method({
  126. selector: "isHeliosSplitter",
  127. category: 'testing',
  128. fn: function (){
  129. var self=this;
  130. return true;
  131. },
  132. args: [],
  133. source: "isHeliosSplitter\x0a\x09^ true",
  134. messageSends: [],
  135. referencedClasses: []
  136. }),
  137. smalltalk.HLSplitter);
  138. smalltalk.addMethod(
  139. "_panesCssClass",
  140. smalltalk.method({
  141. selector: "panesCssClass",
  142. category: 'rendering',
  143. fn: function (){
  144. var self=this;
  145. return "panes";
  146. },
  147. args: [],
  148. source: "panesCssClass\x0a\x09^ 'panes'",
  149. messageSends: [],
  150. referencedClasses: []
  151. }),
  152. smalltalk.HLSplitter);
  153. smalltalk.addMethod(
  154. "_renderOn_",
  155. smalltalk.method({
  156. selector: "renderOn:",
  157. category: 'rendering',
  158. fn: function (html){
  159. var self=this;
  160. var $1,$3,$4,$5,$6,$2,$7;
  161. $1=smalltalk.send(html,"_div",[]);
  162. smalltalk.send($1,"_class_",[smalltalk.send(self,"_panesCssClass",[])]);
  163. $2=smalltalk.send($1,"_with_",[(function(){
  164. $3=smalltalk.send(html,"_div",[]);
  165. smalltalk.send($3,"_class_",["pane"]);
  166. $4=smalltalk.send($3,"_with_",[smalltalk.send(self,"_firstWidget",[])]);
  167. self["@firstPane"]=$4;
  168. self["@firstPane"];
  169. self["@splitter"]=smalltalk.send(smalltalk.send(html,"_div",[]),"_class_",[smalltalk.send(self,"_cssClass",[])]);
  170. self["@splitter"];
  171. $5=smalltalk.send(html,"_div",[]);
  172. smalltalk.send($5,"_class_",["pane"]);
  173. $6=smalltalk.send($5,"_with_",[smalltalk.send(self,"_secondWidget",[])]);
  174. self["@secondPane"]=$6;
  175. return self["@secondPane"];
  176. })]);
  177. smalltalk.send(self,"_setupSplitter",[]);
  178. $7=smalltalk.send(self,"_resize",[]);
  179. return self},
  180. args: ["html"],
  181. source: "renderOn: html\x0a\x09html div class: self panesCssClass; with: [\x0a\x09\x09firstPane := html div class: 'pane'; with: self firstWidget.\x0a \x09splitter := html div class: self cssClass.\x0a \x09secondPane := html div class: 'pane'; with: self secondWidget ].\x0a \x0a\x09self \x0a \x09setupSplitter;\x0a resize",
  182. messageSends: ["class:", "panesCssClass", "div", "with:", "firstWidget", "cssClass", "secondWidget", "setupSplitter", "resize"],
  183. referencedClasses: []
  184. }),
  185. smalltalk.HLSplitter);
  186. smalltalk.addMethod(
  187. "_resize",
  188. smalltalk.method({
  189. selector: "resize",
  190. category: 'rendering',
  191. fn: function (){
  192. var self=this;
  193. var $1,$2;
  194. $1=smalltalk.send(smalltalk.send(self,"_firstWidget",[]),"_isHeliosSplitter",[]);
  195. if(smalltalk.assert($1)){
  196. smalltalk.send(smalltalk.send(self,"_firstWidget",[]),"_resize",[]);
  197. };
  198. $2=smalltalk.send(smalltalk.send(self,"_secondWidget",[]),"_isHeliosSplitter",[]);
  199. if(smalltalk.assert($2)){
  200. smalltalk.send(smalltalk.send(self,"_secondWidget",[]),"_resize",[]);
  201. };
  202. return self},
  203. args: [],
  204. source: "resize\x0a\x09self firstWidget isHeliosSplitter ifTrue: [ self firstWidget resize ].\x0a self secondWidget isHeliosSplitter ifTrue: [ self secondWidget resize ]\x0a \x0a ",
  205. messageSends: ["ifTrue:", "resize", "firstWidget", "isHeliosSplitter", "secondWidget"],
  206. referencedClasses: []
  207. }),
  208. smalltalk.HLSplitter);
  209. smalltalk.addMethod(
  210. "_secondWidget",
  211. smalltalk.method({
  212. selector: "secondWidget",
  213. category: 'accessing',
  214. fn: function (){
  215. var self=this;
  216. return self["@secondWidget"];
  217. },
  218. args: [],
  219. source: "secondWidget\x0a\x09^ secondWidget",
  220. messageSends: [],
  221. referencedClasses: []
  222. }),
  223. smalltalk.HLSplitter);
  224. smalltalk.addMethod(
  225. "_secondWidget_",
  226. smalltalk.method({
  227. selector: "secondWidget:",
  228. category: 'accessing',
  229. fn: function (aWidget){
  230. var self=this;
  231. self["@secondWidget"]=aWidget;
  232. return self},
  233. args: ["aWidget"],
  234. source: "secondWidget: aWidget\x0a\x09secondWidget := aWidget",
  235. messageSends: [],
  236. referencedClasses: []
  237. }),
  238. smalltalk.HLSplitter);
  239. smalltalk.addMethod(
  240. "_setupSplitter",
  241. smalltalk.method({
  242. selector: "setupSplitter",
  243. category: 'rendering',
  244. fn: function (){
  245. var self=this;
  246. return self},
  247. args: [],
  248. source: "setupSplitter",
  249. messageSends: [],
  250. referencedClasses: []
  251. }),
  252. smalltalk.HLSplitter);
  253. smalltalk.addMethod(
  254. "_with_with_",
  255. smalltalk.method({
  256. selector: "with:with:",
  257. category: 'instance creation',
  258. fn: function (aWidget,anotherWidget){
  259. var self=this;
  260. var $2,$3,$1;
  261. $2=smalltalk.send(self,"_new",[]);
  262. smalltalk.send($2,"_firstWidget_",[aWidget]);
  263. smalltalk.send($2,"_secondWidget_",[anotherWidget]);
  264. $3=smalltalk.send($2,"_yourself",[]);
  265. $1=$3;
  266. return $1;
  267. },
  268. args: ["aWidget", "anotherWidget"],
  269. source: "with: aWidget with: anotherWidget\x0a\x09^ self new\x0a \x09\x09firstWidget: aWidget;\x0a secondWidget: anotherWidget;\x0a yourself",
  270. messageSends: ["firstWidget:", "new", "secondWidget:", "yourself"],
  271. referencedClasses: []
  272. }),
  273. smalltalk.HLSplitter.klass);
  274. smalltalk.addClass('HLHorizontalSplitter', smalltalk.HLSplitter, [], 'Helios-Layout');
  275. smalltalk.addMethod(
  276. "_cssClass",
  277. smalltalk.method({
  278. selector: "cssClass",
  279. category: 'accessing',
  280. fn: function (){
  281. var self=this;
  282. var $1;
  283. $1=smalltalk.send(smalltalk.send(self,"_cssClass",[],smalltalk.HLSplitter),"__comma",[" horizontal"]);
  284. return $1;
  285. },
  286. args: [],
  287. source: "cssClass\x0a\x09^ super cssClass, ' horizontal'",
  288. messageSends: [",", "cssClass"],
  289. referencedClasses: []
  290. }),
  291. smalltalk.HLHorizontalSplitter);
  292. smalltalk.addMethod(
  293. "_panesCssClass",
  294. smalltalk.method({
  295. selector: "panesCssClass",
  296. category: 'accessing',
  297. fn: function (){
  298. var self=this;
  299. var $1;
  300. $1=smalltalk.send(smalltalk.send(self,"_panesCssClass",[],smalltalk.HLSplitter),"__comma",[" horizontal"]);
  301. return $1;
  302. },
  303. args: [],
  304. source: "panesCssClass\x0a\x09^ super panesCssClass, ' horizontal'",
  305. messageSends: [",", "panesCssClass"],
  306. referencedClasses: []
  307. }),
  308. smalltalk.HLHorizontalSplitter);
  309. smalltalk.addMethod(
  310. "_resize",
  311. smalltalk.method({
  312. selector: "resize",
  313. category: 'actions',
  314. fn: function (){
  315. var self=this;
  316. var container;
  317. var position;
  318. container=smalltalk.send(smalltalk.send(self["@firstPane"],"_asJQuery",[]),"_parent",[]);
  319. position=smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_offset",[]),"_top",[]),"__minus",[smalltalk.send(smalltalk.send(container,"_offset",[]),"_top",[])]);
  320. smalltalk.send(smalltalk.send(self["@firstPane"],"_asJQuery",[]),"_height_",[smalltalk.send(smalltalk.send(position,"_min_",[smalltalk.send(smalltalk.send(container,"_height",[]),"__minus",[(100)])]),"_max_",[(100)])]);
  321. smalltalk.send(smalltalk.send(self["@secondPane"],"_asJQuery",[]),"_height_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(container,"_height",[]),"__minus",[position]),"_min_",[smalltalk.send(smalltalk.send(container,"_height",[]),"__minus",[(100)])]),"_max_",[(100)]),"__minus",[(6)])]);
  322. smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_css_value_",["top",(0)]);
  323. smalltalk.send(self,"_resize",[],smalltalk.HLSplitter);
  324. return self},
  325. args: [],
  326. source: "resize\x0a\x09| container position |\x0a \x0a container := firstPane asJQuery parent.\x0a position := splitter asJQuery offset top - container offset top.\x0a \x0a\x09firstPane asJQuery height: ((position min: container height - 100) max: 100).\x0a secondPane asJQuery height: (((container height - position) min: container height - 100) max: 100) - 6.\x0a \x0a \x22Put the splitter div back to a relative position\x22 \x0a splitter asJQuery css: 'top' value: 0.\x0a \x0a super resize",
  327. messageSends: ["parent", "asJQuery", "-", "top", "offset", "height:", "max:", "min:", "height", "css:value:", "resize"],
  328. referencedClasses: []
  329. }),
  330. smalltalk.HLHorizontalSplitter);
  331. smalltalk.addMethod(
  332. "_setupSplitter",
  333. smalltalk.method({
  334. selector: "setupSplitter",
  335. category: 'rendering',
  336. fn: function (){
  337. var self=this;
  338. smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_draggable_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("axis","__minus_gt",["y"]),smalltalk.send("stop","__minus_gt",[(function(){
  339. return smalltalk.send(self,"_resize",[]);
  340. })])])]);
  341. return self},
  342. args: [],
  343. source: "setupSplitter\x0a\x09splitter asJQuery draggable: #{ 'axis' -> 'y'. 'stop' -> [ self resize ] }",
  344. messageSends: ["draggable:", "->", "resize", "asJQuery"],
  345. referencedClasses: []
  346. }),
  347. smalltalk.HLHorizontalSplitter);
  348. smalltalk.addClass('HLVerticalSplitter', smalltalk.HLSplitter, [], 'Helios-Layout');
  349. smalltalk.addMethod(
  350. "_cssClass",
  351. smalltalk.method({
  352. selector: "cssClass",
  353. category: 'accessing',
  354. fn: function (){
  355. var self=this;
  356. var $1;
  357. $1=smalltalk.send(smalltalk.send(self,"_cssClass",[],smalltalk.HLSplitter),"__comma",[" vertical"]);
  358. return $1;
  359. },
  360. args: [],
  361. source: "cssClass\x0a\x09^ super cssClass, ' vertical'",
  362. messageSends: [",", "cssClass"],
  363. referencedClasses: []
  364. }),
  365. smalltalk.HLVerticalSplitter);
  366. smalltalk.addMethod(
  367. "_panesCssClass",
  368. smalltalk.method({
  369. selector: "panesCssClass",
  370. category: 'accessing',
  371. fn: function (){
  372. var self=this;
  373. var $1;
  374. $1=smalltalk.send(smalltalk.send(self,"_panesCssClass",[],smalltalk.HLSplitter),"__comma",[" vertical"]);
  375. return $1;
  376. },
  377. args: [],
  378. source: "panesCssClass\x0a\x09^ super panesCssClass, ' vertical'",
  379. messageSends: [",", "panesCssClass"],
  380. referencedClasses: []
  381. }),
  382. smalltalk.HLVerticalSplitter);
  383. smalltalk.addMethod(
  384. "_resize",
  385. smalltalk.method({
  386. selector: "resize",
  387. category: 'actions',
  388. fn: function (){
  389. var self=this;
  390. var container;
  391. var position;
  392. container=smalltalk.send(smalltalk.send(self["@firstPane"],"_asJQuery",[]),"_parent",[]);
  393. position=smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_offset",[]),"_left",[]),"__minus",[smalltalk.send(smalltalk.send(container,"_offset",[]),"_left",[])]);
  394. smalltalk.send(smalltalk.send(self["@firstPane"],"_asJQuery",[]),"_width_",[smalltalk.send(smalltalk.send(position,"_min_",[smalltalk.send(smalltalk.send(container,"_width",[]),"__minus",[(100)])]),"_max_",[(100)])]);
  395. smalltalk.send(smalltalk.send(self["@secondPane"],"_asJQuery",[]),"_width_",[smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(container,"_width",[]),"__minus",[position]),"_min_",[smalltalk.send(smalltalk.send(container,"_width",[]),"__minus",[(100)])]),"_max_",[(100)]),"__minus",[(6)])]);
  396. smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_css_value_",["left",(0)]);
  397. smalltalk.send(self,"_resize",[],smalltalk.HLSplitter);
  398. return self},
  399. args: [],
  400. source: "resize\x0a\x09| container position |\x0a \x0a container := firstPane asJQuery parent.\x0a position := splitter asJQuery offset left - container offset left.\x0a \x0a\x09firstPane asJQuery width: ((position min: container width - 100) max: 100).\x0a secondPane asJQuery width: (((container width - position) min: container width - 100) max: 100) - 6.\x0a \x0a \x22Put the splitter div back to a relative position\x22 \x0a splitter asJQuery css: 'left' value: 0.\x0a \x0a super resize",
  401. messageSends: ["parent", "asJQuery", "-", "left", "offset", "width:", "max:", "min:", "width", "css:value:", "resize"],
  402. referencedClasses: []
  403. }),
  404. smalltalk.HLVerticalSplitter);
  405. smalltalk.addMethod(
  406. "_setupSplitter",
  407. smalltalk.method({
  408. selector: "setupSplitter",
  409. category: 'rendering',
  410. fn: function (){
  411. var self=this;
  412. smalltalk.send(smalltalk.send(self["@splitter"],"_asJQuery",[]),"_draggable_",[smalltalk.HashedCollection._fromPairs_([smalltalk.send("axis","__minus_gt",["x"]),smalltalk.send("stop","__minus_gt",[(function(){
  413. return smalltalk.send(self,"_resize",[]);
  414. })])])]);
  415. return self},
  416. args: [],
  417. source: "setupSplitter\x0a\x09splitter asJQuery draggable: #{ 'axis' -> 'x'. 'stop' -> [ self resize ] }",
  418. messageSends: ["draggable:", "->", "resize", "asJQuery"],
  419. referencedClasses: []
  420. }),
  421. smalltalk.HLVerticalSplitter);
  422. smalltalk.addMethod(
  423. "_isHeliosSplitter",
  424. smalltalk.method({
  425. selector: "isHeliosSplitter",
  426. category: '*Helios-Layout',
  427. fn: function (){
  428. var self=this;
  429. return false;
  430. },
  431. args: [],
  432. source: "isHeliosSplitter\x0a\x09^ false",
  433. messageSends: [],
  434. referencedClasses: []
  435. }),
  436. smalltalk.Object);