import { GeeEvent } from "@gvol-org/geovis-brain-core";
import { List }  from "../dataType/List";
/**
 *  @memberof data
 * @class data.ActiveDictionary
 * @since ui.data
 */
export class ActiveDictionary {
  style: Style;
  event: GeeEvent;
  // /**
  //  * @hideconstructor
  //  * @return data.ActiveDictionary
  //  */
  constructor(object?: object, allowedProperties?: List<String>) {
    if (!(this instanceof ActiveDictionary)) {
      return new ActiveDictionary(object, allowedProperties);
    }
    this.event = GeeEvent.getInstance();
    this.style = new Style();
    if (object) {
      for (let key in object) {
        //    this.set(key,object[key]);
        this.style[key] = object[key];
      }
    }
  }
  /**
   * 返回该对象的克隆,如果提供了键
   * @param key 带有传入键的属性值。查看构造函数的参数,以查看哪些属性可用。
   * @returns 克隆的对象
   */
  get(key: string) {
    //Returns either a clone of this object or, if a key is provided,
    // the value of the property with the passed-in key. Look at the constructor's parameters to see which properties are available.
    return this.style[key];
  }
  /**
   * 设置给定属性的值。如果对象不支持所提供的键,则抛出错误。查看构造函数的参数
   * @param {String} keyOrDict 要设置的属性的键或要在对象上设置的键/值对字典。
   * @param {Object} value optional 属性的新值。当第一个参数是键字符串时,这是必需的。
   * @returns ui.data.ActiveDictionary.
   */
  set(keyOrDict: string, value?: Object) {
    // Sets the value of a given property. Throws an error if the key provided is not supported by the object. Look at the constructor's parameters to see which properties can be set.
    // Returns this ui.data.ActiveDictionary.
    this.style[keyOrDict] = value;
    //更新元素el
    this.event.emit("updateStyle", keyOrDict, value);
  }
}
export class Style {
  width?: string;
  maxWidth?: string;
  minWidth?: string;
  height?: string;
  maxHeight?: string;
  minHeight?: string;
  margin?: string;
  padding?: string;
  color?: string;
  backgroundColor?: string;
  border?: string;
  fontSize?: string;
  fontWeight?: string;
  fontFamily?: string;
  textAlign?: string;
  textDecoration?: string;
  whiteSpace?: string;
  shown?: boolean;
  stretch?: string;
  position?: string;
  constructor() { }
}