1 import org.aswing.Insets; 2 /** 3 * The <code>GridBagConstraints</code> class specifies constraints 4 * for components that are laid out using the 5 * <code>GridBagLayout</code> class. 6 * 7 * @author Tomato 8 */ 9 class org.aswing.GridBagConstraints { 10 11 /** 12 * Specifies that this component is the next-to-last component in its 13 * column or row (<code>gridwidth</code>, <code>gridheight</code>), 14 * or that this component be placed next to the previously added 15 * component (<code>gridx</code>, <code>gridy</code>). 16 * @see org.aswing.GridBagConstraints#gridwidth 17 * @see org.aswing.GridBagConstraints#gridheight 18 * @see org.aswing.GridBagConstraints#gridx 19 * @see org.aswing.GridBagConstraints#gridy 20 */ 21 22 public static var RELATIVE : Number = -2; //-1; 23 24 /** 25 * Specifies that this component is the 26 * last component in its column or row. 27 */ 28 29 public static var REMAINDER : Number = -1; //0; 30 31 /** 32 * Do not resize the component. 33 */ 34 35 public static var NONE : Number = 0; 36 37 /** 38 * Resize the component both horizontally and vertically. 39 */ 40 41 public static var BOTH : Number = 1; 42 43 /** 44 * Resize the component horizontally but not vertically. 45 */ 46 47 public static var HORIZONTAL : Number = 2; 48 49 /** 50 * Resize the component vertically but not horizontally. 51 */ 52 53 public static var VERTICAL : Number = 3; 54 55 /** 56 * Put the component in the center of its display area. 57 */ 58 59 public static var CENTER : Number = 10; 60 61 /** 62 * Put the component at the top of its display area, 63 * centered horizontally. 64 */ 65 66 public static var NORTH : Number = 11; 67 68 /** 69 * Put the component at the top-right corner of its display area. 70 */ 71 72 public static var NORTHEAST : Number = 12; 73 74 /** 75 * Put the component on the right side of its display area, 76 * centered vertically. 77 */ 78 79 public static var EAST : Number = 13; 80 81 /** 82 * Put the component at the bottom-right corner of its display area. 83 */ 84 85 public static var SOUTHEAST : Number = 14; 86 87 /** 88 * Put the component at the bottom of its display area, centered 89 * horizontally. 90 */ 91 92 public static var SOUTH : Number = 15; 93 94 /** 95 * Put the component at the bottom-left corner of its display area. 96 */ 97 98 public static var SOUTHWEST : Number = 16; 99 100 /** 101 * Put the component on the left side of its display area, 102 * centered vertically. 103 */ 104 105 public static var WEST : Number = 17; 106 107 /** 108 * Put the component at the top-left corner of its display area. 109 */ 110 111 public static var NORTHWEST : Number = 18; 112 113 // ------------------------------------------------------------------------------------ 114 115 116 /** 117 * Specifies the cell containing the leading edge of the component's 118 * display area, where the first cell in a row has <code>gridx=0</code>. 119 * The leading edge of a component's display area is its left edge for 120 * a horizontal, left-to-right container and its right edge for a 121 * horizontal, right-to-left container. 122 * The value 123 * <code>RELATIVE</code> specifies that the component be placed 124 * immediately following the component that was added to the container 125 * just before this component was added. 126 * <p> 127 * The default value is <code>RELATIVE</code>. 128 * <code>gridx</code> should be a non-negative value. 129 * 130 * @see org.aswing.GridBagConstraints#gridy 131 * 132 */ 133 134 public var gridx : Number; 135 136 /** 137 * Specifies the cell at the top of the component's display area, 138 * where the topmost cell has <code>gridy=0</code>. The value 139 * <code>RELATIVE</code> specifies that the component be placed just 140 * below the component that was added to the container just before 141 * this component was added. 142 * <p> 143 * The default value is <code>RELATIVE</code>. 144 * <code>gridy</code> should be a non-negative value. 145 * 146 * @see org.aswing.GridBagConstraints#gridx 147 * 148 */ 149 150 public var gridy : Number; 151 152 /** 153 * Specifies the number of cells in a row for the component's 154 * display area. 155 * <p> 156 * Use <code>REMAINDER</code> to specify that the component be the 157 * last one in its row. Use <code>RELATIVE</code> to specify that the 158 * component be the next-to-last one in its row. 159 * <p> 160 * <code>gridwidth</code> should be non-negative and the default 161 * value is 1. 162 * 163 * @see org.aswing.GridBagConstraints#gridheight 164 * 165 */ 166 167 public var gridwidth : Number; 168 169 /** 170 * Specifies the number of cells in a column for the component's 171 * display area. 172 * <p> 173 * Use <code>REMAINDER</code> to specify that the component be the 174 * last one in its column. Use <code>RELATIVE</code> to specify that 175 * the component be the next-to-last one in its column. 176 * <p> 177 * <code>gridheight</code> should be a non-negative value and the 178 * default value is 1. 179 * 180 * @see org.aswing.GridBagConstraints#gridwidth 181 * 182 */ 183 184 public var gridheight : Number; 185 186 /** 187 * Specifies how to distribute extra horizontal space. 188 * <p> 189 * The grid bag layout manager calculates the weight of a column to 190 * be the maximum <code>weightx</code> of all the components in a 191 * column. If the resulting layout is smaller horizontally than the area 192 * it needs to fill, the extra space is distributed to each column in 193 * proportion to its weight. A column that has a weight of zero receives 194 * no extra space. 195 * <p> 196 * If all the weights are zero, all the extra space appears between 197 * the grids of the cell and the left and right edges. 198 * <p> 199 * The default value of this field is <code>0</code>. 200 * <code>weightx</code> should be a non-negative value. 201 * 202 * @see org.aswing.GridBagConstraints#weighty 203 * 204 */ 205 206 public var weightx : Number; 207 208 /** 209 * Specifies how to distribute extra vertical space. 210 * <p> 211 * The grid bag layout manager calculates the weight of a row to be 212 * the maximum <code>weighty</code> of all the components in a row. 213 * If the resulting layout is smaller vertically than the area it 214 * needs to fill, the extra space is distributed to each row in 215 * proportion to its weight. A row that has a weight of zero receives no 216 * extra space. 217 * <p> 218 * If all the weights are zero, all the extra space appears between 219 * the grids of the cell and the top and bottom edges. 220 * <p> 221 * The default value of this field is <code>0</code>. 222 * <code>weighty</code> should be a non-negative value. 223 * 224 * @see org.aswing.GridBagConstraints#weightx 225 * 226 */ 227 228 public var weighty : Number; 229 230 /** 231 * This field is used when the component is smaller than its display 232 * area. It determines where, within the display area, to place the 233 * component. 234 * The default value is <code>CENTER</code>. 235 * 236 * @see org.aswing.ComponentOrientation 237 * 238 */ 239 240 public var anchor : Number; 241 242 /** 243 * This field is used when the component's display area is larger 244 * than the component's requested size. It determines whether to 245 * resize the component, and if so, how. 246 * <p> 247 * The following values are valid for <code>fill</code>: 248 * <p> 249 * <ul> 250 * <li> 251 * <code>NONE</code>: Do not resize the component. 252 * <li> 253 * <code>HORIZONTAL</code>: Make the component wide enough to fill 254 * its display area horizontally, but do not change its height. 255 * <li> 256 * <code>VERTICAL</code>: Make the component tall enough to fill its 257 * display area vertically, but do not change its width. 258 * <li> 259 * <code>BOTH</code>: Make the component fill its display area 260 * entirely. 261 * </ul> 262 * <p> 263 * The default value is <code>NONE</code>. 264 */ 265 266 public var fill : Number; 267 268 /** 269 * This field specifies the external padding of the component, the 270 * minimum amount of space between the component and the edges of its 271 * display area. 272 * <p> 273 * The default value is <code>new Insets(0, 0, 0, 0)</code>. 274 */ 275 276 public var insets : Insets; 277 278 /** 279 * This field specifies the internal padding of the component, how much 280 * space to add to the minimum width of the component. The width of 281 * the component is at least its minimum width plus 282 * <code>(ipadx * 2)</code> pixels. 283 * <p> 284 * The default value is <code>0</code>. 285 * 286 * @see org.aswing.GridBagConstraints#ipady 287 * 288 */ 289 290 public var ipadx : Number; 291 292 /** 293 * This field specifies the internal padding, that is, how much 294 * space to add to the minimum height of the component. The height of 295 * the component is at least its minimum height plus 296 * <code>(ipady * 2)</code> pixels. 297 * <p> 298 * The default value is 0. 299 * 300 * @see org.aswing.GridBagConstraints#ipadx 301 * 302 */ 303 304 public var ipady : Number; 305 306 307 // ------------------------------------------------------------------------------------------- 308 309 310 /** 311 * Temporary place holder for the x coordinate. 312 */ 313 // var tempX:Number; 314 /** 315 * Temporary place holder for the y coordinate. 316 */ 317 // var tempY:Number; 318 /** 319 * Temporary place holder for the Width of the component. 320 */ 321 // var tempWidth:Number; 322 /** 323 * Temporary place holder for the Height of the component. 324 */ 325 // var tempHeight:Number; 326 /** 327 * The minimum width of the component. It is used to calculate 328 * <code>ipady</code>, where the default will be 0. 329 * 330 * @see #ipady 331 * 332 */ 333 // var minWidth:Number; 334 /** 335 * The minimum height of the component. It is used to calculate 336 * <code>ipadx</code>, where the default will be 0. 337 * 338 * @see #ipadx 339 * 340 */ 341 // var minHeight:Number; 342 343 // ------------------------------------------------------------------------------------------------- 344 345 /** 346 * Creates a <code>GridBagConstraint</code> object with 347 * all of its fields set to their default value. 348 */ 349 350 public function GridBagConstraints() { 351 gridx = RELATIVE; 352 gridy = RELATIVE; 353 gridwidth = 1; 354 gridheight = 1; 355 356 weightx = 0; 357 weighty = 0; 358 anchor = CENTER; 359 fill = NONE; 360 361 insets = new Insets(0, 0, 0, 0); 362 ipadx = 0; 363 ipady = 0; 364 } 365 366 public function clone():GridBagConstraints{ 367 var gbc:GridBagConstraints = new GridBagConstraints(); 368 369 gbc.gridx = gridx; 370 gbc.gridy = gridy; 371 gbc.gridwidth = gridwidth; 372 gbc.gridheight = gridheight; 373 gbc.weightx = weightx; 374 gbc.weighty = weighty; 375 gbc.anchor = anchor; 376 gbc.fill = fill; 377 gbc.ipadx = ipadx; 378 gbc.ipady = ipady; 379 380 gbc.insets = new Insets(insets.top, insets.left, insets.bottom, insets.right); 381 382 return gbc; 383 } 384 385 }