-
Notifications
You must be signed in to change notification settings - Fork 29
/
pdf_radioitem.ts
44 lines (42 loc) · 1.86 KB
/
pdf_radioitem.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { IQuestion } from 'survey-core';
import { IRect, DocController } from '../doc_controller';
import { PdfBrick } from './pdf_brick';
import { SurveyHelper } from '../helper_survey';
export class RadioGroupWrap {
private _radioGroup: any;
public constructor(private name: string, private controller: DocController, private readOnly: boolean = false) {
}
public addToPdf() {
this._radioGroup = new this.controller.doc.AcroFormRadioButton();
this._radioGroup.value = this.name;
this._radioGroup.readOnly = this.readOnly;
this._radioGroup.color = SurveyHelper.FORM_BORDER_COLOR;
this.controller.doc.addField(this._radioGroup);
}
get radioGroup() {
return this._radioGroup;
}
}
export class RadioItemBrick extends PdfBrick {
public constructor(question: IQuestion, controller: DocController,
rect: IRect, private index: number, private сhecked: Boolean,
private radioGroupWrap: RadioGroupWrap) {
super(question, controller, rect);
}
public async renderInteractive(): Promise<void> {
if (this.index == 0) {
this.radioGroupWrap.addToPdf();
}
let name = this.radioGroupWrap.radioGroup.value + 'index' + this.index;
let radioButton = this.radioGroupWrap.radioGroup.createOption(name);
radioButton.Rect = SurveyHelper.createAcroformRect(this);
if (this.сhecked) {
radioButton.AS = '/' + name;
}
let formScale = SurveyHelper.formScale(this.controller, this);
radioButton.Rect = SurveyHelper.createAcroformRect(SurveyHelper.scaleRect(this, formScale));
radioButton.color = SurveyHelper.FORM_BORDER_COLOR;
SurveyHelper.wrapFlatInBorders(this.controller, this);
this.radioGroupWrap.radioGroup.setAppearance(this.controller.doc.AcroForm.Appearance.RadioButton.Circle);
}
}