DUI version 00.07 |
||
![]() images
/* * This file is part of dui. * * dui is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * dui is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with dui; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ module test.TestImage; import dui.All; /** * This tests the DUI loading and display and image file */ class TestImage : VBox , ButtonClickedListener , MouseEnterListener { Table table; FileSelection fs; Dispatcher dispatcher; this() { debug(1) { printf("instantiating TestImage\n"); } super(false,8); // make sure the dispatcher is initialized dispatcher = Dispatcher.getDispatcher(); ScrolledWindow sw = new ScrolledWindow(null,null); sw.addWithViewport(initTable()); HButtonBox hBox = HButtonBox.createActionBox(); Button loadDir = new Button("Load Files"); hBox.packStart(loadDir,false,false,0); dispatcher.addButtonClickedListener(this,loadDir,"LoadImagesFromDir"); packStart(sw,true,true,0); packStart(hBox,false,false,0); } Table initTable() { // I don't think D can read the content of a directory yet // so here it is static char [][] pngs = [ "gnome-about-logo.png", "gnome-aisleriot.png", "gnome-amusements.png", "gnome-aorta.png", "gnome-applets.png", "gnome-application-vnd.lotus-1-2-3.png", "gnome-application-x-applix-spreadsheet.png", "gnome-application-x-generic-spreadsheet.png", "gnome-application-x-gnumeric.png", "gnome-application-x-xls.png", "gnome-applications.png", "gnome-audio2.png", "gnome-background.png", "gnome-calc2.png", "gnome-calc3.png", "gnome-calendar-conduit.png", "gnome-calendar.png", "gnome-cardgame.png", "gnome-ccbackground.png", "gnome-ccdesktop.png", "gnome-ccdialog.png", "gnome-cckeyboard-bell.png", "gnome-cckeyboard.png", "gnome-ccmime.png", "gnome-ccperiph.png", "gnome-ccscreensaver.png", "gnome-ccthemes.png", "gnome-ccwindowmanager.png", "gnome-cd.png", "gnome-cdplayer-icon.png", "gnome-character-map.png", "gnome-clock.png", "gnome-color-browser.png", "gnome-color-xterm.png", "gnome-computer.png", "gnome-cpu.png", "gnome-cromagnon.png", "gnome-day.png", "gnome-debian.png", "gnome-default-dlg.png", "gnome-devel.png", "gnome-die1.png", "gnome-die2.png", "gnome-die3.png", "gnome-die4.png", "gnome-die5.png", "gnome-die6.png", "gnome-diskfree.png", "gnome-emacs.png", "gnome-eog.png", "gnome-error.png", "gnome-eterm.png", "gnome-eyes.png", "gnome-favorites.png", "gnome-file-c.png", "gnome-file-h.png", "gnome-fish.png", "gnome-folder.png", "gnome-gegl.png", "gnome-gegl2-2.png", "gnome-gegl2.png", "gnome-gemvt.png", "gnome-ghex.png", "gnome-ghostview.png", "gnome-gimp.png", "gnome-globe.png", "gnome-gmenu.png", "gnome-gmush.png", "gnome-gnobots2.png", "gnome-gnomecard.png", "gnome-gnomeicu.png", "gnome-gnomine.png", "gnome-gnomoku.png", "gnome-gnumeric.png", "gnome-graphics.png", "gnome-grecord.png", "gnome-gsame.png", "gnome-gtali.png", "gnome-gtetris.png", "gnome-guppi.png", "gnome-help.png", "gnome-home.png", "gnome-html.png", "gnome-image-gif.png", "gnome-image-jpeg.png", "gnome-info.png", "gnome-irc.png", "gnome-joystick.png", "gnome-laptop.png", "gnome-lockscreen.png", "gnome-log.png", "gnome-logo-icon-transparent.png", "gnome-logo-icon.png", "gnome-logo-large.png", "gnome-mahjongg.png", "gnome-mailcheck.png", "gnome-mdi.png", "gnome-mini-commander.png", "gnome-mixer.png", "gnome-mnemonic.png", "gnome-modem.png", "gnome-money.png", "gnome-monitor.png", "gnome-month.png", "gnome-mouse.png", "gnome-multimedia.png", "gnome-networktool.png", "gnome-news.png", "gnome-nibbles.png", "gnome-note.png", "gnome-palm-conduit.png", "gnome-palm.png", "gnome-panel-type-corner.png", "gnome-panel-type-edge.png", "gnome-panel-type-floating.png", "gnome-panel-type-menu.png", "gnome-panel-type-sliding.png", "gnome-panel.png", // too big ignore - "gnome-ppp-animation.png", "gnome-ppp-filled.png", "gnome-qeye.png", "gnome-question.png", "gnome-reclevel.png", "gnome-run.png", "gnome-screenshot.png", "gnome-searchtool.png", "gnome-session.png", "gnome-set-time.png", "gnome-settings.png", "gnome-show-desktop.png", "gnome-spider.png", "gnome-squeak.png", "gnome-stones-file.png", "gnome-stones.png", "gnome-suse.png", "gnome-system.png", "gnome-talk.png", "gnome-term-linux.png", "gnome-term-linux2.png", "gnome-term-night.png", "gnome-term-tiger.png", "gnome-term.png", "gnome-terminal.png" "gnome-tigert.png", "gnome-touristinfo.png", "gnome-unknown.png", "gnome-user-interface.png", "gnome-util.png", "gnome-vumeter.png", "gnome-warning.png", "gnome-week.png", "gnome-windows.png", "gnome-word.png", "gnome-workspace.png", "gnome-xbill.png", "gnome-xterm.png", "gnomemeeting-logo-icon.png", // too big ignore - "gnomemeeting-logo.png", // too big ignore - "gnomemeeting-splash.png", ]; //loadTable(table,pngs); return loadTable(pngs); } private Table loadTable(char [][] imageFiles) { //Table table = new Table(1,1,false); if ( table === null ) { table = new Table(1,1,false); } else { table.removeAll(); } int row = 0; int col = 0; Image image; // Window progressWindow = new Window();//WindowType.POPUP); // progressWindow.setBorderWidth(10); // ProgressBar progressBar = new ProgressBar(); // progressWindow.add(progressBar); // progressWindow.show(); for ( int i=0 ; i<imageFiles.length ;i++) { char [] fileName = imageFiles[i]; if ( fileName[0] != '/' ) { fileName = "/usr/share/pixmaps/"~fileName; } image = new Image(fileName); dispatcher.addMouseEnterListener(this,image); table.attach(image,col,col+1,row,row+1,AttachOptions.FILL,AttachOptions.FILL,4,4); ++col; if ( col == 8 ) { col = 0; ++row; } } return table; } void buttonClickedCallback(Button button, char [] action) { switch(action) { case "LoadImagesFromDir": if ( fs === null ) { fs = new FileSelection("File Selection"); } fs.setMultiple(true); Response response = fs.run(); if ( response == Response.OK ) { char [][] selections = fs.getSelections(); Table table = loadTable(selections); } fs.hide(); break; } } bit enterNotifyCallback(Widget widget, EventCrossing event) { printf("TestImage.mouseEnterNotify\n"); return true; } bit leaveNotifyCallback(Widget widget, EventCrossing event) { printf("TestImage.mouseLeaveNotify\n"); return true; } } |
||