| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.6 - 28 Apr 2005 - TWikiGuest) |
| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.5 - 26 Jan 2005 - LiYan) |
| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.4 - 19 Jan 2005 - ArjanB) |
| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.3 - 25 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | import org.nice.swt; import org.nice.swt.events; import org.nice.swt.layout; import org.nice.swt.widgets; |
| > > | import nice.swt; import nice.swt.events; import nice.swt.layout; import nice.swt.widgets; |
| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.2 - 21 Feb 2004 - IsaacGouy) |
| Changed: | |
| < < | nicec --sourcepath .. -d . --classpath .\swt.jar -a helloswt.jar helloswt |
| > > | nicec --classpath "niceswt.jar;swt.jar" -a helloswt.jar helloswt |
| Changed: | |
| < < | import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; |
| > > | import org.nice.swt; import org.nice.swt.events; import org.nice.swt.layout; import org.nice.swt.widgets; |
| Changed: | |
| < < | NiceSelectionAdapter? helloButtonSelected(HelloGoodbye? v) = new NiceSelectionAdapter?( selected: SelectionEvent? e => { |
| > > | SelectionAdapter? helloButtonSelected(HelloGoodbye? v) = new SelectionAdapter?( widgetSelected: SelectionEvent? e => { |
| Changed: | |
| < < | NiceSelectionAdapter? goodbyeButtonSelected(HelloGoodbye? v) = new NiceSelectionAdapter?( selected: SelectionEvent? e => { |
| > > | SelectionAdapter? goodbyeButtonSelected(HelloGoodbye? v) = new SelectionAdapter?( widgetSelected: SelectionEvent? e => { |
| Deleted: | |
| < < | // Let's just make the SWT SelectionAdapter? configurable class NiceSelectionAdapter? extends SelectionAdapter? { SelectionEvent??->void selected = null; SelectionEvent??->void defaultSelected = null; widgetSelected(SelectionEvent? e){ let f = selected; if (f != null) f(e); else super; } widgetDefaultSelected(SelectionEvent? e){ let f = defaultSelected; if (f != null) f(e); else super; } } |
| <<O>> Difference Topic HelloSwtUserInterfaceExample (r1.1 - 17 Feb 2004 - IsaacGouy) |
| Added: | |
| > > |
%META:TOPICINFO{author="IsaacGouy" date="1076984376" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="CodeExamples"}%
/*
To compile:
nicec --sourcepath .. -d . --classpath .\swt.jar -a helloswt.jar helloswt
To run:
java -cp swt.jar;helloswt.jar helloswt.fun
*/
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
void main(String[] args){
makeHelloGoodbye().open;
}
HelloGoodbye makeHelloGoodbye(){
let d = new Display();
let s = new Shell(d, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
s.setLayout( new FillLayout(SWT.VERTICAL) );
s.setText(" SWT Nice Hello/Goodbye ");
s.setSize(200, 100);
let b1 = new Button(s, SWT.PUSH);
b1.setText("Hello");
let b2 = new Button(s, SWT.PUSH);
b2.setText("Goodbye");
let v =
new HelloGoodbye(
display: d,
shell: s,
helloButton: b1,
goodbyeButton: b2
);
b1.addSelectionListener( v.helloButtonSelected );
b2.addSelectionListener( v.goodbyeButtonSelected );
return v;
}
void open(HelloGoodbye v){
v.shell.open;
while (!v.shell.isDisposed) {
if (!v.display.readAndDispatch)
v.display.sleep;
}
v.display.dispose;
}
// Some prefer to separate the UI event
// handling from the UI initialization.
NiceSelectionAdapter helloButtonSelected(HelloGoodbye v) =
new NiceSelectionAdapter( selected: SelectionEvent e => {
if (v.helloIsReply)
v.helloButton.setText("Hello");
else
v.helloButton.setText("HELLO!");
v.helloIsReply = ! v.helloIsReply;
}
);
NiceSelectionAdapter goodbyeButtonSelected(HelloGoodbye v) =
new NiceSelectionAdapter( selected: SelectionEvent e => {
if (v.goodbyeIsReply)
v.goodbyeButton.setText("Goodbye");
else
v.goodbyeButton.setText("Bye!");
v.goodbyeIsReply = ! v.goodbyeIsReply;
}
);
class HelloGoodbye {
Display display;
Shell shell;
Button helloButton;
Button goodbyeButton;
boolean helloIsReply = false;
boolean goodbyeIsReply = false;
}
// Let's just make the SWT SelectionAdapter configurable
class NiceSelectionAdapter extends SelectionAdapter {
SelectionEvent?->void selected = null;
SelectionEvent?->void defaultSelected = null;
widgetSelected(SelectionEvent e){
let f = selected;
if (f != null) f(e); else super;
}
widgetDefaultSelected(SelectionEvent e){
let f = defaultSelected;
if (f != null) f(e); else super;
}
}
-- IsaacGouy - 17 Feb 2004 |
| Topic HelloSwtUserInterfaceExample . { View | Diffs | r1.6 | > | r1.5 | > | r1.4 | More } |
|
Revision r1.1 - 17 Feb 2004 - 02:19 GMT - IsaacGouy Revision r1.6 - 28 Apr 2005 - 11:53 GMT - TWikiGuest |
Copyright © 1999-2003 by the contributing authors.
All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding TWiki? Send feedback. |