Repository navigation
Expand file tree
/
Copy pathapp.d
More file actions
208 lines (169 loc) · 6.37 KB
/
Copy pathapp.d
File metadata and controls
208 lines (169 loc) · 6.37 KB
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
#!rdmd
import std.stdio;
import wings;
// Since, Wings use delegates for event handling and D is an OOP language...
// We can wrap up the entire app in a class. It's handy.
class App {
// import wings.commons: log;
this() {
this.createControls();
this.setControlProps();
}
void createControls() {
// First of all, create the form aka window.
frm = new Form("Wing window in D Lang", 900, 500);
frm.enablePrintPoint();
// frm.createHandle();
//Let's create a tray icon for this program.
tic = new TrayIcon("Wings tray icon!", "wings_icon.ico");
// Now, add a context menu to our tray. '|' is for separator.
tic.addContextMenu(true, TrayMenuTrigger.anyClick, "Windows_ti", "Linux_ti", "|", "MacOS_ti");
// // If this set to true, all control handles will be
// // created right after the class ctor finished.
frm.createChildHandles = true;
//Let's add a menu bar and some menu items
mb = frm.addMenuBar(true, "Windows", "Linux", "MacOS");
// Add 3 buttons
btn1 = new Button(frm, "Normal", 10, 10);
btn2 = new Button(frm, "Color", btn1.right!10, 10);
btn3 = new Button(frm, "Gradient", btn2.right!10, 10);
cmb = new ComboBox(frm, btn3.right!10, 10, 150, 30);
dtp = new DateTimePicker(frm, cmb.right!10, 10);
gb1 = new GroupBox(frm, "Compiler Options", 10, btn1.bottom!10, 200, 170);
cb1 = new CheckBox(gb1, "Profile", 15, 35);
cb2 = new CheckBox(gb1, "Low Mem", 15, 65);
rb1 = new RadioButton(gb1, "Console App", 15, 95);
rb2 = new RadioButton(gb1, "Windowed App", 15, 125);
rb2.checked = true;
gb2 = new GroupBox(frm, "Project Settings", 10, gb1.bottom!
8000
10, 220, 100);
lb1 = new Label(gb2, "Line Space", 10, 35);
lb2 = new Label(gb2, "Thread Count", 10, 65);
// NumberPicker aka NumericUpdown in .NET
np1 = new NumberPicker(gb2, 100, 30);
np2 = new NumberPicker(gb2, 100, 60, btnLeft: true);
pgb = new ProgressBar(frm, 10, gb2.bottom!10, 204, 25);
// auto catimage = "D:\\Downloads_Ex\\2026\\nvidia-com.png";
pbx = new PictureBox(frm, 710, 272, 150, 150, "nvidia-com.png", PictureSizeMode.stretch);
tb = new TextBox(frm, 10, pgb.bottom!10, pgb.width, 30);
lbx = new ListBox(frm, gb1.right!10, btn1.bottom!15, 120, 160);
// ListView ctor takes an array for items and another for col widths.
lv = new ListView(frm, lbx.right!10, btn1.bottom!15, 300, 180);
// Trackbar ctor takes a delegate for onValueChanged event.
tkb1 = new TrackBar(frm, dtp.right!10, 10, 150, 40, true, &this.onTrackValueChanged);
tv = new TreeView(frm, lv.right!10, lv.ypos, 200, 200);
// Calendar aka MonthCalendar in .NET
cal = new Calendar(frm, gb2.right!10, lv.bottom!15);
// Another trackbar but this time, it's vertical.
tkb2 = new TrackBar(frm, 500, 270, 60, 150, vertical: true, cdraw: true);
// Add a timer with a delegate to handle the onTick event.
tmr = frm.addTimer(&this.timerTickHandler, 800);
}
void setControlProps() {
// Set some properties of our controls.
btn1.>
btn1.font.name = "Blackadder ITC";
btn2.backColor = 0x83c5be;
btn3.setGradientColors(0xeeef20, 0x70e000);
btn3.>
cmb.addRange("Form", "Button", "Calendar", "CheckBox", "ComboBox", "DateTimePicker", "GroupBox", 4500);
cmb.dropDownStyle = DropDownStyle.labelCombo;
cmb.selectedIndex = 4;
gb1.foreColor = 0xd90429; // This only works for GroupBox text.
np1.foreColor = 0x3f37c9;
np1.backColor = 0xee9b00;
np1.step = 0.25;
np2.decimalPrecision = 0;
np2.backColor = 0x2ec4b6;
pgb.showPercentage = true;
tb.foreColor = 0xff0000;
tb.cueBanner = "Type something here...";
tkb1.>
lbx.addRange("Windows", "Linux", "MacOS", "ReactOS");
lv.addColumns(["Windows", "MacOS", "Linux"], [80, 120, 100]);
lv.addRow("XP", "Mountain Lion", "RedHat");
lv.addRow("Vista", "Mavericks", "Mint");
lv.addRow("Win7", "Mavericks", "Ubuntu");
lv.addRow("Win8", "Catalina", "Debian");
lv.addRow("Win10", "Big Sur", "Kali");
// lv.createHandle();
lv.addContextMenu("Windows", "Linux", "|", "MacOS");
tv.backColor = 0xddddbb;
tv.addNodeWithChildren("Windows", "Win 11", "Win 10", "Win 8");
tv.addNodeWithChildren("Linux", "Ubuntu", "Debian", "Fedora");
tv.addNodeWithChildren("MacOS", "Monterey", "Catalina", "Big Sur");
// tv.createHandle();
// Add menu items for our main menus.
mb["Windows"].addItems("Windows 8", "|", "Windows 10", "Windows 11");
mb["Linux"].addItems("Ubuntu", "Debian", "Kali");
mb["MacOS"].addItems("Mavericks", "Catalina", "Big Sur");
// Add menu click event handler for tray icon context menu.
tic.contextMenu["Windows_ti"].>
// Add handler for listview's context menu.
lv.contextMenu["Linux"].>
np1.>
np1.>
}
void display() {this.frm.show();}
// When clicked on button, combo's drop down style will change.
void btn1OnClick(Object s, EventArgs e) {
auto ofd = new FileOpenDialog("Open files", "",
"Pdf Files|*.pdf|Text Files|*.txt");
ofd.multiSelection = true;
if (ofd.showDialog()) {
print("Selected file: ", ofd.fileNames);
}
}
// Timer tick event handler
void timerTickHandler(Object c, EventArgs e) {writeln("Timer ticked...");}
// ProgressBar will show the track bar values.
void onTrackValueChanged(Object c, EventArgs e) {
pgb.value = tkb1.value;
}
void onContextMenuClick(Object m, EventArgs e) {
// delay(3000);
writeln("Windows menu clicked");
}
void onLVContextMenuClick(Object m, EventArgs e) {
// delay(3000);
writeln("Linux menu clicked");
}
void btn3Click(Object c, EventArgs e) {
// this.tic.showBalloon("Wings Balloon", "This is Wings Balloon Text", 3000);
print("Gradient button clicked");
}
void menter(Object c, EventArgs e) {
writeln("Mouse entered nump");
}
void mleave(Object c, EventArgs e) {
writeln("Mouse leave from numpi");
}
private:
Form frm;
Button btn1, btn2, btn3;
Calendar cal;
CheckBox cb1, cb2;
ComboBox cmb;
DateTimePicker dtp;
GroupBox gb1, gb2;
Label lb1, lb2;
ListBox lbx;
ListView lv;
MenuBar mb;
NumberPicker np1, np2;
ProgressBar pgb;
PictureBox pbx;
RadioButton rb1, rb2;
TextBox tb;
TrackBar tkb1, tkb2;
TreeView tv;
Timer tmr;
TrayIcon tic;
}
void main()
{
import core.sys.windows.windows;
auto app = new App();
app.btn1.tpr();
app.display();
}
// 91471 66 30 84 7
You can’t perform that action at this time.