hbox.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <html>
  2. <head>
  3. <title>HBox Layout</title>
  4. <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  5. <link rel="stylesheet" type="text/css" href="../shared/example.css" />
  6. <!-- GC -->
  7. <script type="text/javascript" src="../../ext-all.js"></script>
  8. <style type="text/css">
  9. html, body {
  10. font: normal 12px verdana;
  11. margin: 0;
  12. padding: 0;
  13. border: 0 none;
  14. }
  15. </style>
  16. <script type="text/javascript">
  17. Ext.onReady(function() {
  18. var currentName,
  19. viewport;
  20. var replace = function(config, name) {
  21. var btns = Ext.getCmp('btns');
  22. if (name && name != currentName) {
  23. currentName = name;
  24. btns.remove(0);
  25. btns.add(Ext.apply(config));
  26. }
  27. };
  28. viewport = Ext.create('Ext.Viewport', {
  29. layout:'border',
  30. items: [{
  31. id:'btns',
  32. region:'north',
  33. baseCls:'x-plain',
  34. split: true,
  35. height: 100,
  36. minHeight: 75,
  37. maxHeight: 150,
  38. layout:'fit',
  39. margins: '5 5 0 5',
  40. items: {
  41. baseCls: 'x-plain',
  42. html: '<p style="padding:10px;color:#556677;">Select a configuration below:</p>'
  43. }
  44. }, {
  45. region:'center',
  46. margins: '0 5 5 5',
  47. layout:'anchor',
  48. items:[{
  49. anchor:'100%',
  50. baseCls:'x-plain',
  51. layout: {
  52. type: 'hbox',
  53. padding: 10
  54. },
  55. defaults:{
  56. margins:'0 5 0 0',
  57. pressed: false,
  58. toggleGroup:'btns',
  59. allowDepress: false
  60. },
  61. items: [{
  62. xtype:'button',
  63. text: 'Spaced',
  64. handler: function(){
  65. replace({
  66. layout: {
  67. type: 'hbox',
  68. padding:'5',
  69. align:'top'
  70. },
  71. defaults:{margins:'0 5 0 0'},
  72. items:[{
  73. xtype:'button',
  74. text: 'Small Size'
  75. },{
  76. xtype:'tbspacer',
  77. flex:1
  78. },{
  79. xtype:'button',
  80. scale: 'medium',
  81. text: 'Medium Size'
  82. },{
  83. xtype:'tbspacer',
  84. flex:1
  85. },{
  86. xtype:'button',
  87. scale: 'large',
  88. text: 'Large Size',
  89. margins:'0'
  90. }]
  91. }, 'spaced');
  92. }
  93. },{
  94. xtype:'button',
  95. text: 'Align: top',
  96. handler: function(){
  97. replace({
  98. layout: {
  99. type: 'hbox',
  100. padding:'5',
  101. align:'top'
  102. },
  103. defaults:{margins:'0 5 0 0'},
  104. items:[{
  105. xtype:'button',
  106. text: 'Small Size'
  107. },{
  108. xtype:'button',
  109. scale: 'medium',
  110. text: 'Medium Size'
  111. },{
  112. xtype:'button',
  113. scale: 'large',
  114. text: 'Large Size'
  115. }]
  116. }, 'align top');
  117. }
  118. },{
  119. xtype:'button',
  120. text: 'Align: middle',
  121. handler: function(){
  122. replace({
  123. layout: {
  124. type: 'hbox',
  125. padding:'5',
  126. align:'middle'
  127. },
  128. defaults:{margins:'0 5 0 0'},
  129. items:[{
  130. xtype:'button',
  131. text: 'Small Size'
  132. },{
  133. xtype:'button',
  134. scale: 'medium',
  135. text: 'Medium Size'
  136. },{
  137. xtype:'button',
  138. scale: 'large',
  139. text: 'Large Size'
  140. }]
  141. }, 'align middle');
  142. }
  143. },{
  144. xtype:'button',
  145. text: 'Align: stretch',
  146. handler: function(){
  147. replace({
  148. layout: {
  149. type: 'hbox',
  150. padding:'5',
  151. align:'stretch'
  152. },
  153. defaults:{margins:'0 5 0 0'},
  154. items:[{
  155. xtype:'button',
  156. text: 'Small Size'
  157. },{
  158. xtype:'button',
  159. scale: 'medium',
  160. text: 'Medium Size'
  161. },{
  162. xtype:'button',
  163. scale: 'large',
  164. text: 'Large Size'
  165. }]
  166. }, 'align stretch');
  167. }
  168. },{
  169. xtype:'button',
  170. text: 'Align: stretchmax',
  171. handler: function(){
  172. replace({
  173. layout: {
  174. type: 'hbox',
  175. padding:'5',
  176. align:'stretchmax'
  177. },
  178. defaults:{margins:'0 5 0 0'},
  179. items:[{
  180. xtype:'button',
  181. text: 'Small Size'
  182. },{
  183. xtype:'button',
  184. scale: 'medium',
  185. text: 'Medium Size'
  186. },{
  187. xtype:'button',
  188. scale: 'large',
  189. text: 'Large Size'
  190. }]
  191. }, 'align stretchmax');
  192. }
  193. }]
  194. },{
  195. anchor:'100%',
  196. baseCls:'x-plain',
  197. layout: {
  198. type: 'hbox',
  199. padding: '0 10 10'
  200. },
  201. defaults:{
  202. margins:'0 5 0 0',
  203. pressed: false,
  204. toggleGroup:'btns',
  205. allowDepress: false
  206. },
  207. items: [{
  208. xtype:'button',
  209. text: 'Flex: All even / Align: middle',
  210. handler: function(){
  211. replace({
  212. layout: {
  213. type: 'hbox',
  214. padding: '5',
  215. align: 'middle'
  216. },
  217. defaults:{
  218. margins: '0 5 0 0'
  219. },
  220. items:[{
  221. xtype: 'button',
  222. text: 'Button 1',
  223. flex: 1
  224. },{
  225. xtype: 'button',
  226. text: 'Button 2',
  227. flex: 1
  228. },{
  229. xtype: 'button',
  230. text: 'Button 3',
  231. flex: 1
  232. },{
  233. xtype: 'button',
  234. text: 'Button 4',
  235. flex: 1,
  236. margins: '0'
  237. }]
  238. }, 'flex all even');
  239. }
  240. },{
  241. xtype:'button',
  242. text: 'Flex: Ratio / Align: top',
  243. handler: function(){
  244. replace({
  245. layout: {
  246. type: 'hbox',
  247. padding:'5',
  248. align:'top'
  249. },
  250. defaults:{margins:'0 5 0 0'},
  251. items:[{
  252. xtype:'button',
  253. text: 'Button 1',
  254. flex:1
  255. },{
  256. xtype:'button',
  257. text: 'Button 2',
  258. flex:1
  259. },{
  260. xtype:'button',
  261. text: 'Button 3',
  262. flex:1
  263. },{
  264. xtype:'button',
  265. text: 'Button 4',
  266. flex:3,
  267. margins:'0'
  268. }]
  269. }, 'flex ratio');
  270. }
  271. },{
  272. xtype:'button',
  273. text: 'Pack: start / Align: middle',
  274. handler: function(){
  275. replace({
  276. layout: {
  277. type: 'hbox',
  278. padding:'5',
  279. pack:'start',
  280. align:'middle'
  281. },
  282. defaults:{margins:'0 5 0 0'},
  283. items:[{
  284. xtype:'button',
  285. text: 'Button 1'
  286. },{
  287. xtype:'button',
  288. text: 'Button 2'
  289. },{
  290. xtype:'button',
  291. text: 'Button 3'
  292. },{
  293. xtype:'button',
  294. text: 'Button 4'
  295. }]
  296. }, 'pack start');
  297. }
  298. },{
  299. xtype:'button',
  300. text: 'Pack: center / Align: middle',
  301. handler: function(){
  302. replace({
  303. layout: {
  304. type: 'hbox',
  305. padding:'5',
  306. pack:'center',
  307. align:'middle'
  308. },
  309. defaults:{margins:'0 5 0 0'},
  310. items:[{
  311. xtype:'button',
  312. text: 'Button 1'
  313. },{
  314. xtype:'button',
  315. text: 'Button 2'
  316. },{
  317. xtype:'button',
  318. text: 'Button 3'
  319. },{
  320. xtype:'button',
  321. text: 'Button 4',
  322. margins:'0'
  323. }]
  324. }, 'pack center');
  325. }
  326. },{
  327. xtype:'button',
  328. text: 'Pack: end / Align: middle',
  329. handler: function(){
  330. replace({
  331. layout: {
  332. type: 'hbox',
  333. padding:'5',
  334. pack:'end',
  335. align:'middle'
  336. },
  337. defaults:{margins:'0 5 0 0'},
  338. items:[{
  339. xtype:'button',
  340. text: 'Button 1'
  341. },{
  342. xtype:'button',
  343. text: 'Button 2'
  344. },{
  345. xtype:'button',
  346. text: 'Button 3'
  347. },{
  348. xtype:'button',
  349. text: 'Button 4',
  350. margins:'0'
  351. }]
  352. }, 'pack end');
  353. }
  354. }]
  355. }]
  356. }]
  357. });
  358. });
  359. </script>
  360. </head>
  361. <body>
  362. </body>
  363. </html>