forked from UplinkCoder/d-tui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwidget.d
960 lines (854 loc) · 25 KB
/
twidget.d
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
/**
* D Text User Interface library - TWidget class
*
* Version: $Id$
*
* Author: Kevin Lamonte, <a href="mailto:[email protected]">[email protected]</a>
*
* License: LGPLv3 or later
*
* Copyright: This module is licensed under the GNU Lesser General
* Public License Version 3. Please see the file "COPYING" in this
* directory for more information about the GNU Lesser General Public
* License Version 3.
*
* Copyright (C) 2013 Kevin Lamonte
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see
* http://www.gnu.org/licenses/, or write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
module tui.twidget;
// Description ---------------------------------------------------------------
// Imports -------------------------------------------------------------------
import tui.base;
import tui.tmenu;
import tui.tscroll;
import tui.twindow;
// Convenience constructors
import tui.tbutton;
import tui.tcheckbox;
import tui.tdirlist;
import tui.tfield;
import tui.tlabel;
import tui.tprogress;
import tui.tradio;
import tui.ttext;
import tui.ttreeview;
// Defines -------------------------------------------------------------------
// Globals -------------------------------------------------------------------
// Classes -------------------------------------------------------------------
/**
* TWidget is the base class of all objects that can be drawn on
* screen or handle user input events.
*/
public class TWidget {
/// Every widget has a parent widget that it may be "contained"
/// in. For example, a TWindow might contain several TTextFields,
/// or a TComboBox may contain a TScrollBar.
public TWidget parent = null;
/// Child widgets that this widget contains.
public TWidget [] children;
/// The currently active child widget that will receive keypress events.
public TWidget activeChild = null;
/// If true, this widget will receive events.
public bool active = false;
/// The window that this widget draws to.
public TWindow window = null;
/// Absolute X position of the top-left corner.
public int x = 0;
/// Absolute Y position of the top-left corner.
public int y = 0;
/// Width
public uint width = 0;
/// Height
public uint height = 0;
/// My tab order inside a window or containing widget
private int tabOrder = 0;
/// If true, this widget can be tabbed to or receive events
private bool _enabled = true;
/// If true, this widget can be tabbed to or receive events
@property public bool enabled() {
return _enabled;
}
/// If true, this widget can be tabbed to or receive events
@property public bool enabled(bool value) {
_enabled = value;
if (value == false) {
active = false;
// See if there are any active siblings to switch to
bool foundSibling = false;
if (parent !is null) {
foreach (w; parent.children) {
if ((w.enabled) &&
(!cast(THScroller)this) &&
(!cast(TVScroller)this)
) {
parent.activate(w);
foundSibling = true;
break;
}
}
if (!foundSibling) {
parent.activeChild = null;
}
}
}
return _enabled;
}
/// If true, this widget has a cursor
public bool hasCursor = false;
/// Cursor column position in relative coordinates
public uint cursorX = 0;
/// Cursor row position in relative coordinates
public uint cursorY = 0;
/// Comparison operator sorts on tabOrder
public override int opCmp(Object rhs) {
auto that = cast(TWidget)rhs;
if (!that) {
return 0;
}
return tabOrder - that.tabOrder;
}
/**
* See if this widget should render with the active color.
*
* Returns:
* true if this widget is active and all of its parents are active.
*/
public bool getAbsoluteActive() {
if (parent is this) {
return active;
}
return (active && parent.getAbsoluteActive());
}
/**
* Returns the cursor X position.
*
* Returns:
* absolute screen column number for the cursor's X position
*/
public uint getCursorAbsoluteX() {
assert(hasCursor == true);
return getAbsoluteX() + cursorX;
}
/**
* Returns the cursor Y position.
*
* Returns:
* absolute screen row number for the cursor's Y position
*/
public uint getCursorAbsoluteY() {
assert(hasCursor == true);
return getAbsoluteY() + cursorY;
}
/**
* Compute my absolute X position as the sum of my X plus all my
* parent's X's.
*
* Returns:
* absolute screen column number for my X position
*/
public int getAbsoluteX() {
assert (parent !is null);
if (parent is this) {
return x;
}
if ((cast(TWindow)parent) && (!cast(TMenu)parent)) {
// Widgets on a TWindow have (0,0) as their top-left, but
// this is actually the TWindow's (1,1).
return parent.getAbsoluteX() + x + 1;
}
return parent.getAbsoluteX() + x;
}
/**
* Compute my absolute Y position as the sum of my Y plus all my
* parent's Y's.
*
* Returns:
* absolute screen row number for my Y position
*/
public int getAbsoluteY() {
assert (parent !is null);
if (parent is this) {
return y;
}
if ((cast(TWindow)parent) && (!cast(TMenu)parent)) {
// Widgets on a TWindow have (0,0) as their top-left, but
// this is actually the TWindow's (1,1).
return parent.getAbsoluteY() + y + 1;
}
return parent.getAbsoluteY() + y;
}
/// Draw my specific widget. When called, the screen rectangle I
/// draw into is already setup (offset and clipping).
public void draw() {
// Default widget draws nothing.
}
/// Called by parent to render to TWindow.
public final void drawChildren() {
// Set my clipping rectangle
assert (window !is null);
assert (window.screen !is null);
window.screen.clipRight = width;
window.screen.clipBottom = height;
int absoluteRightEdge = window.getAbsoluteX() + window.width;
int absoluteBottomEdge = window.getAbsoluteY() + window.height;
if ((!cast(TWindow)this) && (!cast(TVScroller)this)) {
absoluteRightEdge -= 1;
}
if ((!cast(TWindow)this) && (!cast(THScroller)this)) {
absoluteBottomEdge -= 1;
}
int myRightEdge = getAbsoluteX() + width;
int myBottomEdge = getAbsoluteY() + height;
if (getAbsoluteX() > absoluteRightEdge) {
// I am offscreen
window.screen.clipRight = 0;
} else if (myRightEdge > absoluteRightEdge) {
window.screen.clipRight -= myRightEdge - absoluteRightEdge;
}
if (getAbsoluteY() > absoluteBottomEdge) {
// I am offscreen
window.screen.clipBottom = 0;
} else if (myBottomEdge > absoluteBottomEdge) {
window.screen.clipBottom -= myBottomEdge - absoluteBottomEdge;
}
// Set my offset
window.screen.offsetX = getAbsoluteX();
window.screen.offsetY = getAbsoluteY();
// Draw me
draw();
// Continue down the chain
foreach (w; children) {
w.drawChildren();
}
}
/// TWindow needs this constructor.
protected this() {}
/**
* Public constructor
*
* Params:
* parent = parent widget
*/
public this(TWidget parent) {
this.parent = parent;
this.window = parent.window;
parent.addChild(this);
}
/**
* Add a child widget to my list of children. We set its tabOrder
* to 0 and increment the tabOrder of all other children.
*
* Params:
* child = TWidget to add
*/
private void addChild(TWidget child) {
children ~= child;
if ((child.enabled) &&
(!cast(THScroller)child) &&
(!cast(TVScroller)child)
) {
foreach (w; children) {
w.active = false;
}
child.active = true;
activeChild = child;
}
for (auto i = 0; i < children.length; i++) {
children[i].tabOrder = i;
}
}
/**
* Switch the active child
*
* Params:
* child = TWidget to activate
*/
public void activate(TWidget child) {
assert(child.enabled);
if ((cast(THScroller)child) ||
(cast(TVScroller)child)) {
return;
}
if (child !is activeChild) {
if (activeChild !is null) {
activeChild.active = false;
}
child.active = true;
activeChild = child;
}
}
/**
* Switch the active child
*
* Params:
* tabOrder = tabOrder of the child to activate. If that child
* isn't enabled, then the next enabled child will be
* activated.
*/
public void activate(ulong tabOrder) {
if (activeChild is null) {
return;
}
TWidget child = null;
foreach (w; children) {
if ((w.enabled == true) &&
(!cast(THScroller)w) &&
(!cast(TVScroller)w) &&
(w.tabOrder >= tabOrder)
) {
child = w;
break;
}
}
if ((child !is null) && (child !is activeChild)) {
activeChild.active = false;
assert(child.enabled);
child.active = true;
activeChild = child;
}
}
/**
* Switch the active widget with the next in the tab order.
*
* Param:
* forward = switch to the next enabled widget in the list
*/
final public void switchWidget(bool forward) {
// Only switch if there are multiple enabled widgets
if ((children.length < 2) || (activeChild is null)) {
return;
}
int tabOrder = activeChild.tabOrder;
do {
if (forward) {
tabOrder++;
} else {
tabOrder--;
}
if (tabOrder < 0) {
// If at the end, pass the switch to my parent.
if ((!forward) && (parent !is this)) {
parent.switchWidget(forward);
return;
}
tabOrder = cast(int)children.length - 1;
} else if (tabOrder == children.length) {
// If at the end, pass the switch to my parent.
if ((forward) && (parent !is this)) {
parent.switchWidget(forward);
return;
}
tabOrder = 0;
}
if (activeChild.tabOrder == tabOrder) {
// We wrapped around
break;
}
} while ((children[tabOrder].enabled == false) &&
!cast(THScroller)(children[tabOrder]) &&
!cast(TVScroller)(children[tabOrder]));
assert(children[tabOrder].enabled == true);
activeChild.active = false;
children[tabOrder].active = true;
activeChild = children[tabOrder];
// Refresh
window.application.repaint = true;
}
/**
* Returns my active widget.
*
* Returns:
* widget that is active, or this if no children
*/
public TWidget getActiveChild() {
if ((cast(THScroller)this) ||
(cast(TVScroller)this)
) {
return parent;
}
foreach (w; children) {
if (w.active) {
return w.getActiveChild();
}
}
// No active children, return me
return this;
}
/**
* Method that subclasses can override to handle keystrokes.
*
* Params:
* keypress = keystroke event
*/
public void onKeypress(TKeypressEvent keypress) {
if ((children.length == 0) ||
(cast(TTreeView)this) ||
(cast(TText)this)
) {
// Defaults:
// tab / shift-tab - switch to next/previous widget
// right-arrow or down-arrow: same as tab
// left-arrow or up-arrow: same as shift-tab
if ((keypress.key == kbTab) ||
(keypress.key == kbRight) ||
(keypress.key == kbDown)
) {
parent.switchWidget(true);
return;
} else if ((keypress.key == kbShiftTab) ||
(keypress.key == kbBackTab) ||
(keypress.key == kbLeft) ||
(keypress.key == kbUp)
) {
parent.switchWidget(false);
return;
}
}
// If I have any buttons on me AND this is an Alt-key that matches
// its mnemonic, send it an Enter keystroke
foreach (w; children) {
if (TButton button = cast(TButton)w) {
if (button.enabled &&
!keypress.key.isKey &&
keypress.key.alt &&
!keypress.key.ctrl &&
(toLowercase(button.mnemonic.shortcut) == toLowercase(keypress.key.ch))) {
w.handleEvent(new TKeypressEvent(kbEnter));
return;
}
}
}
// Dispatch the keypress to an active widget
foreach (w; children) {
if (w.active) {
window.application.repaint = true;
w.handleEvent(keypress);
return;
}
}
}
/**
* Method that subclasses can override to handle mouse button
* presses.
*
* Params:
* event = mouse button event
*/
public void onMouseDown(TMouseEvent event) {
// Default: do nothing, pass to children instead
foreach (w; children) {
if (w.mouseWouldHit(event)) {
// Dispatch to this child, also activate it
activate(w);
// Set x and y relative to the child's coordinates
event.x = event.absoluteX - w.getAbsoluteX();
event.y = event.absoluteY - w.getAbsoluteY();
w.handleEvent(event);
return;
}
}
}
/**
* Method that subclasses can override to handle mouse button
* releases.
*
* Params:
* event = mouse button release event
*/
public void onMouseUp(TMouseEvent event) {
// Default: do nothing, pass to children instead
foreach (w; children) {
if (w.mouseWouldHit(event)) {
// Dispatch to this child, also activate it
activate(w);
// Set x and y relative to the child's coordinates
event.x = event.absoluteX - w.getAbsoluteX();
event.y = event.absoluteY - w.getAbsoluteY();
w.handleEvent(event);
return;
}
}
}
/**
* Method that subclasses can override to handle mouse movements.
*
* Params:
* event = mouse motion event
*/
public void onMouseMotion(TMouseEvent event) {
// Default: do nothing, pass it on to ALL of my children. This way
// the children can see the mouse "leaving" their area.
foreach (w; children) {
// Set x and y relative to the child's coordinates
event.x = event.absoluteX - w.getAbsoluteX();
event.y = event.absoluteY - w.getAbsoluteY();
w.handleEvent(event);
}
}
/**
* Method that subclasses can override to handle window/screen
* resize events.
*
* Params:
* event = resize event
*/
public void onResize(TResizeEvent event) {
// Default: do nothing, pass to children instead
foreach (w; children) {
w.onResize(event);
}
}
/**
* Method that subclasses can override to handle menu or posted command
* events.
*
* Params:
* event = command event
*/
public void onCommand(TCommandEvent event) {
// Default: do nothing, pass to children instead
foreach (w; children) {
w.onCommand(event);
}
}
/**
* Method that subclasses can override to handle menu or posted menu
* events.
*
* Params:
* menu = menu event
*/
public void onMenu(TMenuEvent menu) {
// Default: do nothing, pass to children instead
foreach (w; children) {
w.onMenu(menu);
}
}
/**
* Method that subclasses can override to do processing when the UI is
* idle.
*/
public void onIdle() {
// Default: do nothing, pass to children instead
foreach (w; children) {
w.onIdle();
}
}
/**
* Consume event. Subclasses that want to intercept all events
* in one go can override this method.
*
* Params:
* event = keyboard or mouse event
*/
final public void handleEvent(TInputEvent event) {
// std.stdio.stderr.writefln("TWidget (%s) event: %s", this.classinfo.name, event);
if (!enabled) {
// Discard event
// std.stdio.stderr.writefln(" -- discard --");
return;
}
if (auto keypress = cast(TKeypressEvent)event) {
onKeypress(keypress);
} else if (auto mouse = cast(TMouseEvent)event) {
final switch (mouse.type) {
case TMouseEvent.Type.MOUSE_DOWN:
onMouseDown(mouse);
break;
case TMouseEvent.Type.MOUSE_UP:
onMouseUp(mouse);
break;
case TMouseEvent.Type.MOUSE_MOTION:
onMouseMotion(mouse);
break;
}
} else if (auto resize = cast(TResizeEvent)event) {
onResize(resize);
} else if (auto cmd = cast(TCommandEvent)event) {
onCommand(cmd);
} else if (auto menu = cast(TMenuEvent)event) {
onMenu(menu);
}
// Do nothing else
return;
}
/**
* Check if a mouse press/release event coordinate is contained in this
* widget.
*
* Params:
* mouse = a mouse-based event
*
* Returns:
* whether or not a mouse click would be sent to this widget
*/
public bool mouseWouldHit(TMouseEvent mouse) {
if (!enabled) {
return false;
}
if ((mouse.absoluteX >= getAbsoluteX()) &&
(mouse.absoluteX < getAbsoluteX() + width) &&
(mouse.absoluteY >= getAbsoluteY()) &&
(mouse.absoluteY < getAbsoluteY() + height)
) {
return true;
}
return false;
}
/**
* Convenience function to add a button to this container/window.
*
* Params:
* text = label on the button
* x = column relative to parent
* y = row relative to parent
* actionFn = function to call when button is pressed
*
* Returns:
* the new button
*/
public TButton addButton(dstring text, uint x, uint y, void function() actionFn) {
return new TButton(this, text, x, y, actionFn);
}
/**
* Convenience function to add a button to this container/window.
*
* Params:
* text = label on the button
* x = column relative to parent
* y = row relative to parent
* actionFn = function to call when button is pressed
*
* Returns:
* the new button
*/
public TButton addButton(dstring text, uint x, uint y, void delegate() actionFn) {
return new TButton(this, text, x, y, actionFn);
}
/**
* Convenience function to add a label to this container/window.
*
* Params:
* text = label
* x = column relative to parent
* y = row relative to parent
* colorKey = ColorTheme key color to use for foreground text. Default is "tlabel"
*
* Returns:
* the new label
*/
public TLabel addLabel(dstring text, uint x, uint y, string colorKey = "tlabel") {
return new TLabel(this, text, x, y, colorKey);
}
/**
* Convenience function to add a field to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = visible text width
* fixed = if true, the text cannot exceed the display width
* text = initial text, default is empty string
*
* Returns:
* the new field
*/
public TField addField(uint x, uint y, uint width, bool fixed, dstring text = "") {
return new TField(this, x, y, width, fixed, text);
}
/**
* Convenience function to add a field to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = visible text width
* fixed = if true, the text cannot exceed the display width
* text = initial text
* actionFn = function to call when button is pressed
*
* Returns:
* the new field
*/
public TField addField(uint x, uint y, uint width, bool fixed, dstring text,
void delegate(bool) actionFn) {
return new TField(this, x, y, width, fixed, text, actionFn);
}
/**
* Convenience function to add a field to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = visible text width
* fixed = if true, the text cannot exceed the display width
* text = initial text
* actionFn = function to call when button is pressed
*
* Returns:
* the new field
*/
public TField addField(uint x, uint y, uint width, bool fixed, dstring text,
void function(bool) actionFn) {
return new TField(this, x, y, width, fixed, text, actionFn);
}
/**
* Convenience function to add a checkbox to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* label = label to display next to (right of) the checkbox
* checked = initial check state
*
* Returns:
* the new checkbox
*/
public TCheckbox addCheckbox(uint x, uint y, dstring label, bool checked = false) {
return new TCheckbox(this, x, y, label, checked);
}
/**
* Convenience function to add a radio group to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* label = label to display on the group box
*
* Returns:
* the new radio group
*/
public TRadioGroup addRadioGroup(uint x, uint y, dstring label) {
return new TRadioGroup(this, x, y, label);
}
/**
* Convenience function to add a resizable text area to this
* container/window.
*
* Params:
* text = text on the screen
* x = column relative to parent
* y = row relative to parent
* width = width of text area
* height = height of text area
* colorKey = ColorTheme key color to use for foreground text. Default is "ttext"
*/
public TText addText(dstring text, uint x, uint y, uint width, uint height,
string colorKey = "ttext") {
return new TText(this, text, x, y, width, height, colorKey);
}
/**
* Convenience function to add a progress bar to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = width of progress bar
* value = initial value of percent complete
*/
public TProgressBar addProgressBar(uint x, uint y, uint width, int value = 0) {
return new TProgressBar(this, x, y, width, value = 0);
}
/**
* Convenience function to add a tree view to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = width of tree view
* height = height of tree view
*/
public TTreeView addTreeView(uint x, uint y, uint width, uint height) {
return new TTreeView(this, x, y, width, height);
}
/**
* Convenience function to add a tree view to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = width of tree view
* height = height of tree view
* actionFn = function to call when an item is selected
*/
public TTreeView addTreeView(uint x, uint y, uint width, uint height,
void delegate(TTreeItem) actionFn) {
return new TTreeView(this, x, y, width, height, actionFn);
}
/**
* Convenience function to add a tree view to this container/window.
*
* Params:
* x = column relative to parent
* y = row relative to parent
* width = width of tree view
* height = height of tree view
* actionFn = function to call when an item is selected
*/
public TTreeView addTreeView(uint x, uint y, uint width, uint height,
void function(TTreeItem) actionFn) {
return new TTreeView(this, x, y, width, height, actionFn);
}
/**
* Convenience function to add a directory list view to this
* container/window.
*
* Params:
* path = directory path, must be a directory
* x = column relative to parent
* y = row relative to parent
* width = width of text area
* height = height of text area
*/
public TDirectoryList addDirectoryList(dstring path, uint x, uint y, uint width, uint height) {
return new TDirectoryList(this, path, x, y, width, height);
}
/**
* Convenience function to add a directory list view to this
* container/window.
*
* Params:
* path = directory path, must be a directory
* x = column relative to parent
* y = row relative to parent
* width = width of text area
* height = height of text area
* actionFn = function to call when an item is selected
*/
public TDirectoryList addDirectoryList(dstring path, uint x, uint y, uint width, uint height,
void function() actionFn) {
return new TDirectoryList(this, path, x, y, width, height, actionFn);
}
/**
* Convenience function to add a directory list view to this
* container/window.
*
* Params:
* path = directory path, must be a directory
* x = column relative to parent
* y = row relative to parent
* width = width of text area
* height = height of text area
* actionFn = function to call when an item is selected
*/
public TDirectoryList addDirectoryList(dstring path, uint x, uint y, uint width, uint height,
void delegate() actionFn) {
return new TDirectoryList(this, path, x, y, width, height, actionFn);
}
}
// Functions -----------------------------------------------------------------