2 * This file is part of dui.
4 * dui is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * dui is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with dui; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 module duit
.TestImage
;
21 private import gtk
.VBox
;
23 private import gtk
.Table
;
24 private import gtk
.FileChooserDialog
;
25 private import gtk
.Button
;
26 private import gtk
.Widget
;
27 private import gtk
.ScrolledWindow
;
28 private import gtk
.ButtonBox
;
29 private import gtk
.HButtonBox
;
30 private import gtk
.Image
;
32 private import gtk
.Window
;
34 private import gtk
.gtktypes
;
36 private import std
.stdio
;
38 private import glib
.Str
;
41 * This tests the DUI loading and display and image file
43 class TestImage
: VBox
56 printf("instantiating TestImage\n");
61 sw
= new ScrolledWindow(null,null);
63 sw
.addWithViewport(initTable());
65 ButtonBox hBox
= HButtonBox
.createActionBox();
66 Button loadDir
= new Button("Load Files", &loadImages
);
67 hBox
.packStart(loadDir
,false,false,0);
69 packStart(sw
,true,true,0);
70 packStart(hBox
,false,false,0);
77 // I don't think D can read the content of a directory yet
81 pngs
~= "/home/ruimt/devel/D/DUI/images/duiIcon_t.xpm";
82 pngs
~= "/home/ruimt/devel/D/DUI/images/duiLogo.gif";
83 pngs
~= "/home/ruimt/devel/D/DUI/images/duiLogo.xpm";
84 pngs
~= "/home/ruimt/devel/D/DUI/images/duiLogo_2.xpm";
85 pngs
~= "/home/ruimt/devel/D/DUI/images/duiLogo_4.xpm";
86 pngs
~= "/home/ruimt/devel/D/DUI/images/duiLogo_8.xpm";
88 return loadTable(pngs
);
91 private Table
loadTable(char[][] imageFiles
)
93 //Table table = new Table(1,1,false);
96 table
= new Table(1,1,false);
110 // Window progressWindow = new Window();//WindowType.POPUP);
111 // progressWindow.setBorderWidth(10);
112 // ProgressBar progressBar = new ProgressBar();
113 // progressWindow.add(progressBar);
114 // progressWindow.show();
117 for ( int i
=0 ; i
<imageFiles
.length
;i
++)
119 char[] fileName
= imageFiles
[i
];
120 if ( fileName
[0] != '/' )
122 version(linux
) fileName
= fileName
~ "/usr/share/pixmaps/";
123 version(Windows
) fileName
= fileName
~ "C:\\Projects\\D\\DynDUI\\dui\\images\\";
125 image
= new Image(fileName
);
126 //image.addOnEnterNotify(&onEnter);
127 //image.addOnLeaveNotify(&onLeave);
128 writefln("adding image %s to table at %s,%s", fileName
, col
, row
);
129 table
.resize(col
+1, row
+1);
130 table
.attach(image
,col
,col
+1,row
,row
+1,AttachOptions
.FILL
,AttachOptions
.FILL
,4,4);
142 private import glib
.ListSG
;
144 void loadImages(Button button
)
152 r
~= ResponseType
.GTK_RESPONSE_ACCEPT
;
153 r
~= ResponseType
.GTK_RESPONSE_CANCEL
;
154 fs
= new FileChooserDialog("File Selection", window
, FileChooserAction
.OPEN
, a
, r
);
156 fs
.getFileChooser().setSelectMultiple(true);
157 ResponseType response
= cast(ResponseType
) fs
.run();
158 if ( response
== ResponseType
.GTK_RESPONSE_ACCEPT
)
161 ListSG list
= fs
.getFileChooser().getFilenames();
164 for ( int i
= 0; i
<list
.length() ; i
++)
166 writefln("Testmage.loadImages.File selected = %s",
167 Str
.toString(cast(char*)list
.nthData(i
)));
168 fileNames
~= Str
.toString(cast(char*)list
.nthData(i
)).dup
;
171 loadTable(fileNames
);
176 void onEnter(Widget widget
)
178 printf("TestImage.mouseEnterNotify\n");
181 void onLeave(Widget widget
)
183 printf("TestImage.mouseLeaveNotify\n");