# HG changeset patch # User Frank Benoit # Date 1200863247 -3600 # Node ID 45921f44a4b2a42df129cfbc4575e6f9784abf37 # Parent c8f6e8dc0fcf4884aa4fa24343186d629a6ff463 Fix: stack access from listener in AddressBook example diff -r c8f6e8dc0fcf -r 45921f44a4b2 dwt/widgets/Dialog.d --- a/dwt/widgets/Dialog.d Sun Jan 20 22:07:01 2008 +0100 +++ b/dwt/widgets/Dialog.d Sun Jan 20 22:07:27 2008 +0100 @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright (c) 2000, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 diff -r c8f6e8dc0fcf -r 45921f44a4b2 dwt/widgets/EventTable.d --- a/dwt/widgets/EventTable.d Sun Jan 20 22:07:01 2008 +0100 +++ b/dwt/widgets/EventTable.d Sun Jan 20 22:07:27 2008 +0100 @@ -21,19 +21,6 @@ import dwt.DWT; import dwt.internal.DWTEventListener; -/+ -class EventTable{ - public void hook (int eventType, Listener listener) { - } - public void sendEvent (Event event) {} - public bool hooks (int eventType) { return false; } - public void unhook (int eventType, Listener listener) {} - public void unhook (int eventType, DWTEventListener listener) {} - public int size () { return 0;} -} -+/ - - /** * Instances of this class implement a simple * look up mechanism that maps an event type diff -r c8f6e8dc0fcf -r 45921f44a4b2 dwt/widgets/Shell.d --- a/dwt/widgets/Shell.d Sun Jan 20 22:07:01 2008 +0100 +++ b/dwt/widgets/Shell.d Sun Jan 20 22:07:27 2008 +0100 @@ -565,6 +565,7 @@ checkWidget (); closeWidget (); } + void closeWidget () { Event event = new Event (); sendEvent (DWT.Close, event); diff -r c8f6e8dc0fcf -r 45921f44a4b2 dwtexamples/addressbook/AddressBook.d --- a/dwtexamples/addressbook/AddressBook.d Sun Jan 20 22:07:01 2008 +0100 +++ b/dwtexamples/addressbook/AddressBook.d Sun Jan 20 22:07:27 2008 +0100 @@ -10,19 +10,6 @@ *******************************************************************************/ module dwtexamples.addressbook.AddressBook; - -// /* Imports */ -// import java.io.BufferedReader; -// import java.io.File; -// import java.io.FileNotFoundException; -// import java.io.FileReader; -// import java.io.FileWriter; -// import java.io.IOException; -// import java.util.Arrays; -// import java.util.Comparator; -// import java.util.ResourceBundle; - - import dwt.DWT; import dwt.events.MenuAdapter; import dwt.events.MenuEvent; @@ -66,11 +53,12 @@ void main() { Display display = new Display(); - AddressBook application = new AddressBook(); + auto application = new AddressBook(); Shell shell = application.open(display); while(!shell.isDisposed()){ - if(!display.readAndDispatch()) + if(!display.readAndDispatch()){ display.sleep(); + } } display.dispose(); } @@ -111,10 +99,13 @@ resAddressBook.getString("Fax") ]; } } + + public Shell open(Display display) { shell = new Shell(display); shell.setLayout(new FillLayout()); - shell.addShellListener(new class() ShellAdapter { + + shell.addShellListener( new class() ShellAdapter { public void shellClosed(ShellEvent e) { e.doit = closeAddressBook(); } @@ -144,10 +135,12 @@ TableColumn column = new TableColumn(table, DWT.NONE); column.setText(columnNames[i]); column.setWidth(150); - final int columnIndex = i; - column.addSelectionListener(new class() SelectionAdapter { + int columnIndex = i; + column.addSelectionListener(new class(columnIndex) SelectionAdapter { + int c; + this( int c ){ this.c = c; } public void widgetSelected(SelectionEvent e) { - sort(columnIndex); + sort(c); } }); } @@ -696,13 +689,14 @@ for(int i = 0; i < columnNames.length; i++) { subitem = new MenuItem (submenu, DWT.NONE); subitem.setText(columnNames [i]); - final int column = i; - subitem.addSelectionListener(new class() SelectionAdapter { + int column = i; + subitem.addSelectionListener(new class(column) SelectionAdapter { + int c; + this(int c){ this.c = c; } public void widgetSelected(SelectionEvent e) { - sort(column); + sort(c); } }); - } return submenu;