mirror of
https://github.com/Rayerd/dfl.git
synced 2025-04-25 20:49:58 +03:00
Add simple clock example.
This commit is contained in:
parent
3d9fc4aee3
commit
497e87cfa5
10 changed files with 136 additions and 1 deletions
|
@ -21,6 +21,7 @@ DFL is a Win32 windowing library for the D language.
|
|||

|
||||

|
||||

|
||||

|
||||
|
||||
## Recent major features
|
||||
- **Module "dfl.printing" is now comming.**
|
||||
|
@ -81,7 +82,7 @@ In order to make and move *.lib to paths below:
|
|||
- **go.bat 32mscoff** (MSVC required) : ditto
|
||||
- **go64.bat** (MSVC required) : Make and move *.lib to %dmd_path%\lib64
|
||||
|
||||
## With DUB
|
||||
## With DUB **(RECOMMENDED)**
|
||||
First, add DFL to local DUB registry:
|
||||
```bat
|
||||
> cd dfl
|
||||
|
@ -102,4 +103,5 @@ See also **./examples/hello_dfl/dub.json**.
|
|||
|
||||
## License
|
||||
DFL is under the boost and/or zlib/libpng license.
|
||||
|
||||
However, trackbar.d is covered by the MIT license.
|
||||
|
|
16
examples/dclock/.gitignore
vendored
Normal file
16
examples/dclock/.gitignore
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
.dub
|
||||
docs.json
|
||||
__dummy.html
|
||||
docs/
|
||||
/hello_dfl
|
||||
hello_dfl.so
|
||||
hello_dfl.dylib
|
||||
hello_dfl.dll
|
||||
hello_dfl.a
|
||||
hello_dfl.lib
|
||||
hello_dfl-test-*
|
||||
*.exe
|
||||
*.pdb
|
||||
*.o
|
||||
*.obj
|
||||
*.lst
|
13
examples/dclock/.vscode/launch.json
vendored
Normal file
13
examples/dclock/.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"version": "0.1.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C++ Launch (Windows) Dclock",
|
||||
"type": "cppvsdbg",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"program": "./bin/dclock.exe",
|
||||
"console": "internalConsole"
|
||||
}
|
||||
]
|
||||
}
|
20
examples/dclock/.vscode/tasks.json
vendored
Normal file
20
examples/dclock/.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "dub",
|
||||
"run": false,
|
||||
"cwd": ".",
|
||||
"compiler": "$current",
|
||||
"archType": "$current",
|
||||
"buildType": "$current",
|
||||
"configuration": "$current",
|
||||
"problemMatcher": [
|
||||
"$dmd"
|
||||
],
|
||||
"group": "build",
|
||||
"label": "dub: Build dclock",
|
||||
"detail": "dub build --compiler=dmd.EXE -a=x86_64 -b=debug -c=application"
|
||||
}
|
||||
]
|
||||
}
|
2
examples/dclock/README.md
Normal file
2
examples/dclock/README.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Screen Shot
|
||||

|
12
examples/dclock/dclock.code-workspace
Normal file
12
examples/dclock/dclock.code-workspace
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"d.projectImportPaths": [
|
||||
"..\\..\\..\\dfl\\source"
|
||||
]
|
||||
}
|
||||
}
|
16
examples/dclock/dub.json
Normal file
16
examples/dclock/dub.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"authors": ["haru-s"],
|
||||
"copyright": "Copyright (C) 2024 haru-s",
|
||||
"description": "Dclock",
|
||||
"name": "dclock",
|
||||
"targetType": "executable",
|
||||
"targetPath": "bin",
|
||||
"dependencies": {
|
||||
"dfl": {
|
||||
"path": "../../../dfl"
|
||||
}
|
||||
},
|
||||
"lflags-windows-x86_omf-dmd": ["/exet:nt/su:windows:6.0"],
|
||||
"lflags-windows-x86_mscoff-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"],
|
||||
"lflags-windows-x86_64-dmd": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"]
|
||||
}
|
BIN
examples/dclock/image/screenshot.png
Normal file
BIN
examples/dclock/image/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 38 KiB |
3
examples/dclock/shell.bat
Normal file
3
examples/dclock/shell.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
set dmd_path=c:\d\dmd2\windows
|
||||
set dmc_path=c:\dmc\dm
|
||||
cmd
|
51
examples/dclock/source/dclock.d
Normal file
51
examples/dclock/source/dclock.d
Normal file
|
@ -0,0 +1,51 @@
|
|||
import std;
|
||||
import dfl;
|
||||
|
||||
class MainForm : Form
|
||||
{
|
||||
private Label _label;
|
||||
private Timer _timer;
|
||||
|
||||
public this()
|
||||
{
|
||||
this.text = "Dclock";
|
||||
this.size = Size(300, 150);
|
||||
this.formBorderStyle = FormBorderStyle.FIXED_SINGLE;
|
||||
this.maximizeBox = false;
|
||||
this.topMost = true;
|
||||
|
||||
void drawClock()
|
||||
{
|
||||
DateTime now = cast(DateTime)Clock.currTime();
|
||||
_label.text = format(
|
||||
"%.4d/%.2d/%.2d\n(%s)%.2d:%.2d",
|
||||
now.year, now.month, now.day,
|
||||
["日","月","火","水","木","金","土"][now.dayOfWeek],
|
||||
now.hour, now.minute);
|
||||
}
|
||||
|
||||
_label = new Label;
|
||||
_label.location = Point(0, 0);
|
||||
_label.font = new Font("MS Gothic", 40f);
|
||||
_label.autoSize = true;
|
||||
_label.parent = this;
|
||||
drawClock();
|
||||
|
||||
_timer = new Timer;
|
||||
_timer.interval = 1000;
|
||||
_timer.start();
|
||||
_timer.tick ~= (Timer t, EventArgs e) {
|
||||
drawClock();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
Application.enableVisualStyles();
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
Application.run(new MainForm());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue