/*
* GridSizer
*
* Copyright (c) 2014 Renato de Pontes Pereira.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* @module Creatine
**/
// namespace:
this.creatine = this.creatine || {};
(function() {
"use strict";
/**
* GridSizer is a layout manager that organizes its components in a regular
* grid.
*
* Parameters rows
and cols
specify how many rows and
* columns the grid will have, respectively. All cells in the grid have the
* same size. However, each cell can have an individual border, by setting the
* border parameter when adding an object to the sizer.
* The anchor parameter can be specified using the following constants:
* LEFT, RIGHT, TOP, BOTTOM, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT,
* BOTTOM_RIGHT, CENTER
.
*
*
creatine.TOP_LEFT
**/
p.add = function(object, border, anchor) {
anchor = anchor || creatine.TOP_LEFT;
border = border || 0;
this.children.push([object, anchor, border]);
}
/**
* Resize this sizer and its children.
*
* For the root sizer, the parameter area
does not to be
* specified, but it is automatically set in nested sizers.
*
* @method layout
* @param {createjs.Rectangle} area A rectangle containing the usable area
* of the sizer.
**/
p.layout = function(area) {
if (area)
this.area = area;
var base_w = this.area.width/this.cols;
var base_h = this.area.height/this.rows;
for (var i=0; i