x4js 1.4.4 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/lib/application.d.ts +96 -0
  2. package/lib/application.js +146 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +139 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +81 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +241 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +241 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +358 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +156 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +130 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +588 -0
  19. package/lib/colorpicker.js +86 -80
  20. package/lib/combobox.js +26 -22
  21. package/lib/component.d.ts +572 -0
  22. package/lib/component.js +1729 -0
  23. package/lib/datastore.js +29 -20
  24. package/lib/dialog.js +41 -36
  25. package/lib/dom_events.d.ts +284 -0
  26. package/lib/dom_events.js +14 -0
  27. package/lib/drag_manager.js +4 -1
  28. package/lib/drawtext.js +9 -5
  29. package/lib/fileupload.js +19 -12
  30. package/lib/form.js +29 -25
  31. package/lib/formatters.js +19 -10
  32. package/lib/gridview.js +40 -35
  33. package/lib/hosts/host.d.ts +44 -0
  34. package/lib/hosts/host.js +73 -0
  35. package/lib/i18n.d.ts +67 -0
  36. package/lib/i18n.js +175 -0
  37. package/lib/icon.d.ts +56 -0
  38. package/lib/icon.js +178 -0
  39. package/lib/image.js +7 -3
  40. package/lib/index.js +71 -55
  41. package/lib/input.d.ts +86 -0
  42. package/lib/input.js +176 -0
  43. package/lib/label.d.ts +54 -0
  44. package/lib/label.js +90 -0
  45. package/lib/layout.d.ts +77 -0
  46. package/lib/layout.js +271 -0
  47. package/lib/link.js +9 -5
  48. package/lib/listview.js +34 -27
  49. package/lib/md5.js +5 -1
  50. package/lib/menu.d.ts +122 -0
  51. package/lib/menu.js +284 -0
  52. package/lib/messagebox.js +22 -17
  53. package/lib/panel.js +13 -9
  54. package/lib/popup.d.ts +71 -0
  55. package/lib/popup.js +378 -0
  56. package/lib/property_editor.js +20 -16
  57. package/lib/radiobtn.js +13 -9
  58. package/lib/rating.js +13 -9
  59. package/lib/request.js +16 -9
  60. package/lib/router.js +5 -1
  61. package/lib/settings.d.ts +33 -0
  62. package/lib/settings.js +67 -0
  63. package/lib/sidebarview.js +12 -8
  64. package/lib/smartedit.js +16 -11
  65. package/lib/spreadsheet.js +35 -31
  66. package/lib/styles.d.ts +81 -0
  67. package/lib/styles.js +268 -0
  68. package/lib/svgcomponent.js +8 -3
  69. package/lib/tabbar.js +10 -6
  70. package/lib/tabview.js +10 -6
  71. package/lib/textarea.js +10 -6
  72. package/lib/textedit.js +39 -35
  73. package/lib/texthiliter.js +8 -4
  74. package/lib/toaster.js +8 -4
  75. package/lib/tools.d.ts +382 -0
  76. package/lib/tools.js +1142 -0
  77. package/lib/tooltips.js +14 -9
  78. package/lib/treeview.js +30 -26
  79. package/lib/x4_events.d.ts +253 -0
  80. package/lib/x4_events.js +375 -0
  81. package/package.json +1 -1
  82. package/src/application.ts +9 -4
  83. package/src/x4.less +143 -107
  84. package/tsconfig.json +1 -1
  85. package/x4.css +1541 -0
package/lib/button.js ADDED
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ /**
3
+ * ___ ___ __
4
+ * \ \/ / / _
5
+ * \ / /_| |_
6
+ * / \____ _|
7
+ * /__/\__\ |_|
8
+ *
9
+ * @file button.ts
10
+ * @author Etienne Cochard
11
+ * @license
12
+ * Copyright (c) 2019-2021 R-libre ingenierie
13
+ *
14
+ * This program is free software; you can redistribute it and/or modify
15
+ * it under the terms of the GNU General Public License as published by
16
+ * the Free Software Foundation; either version 3 of the License, or
17
+ * (at your option) any later version.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+ **/
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.ToggleButton = exports.Button = exports.BaseButton = void 0;
28
+ const component_1 = require("./component");
29
+ const x4_events_1 = require("./x4_events");
30
+ const icon_1 = require("./icon");
31
+ const label_1 = require("./label");
32
+ const menu_1 = require("./menu");
33
+ const tools_1 = require("./tools");
34
+ /**
35
+ * Base button
36
+ */
37
+ class BaseButton extends component_1.Component {
38
+ constructor(props) {
39
+ super(props);
40
+ this.setProp('tag', 'button');
41
+ this.setDomEvent('click', (e) => this._handleClick(e));
42
+ this.setDomEvent('mousedown', () => { this._startAutoRep(true); });
43
+ this.setDomEvent('mouseup', () => { this._startAutoRep(false); });
44
+ this.setDomEvent('keydown', (e) => this._handleKeyDown(e));
45
+ this.mapPropEvents(props, 'click');
46
+ }
47
+ render(props) {
48
+ let icon = props.icon ? new icon_1.Icon({ icon: props.icon, cls: 'left', ref: 'l_icon' }) : null;
49
+ let label = new label_1.Label({ flex: 1, text: props.text ?? '', align: props.align, ref: 'label' });
50
+ let ricon = props.rightIcon ? new icon_1.Icon({ icon: props.rightIcon, cls: 'right', ref: 'r_icon' }) : null;
51
+ this.setContent([icon, label, ricon]);
52
+ this._setTabIndex(props.tabIndex);
53
+ }
54
+ /**
55
+ * starts/stops the autorepeat
56
+ */
57
+ _startAutoRep(start) {
58
+ if (!this.m_props.autoRepeat) {
59
+ return;
60
+ }
61
+ if (start) {
62
+ // 1st timer 1s
63
+ this.startTimer('repeat', 700, false, () => {
64
+ // auto click
65
+ this.startTimer('repeat', this.m_props.autoRepeat, true, this._sendClick);
66
+ });
67
+ }
68
+ else {
69
+ this.stopTimer('repeat');
70
+ }
71
+ }
72
+ /**
73
+ *
74
+ */
75
+ _handleKeyDown(ev) {
76
+ if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey) {
77
+ if (ev.key == 'Enter' || ev.key == ' ') {
78
+ this._sendClick();
79
+ ev.preventDefault();
80
+ ev.stopPropagation();
81
+ }
82
+ }
83
+ }
84
+ /**
85
+ * called by the system on click event
86
+ */
87
+ _handleClick(ev) {
88
+ if (this.m_props.menu) {
89
+ let menu = new menu_1.Menu({
90
+ items: (0, tools_1.isFunction)(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
91
+ });
92
+ let rc = this.getBoundingRect();
93
+ menu.displayAt(rc.left, rc.bottom, 'tl');
94
+ }
95
+ else {
96
+ this._sendClick();
97
+ }
98
+ ev.preventDefault();
99
+ ev.stopPropagation();
100
+ }
101
+ /**
102
+ * sends a click to the observers
103
+ */
104
+ _sendClick() {
105
+ if (this.m_props.menu) {
106
+ let menu = new menu_1.Menu({
107
+ items: (0, tools_1.isFunction)(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
108
+ });
109
+ let rc = this.getBoundingRect();
110
+ menu.displayAt(rc.left, rc.bottom, 'tl');
111
+ }
112
+ else {
113
+ this.emit('click', (0, x4_events_1.EvClick)());
114
+ }
115
+ }
116
+ /**
117
+ * change the button text
118
+ * @example
119
+ * ```ts
120
+ * let btn = new Button( {
121
+ * text: 'hello'
122
+ * });
123
+ *
124
+ * btn.text = 'world';
125
+ * ```
126
+ */
127
+ set text(text) {
128
+ this.m_props.text = text;
129
+ let label = this.itemWithRef('label');
130
+ if (label) {
131
+ label.text = text;
132
+ }
133
+ }
134
+ get text() {
135
+ let label = this.itemWithRef('label');
136
+ return label?.text;
137
+ }
138
+ /**
139
+ * change the button icon
140
+ * todo: do nothing if no icon defined at startup
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * let btn = new Button( {
145
+ * text: 'hello',
146
+ * icon: 'close'
147
+ * });
148
+ * btn.setIcon( 'open' );
149
+ * ```
150
+ */
151
+ set icon(icon) {
152
+ this.m_props.icon = icon;
153
+ let ico = this.itemWithRef('l_icon');
154
+ if (ico) {
155
+ ico.icon = icon;
156
+ }
157
+ else {
158
+ this.update();
159
+ }
160
+ }
161
+ get icon() {
162
+ let ico = this.itemWithRef('l_icon');
163
+ return ico?.icon;
164
+ }
165
+ /**
166
+ * change the button right icon
167
+ * todo: do nothing if no icon defined at startup
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * let btn = new Button( {
172
+ * text: 'hello',
173
+ * icon: 'close'
174
+ * });
175
+ * btn.setIcon( 'open' );
176
+ * ```
177
+ */
178
+ set rightIcon(icon) {
179
+ this.m_props.rightIcon = icon;
180
+ let ico = this.itemWithRef('r_icon');
181
+ if (ico) {
182
+ ico.icon = icon;
183
+ }
184
+ }
185
+ get rightIcon() {
186
+ let ico = this.itemWithRef('l_icon');
187
+ return ico?.icon;
188
+ }
189
+ /**
190
+ *
191
+ */
192
+ set menu(items) {
193
+ this.m_props.menu = items;
194
+ }
195
+ }
196
+ exports.BaseButton = BaseButton;
197
+ // :: BUTTON ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
198
+ /**
199
+ *
200
+ */
201
+ class Button extends BaseButton {
202
+ }
203
+ exports.Button = Button;
204
+ /**
205
+ *
206
+ */
207
+ class ToggleButton extends BaseButton {
208
+ constructor(props) {
209
+ super(props);
210
+ }
211
+ /**
212
+ *
213
+ */
214
+ render(props) {
215
+ super.render(props);
216
+ if (props.checked) {
217
+ this.addClass('checked');
218
+ this._updateIcon();
219
+ }
220
+ }
221
+ /**
222
+ *
223
+ */
224
+ _sendClick() {
225
+ super._sendClick();
226
+ this.m_props.checked = !this.m_props.checked;
227
+ this.setClass('checked', this.m_props.checked);
228
+ this.emit('change', (0, x4_events_1.EvChange)(this.m_props.checked));
229
+ this._updateIcon();
230
+ }
231
+ _updateIcon() {
232
+ if (this.m_props.checkedIcon) {
233
+ const ic = this.m_props.checked ? this.m_props.checkedIcon : this.m_props.icon;
234
+ let ico = this.itemWithRef('l_icon');
235
+ if (ico) {
236
+ ico.icon = ic;
237
+ }
238
+ }
239
+ }
240
+ }
241
+ exports.ToggleButton = ToggleButton;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file calendar.ts
9
+ * @author Etienne Cochard
10
+ * @license
11
+ * Copyright (c) 2019-2021 R-libre ingenierie
12
+ *
13
+ * This program is free software; you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation; either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
24
+ **/
25
+ import { Popup } from './popup';
26
+ import { CProps, ContainerEventMap } from './component';
27
+ import { EvChange, EventCallback } from './x4_events';
28
+ import { VLayout } from './layout';
29
+ interface CalendarEventMap extends ContainerEventMap {
30
+ change?: EvChange;
31
+ }
32
+ interface CalendarProps extends CProps<CalendarEventMap> {
33
+ date?: Date;
34
+ minDate?: Date;
35
+ maxDate?: Date;
36
+ change?: EventCallback<EvChange>;
37
+ }
38
+ /**
39
+ * default calendar control
40
+ *
41
+ * fires:
42
+ * EventChange ( value = Date )
43
+ */
44
+ export declare class Calendar extends VLayout<CalendarProps, CalendarEventMap> {
45
+ private m_date;
46
+ constructor(props: CalendarProps);
47
+ /** @ignore */
48
+ render(props: CalendarProps): void;
49
+ /**
50
+ * select the given date
51
+ * @param date
52
+ */
53
+ private select;
54
+ /**
55
+ *
56
+ */
57
+ private _next;
58
+ /**
59
+ *
60
+ */
61
+ private _choose;
62
+ get date(): Date;
63
+ set date(date: Date);
64
+ }
65
+ /**
66
+ * default popup calendar
67
+ */
68
+ export declare class PopupCalendar extends Popup {
69
+ m_cal: Calendar;
70
+ constructor(props: CalendarProps);
71
+ private _handleClick;
72
+ /** @ignore */
73
+ show(modal?: boolean): void;
74
+ /** @ignore */
75
+ close(): void;
76
+ }
77
+ export {};
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ /**
3
+ * ___ ___ __
4
+ * \ \/ / / _
5
+ * \ / /_| |_
6
+ * / \____ _|
7
+ * /__/\__\ |_|
8
+ *
9
+ * @file calendar.ts
10
+ * @author Etienne Cochard
11
+ * @license
12
+ * Copyright (c) 2019-2021 R-libre ingenierie
13
+ *
14
+ * This program is free software; you can redistribute it and/or modify
15
+ * it under the terms of the GNU General Public License as published by
16
+ * the Free Software Foundation; either version 3 of the License, or
17
+ * (at your option) any later version.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
25
+ **/
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PopupCalendar = exports.Calendar = void 0;
28
+ const button_1 = require("./button");
29
+ const popup_1 = require("./popup");
30
+ const component_1 = require("./component");
31
+ const x4_events_1 = require("./x4_events");
32
+ const i18n_1 = require("./i18n");
33
+ const label_1 = require("./label");
34
+ const layout_1 = require("./layout");
35
+ const tools_1 = require("./tools");
36
+ const menu_1 = require("./menu");
37
+ /**
38
+ * default calendar control
39
+ *
40
+ * fires:
41
+ * EventChange ( value = Date )
42
+ */
43
+ class Calendar extends layout_1.VLayout {
44
+ m_date;
45
+ constructor(props) {
46
+ super(props);
47
+ this.mapPropEvents(props, 'change');
48
+ this.m_date = props.date?.clone() ?? new Date();
49
+ }
50
+ /** @ignore */
51
+ render(props) {
52
+ let month_start = (0, tools_1.date_clone)(this.m_date);
53
+ month_start.setDate(1);
54
+ let day = month_start.getDay();
55
+ if (day == 0) {
56
+ day = 7;
57
+ }
58
+ month_start.setDate(-day + 1 + 1);
59
+ let dte = (0, tools_1.date_clone)(month_start);
60
+ let today = this.m_date.hash();
61
+ let month_end = (0, tools_1.date_clone)(this.m_date);
62
+ month_end.setDate(1);
63
+ month_end.setMonth(month_end.getMonth() + 1);
64
+ month_end.setDate(0);
65
+ let end_of_month = (0, tools_1.date_hash)(month_end);
66
+ let rows = [];
67
+ // month selector
68
+ let header = new layout_1.HLayout({
69
+ cls: 'month-sel',
70
+ content: [
71
+ new label_1.Label({
72
+ cls: 'month',
73
+ text: (0, tools_1.formatIntlDate)(this.m_date, 'O'),
74
+ dom_events: {
75
+ click: () => this._choose('month')
76
+ }
77
+ }),
78
+ new label_1.Label({
79
+ cls: 'year',
80
+ text: (0, tools_1.formatIntlDate)(this.m_date, 'Y'),
81
+ dom_events: {
82
+ click: () => this._choose('year')
83
+ }
84
+ }),
85
+ new component_1.Flex(),
86
+ new button_1.Button({ text: '<', click: () => this._next(false) }),
87
+ new button_1.Button({ text: '>', click: () => this._next(true) })
88
+ ]
89
+ });
90
+ rows.push(header);
91
+ // calendar part
92
+ let day_names = [];
93
+ // day names
94
+ // empty week num
95
+ day_names.push(new layout_1.HLayout({
96
+ cls: 'weeknum cell',
97
+ }));
98
+ for (let d = 0; d < 7; d++) {
99
+ day_names.push(new label_1.Label({
100
+ cls: 'cell',
101
+ flex: 1,
102
+ text: i18n_1._tr.global.day_short[(d + 1) % 7]
103
+ }));
104
+ }
105
+ rows.push(new layout_1.HLayout({
106
+ cls: 'week header',
107
+ content: day_names
108
+ }));
109
+ let cmonth = this.m_date.getMonth();
110
+ // weeks
111
+ let first = true;
112
+ while ((0, tools_1.date_hash)(dte) <= end_of_month) {
113
+ let days = [
114
+ new layout_1.HLayout({ cls: 'weeknum cell', content: new component_1.Component({ tag: 'span', content: (0, tools_1.formatIntlDate)(dte, 'w') }) })
115
+ ];
116
+ // days
117
+ for (let d = 0; d < 7; d++) {
118
+ let cls = 'cell day';
119
+ if (dte.hash() == today) {
120
+ cls += ' today';
121
+ }
122
+ if (dte.getMonth() != cmonth) {
123
+ cls += ' out';
124
+ }
125
+ days.push(new layout_1.HLayout({
126
+ cls,
127
+ flex: 1,
128
+ content: new component_1.Component({
129
+ tag: 'span',
130
+ content: (0, tools_1.formatIntlDate)(dte, 'd'),
131
+ }),
132
+ dom_events: {
133
+ click: () => this.select(dte.clone())
134
+ }
135
+ }));
136
+ dte.setDate(dte.getDate() + 1);
137
+ first = false;
138
+ }
139
+ rows.push(new layout_1.HLayout({
140
+ cls: 'week',
141
+ flex: 1,
142
+ content: days
143
+ }));
144
+ }
145
+ this.setContent(rows);
146
+ }
147
+ /**
148
+ * select the given date
149
+ * @param date
150
+ */
151
+ select(date) {
152
+ this.m_date = date;
153
+ this.emit('change', (0, x4_events_1.EvChange)(date));
154
+ this.update();
155
+ }
156
+ /**
157
+ *
158
+ */
159
+ _next(n) {
160
+ this.m_date.setMonth(this.m_date.getMonth() + (n ? 1 : -1));
161
+ this.update();
162
+ }
163
+ /**
164
+ *
165
+ */
166
+ _choose(type) {
167
+ let items = [];
168
+ if (type == 'month') {
169
+ for (let m = 0; m < 12; m++) {
170
+ items.push(new menu_1.MenuItem({
171
+ text: i18n_1._tr.global.month_long[m],
172
+ click: () => { this.m_date.setMonth(m); this.update(); }
173
+ }));
174
+ }
175
+ }
176
+ else if (type == 'year') {
177
+ let min = this.m_props.minDate?.getFullYear() ?? 1900;
178
+ let max = this.m_props.maxDate?.getFullYear() ?? 2037;
179
+ for (let m = min; m < max; m++) {
180
+ items.push(new menu_1.MenuItem({
181
+ text: '' + m,
182
+ click: () => { this.m_date.setFullYear(m); this.update(); }
183
+ }));
184
+ }
185
+ }
186
+ let menu = new menu_1.Menu({
187
+ items
188
+ });
189
+ let rc = this.getBoundingRect();
190
+ menu.displayAt(rc.left, rc.top);
191
+ }
192
+ get date() {
193
+ return this.m_date;
194
+ }
195
+ set date(date) {
196
+ this.m_date = date;
197
+ this.update();
198
+ }
199
+ }
200
+ exports.Calendar = Calendar;
201
+ /**
202
+ * default popup calendar
203
+ */
204
+ class PopupCalendar extends popup_1.Popup {
205
+ m_cal;
206
+ constructor(props) {
207
+ super({ tabIndex: 1 });
208
+ this.enableMask(false);
209
+ this.m_cal = new Calendar(props);
210
+ this.m_cal.addClass('@fit');
211
+ this.setContent(this.m_cal);
212
+ }
213
+ // binded
214
+ _handleClick = (e) => {
215
+ if (!this.dom) {
216
+ return;
217
+ }
218
+ let newfocus = e.target;
219
+ // child of this: ok
220
+ if (this.dom.contains(newfocus)) {
221
+ return;
222
+ }
223
+ // menu: ok
224
+ let dest = component_1.Component.getElement(newfocus, menu_1.MenuItem);
225
+ if (dest) {
226
+ return;
227
+ }
228
+ this.close();
229
+ };
230
+ /** @ignore */
231
+ show(modal) {
232
+ document.addEventListener('mousedown', this._handleClick);
233
+ super.show(modal);
234
+ }
235
+ /** @ignore */
236
+ close() {
237
+ document.removeEventListener('mousedown', this._handleClick);
238
+ super.close();
239
+ }
240
+ }
241
+ exports.PopupCalendar = PopupCalendar;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file canvas.ts
9
+ * @author Etienne Cochard
10
+ * @license
11
+ * Copyright (c) 2019-2021 R-libre ingenierie
12
+ *
13
+ * This program is free software; you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License as published by
15
+ * the Free Software Foundation; either version 3 of the License, or
16
+ * (at your option) any later version.
17
+ *
18
+ * This program is distributed in the hope that it will be useful,
19
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ * GNU General Public License for more details.
22
+ *
23
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
24
+ **/
25
+ import { Component, CProps, CEventMap } from './component';
26
+ import { BasicEvent, EventCallback } from './x4_events';
27
+ interface EvPaint extends BasicEvent {
28
+ ctx: CanvasPainter;
29
+ }
30
+ declare function EvPaint(ctx: CanvasPainter): EvPaint;
31
+ interface CanvasEventMap extends CEventMap {
32
+ paint: EvPaint;
33
+ }
34
+ interface CanvasProps extends CProps<CanvasEventMap> {
35
+ autoClear?: boolean;
36
+ painter?: PaintHandler;
37
+ paint: EventCallback<EvPaint>;
38
+ }
39
+ export interface CanvasPainter extends CanvasRenderingContext2D {
40
+ width: number;
41
+ height: number;
42
+ smoothLine(points: any[], path: CanvasPath, move: boolean): void;
43
+ smoothLineEx(_points: any[], tension: number, numOfSeg: number, path: CanvasPath, move?: boolean, close?: boolean): void;
44
+ line(x1: number, y1: number, x2: number, y2: number, color: string, lineWidth: number): void;
45
+ roundRect(x: number, y: number, width: number, height: number, radius: number): void;
46
+ calcTextSize(text: string, rounded: boolean): {
47
+ width: number;
48
+ height: number;
49
+ };
50
+ setFontSize(fs: number): void;
51
+ circle(x: number, y: number, radius: number): void;
52
+ }
53
+ declare type PaintHandler = (ctx: CanvasPainter) => any;
54
+ /**
55
+ *
56
+ */
57
+ /**
58
+ * Standard Canvas
59
+ */
60
+ export declare class Canvas extends Component<CanvasProps, CanvasEventMap> {
61
+ private m_iwidth;
62
+ private m_iheight;
63
+ private m_scale;
64
+ private m_canvas;
65
+ constructor(props: CanvasProps);
66
+ /** @ignore */
67
+ render(): void;
68
+ update(delay?: number): void;
69
+ /**
70
+ * scale the whole canvas
71
+ */
72
+ scale(scale: number): void;
73
+ /**
74
+ * return the internal canvas
75
+ */
76
+ get canvas(): Component;
77
+ /**
78
+ * redraw the canvas (force a paint)
79
+ */
80
+ private $update_rep;
81
+ redraw(wait?: number): void;
82
+ /**
83
+ *
84
+ */
85
+ private _paint;
86
+ protected paint(ctx: CanvasPainter): void;
87
+ }
88
+ export {};