Moka-Layouts.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. define("amber_core/Moka-Layouts", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_vm/globals", "amber_core/Kernel-Objects", "amber_core/Kernel-Collections"], function(smalltalk,nil,_st, globals){
  2. smalltalk.addPackage('Moka-Layouts');
  3. smalltalk.packages["Moka-Layouts"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('MKLayout', globals.Object, ['properties'], 'Moka-Layouts');
  5. globals.MKLayout.comment="I am responsible for the layout of a `MKLayoutView`.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "asCssString",
  9. protocol: 'converting',
  10. fn: function (){
  11. var self=this;
  12. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  13. return smalltalk.withContext(function($ctx1) {
  14. var $1;
  15. $1=_st($String())._streamContents_((function(stream){
  16. return smalltalk.withContext(function($ctx2) {
  17. return _st(self["@properties"])._valuesDo_((function(each){
  18. return smalltalk.withContext(function($ctx3) {
  19. _st(each)._printCssOn_(stream);
  20. return _st(stream).__lt_lt(";");
  21. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,2)})}));
  22. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
  23. return $1;
  24. }, function($ctx1) {$ctx1.fill(self,"asCssString",{},globals.MKLayout)})},
  25. args: [],
  26. source: "asCssString\x0a\x09^ String streamContents: [ :stream |\x0a\x09\x09properties valuesDo: [ :each | \x0a\x09\x09\x09each printCssOn: stream.\x0a\x09\x09\x09stream << ';' ] ]",
  27. messageSends: ["streamContents:", "valuesDo:", "printCssOn:", "<<"],
  28. referencedClasses: ["String"]
  29. }),
  30. globals.MKLayout);
  31. smalltalk.addMethod(
  32. smalltalk.method({
  33. selector: "bottom:",
  34. protocol: 'accessing',
  35. fn: function (aNumber){
  36. var self=this;
  37. return smalltalk.withContext(function($ctx1) {
  38. var $1;
  39. _st(self["@properties"])._at_put_("bottom",self._propertyLabelled_value_("bottom",aNumber));
  40. $1=self._hasProperty_("top");
  41. if(smalltalk.assert($1)){
  42. self._removeProperty_("height");
  43. $ctx1.sendIdx["removeProperty:"]=1;
  44. };
  45. self._removeProperty_("centerY");
  46. return self}, function($ctx1) {$ctx1.fill(self,"bottom:",{aNumber:aNumber},globals.MKLayout)})},
  47. args: ["aNumber"],
  48. source: "bottom: aNumber\x0a\x09properties \x0a\x09\x09at: 'bottom' \x0a\x09\x09put: (self propertyLabelled: 'bottom' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'top') ifTrue: [\x0a\x09\x09self removeProperty: 'height' ].\x0a\x09self removeProperty: 'centerY'",
  49. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  50. referencedClasses: []
  51. }),
  52. globals.MKLayout);
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "centerX:",
  56. protocol: 'accessing',
  57. fn: function (aNumber){
  58. var self=this;
  59. function $MKHorizontalCenteringLayoutProperty(){return globals.MKHorizontalCenteringLayoutProperty||(typeof MKHorizontalCenteringLayoutProperty=="undefined"?nil:MKHorizontalCenteringLayoutProperty)}
  60. return smalltalk.withContext(function($ctx1) {
  61. var $1;
  62. _st(self["@properties"])._at_put_("centerX",_st($MKHorizontalCenteringLayoutProperty())._layout_value_(self,aNumber));
  63. self._removeProperty_("left");
  64. $ctx1.sendIdx["removeProperty:"]=1;
  65. $1=self._removeProperty_("right");
  66. return self}, function($ctx1) {$ctx1.fill(self,"centerX:",{aNumber:aNumber},globals.MKLayout)})},
  67. args: ["aNumber"],
  68. source: "centerX: aNumber\x0a\x09properties\x0a\x09\x09at: 'centerX'\x0a\x09\x09put: (MKHorizontalCenteringLayoutProperty layout: self value: aNumber).\x0a\x09\x0a\x09self \x0a\x09\x09removeProperty: 'left';\x0a\x09\x09removeProperty: 'right'",
  69. messageSends: ["at:put:", "layout:value:", "removeProperty:"],
  70. referencedClasses: ["MKHorizontalCenteringLayoutProperty"]
  71. }),
  72. globals.MKLayout);
  73. smalltalk.addMethod(
  74. smalltalk.method({
  75. selector: "centerY:",
  76. protocol: 'accessing',
  77. fn: function (aNumber){
  78. var self=this;
  79. function $MKVerticalCenteringLayoutProperty(){return globals.MKVerticalCenteringLayoutProperty||(typeof MKVerticalCenteringLayoutProperty=="undefined"?nil:MKVerticalCenteringLayoutProperty)}
  80. return smalltalk.withContext(function($ctx1) {
  81. var $1;
  82. _st(self["@properties"])._at_put_("centerY",_st($MKVerticalCenteringLayoutProperty())._layout_value_(self,aNumber));
  83. self._removeProperty_("top");
  84. $ctx1.sendIdx["removeProperty:"]=1;
  85. $1=self._removeProperty_("bottom");
  86. return self}, function($ctx1) {$ctx1.fill(self,"centerY:",{aNumber:aNumber},globals.MKLayout)})},
  87. args: ["aNumber"],
  88. source: "centerY: aNumber\x0a\x09properties\x0a\x09\x09at: 'centerY'\x0a\x09\x09put: (MKVerticalCenteringLayoutProperty layout: self value: aNumber).\x0a\x09\x09\x0a\x09self \x0a\x09\x09removeProperty: 'top';\x0a\x09\x09removeProperty: 'bottom'",
  89. messageSends: ["at:put:", "layout:value:", "removeProperty:"],
  90. referencedClasses: ["MKVerticalCenteringLayoutProperty"]
  91. }),
  92. globals.MKLayout);
  93. smalltalk.addMethod(
  94. smalltalk.method({
  95. selector: "hasProperty:",
  96. protocol: 'private',
  97. fn: function (aString){
  98. var self=this;
  99. return smalltalk.withContext(function($ctx1) {
  100. var $1;
  101. $1=_st(self["@properties"])._includesKey_(aString);
  102. return $1;
  103. }, function($ctx1) {$ctx1.fill(self,"hasProperty:",{aString:aString},globals.MKLayout)})},
  104. args: ["aString"],
  105. source: "hasProperty: aString\x0a\x09^ properties includesKey: aString",
  106. messageSends: ["includesKey:"],
  107. referencedClasses: []
  108. }),
  109. globals.MKLayout);
  110. smalltalk.addMethod(
  111. smalltalk.method({
  112. selector: "height",
  113. protocol: 'accessing',
  114. fn: function (){
  115. var self=this;
  116. return smalltalk.withContext(function($ctx1) {
  117. var $1;
  118. $1=_st(self["@properties"])._at_ifPresent_ifAbsent_("height",(function(property){
  119. return smalltalk.withContext(function($ctx2) {
  120. return _st(property)._value();
  121. }, function($ctx2) {$ctx2.fillBlock({property:property},$ctx1,1)})}),(function(){
  122. return smalltalk.withContext(function($ctx2) {
  123. return (1);
  124. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  125. return $1;
  126. }, function($ctx1) {$ctx1.fill(self,"height",{},globals.MKLayout)})},
  127. args: [],
  128. source: "height\x0a\x09^ properties \x0a\x09\x09at: 'height' \x0a\x09\x09ifPresent: [ :property | property value ]\x0a\x09\x09ifAbsent: [ 1 ]",
  129. messageSends: ["at:ifPresent:ifAbsent:", "value"],
  130. referencedClasses: []
  131. }),
  132. globals.MKLayout);
  133. smalltalk.addMethod(
  134. smalltalk.method({
  135. selector: "height:",
  136. protocol: 'accessing',
  137. fn: function (aNumber){
  138. var self=this;
  139. return smalltalk.withContext(function($ctx1) {
  140. var $1;
  141. _st(self["@properties"])._at_put_("height",self._propertyLabelled_value_("height",aNumber));
  142. $1=self._hasProperty_("top");
  143. if(smalltalk.assert($1)){
  144. self._removeProperty_("bottom");
  145. };
  146. return self}, function($ctx1) {$ctx1.fill(self,"height:",{aNumber:aNumber},globals.MKLayout)})},
  147. args: ["aNumber"],
  148. source: "height: aNumber\x0a\x09properties \x0a\x09\x09at: 'height' \x0a\x09\x09put: (self propertyLabelled: 'height' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'top') ifTrue: [\x0a\x09\x09self removeProperty: 'bottom' ]",
  149. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  150. referencedClasses: []
  151. }),
  152. globals.MKLayout);
  153. smalltalk.addMethod(
  154. smalltalk.method({
  155. selector: "initialize",
  156. protocol: 'initialization',
  157. fn: function (){
  158. var self=this;
  159. function $Dictionary(){return globals.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  160. return smalltalk.withContext(function($ctx1) {
  161. globals.MKLayout.superclass.fn.prototype._initialize.apply(_st(self), []);
  162. self["@properties"]=_st($Dictionary())._new();
  163. return self}, function($ctx1) {$ctx1.fill(self,"initialize",{},globals.MKLayout)})},
  164. args: [],
  165. source: "initialize\x0a\x09super initialize.\x0a\x09properties := Dictionary new",
  166. messageSends: ["initialize", "new"],
  167. referencedClasses: ["Dictionary"]
  168. }),
  169. globals.MKLayout);
  170. smalltalk.addMethod(
  171. smalltalk.method({
  172. selector: "left:",
  173. protocol: 'accessing',
  174. fn: function (aNumber){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx1) {
  177. var $1;
  178. _st(self["@properties"])._at_put_("left",self._propertyLabelled_value_("left",aNumber));
  179. $1=self._hasProperty_("width");
  180. if(smalltalk.assert($1)){
  181. self._removeProperty_("right");
  182. $ctx1.sendIdx["removeProperty:"]=1;
  183. };
  184. self._removeProperty_("centerX");
  185. return self}, function($ctx1) {$ctx1.fill(self,"left:",{aNumber:aNumber},globals.MKLayout)})},
  186. args: ["aNumber"],
  187. source: "left: aNumber\x0a\x09properties \x0a\x09\x09at: 'left' \x0a\x09\x09put: (self propertyLabelled: 'left' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'width') ifTrue: [\x0a\x09\x09self removeProperty: 'right' ].\x0a\x09self removeProperty: 'centerX'",
  188. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  189. referencedClasses: []
  190. }),
  191. globals.MKLayout);
  192. smalltalk.addMethod(
  193. smalltalk.method({
  194. selector: "propertyLabelled:value:",
  195. protocol: 'factory',
  196. fn: function (aString,aValue){
  197. var self=this;
  198. function $MKLabelledLayoutProperty(){return globals.MKLabelledLayoutProperty||(typeof MKLabelledLayoutProperty=="undefined"?nil:MKLabelledLayoutProperty)}
  199. return smalltalk.withContext(function($ctx1) {
  200. var $1;
  201. $1=_st($MKLabelledLayoutProperty())._layout_label_value_(self,aString,aValue);
  202. return $1;
  203. }, function($ctx1) {$ctx1.fill(self,"propertyLabelled:value:",{aString:aString,aValue:aValue},globals.MKLayout)})},
  204. args: ["aString", "aValue"],
  205. source: "propertyLabelled: aString value: aValue\x0a\x09^ MKLabelledLayoutProperty layout: self label: aString value: aValue",
  206. messageSends: ["layout:label:value:"],
  207. referencedClasses: ["MKLabelledLayoutProperty"]
  208. }),
  209. globals.MKLayout);
  210. smalltalk.addMethod(
  211. smalltalk.method({
  212. selector: "removeProperty:",
  213. protocol: 'private',
  214. fn: function (aString){
  215. var self=this;
  216. return smalltalk.withContext(function($ctx1) {
  217. _st(self["@properties"])._remove_ifAbsent_(aString,(function(){
  218. return smalltalk.withContext(function($ctx2) {
  219. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  220. return self}, function($ctx1) {$ctx1.fill(self,"removeProperty:",{aString:aString},globals.MKLayout)})},
  221. args: ["aString"],
  222. source: "removeProperty: aString\x0a\x09properties remove: aString ifAbsent: []",
  223. messageSends: ["remove:ifAbsent:"],
  224. referencedClasses: []
  225. }),
  226. globals.MKLayout);
  227. smalltalk.addMethod(
  228. smalltalk.method({
  229. selector: "right:",
  230. protocol: 'accessing',
  231. fn: function (aNumber){
  232. var self=this;
  233. return smalltalk.withContext(function($ctx1) {
  234. var $1;
  235. _st(self["@properties"])._at_put_("right",self._propertyLabelled_value_("right",aNumber));
  236. $1=self._hasProperty_("width");
  237. if(smalltalk.assert($1)){
  238. self._removeProperty_("left");
  239. $ctx1.sendIdx["removeProperty:"]=1;
  240. };
  241. self._removeProperty_("centerX");
  242. return self}, function($ctx1) {$ctx1.fill(self,"right:",{aNumber:aNumber},globals.MKLayout)})},
  243. args: ["aNumber"],
  244. source: "right: aNumber\x0a\x09properties \x0a\x09\x09at: 'right' \x0a\x09\x09put: (self propertyLabelled: 'right' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'width') ifTrue: [\x0a\x09\x09self removeProperty: 'left' ].\x0a\x09self removeProperty: 'centerX'",
  245. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  246. referencedClasses: []
  247. }),
  248. globals.MKLayout);
  249. smalltalk.addMethod(
  250. smalltalk.method({
  251. selector: "top:",
  252. protocol: 'accessing',
  253. fn: function (aNumber){
  254. var self=this;
  255. return smalltalk.withContext(function($ctx1) {
  256. var $1;
  257. _st(self["@properties"])._at_put_("top",self._propertyLabelled_value_("top",aNumber));
  258. $1=self._hasProperty_("height");
  259. if(smalltalk.assert($1)){
  260. self._removeProperty_("bottom");
  261. $ctx1.sendIdx["removeProperty:"]=1;
  262. };
  263. self._removeProperty_("centerY");
  264. return self}, function($ctx1) {$ctx1.fill(self,"top:",{aNumber:aNumber},globals.MKLayout)})},
  265. args: ["aNumber"],
  266. source: "top: aNumber\x0a\x09properties \x0a\x09\x09at: 'top' \x0a\x09\x09put: (self propertyLabelled: 'top' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'height') ifTrue: [\x0a\x09\x09self removeProperty: 'bottom' ].\x0a\x09self removeProperty: 'centerY'",
  267. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  268. referencedClasses: []
  269. }),
  270. globals.MKLayout);
  271. smalltalk.addMethod(
  272. smalltalk.method({
  273. selector: "width",
  274. protocol: 'accessing',
  275. fn: function (){
  276. var self=this;
  277. return smalltalk.withContext(function($ctx1) {
  278. var $1;
  279. $1=_st(self["@properties"])._at_ifPresent_ifAbsent_("width",(function(property){
  280. return smalltalk.withContext(function($ctx2) {
  281. return _st(property)._value();
  282. }, function($ctx2) {$ctx2.fillBlock({property:property},$ctx1,1)})}),(function(){
  283. return smalltalk.withContext(function($ctx2) {
  284. return (1);
  285. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  286. return $1;
  287. }, function($ctx1) {$ctx1.fill(self,"width",{},globals.MKLayout)})},
  288. args: [],
  289. source: "width\x0a\x09^ properties \x0a\x09\x09at: 'width' \x0a\x09\x09ifPresent: [ :property | property value ]\x0a\x09\x09ifAbsent: [ 1 ]",
  290. messageSends: ["at:ifPresent:ifAbsent:", "value"],
  291. referencedClasses: []
  292. }),
  293. globals.MKLayout);
  294. smalltalk.addMethod(
  295. smalltalk.method({
  296. selector: "width:",
  297. protocol: 'accessing',
  298. fn: function (aNumber){
  299. var self=this;
  300. return smalltalk.withContext(function($ctx1) {
  301. var $1;
  302. _st(self["@properties"])._at_put_("width",self._propertyLabelled_value_("width",aNumber));
  303. $1=self._hasProperty_("left");
  304. if(smalltalk.assert($1)){
  305. self._removeProperty_("right");
  306. };
  307. return self}, function($ctx1) {$ctx1.fill(self,"width:",{aNumber:aNumber},globals.MKLayout)})},
  308. args: ["aNumber"],
  309. source: "width: aNumber\x0a\x09properties \x0a\x09\x09at: 'width' \x0a\x09\x09put: (self propertyLabelled: 'width' value: aNumber).\x0a\x09\x0a\x09(self hasProperty: 'left') ifTrue: [\x0a\x09\x09self removeProperty: 'right' ]",
  310. messageSends: ["at:put:", "propertyLabelled:value:", "ifTrue:", "hasProperty:", "removeProperty:"],
  311. referencedClasses: []
  312. }),
  313. globals.MKLayout);
  314. smalltalk.addClass('MKLabelLayout', globals.MKLayout, [], 'Moka-Layouts');
  315. globals.MKLabelLayout.comment="I am a specialized layout for label views. I can set a `textAlign` property, taking a string argument, `'left'`, `'center'` or `'right'`.";
  316. smalltalk.addMethod(
  317. smalltalk.method({
  318. selector: "textAlign:",
  319. protocol: 'accessing',
  320. fn: function (aString){
  321. var self=this;
  322. return smalltalk.withContext(function($ctx1) {
  323. _st(self["@properties"])._at_put_("text-align",self._propertyLabelled_value_("text-align",aString));
  324. return self}, function($ctx1) {$ctx1.fill(self,"textAlign:",{aString:aString},globals.MKLabelLayout)})},
  325. args: ["aString"],
  326. source: "textAlign: aString\x0a\x09\x22Map to CSS' text-align property. Possible values are `'left'`, `'center'` and `'right'`\x22\x0a\x09\x0a\x09properties \x0a\x09\x09at: 'text-align' \x0a\x09\x09put: (self propertyLabelled: 'text-align' value: aString)",
  327. messageSends: ["at:put:", "propertyLabelled:value:"],
  328. referencedClasses: []
  329. }),
  330. globals.MKLabelLayout);
  331. smalltalk.addClass('MKPaneLayout', globals.MKLayout, [], 'Moka-Layouts');
  332. globals.MKPaneLayout.comment="I am a specialized layout for pane views. I can set border widths to my views.";
  333. smalltalk.addMethod(
  334. smalltalk.method({
  335. selector: "borderBottom:",
  336. protocol: 'accessing',
  337. fn: function (aNumber){
  338. var self=this;
  339. return smalltalk.withContext(function($ctx1) {
  340. _st(self["@properties"])._at_put_("border-bottom",self._propertyLabelled_value_("border-bottom-width",_st(aNumber)._asMokaPixelString()));
  341. return self}, function($ctx1) {$ctx1.fill(self,"borderBottom:",{aNumber:aNumber},globals.MKPaneLayout)})},
  342. args: ["aNumber"],
  343. source: "borderBottom: aNumber\x0a\x09properties \x0a\x09\x09at: 'border-bottom' \x0a\x09\x09put: (self propertyLabelled: 'border-bottom-width' value: aNumber asMokaPixelString)",
  344. messageSends: ["at:put:", "propertyLabelled:value:", "asMokaPixelString"],
  345. referencedClasses: []
  346. }),
  347. globals.MKPaneLayout);
  348. smalltalk.addMethod(
  349. smalltalk.method({
  350. selector: "borderLeft:",
  351. protocol: 'accessing',
  352. fn: function (aNumber){
  353. var self=this;
  354. return smalltalk.withContext(function($ctx1) {
  355. _st(self["@properties"])._at_put_("border-left",self._propertyLabelled_value_("border-left-width",_st(aNumber)._asMokaPixelString()));
  356. return self}, function($ctx1) {$ctx1.fill(self,"borderLeft:",{aNumber:aNumber},globals.MKPaneLayout)})},
  357. args: ["aNumber"],
  358. source: "borderLeft: aNumber\x0a\x09properties \x0a\x09\x09at: 'border-left' \x0a\x09\x09put: (self propertyLabelled: 'border-left-width' value: aNumber asMokaPixelString)",
  359. messageSends: ["at:put:", "propertyLabelled:value:", "asMokaPixelString"],
  360. referencedClasses: []
  361. }),
  362. globals.MKPaneLayout);
  363. smalltalk.addMethod(
  364. smalltalk.method({
  365. selector: "borderRight:",
  366. protocol: 'accessing',
  367. fn: function (aNumber){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) {
  370. _st(self["@properties"])._at_put_("border-right",self._propertyLabelled_value_("border-right-width",_st(aNumber)._asMokaPixelString()));
  371. return self}, function($ctx1) {$ctx1.fill(self,"borderRight:",{aNumber:aNumber},globals.MKPaneLayout)})},
  372. args: ["aNumber"],
  373. source: "borderRight: aNumber\x0a\x09properties \x0a\x09\x09at: 'border-right' \x0a\x09\x09put: (self propertyLabelled: 'border-right-width' value: aNumber asMokaPixelString)",
  374. messageSends: ["at:put:", "propertyLabelled:value:", "asMokaPixelString"],
  375. referencedClasses: []
  376. }),
  377. globals.MKPaneLayout);
  378. smalltalk.addMethod(
  379. smalltalk.method({
  380. selector: "borderTop:",
  381. protocol: 'accessing',
  382. fn: function (aNumber){
  383. var self=this;
  384. return smalltalk.withContext(function($ctx1) {
  385. _st(self["@properties"])._at_put_("border-top",self._propertyLabelled_value_("border-top-width",_st(aNumber)._asMokaPixelString()));
  386. return self}, function($ctx1) {$ctx1.fill(self,"borderTop:",{aNumber:aNumber},globals.MKPaneLayout)})},
  387. args: ["aNumber"],
  388. source: "borderTop: aNumber\x0a\x09properties \x0a\x09\x09at: 'border-top' \x0a\x09\x09put: (self propertyLabelled: 'border-top-width' value: aNumber asMokaPixelString)",
  389. messageSends: ["at:put:", "propertyLabelled:value:", "asMokaPixelString"],
  390. referencedClasses: []
  391. }),
  392. globals.MKPaneLayout);
  393. smalltalk.addClass('MKLayoutProperty', globals.Object, ['layout', 'value'], 'Moka-Layouts');
  394. globals.MKLayoutProperty.comment="I represent a single layout property.";
  395. smalltalk.addMethod(
  396. smalltalk.method({
  397. selector: "asCssString",
  398. protocol: 'converting',
  399. fn: function (){
  400. var self=this;
  401. function $String(){return globals.String||(typeof String=="undefined"?nil:String)}
  402. return smalltalk.withContext(function($ctx1) {
  403. var $1;
  404. $1=_st($String())._streamContents_((function(stream){
  405. return smalltalk.withContext(function($ctx2) {
  406. return self._printCssOn_(stream);
  407. }, function($ctx2) {$ctx2.fillBlock({stream:stream},$ctx1,1)})}));
  408. return $1;
  409. }, function($ctx1) {$ctx1.fill(self,"asCssString",{},globals.MKLayoutProperty)})},
  410. args: [],
  411. source: "asCssString\x0a\x09^ String streamContents: [ :stream | \x0a\x09\x09self printCssOn: stream ]",
  412. messageSends: ["streamContents:", "printCssOn:"],
  413. referencedClasses: ["String"]
  414. }),
  415. globals.MKLayoutProperty);
  416. smalltalk.addMethod(
  417. smalltalk.method({
  418. selector: "layout",
  419. protocol: 'accessing',
  420. fn: function (){
  421. var self=this;
  422. var $1;
  423. $1=self["@layout"];
  424. return $1;
  425. },
  426. args: [],
  427. source: "layout\x0a\x09^ layout",
  428. messageSends: [],
  429. referencedClasses: []
  430. }),
  431. globals.MKLayoutProperty);
  432. smalltalk.addMethod(
  433. smalltalk.method({
  434. selector: "layout:",
  435. protocol: 'accessing',
  436. fn: function (aLayout){
  437. var self=this;
  438. self["@layout"]=aLayout;
  439. return self},
  440. args: ["aLayout"],
  441. source: "layout: aLayout\x0a\x09layout := aLayout",
  442. messageSends: [],
  443. referencedClasses: []
  444. }),
  445. globals.MKLayoutProperty);
  446. smalltalk.addMethod(
  447. smalltalk.method({
  448. selector: "printCssOn:",
  449. protocol: 'printing',
  450. fn: function (aStream){
  451. var self=this;
  452. return smalltalk.withContext(function($ctx1) {
  453. self._subclassResponsibility();
  454. return self}, function($ctx1) {$ctx1.fill(self,"printCssOn:",{aStream:aStream},globals.MKLayoutProperty)})},
  455. args: ["aStream"],
  456. source: "printCssOn: aStream\x0a\x09self subclassResponsibility",
  457. messageSends: ["subclassResponsibility"],
  458. referencedClasses: []
  459. }),
  460. globals.MKLayoutProperty);
  461. smalltalk.addMethod(
  462. smalltalk.method({
  463. selector: "value",
  464. protocol: 'accessing',
  465. fn: function (){
  466. var self=this;
  467. var $1;
  468. $1=self["@value"];
  469. return $1;
  470. },
  471. args: [],
  472. source: "value\x0a\x09^ value",
  473. messageSends: [],
  474. referencedClasses: []
  475. }),
  476. globals.MKLayoutProperty);
  477. smalltalk.addMethod(
  478. smalltalk.method({
  479. selector: "value:",
  480. protocol: 'accessing',
  481. fn: function (aValue){
  482. var self=this;
  483. self["@value"]=aValue;
  484. return self},
  485. args: ["aValue"],
  486. source: "value: aValue\x0a\x09value := aValue",
  487. messageSends: [],
  488. referencedClasses: []
  489. }),
  490. globals.MKLayoutProperty);
  491. smalltalk.addMethod(
  492. smalltalk.method({
  493. selector: "layout:value:",
  494. protocol: 'instance creation',
  495. fn: function (aLayout,aValue){
  496. var self=this;
  497. return smalltalk.withContext(function($ctx1) {
  498. var $2,$3,$1;
  499. $2=self._new();
  500. _st($2)._layout_(aLayout);
  501. _st($2)._value_(aValue);
  502. $3=_st($2)._yourself();
  503. $1=$3;
  504. return $1;
  505. }, function($ctx1) {$ctx1.fill(self,"layout:value:",{aLayout:aLayout,aValue:aValue},globals.MKLayoutProperty.klass)})},
  506. args: ["aLayout", "aValue"],
  507. source: "layout: aLayout value: aValue\x0a\x09^ self new\x0a\x09\x09layout: aLayout;\x0a\x09\x09value: aValue;\x0a\x09\x09yourself",
  508. messageSends: ["layout:", "new", "value:", "yourself"],
  509. referencedClasses: []
  510. }),
  511. globals.MKLayoutProperty.klass);
  512. smalltalk.addClass('MKHorizontalCenteringLayoutProperty', globals.MKLayoutProperty, [], 'Moka-Layouts');
  513. smalltalk.addMethod(
  514. smalltalk.method({
  515. selector: "marginLeft",
  516. protocol: 'accessing',
  517. fn: function (){
  518. var self=this;
  519. return smalltalk.withContext(function($ctx1) {
  520. var $1;
  521. $1=(0).__minus(_st(_st(_st(self._layout())._width()).__slash((2))).__plus(self._value()));
  522. return $1;
  523. }, function($ctx1) {$ctx1.fill(self,"marginLeft",{},globals.MKHorizontalCenteringLayoutProperty)})},
  524. args: [],
  525. source: "marginLeft\x0a\x09^ 0 - ((self layout width / 2) + self value)",
  526. messageSends: ["-", "+", "/", "width", "layout", "value"],
  527. referencedClasses: []
  528. }),
  529. globals.MKHorizontalCenteringLayoutProperty);
  530. smalltalk.addMethod(
  531. smalltalk.method({
  532. selector: "printCssOn:",
  533. protocol: 'printing',
  534. fn: function (aStream){
  535. var self=this;
  536. return smalltalk.withContext(function($ctx1) {
  537. _st(aStream).__lt_lt("left:50%;");
  538. $ctx1.sendIdx["<<"]=1;
  539. _st(_st(aStream).__lt_lt("margin-left:")).__lt_lt(_st(self._marginLeft())._asMokaCssString());
  540. $ctx1.sendIdx["<<"]=2;
  541. return self}, function($ctx1) {$ctx1.fill(self,"printCssOn:",{aStream:aStream},globals.MKHorizontalCenteringLayoutProperty)})},
  542. args: ["aStream"],
  543. source: "printCssOn: aStream\x0a\x09aStream << 'left:50%;'.\x0a\x09aStream << 'margin-left:' << self marginLeft asMokaCssString",
  544. messageSends: ["<<", "asMokaCssString", "marginLeft"],
  545. referencedClasses: []
  546. }),
  547. globals.MKHorizontalCenteringLayoutProperty);
  548. smalltalk.addClass('MKLabelledLayoutProperty', globals.MKLayoutProperty, ['label'], 'Moka-Layouts');
  549. smalltalk.addMethod(
  550. smalltalk.method({
  551. selector: "label",
  552. protocol: 'accessing',
  553. fn: function (){
  554. var self=this;
  555. var $1;
  556. $1=self["@label"];
  557. return $1;
  558. },
  559. args: [],
  560. source: "label\x0a\x09^ label",
  561. messageSends: [],
  562. referencedClasses: []
  563. }),
  564. globals.MKLabelledLayoutProperty);
  565. smalltalk.addMethod(
  566. smalltalk.method({
  567. selector: "label:",
  568. protocol: 'accessing',
  569. fn: function (aString){
  570. var self=this;
  571. self["@label"]=aString;
  572. return self},
  573. args: ["aString"],
  574. source: "label: aString\x0a\x09label := aString",
  575. messageSends: [],
  576. referencedClasses: []
  577. }),
  578. globals.MKLabelledLayoutProperty);
  579. smalltalk.addMethod(
  580. smalltalk.method({
  581. selector: "printCssOn:",
  582. protocol: 'printing',
  583. fn: function (aStream){
  584. var self=this;
  585. return smalltalk.withContext(function($ctx1) {
  586. var $1;
  587. $1=_st(_st(aStream).__lt_lt(self._label())).__lt_lt(":");
  588. $ctx1.sendIdx["<<"]=2;
  589. _st($1).__lt_lt(_st(self._value())._asMokaCssString());
  590. $ctx1.sendIdx["<<"]=1;
  591. return self}, function($ctx1) {$ctx1.fill(self,"printCssOn:",{aStream:aStream},globals.MKLabelledLayoutProperty)})},
  592. args: ["aStream"],
  593. source: "printCssOn: aStream\x0a\x09aStream << self label << ':' << self value asMokaCssString",
  594. messageSends: ["<<", "label", "asMokaCssString", "value"],
  595. referencedClasses: []
  596. }),
  597. globals.MKLabelledLayoutProperty);
  598. smalltalk.addMethod(
  599. smalltalk.method({
  600. selector: "layout:label:value:",
  601. protocol: 'instance creation',
  602. fn: function (aLayout,aString,aValue){
  603. var self=this;
  604. return smalltalk.withContext(function($ctx1) {
  605. var $2,$3,$1;
  606. $2=self._new();
  607. _st($2)._layout_(aLayout);
  608. _st($2)._label_(aString);
  609. _st($2)._value_(aValue);
  610. $3=_st($2)._yourself();
  611. $1=$3;
  612. return $1;
  613. }, function($ctx1) {$ctx1.fill(self,"layout:label:value:",{aLayout:aLayout,aString:aString,aValue:aValue},globals.MKLabelledLayoutProperty.klass)})},
  614. args: ["aLayout", "aString", "aValue"],
  615. source: "layout: aLayout label: aString value: aValue\x0a\x09^ self new\x0a\x09\x09layout: aLayout;\x0a\x09\x09label: aString;\x0a\x09\x09value: aValue;\x0a\x09\x09yourself",
  616. messageSends: ["layout:", "new", "label:", "value:", "yourself"],
  617. referencedClasses: []
  618. }),
  619. globals.MKLabelledLayoutProperty.klass);
  620. smalltalk.addClass('MKVerticalCenteringLayoutProperty', globals.MKLayoutProperty, [], 'Moka-Layouts');
  621. smalltalk.addMethod(
  622. smalltalk.method({
  623. selector: "marginTop",
  624. protocol: 'accessing',
  625. fn: function (){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. var $1;
  629. $1=(0).__minus(_st(_st(_st(self._layout())._height()).__slash((2))).__plus(self._value()));
  630. return $1;
  631. }, function($ctx1) {$ctx1.fill(self,"marginTop",{},globals.MKVerticalCenteringLayoutProperty)})},
  632. args: [],
  633. source: "marginTop\x0a\x09^ 0 - ((self layout height / 2) + self value)",
  634. messageSends: ["-", "+", "/", "height", "layout", "value"],
  635. referencedClasses: []
  636. }),
  637. globals.MKVerticalCenteringLayoutProperty);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "printCssOn:",
  641. protocol: 'printing',
  642. fn: function (aStream){
  643. var self=this;
  644. return smalltalk.withContext(function($ctx1) {
  645. _st(aStream).__lt_lt("top:50%;");
  646. $ctx1.sendIdx["<<"]=1;
  647. _st(_st(aStream).__lt_lt("margin-top:")).__lt_lt(_st(self._marginTop())._asMokaCssString());
  648. $ctx1.sendIdx["<<"]=2;
  649. return self}, function($ctx1) {$ctx1.fill(self,"printCssOn:",{aStream:aStream},globals.MKVerticalCenteringLayoutProperty)})},
  650. args: ["aStream"],
  651. source: "printCssOn: aStream\x0a\x09aStream << 'top:50%;'.\x0a\x09aStream << 'margin-top:' << self marginTop asMokaCssString",
  652. messageSends: ["<<", "asMokaCssString", "marginTop"],
  653. referencedClasses: []
  654. }),
  655. globals.MKVerticalCenteringLayoutProperty);
  656. smalltalk.addMethod(
  657. smalltalk.method({
  658. selector: "asMokaCssString",
  659. protocol: '*Moka-Layouts',
  660. fn: function (){
  661. var self=this;
  662. return smalltalk.withContext(function($ctx1) {
  663. var $2,$1;
  664. $2=_st(self._abs()).__gt((1));
  665. if(smalltalk.assert($2)){
  666. $1=self._asMokaPixelString();
  667. } else {
  668. $1=self._asMokaPercentString();
  669. };
  670. return $1;
  671. }, function($ctx1) {$ctx1.fill(self,"asMokaCssString",{},globals.Number)})},
  672. args: [],
  673. source: "asMokaCssString\x0a\x09^ self abs > 1 \x09\x0a\x09\x09ifTrue: [ self asMokaPixelString ]\x0a\x09\x09ifFalse: [ self asMokaPercentString ]",
  674. messageSends: ["ifTrue:ifFalse:", ">", "abs", "asMokaPixelString", "asMokaPercentString"],
  675. referencedClasses: []
  676. }),
  677. globals.Number);
  678. smalltalk.addMethod(
  679. smalltalk.method({
  680. selector: "asMokaPercentString",
  681. protocol: '*Moka-Layouts',
  682. fn: function (){
  683. var self=this;
  684. return smalltalk.withContext(function($ctx1) {
  685. var $1;
  686. $1=_st(_st(self.__star((100)))._asString()).__comma("%");
  687. return $1;
  688. }, function($ctx1) {$ctx1.fill(self,"asMokaPercentString",{},globals.Number)})},
  689. args: [],
  690. source: "asMokaPercentString\x0a\x09^ (self * 100) asString, '%'",
  691. messageSends: [",", "asString", "*"],
  692. referencedClasses: []
  693. }),
  694. globals.Number);
  695. smalltalk.addMethod(
  696. smalltalk.method({
  697. selector: "asMokaPixelString",
  698. protocol: '*Moka-Layouts',
  699. fn: function (){
  700. var self=this;
  701. return smalltalk.withContext(function($ctx1) {
  702. var $1;
  703. $1=_st(self._asString()).__comma("px");
  704. return $1;
  705. }, function($ctx1) {$ctx1.fill(self,"asMokaPixelString",{},globals.Number)})},
  706. args: [],
  707. source: "asMokaPixelString\x0a\x09^ self asString, 'px'",
  708. messageSends: [",", "asString"],
  709. referencedClasses: []
  710. }),
  711. globals.Number);
  712. smalltalk.addMethod(
  713. smalltalk.method({
  714. selector: "asMokaCssString",
  715. protocol: '*Moka-Layouts',
  716. fn: function (){
  717. var self=this;
  718. return self;
  719. },
  720. args: [],
  721. source: "asMokaCssString\x0a\x09^ self",
  722. messageSends: [],
  723. referencedClasses: []
  724. }),
  725. globals.String);
  726. });