import {IBase, Assigner} from "./common"; interface ICellStyle extends IBase{ backgroundColor?: string; color?: string; fontWeight?: string; fontSize?: string; textAlign?: string; text?: string; } class CellStyle extends Assigner{ private _textAlign: string = ""; private _backgroundColor: string = ""; private _color: string = ""; private _fontSize: string = ""; private _fontWeight: string = ""; //getter method //getter setter public get textAlign(): string { return this._textAlign; } public get backgroundColor(): string { return this._backgroundColor; } public get color(): string { return this._color; } public get fontSize(): string { return this._fontSize; } public get FontWeight(): string { return this._fontWeight; } //setter method public set textAlign(newAli:string){ if (this._textAlign != newAli && newAli){ this._textAlign = newAli; } } public set backgroundColor(newBGColor:string){ if (this._backgroundColor != newBGColor && newBGColor){ this._backgroundColor = newBGColor; } } public set color(newColor: string){ if(this._color != newColor && newColor){ this._color = newColor; } } public set fontSize(newSize: string){ if(this._fontSize != newSize && newSize){ this._fontSize = newSize; } } public set fontWeight(newWeight:string){ if(this._fontSize != newWeight && newWeight){ this._fontWeight = newWeight; } } //parsing public parse(styleObj:ICellStyle){ // subtitute => assign() extended this.setProperties(styleObj); //이름수정 } } export class Header extends CellStyle{ private _text: string; constructor(){ super(); this._text = ""; this.backgroundColor = "#dbedff"; this.color = "black"; this.fontSize = "12px"; this.fontWeight = "Bold"; this.textAlign = "center"; } //getter and setter public get text():string{ return this._text } public set text(newText:string){ if(this._text !=newText){ this._text=newText; } } } export class Body extends CellStyle{ constructor(){ super(); this.textAlign = "center"; this.backgroundColor = "white"; this.color = "Black"; this.fontSize = "12px"; this.fontWeight = "normal"; } } export interface IColumnStyle extends IBase{ header: ICellStyle; body: ICellStyle; fieldName: string; visible: boolean; width: number; } export class Column extends Assigner{ private _header: Header; private _body: Body; private _fieldName: string =""; private _visible: boolean=true; private _width: number = 100; constructor(){ super(); this._header = new Header(); this._body = new Body(); } //getter method public get body():Body{ return this._body; } public get fieldName():string{ return this._fieldName; } public get header():Header{ return this._header; } public get visible():boolean{ return this._visible; } public get width():number{ return this._width; } //setter method public setBody(newBody?: ICellStyle){ if(newBody) this._body.parse(newBody); } public set fieldName(newName: string){ if(this._fieldName!=newName && newName != ""){ this._fieldName = newName; } } public setHeader(newHeader?: ICellStyle){ if(newHeader) this._header.parse(newHeader); } public set visible(newVis:boolean){ if(this._visible != newVis){ this._visible = newVis; } } public set width(newWid:number){ if(this._width!=newWid){ this._width = newWid; } } public parse(col:IColumnStyle){ this.setProperties(col) this.setHeader(col.header); this.setBody(col.body); } }