diff --git a/examples/hello_dfl/source/hello_dfl.d b/examples/hello_dfl/source/hello_dfl.d index 2c4d4d6..8eed2d4 100644 --- a/examples/hello_dfl/source/hello_dfl.d +++ b/examples/hello_dfl/source/hello_dfl.d @@ -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()); } diff --git a/source/dfl/drawing.d b/source/dfl/drawing.d index ed87906..0840a8b 100644 --- a/source/dfl/drawing.d +++ b/source/dfl/drawing.d @@ -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()