//package mkv.MyGUI;
//import processing.core.*;
import mkv.MyGUI.*;

/**
 * This is the all encompasing and highly useful MyGUIButton class.
 * It supports many constructors, and a variety of carefully worked out drawing methods.
 */
public class MyGUIBox extends mkv.MyGUI.MyGUIObject
{

  /* Constructor */
  public MyGUIBox(PApplet root, int x, int y, int width, int height) {
    super(root, x, y);
    _width = width;
    _height = height;
  }

  // Draw methods for this object based on states
  public void drawStates() {
    // alias to shorten _style property to st
    MyGUIStyle st = _style;
    if(_style == null) {
      st = _parent.getStyle();
    } else {
      st = _style;
    }
    // set regularly used vars:
    final int halfw = PApplet.round((float)_width/2 + st.padding);
    final int halfh = PApplet.round((float)_height/2 + st.padding);
    
    // move draw object to coordinates
    _root.pushMatrix();
    _root.translate(_x, _y);
    _root.scale(_scale);
    _root.rotate(PApplet.radians(_rotation));
    // Set default properties
    _root.rectMode(PApplet.CORNERS);
    _root.strokeWeight(st.strokeWeight);
    _root.strokeJoin(PApplet.MITER);

    if(isDisabled()) {
      // disabled state
      _root.stroke(st.shadow);
      _root.fill(st.disabled);
      _root.rect(-halfw, -halfh, halfw, halfh);
    } else {
      _root.stroke(st.shadow);
      _root.fill(st.face);
      _root.rect(-halfw, -halfh, halfw, halfh); 
    }
    
    _root.popMatrix();
  }
}
