|
| 1 | +import { QCheckBox } from '@nodegui/nodegui'; |
| 2 | +import { NgComponent } from './component'; |
| 3 | +import { RendererStyleFlags2 } from '@angular/core'; |
| 4 | +import { TextField } from './nodes'; |
| 5 | + |
| 6 | +export class NgCheckbox extends QCheckBox implements NgComponent { |
| 7 | + public static nodeName = 'checkbox'; |
| 8 | + public parent: any; |
| 9 | + |
| 10 | + public appendChild(newChild: any): void { |
| 11 | + if (newChild instanceof TextField) { |
| 12 | + newChild.parent = this; |
| 13 | + this.setText(newChild.value); |
| 14 | + } else { |
| 15 | + console.warn('checkbox may be appendChild only TextField'); |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + public insertBefore(newChild: any, refChild: any) {} |
| 20 | + |
| 21 | + public setNgAttribute( |
| 22 | + name: string, |
| 23 | + value: string, |
| 24 | + namespace?: string | null |
| 25 | + ): void {} |
| 26 | + |
| 27 | + public setProperty(name: string, value: boolean): void { |
| 28 | + switch (name) { |
| 29 | + case 'checked': |
| 30 | + this.setChecked(value); |
| 31 | + break; |
| 32 | + case 'enabled': |
| 33 | + this.setEnabled(value); |
| 34 | + break; |
| 35 | + default: |
| 36 | + break; |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + public setStyle( |
| 41 | + style: string, |
| 42 | + value: any, |
| 43 | + flags?: RendererStyleFlags2 |
| 44 | + ): void { |
| 45 | + this.setInlineStyle(`${style}:${value}`); |
| 46 | + } |
| 47 | + |
| 48 | + public setValue(value: string): void { |
| 49 | + this.setText(value); |
| 50 | + } |
| 51 | + |
| 52 | + removeAttribute(name: string, namespace?: string): void { |
| 53 | + throw new Error('Method not implemented.'); |
| 54 | + } |
| 55 | + removeChild(oldChild: any): void { |
| 56 | + throw new Error('Method not implemented.'); |
| 57 | + } |
| 58 | + removeClass(name: string): void { |
| 59 | + throw new Error('Method not implemented.'); |
| 60 | + } |
| 61 | + removeStyle(style: string, flags?: RendererStyleFlags2): void { |
| 62 | + throw new Error('Method not implemented.'); |
| 63 | + } |
| 64 | +} |
0 commit comments