BenHinkle
Joined: 27 Mar 2004 Posts: 76
|
Posted: Sun Dec 19, 2004 1:23 pm Post subject: progress update: Button and FlowLayout |
|
|
This weekend I got some layout management going and defined a basic push button. It still isn't much to look at but for those curious I've posted the library at
http://home.comcast.net/~benhinkle/minwin/minwin.zip
The class hierarchy implemented so far:
Component
AbstractWindow
Window
WindowChild
AbstractButton
Button
Layout (interface)
FlowLayout : Layout
Application
Here's the sample updated to include a couple of buttons:
/* Sample MinWin application
*
* To build first build minwin.lib in the top level directory. Then run
* dmd sample.d sample.def -I..\.. ..\minwin.lib gdi32.lib phobos.lib ..\app.obj
* note the ..\app.obj is required to make sure the WinMain is included
* in the final exe.
*
* To build using Motif on Linux build minwin and then
* dmd sample.d -I../.. ../libminwin_motif.a -L-L/usr/X11R6/lib -L-lXm -L-lXt
* -L-lX11 -version=Motif
*
* Written by Ben Hinkle and released to the public domain, as
* explained at http://creativecommons.org/licenses/publicdomain
* Email comments and bug reports to ben.hinkle@gmail.com
*/
module minwin.sample;
import minwin.all;
import std.random;
import std.string;
extern (C)
int MinWinMain(Application app) {
Window f = new Window("Testing");
char[] text = "D Does Windows and Motif";
f.quitOnDestroy = true;
f.paintDelegate ~= delegate void(Component source, PaintContext* pc) {
FontData fd;
fd.size = 12;
fd.weight = FontWeight.Bold;
auto Font font = new Font(&fd);
Font oldfont = pc.setFont(font);
pc.drawText(100,100,text);
pc.setFont(oldfont);
};
Button b = new Button(f,"Press me");
Button b2 = new Button(f,"no press me");
f.layoutMgr = new FlowLayout;
b.actionDelegate ~= delegate void(Component source) {
// informationDialog(f, "Hello, world!", "Greeting");
text = toString(rand());
f.repaint();
};
f.pack(); // doesn't do anything yet
f.visible = true;
return app.enterEventLoop();
} |
|