DGui
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Apr 3 22:03:52 PDT 2011
Damn, gotta love that `with` keyword. Here's an app with a couple of
menus, icons, and a context menu:
module test;
import dgui.all;
class MyApplication : Form
{
ToolBar bar;
ContextMenu ctx;
MenuBar mainMenu;
public this()
{
this.text = "My App!";
this.size = Size(500, 400);
this.startPosition = FormStartPosition.CENTER_SCREEN;
auto images = new ImageList();
images.addImage(Icon.fromFile("red.ico"));
images.addImage(Icon.fromFile("green.ico"));
images.addImage(Icon.fromFile("blue.ico"));
with(bar = new ToolBar)
{
parent = this;
imageList = images;
addButton(0, true);
addButton(1, true);
addSeparator();
}
with(ctx = new ContextMenu)
{
addItem("Context Menu 2.1");
addItem("Context Menu 2.2", false);
addSeparator();
addItem("Context Menu 2.3");
bar.addDropdownButton(2, ctx, true);
}
with(mainMenu = new MenuBar)
{
with(addItem("Menu 1"))
{
addItem("Menu 1.1");
addItem("Menu 1.2");
addItem("Menu 1.3");
}
with(addItem("Menu 2"))
{
addItem("Menu 2.1");
addItem("Menu 2.2");
addItem("Menu 2.3");
}
with(addItem("Menu 3"))
{
addItem("Menu 3.1");
addItem("Menu 3.2");
addItem("Menu 3.3");
}
this.menu = mainMenu;
}
}
}
int main(string[] args)
{
return Application.run(new MyApplication());
}
And a screenshot:
http://i.imgur.com/ETPzq.jpg
Takes about 0.3 seconds to compile. And yeah, I'm a sucker for that
Windows 98 look. :p
More information about the Digitalmars-d
mailing list