Add fillEllipse()

Uudapte hello_dfl.d
This commit is contained in:
haru-s 2024-04-13 23:00:07 +09:00
parent 38aa9c10f6
commit 331b340629
2 changed files with 45 additions and 16 deletions

View file

@ -9,12 +9,14 @@ else
pragma(lib, "dfl.lib");
}
class MainForm : Form {
class MainForm : Form
{
private Button _button;
private ListBox _listbox;
private MainMenu _menu;
this() {
this()
{
this.text = "Hello DFL";
this.resizeRedraw = true;
@ -28,15 +30,15 @@ class MainForm : Form {
_listbox.size = Size(60, 150);
_listbox.items.add("foo");
_listbox.items.addRange(["hoge", "piyo"]);
_listbox.click ~=
(Control c, EventArgs ea) {
int index = _listbox.selectedIndex;
msgBox(to!string(index));
if(index >= 0) {
string msg = _listbox.selectedItem.toString();
msgBox(msg);
}
};
_listbox.click ~= (Control c, EventArgs ea) {
int index = _listbox.selectedIndex;
msgBox(to!string(index));
if (index >= 0)
{
string msg = _listbox.selectedItem.toString();
msgBox(msg);
}
};
_menu = new MainMenu();
MenuItem item = new MenuItem();
@ -53,21 +55,27 @@ class MainForm : Form {
override void onPaint(PaintEventArgs pea)
{
pea.graphics.drawLine(new Pen(Color.blue, 5, PenStyle.SOLID), Point(50, 200), Point(150, 170));
pea.graphics.drawEllipse(new Pen(Color.red), 100, 10, 50, 50);
pea.graphics.drawRectangle(new Pen(Color.black), 20, 170, 100, 50);
pea.graphics.fillRectangle(Color.green, 200, 10, 50, 50);
pea.graphics.drawEllipse(new Pen(Color.red), 100, 10, 50, 50);
pea.graphics.fillEllipse(new SolidBrush(Color.purple), 200, 100, 50, 50);
}
}
class TestButton : Button {
override void onClick(EventArgs ea) {
class TestButton : Button
{
override void onClick(EventArgs ea)
{
msgBox("hi");
}
}
static this() {
static this()
{
Application.enableVisualStyles();
}
void main() {
void main()
{
Application.run(new MainForm());
}

View file

@ -3080,6 +3080,27 @@ class Graphics // docmain
SelectObject(hdc, prevBrush);
}
///
final void fillEllipse(Brush brush, Rect r)
{
fillEllipse(brush, r.x, r.y, r.width, r.height);
}
/// ditto
final void fillEllipse(Brush brush, int x, int y, int width, int height)
{
HPEN prevPen;
HBRUSH prevBrush;
prevPen = SelectObject(hdc, cast(HPEN)GetStockObject(NULL_PEN));
prevBrush = SelectObject(hdc, brush.handle);
Ellipse(hdc, x, y, x + width, y + height);
// Reset stuff.
SelectObject(hdc, prevPen);
SelectObject(hdc, prevBrush);
}
// TODO: drawPie()