Very basic stuff working on linux 32-bit with dmd and phobos2.
This commit is contained in:
parent
f23eee9828
commit
67f0225e42
152 changed files with 113 additions and 0 deletions
37
tests/minwin_gtk/minwin/samples/CMakeLists.txt
Normal file
37
tests/minwin_gtk/minwin/samples/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
|
||||
|
||||
FIND_PACKAGE (GTK2)
|
||||
|
||||
IF (GTK2_FOUND)
|
||||
INCLUDE_DIRECTORIES (${minwin_gtk_SOURCE_DIR} ${GTK2_INCLUDE_DIRS})
|
||||
LINK_DIRECTORIES (${minwin_gtk_SOURCE_DIR} ${GTK2_LIBRARY_DIRS})
|
||||
|
||||
ADD_EXECUTABLE (sample sample.d)
|
||||
TARGET_LINK_LIBRARIES (sample minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (layout layout.d)
|
||||
TARGET_LINK_LIBRARIES (layout minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (topgroup topgroup.d)
|
||||
TARGET_LINK_LIBRARIES (topgroup minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (widgets widgets.d)
|
||||
TARGET_LINK_LIBRARIES (widgets minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (menus menus.d)
|
||||
TARGET_LINK_LIBRARIES (menus minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (painting painting.d)
|
||||
TARGET_LINK_LIBRARIES (painting minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (sdialog sdialog.d)
|
||||
TARGET_LINK_LIBRARIES (sdialog minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (sdialog2 sdialog2.d)
|
||||
TARGET_LINK_LIBRARIES (sdialog2 minwin_gtk)
|
||||
|
||||
ADD_EXECUTABLE (idle idle.d)
|
||||
TARGET_LINK_LIBRARIES (idle minwin_gtk)
|
||||
|
||||
ENDIF (GTK2_FOUND)
|
40
tests/minwin_gtk/minwin/samples/idle.d
Normal file
40
tests/minwin_gtk/minwin/samples/idle.d
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Sample MinWin application: idle processing
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.idle;
|
||||
|
||||
import minwin.all;
|
||||
import std.random;
|
||||
import std.string;
|
||||
import std.utf;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("Idle processing");
|
||||
char[] text = "Idle processing...";
|
||||
char[] cur = "";
|
||||
win.quitOnDestroy = true;
|
||||
win.paintDelegate ~= delegate void(Component source, GContext gc) {
|
||||
auto Font font = new Font("",14,FontWeight.Bold);
|
||||
Font oldfont = gc.setFont(font);
|
||||
gc.drawText(100,100,text);
|
||||
gc.setFont(oldfont);
|
||||
};
|
||||
win.keyDelegate ~= delegate void(Component source, KeyEvent* event) {
|
||||
if (event.id == KeyPressedEvent) {
|
||||
char[4] buf;
|
||||
cur = toUTF8(buf,event.keyCode).dup;
|
||||
}
|
||||
};
|
||||
app.idleTime = 1000; // every second
|
||||
app.idleDelegate ~= delegate void() {
|
||||
text = cur ~ " " ~ toString(rand());
|
||||
win.repaint();
|
||||
};
|
||||
win.visible = true;
|
||||
return app.enterEventLoop();
|
||||
}
|
84
tests/minwin_gtk/minwin/samples/layout.d
Normal file
84
tests/minwin_gtk/minwin/samples/layout.d
Normal file
|
@ -0,0 +1,84 @@
|
|||
/* Sample MinWin application: layout and groups
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.layout;
|
||||
|
||||
import minwin.all;
|
||||
import std.random;
|
||||
import std.string;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
|
||||
Window win = new Window("Layout Sample");
|
||||
char[] text = "Click the Random number button";
|
||||
win.quitOnDestroy = true;
|
||||
|
||||
// set table layout
|
||||
static double[3] yy = [.3, .2, .5];
|
||||
static double[2] xx = [.5,.5];
|
||||
win.layoutMgr = new TableLayout(xx,yy);
|
||||
|
||||
// define some buttons to put in the table
|
||||
Button b1 = new Button(win,"Random number");
|
||||
Button b2 = new Button(win,"hide groups");
|
||||
Button b3 = new Button(win,"hide layout");
|
||||
|
||||
// define a group to put in the table
|
||||
Group g = new Group(win);
|
||||
FlowLayout flow = new FlowLayout();
|
||||
flow.sideStretch = true;
|
||||
g.layoutMgr = flow;
|
||||
Button sub1 = new Button(g,"click random");
|
||||
Button sub2 = new Button(g,"sub2");
|
||||
|
||||
// make a sub-group of g
|
||||
Group g2 = new Group(g);
|
||||
flow = new FlowLayout(Dir.Horizontal);
|
||||
flow.flowReverse = 1;
|
||||
g2.layoutMgr = flow;
|
||||
Button sub3 = new Button(g2,"sub3");
|
||||
Button sub4 = new Button(g2,"sub4");
|
||||
Button sub5 = new Button(g2,"sub5");
|
||||
|
||||
Button b4 = new Button(win,"b3");
|
||||
|
||||
// define actions
|
||||
b1.actionDelegate ~= delegate void(Component source) {
|
||||
sub1.text = toString(rand());
|
||||
};
|
||||
b2.actionDelegate ~= delegate void(Component source) {
|
||||
g.visible = !g.visible;
|
||||
};
|
||||
b3.actionDelegate ~= delegate void(Component source) {
|
||||
// remove from layout computations
|
||||
g.parentOwnsLayout = !g.parentOwnsLayout;
|
||||
};
|
||||
|
||||
win.pack();
|
||||
win.visible = true;
|
||||
|
||||
Window win2 = new Window("Border Layout Sample");
|
||||
win2.quitOnDestroy = true;
|
||||
BorderLayout bl = new BorderLayout();
|
||||
Button w2b1 = new Button(win2,"north");
|
||||
bl.location[Loc.North] = w2b1;
|
||||
Button w2b2 = new Button(win2,"south");
|
||||
bl.location[Loc.South] = w2b2;
|
||||
Button w2b3 = new Button(win2,"east");
|
||||
bl.location[Loc.East] = w2b3;
|
||||
Button w2b4 = new Button(win2,"west");
|
||||
bl.location[Loc.West] = w2b4;
|
||||
Button w2b5 = new Button(win2,"center");
|
||||
bl.location[Loc.Center] = w2b5;
|
||||
win2.layoutMgr = bl;
|
||||
|
||||
win2.pack();
|
||||
win2.visible = true;
|
||||
|
||||
return app.enterEventLoop();
|
||||
}
|
23
tests/minwin_gtk/minwin/samples/linux.mak
Normal file
23
tests/minwin_gtk/minwin/samples/linux.mak
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
# To build the samples type "make -f win32.mak"
|
||||
|
||||
#VER = Motif
|
||||
#LIB = libminwin_motif.a
|
||||
#XLIBS = -L-L/usr/X11R6/lib -L-lXm -L-lXt -L-lX11 -L-lImlib
|
||||
|
||||
VER = GTK
|
||||
LIB = libminwin_gtk.a
|
||||
XLIBS = -L-L/usr/X11R6/lib -L-lgtk-x11-2.0 -L-lX11
|
||||
|
||||
DMD = dmd
|
||||
|
||||
TARGETS= sample layout topgroup \
|
||||
widgets menus painting sdialog sdialog2 idle
|
||||
|
||||
targets : $(TARGETS)
|
||||
|
||||
% : %.d
|
||||
$(DMD) -g ../$(LIB) -I../.. $(XLIBS) -version=$(VER) -of$@ $< -version=LOG
|
||||
|
||||
clean:
|
||||
- rm *.o $(TARGETS)
|
61
tests/minwin_gtk/minwin/samples/menus.d
Normal file
61
tests/minwin_gtk/minwin/samples/menus.d
Normal file
|
@ -0,0 +1,61 @@
|
|||
/* Sample MinWin application: Menus
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.menus;
|
||||
|
||||
import minwin.all;
|
||||
import std.string;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("Menu Sample");
|
||||
win.quitOnDestroy = true;
|
||||
win.layoutMgr = new FlowLayout;
|
||||
MenuBar mb = new MenuBar(win);
|
||||
Menu file = new Menu(mb,"File");
|
||||
file.add("Open...",100);
|
||||
file.addSeparator();
|
||||
file.add("Save...",234);
|
||||
Menu edit = new Menu(mb,"Edit");
|
||||
edit.add("Hello",400);
|
||||
edit.add("World",500);
|
||||
char[] text = "select menu";
|
||||
win.commandDelegate ~= delegate void(Component source, int cmd) {
|
||||
text = toString(cmd);
|
||||
win.repaint();
|
||||
if (cmd == 100) {
|
||||
// show open file dialog
|
||||
FileDialogData data;
|
||||
data.title = "Open File";
|
||||
if (openFileDialog(win,data)) {
|
||||
text = "you selected " ~ data.result;
|
||||
}
|
||||
} else if (cmd == 234) {
|
||||
// show save file dialog
|
||||
FileFilter[2] filt;
|
||||
filt[0].description = "Foo bar files";
|
||||
filt[0].extensions ~= "*.foo";
|
||||
filt[1].description = "All files";
|
||||
filt[1].extensions ~= "*";
|
||||
FileDialogData data;
|
||||
data.title = "Save File";
|
||||
data.filter = filt;
|
||||
if (saveFileDialog(win,data)) {
|
||||
text = "you saved " ~ data.result;
|
||||
}
|
||||
}
|
||||
};
|
||||
win.paintDelegate ~= delegate void(Component source, GContext gc) {
|
||||
auto Font font = new Font("",12);
|
||||
Font oldfont = gc.setFont(font);
|
||||
gc.drawText(100,100,text);
|
||||
gc.setFont(oldfont);
|
||||
};
|
||||
|
||||
win.visible = true;
|
||||
return app.enterEventLoop();
|
||||
}
|
81
tests/minwin_gtk/minwin/samples/painting.d
Normal file
81
tests/minwin_gtk/minwin/samples/painting.d
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* Sample MinWin application: Graphics and painting
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.painting;
|
||||
|
||||
import minwin.all;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("Painting Sample");
|
||||
win.quitOnDestroy = true;
|
||||
|
||||
Image im = win.getCompatibleImage(100,150);
|
||||
GContext gc = im.getGContext();
|
||||
|
||||
auto Pen p2 = new Pen(RGB(0,0,0));
|
||||
Pen oldPen = gc.setPen(p2);
|
||||
Rect r = LTWH(0,0,100,150);
|
||||
auto Brush b2 = new Brush(RGB(255,255,255));
|
||||
Brush oldBrush = gc.setBrush(b2);
|
||||
gc.fillRect(r);
|
||||
gc.drawRect(r);
|
||||
gc.setBrush(oldBrush);
|
||||
|
||||
PenData pd;
|
||||
pd.width = 4;
|
||||
pd.style = PenStyle.Solid;
|
||||
pd.color = RGB(100,0,120);
|
||||
auto Pen p = new Pen(&pd);
|
||||
gc.setPen(p);
|
||||
gc.drawLine(0,0,100,150);
|
||||
gc.drawLine(100,0,0,150);
|
||||
gc.drawLine(50,0,50,150);
|
||||
gc.setPen(oldPen);
|
||||
gc.dispose();
|
||||
|
||||
win.paintDelegate ~= delegate void(Component source, GContext pc) {
|
||||
|
||||
auto Font font = new Font("", 20, FontWeight.Bold);
|
||||
Font oldfont = pc.setFont(font);
|
||||
pc.drawText(100,100,"testing");
|
||||
pc.setFont(oldfont);
|
||||
|
||||
pc.drawLine(10,10,20,20);
|
||||
pc.drawLine(30,10,35,50);
|
||||
|
||||
static Point[3] pts = [{{40,10}}, {{45,50}}, {{50,30}}];
|
||||
pc.drawPolyline(pts);
|
||||
|
||||
static Point[4] pts2 = [{{70,10}},{{75,50}},{{80,30}},{{90,10}}];
|
||||
pc.drawPolygon(pts2);
|
||||
|
||||
static Point[4] pts3 = [{{100,10}},{{105,50}},{{110,30}},{{120,10}}];
|
||||
pc.fillPolygon(pts3);
|
||||
|
||||
// try different line styles and colors
|
||||
PenData pd;
|
||||
pd.width = 4;
|
||||
pd.color = RGB(100,200,0);
|
||||
pd.style = PenStyle.Dash;
|
||||
auto Pen p1 = new Pen(&pd);
|
||||
Pen oldPen = pc.setPen(p1);
|
||||
pc.drawLine(10,100,20,200);
|
||||
|
||||
pd.color = RGB(0,200,200);
|
||||
auto Pen p2 = new Pen(&pd);
|
||||
pc.setPen(p2);
|
||||
pc.drawLine(50,100,50,200);
|
||||
|
||||
pc.setPen(oldPen);
|
||||
|
||||
pc.drawImage(im,180,30);
|
||||
};
|
||||
|
||||
win.visible = true;
|
||||
return app.enterEventLoop();
|
||||
}
|
67
tests/minwin_gtk/minwin/samples/sample.d
Normal file
67
tests/minwin_gtk/minwin/samples/sample.d
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* Sample MinWin application to mimic winsamp.d
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
module minwin.samples.sample;
|
||||
|
||||
import minwin.all;
|
||||
import minwin.logging;
|
||||
import std.string;
|
||||
version (Windows) {
|
||||
import minwin.mswindows;
|
||||
}
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("MinWin Sample");
|
||||
char[] text = "D Does Windows, Motif and GTK";
|
||||
win.quitOnDestroy = true;
|
||||
win.paintDelegate ~= delegate void(Component source, GContext gc) {
|
||||
FontData fd;
|
||||
fd.size = 18;
|
||||
fd.weight = FontWeight.Bold;
|
||||
auto Font font = new Font(fd);
|
||||
Font oldfont = gc.setFont(font);
|
||||
gc.drawText(100,100,text);
|
||||
gc.setFont(oldfont);
|
||||
// Image im = win.loadCompatibleImage(44);
|
||||
// gc.drawImage(im,200,200);
|
||||
};
|
||||
|
||||
win.mouseDelegate ~= delegate void(Component source, MouseEvent* event) {
|
||||
Point pt = event.point;
|
||||
text = pt.toString ~ " " ~ toString(cast(int)event.id) ~ " " ~ toString(event.modifiers);
|
||||
win.repaint();
|
||||
};
|
||||
|
||||
Button b = new Button(win,"Click me");
|
||||
Button b2 = new Button(win,"Don't click me");
|
||||
|
||||
// like winsamp.d place buttons by hand
|
||||
Point s = b.preferredSize;
|
||||
Rect r = LTWH(20,50,s.x,s.y);
|
||||
b.setBounds(r);
|
||||
s = b2.preferredSize;
|
||||
r.LTWH(100,50,s.x,s.y);
|
||||
b2.setBounds(r);
|
||||
|
||||
// define actions to perform on button clicks
|
||||
b.actionDelegate ~= delegate void(Component source) {
|
||||
informationDialog(win, "Hello, world!", "Greeting");
|
||||
};
|
||||
b2.actionDelegate ~= delegate void(Component source) {
|
||||
warningDialog(win, "You've been warned...", "Prepare to GP fault");
|
||||
*(cast(int*) null) = 666;
|
||||
};
|
||||
|
||||
// show window
|
||||
version (Windows) {
|
||||
ShowWindow(win.peer,gApp.nCmdShow);
|
||||
} else {
|
||||
win.visible = true;
|
||||
}
|
||||
|
||||
return app.enterEventLoop();
|
||||
}
|
2
tests/minwin_gtk/minwin/samples/sample.def
Normal file
2
tests/minwin_gtk/minwin/samples/sample.def
Normal file
|
@ -0,0 +1,2 @@
|
|||
EXETYPE NT
|
||||
SUBSYSTEM WINDOWS,5.0
|
23
tests/minwin_gtk/minwin/samples/sample.exe.manifest
Normal file
23
tests/minwin_gtk/minwin/samples/sample.exe.manifest
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
name="Pub.MinWin.Sample"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Sample MinWin application.</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
|
2
tests/minwin_gtk/minwin/samples/sample.rc
Normal file
2
tests/minwin_gtk/minwin/samples/sample.rc
Normal file
|
@ -0,0 +1,2 @@
|
|||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "sample.exe.manifest"
|
||||
|
63
tests/minwin_gtk/minwin/samples/sdialog.d
Normal file
63
tests/minwin_gtk/minwin/samples/sdialog.d
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Sample dialog application with OOP style
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
module minwin.samples.sdialog;
|
||||
|
||||
import minwin.all;
|
||||
import minwin.logging;
|
||||
|
||||
class MyDialog : Dialog {
|
||||
int result;
|
||||
this(MyWindow win, char[] str) {
|
||||
super(win,str);
|
||||
layoutMgr = new FlowLayout;
|
||||
Button clicked;
|
||||
Button ok = new Button(this,"OK");
|
||||
Button cancel = new Button(this,"Cancel");
|
||||
CheckBox bb = new CheckBox(this,"this is a big check");
|
||||
CheckBox bb2 = new CheckBox(this,"this check");
|
||||
ok.actionDelegate ~= &okCallback;
|
||||
cancel.actionDelegate ~= &cancelCallback;
|
||||
pack();
|
||||
}
|
||||
void okCallback(Component c) {
|
||||
MyWindow win = cast(MyWindow)owner;
|
||||
win.title = "you hit ok";
|
||||
result = 100;
|
||||
visible = false;
|
||||
}
|
||||
void cancelCallback(Component c) {
|
||||
MyWindow win = cast(MyWindow)owner;
|
||||
win.title = "you hit cancel";
|
||||
result = 101;
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
class MyWindow : Window {
|
||||
this(char[] str) {
|
||||
super(str);
|
||||
layoutMgr = new FlowLayout;
|
||||
Button but = new Button(this,"click me");
|
||||
but.actionDelegate ~= &doDialogCallback;
|
||||
}
|
||||
void doDialogCallback(Component c){doDialog();}
|
||||
void doDialog() {
|
||||
MyDialog dlg = new MyDialog(this,"hello");
|
||||
dlg.visible = true;
|
||||
if (dlg.result == 0) {
|
||||
title = "you destroyed the dialog";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
MyWindow win = new MyWindow("window");
|
||||
win.quitOnDestroy = true;
|
||||
win.visible = true;
|
||||
return app.enterEventLoop();
|
||||
}
|
56
tests/minwin_gtk/minwin/samples/sdialog2.d
Normal file
56
tests/minwin_gtk/minwin/samples/sdialog2.d
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* Sample dialog application with procedural style
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.sdialog2;
|
||||
|
||||
import minwin.all;
|
||||
|
||||
const int OK = 100;
|
||||
const int CANCEL = 101;
|
||||
const char[] KEY = "result";
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("window");
|
||||
win.quitOnDestroy = true;
|
||||
win.layoutMgr = new FlowLayout;
|
||||
Button but = new Button(win,"click me");
|
||||
but.actionDelegate ~= delegate void (Component c) {
|
||||
Window w = cast(Window)c.parent;
|
||||
Dialog dlg = new Dialog(w,"hit ok or cancel");
|
||||
dlg.layoutMgr = new FlowLayout;
|
||||
Button ok = new Button(dlg,"OK");
|
||||
ok.cmd = OK;
|
||||
Button cancel = new Button(dlg,"Cancel");
|
||||
cancel.cmd = CANCEL;
|
||||
dlg.commandDelegate ~= delegate void(Component c, int cmd) {
|
||||
Dialog dlg = cast(Dialog)c;
|
||||
switch (cmd) {
|
||||
case OK:
|
||||
dlg.owner.title = "you hit ok";
|
||||
break;
|
||||
case CANCEL:
|
||||
dlg.owner.title = "you hit cancel";
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
// indicate a button was clicked
|
||||
int* data = new int;
|
||||
*data = cmd;
|
||||
dlg.userdata[KEY] = data;
|
||||
// end the dialog modality
|
||||
dlg.visible = false;
|
||||
};
|
||||
dlg.pack();
|
||||
dlg.visible = true;
|
||||
if ((KEY in dlg.userdata) is null) {
|
||||
w.title = "you destroyed the dialog";
|
||||
}
|
||||
};
|
||||
win.visible = true;
|
||||
return app.enterEventLoop();
|
||||
}
|
41
tests/minwin_gtk/minwin/samples/topgroup.d
Normal file
41
tests/minwin_gtk/minwin/samples/topgroup.d
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* MinWin Sample: Groups of top-level windows
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.topgroup;
|
||||
|
||||
import minwin.all;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
|
||||
Window win = new Window("Close window 2");
|
||||
win.cancelCloseDelegate ~= delegate bool(Component c) {
|
||||
// we could pop up a confirm dialog but let's just say
|
||||
// you can't destroy this window
|
||||
return true;
|
||||
};
|
||||
|
||||
Window win2 = new Window("Testing 2");
|
||||
win2.quitOnDestroy = true;
|
||||
|
||||
Group g = new Group(null);
|
||||
g ~= win;
|
||||
g ~= win2;
|
||||
|
||||
static double[2] x = [.5,.5];
|
||||
static double[1] y = [1];
|
||||
g.layoutMgr = new TableLayout(x,y);
|
||||
|
||||
Rect r;
|
||||
r.LTWH(100,100,600,300);
|
||||
g.setBounds(r);
|
||||
g.layout(false);
|
||||
|
||||
g.visible = true;
|
||||
|
||||
return app.enterEventLoop();
|
||||
}
|
80
tests/minwin_gtk/minwin/samples/widgets.d
Normal file
80
tests/minwin_gtk/minwin/samples/widgets.d
Normal file
|
@ -0,0 +1,80 @@
|
|||
/* Sample MinWin application: widgets
|
||||
*
|
||||
* Written by Ben Hinkle and released to the public domain, as
|
||||
* explained at http://creativecommons.org/licenses/publicdomain
|
||||
* Report comments and bugs at dsource: http://www.dsource.org/projects/minwin
|
||||
*/
|
||||
|
||||
module minwin.samples.widgets;
|
||||
|
||||
import minwin.all;
|
||||
import minwin.logging;
|
||||
import std.utf;
|
||||
|
||||
extern (C)
|
||||
int MinWinMain(Application* app) {
|
||||
Window win = new Window("Widgets");
|
||||
win.quitOnDestroy = true;
|
||||
win.backgroundColor = systemBackgroundColor();
|
||||
win.layoutMgr = new FlowLayout;
|
||||
|
||||
CheckBox b3 = new CheckBox(win,"check 1");
|
||||
CheckBox b4 = new CheckBox(win,"check 2");
|
||||
ToggleButton b5 = new ToggleButton(win,"toggle 1");
|
||||
|
||||
ToggleGroup g = new ToggleGroup;
|
||||
GroupBox box = new GroupBox(win,"Group");
|
||||
box.layoutMgr = new FlowLayout;
|
||||
RadioButton b1 = new RadioButton(box,"click me");
|
||||
RadioButton b2 = new RadioButton(box,"no, click me");
|
||||
g.addButton(b1);
|
||||
g.addButton(b2);
|
||||
g.select(0);
|
||||
|
||||
Label lab = new Label(win,"This is a label");
|
||||
Text t1 = new Text(win,"single line");
|
||||
t1.userPreferredWidth = 60;
|
||||
MultiLineText t2 = new MultiLineText(win,"multi line text area");
|
||||
t2.userPreferredSize(60,60);
|
||||
|
||||
char[][] strs;
|
||||
strs ~= "hello";
|
||||
strs ~= "world";
|
||||
strs ~= "bye";
|
||||
ComboBox combo = new ComboBox(win,strs);
|
||||
combo.selection = 0;
|
||||
|
||||
ListBox list = new ListBox(win,strs);
|
||||
list.selection = 0;
|
||||
list.userPreferredHeight = 60;
|
||||
|
||||
Canvas p = new Canvas(win);
|
||||
p.keyDelegate ~= delegate void(Component source, KeyEvent* event) {
|
||||
if (event.id == KeyPressedEvent) {
|
||||
char[4] buf;
|
||||
win.title = "you hit the " ~ toUTF8(buf,event.keyChar) ~ " key";
|
||||
}
|
||||
};
|
||||
p.paintDelegate ~= delegate void(Component source, GContext gc) {
|
||||
assert(source !is null);
|
||||
scope Brush b = new Brush(RGB(250,20,20));
|
||||
Brush oldBrush = gc.setBrush(b);
|
||||
Rect r = LTWH(0,0,source.width(),source.height());
|
||||
gc.fillRect(r);
|
||||
gc.setBrush(oldBrush);
|
||||
};
|
||||
p.userPreferredSize(20,20);
|
||||
|
||||
ScrollBar sb = new ScrollBar(win,Horizontal);
|
||||
|
||||
ScrollPane sp = new ScrollPane(win);
|
||||
MultiLineText t3 = new MultiLineText(sp,"This is a big text block that needs some scrolling maybe if we are lucky");
|
||||
t3.userPreferredSize(221,334); // make a large scrollable area
|
||||
sp.userPreferredSize(100,100);
|
||||
|
||||
win.pack();
|
||||
win.visible = true;
|
||||
|
||||
p.requestFocus(); // on GTK must be made visible first
|
||||
return app.enterEventLoop();
|
||||
}
|
14
tests/minwin_gtk/minwin/samples/win32.mak
Normal file
14
tests/minwin_gtk/minwin/samples/win32.mak
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
# To build the samples type "make -f win32.mak"
|
||||
|
||||
DMD = dmd
|
||||
|
||||
targets : sample.exe layout.exe topgroup.exe \
|
||||
widgets.exe menus.exe painting.exe sdialog.exe sdialog2.exe \
|
||||
idle.exe
|
||||
|
||||
.d.exe :
|
||||
$(DMD) sample.def comdlg32.lib gdi32.lib ..\minwin.lib ..\app.obj -I..\.. -of$@ $< -g -version=LOG
|
||||
|
||||
clean:
|
||||
- del *.obj *.exe
|
Loading…
Add table
Add a link
Reference in a new issue