Mercurial > projects > dwt-win
diff dwt/events/SelectionListener.d @ 253:fbb9174f2a2c
Reuse the tango windows api
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Jul 2008 23:01:25 +0200 |
parents | bef1ed4ebc50 |
children | 02332a154347 |
line wrap: on
line diff
--- a/dwt/events/SelectionListener.d Sun Jul 06 18:45:41 2008 +0200 +++ b/dwt/events/SelectionListener.d Fri Jul 11 23:01:25 2008 +0200 @@ -63,3 +63,62 @@ */ public void widgetDefaultSelected(SelectionEvent e); } + + + +/// Helper class for the dgListener template function +private class _DgSelectionListenerWidgetSelectedT(Dg,T...) : SelectionListener { + + alias ParameterTupleOf!(DgSel) DgArgs; + static assert( is(DgArgs == Tuple!(SelectionEvent,T)), + "Delegate args not correct" ); + + Dg dg; + T t; + + private this( Dg dg, T t ){ + this.dg = dg; + static if( T.length > 0 ){ + this.t = t; + } + } + + public void widgetSelected(SelectionEvent e){ + dg(e,t); + } + public void widgetDefaultSelected(SelectionEvent e){ + } +} + +private class _DgSelectionListenerWidgetDefaultSelectedT(Dg,T...) : SelectionListener { + + alias ParameterTupleOf!(DgSel) DgArgs; + static assert( is(DgArgs == Tuple!(SelectionEvent,T)), + "Delegate args not correct" ); + + Dg dg; + T t; + + private this( Dg dg, T t ){ + this.dg = dg; + static if( T.length > 0 ){ + this.t = t; + } + } + + public void widgetSelected(SelectionEvent e){ + } + public void widgetDefaultSelected(SelectionEvent e){ + dg(e,t); + } +} + +SelectionListener dgSelectionListenerWidgetSelected( Dg, T... )( Dg dg, T args ){ + return new _DgSelectionListenerWidgetSelectedT!( Dg, T )( dg, args ); +} +SelectionListener dgSelectionListenerWidgetDefaultSelected( Dg, T... )( Dg dg, T args ){ + return new _DgSelectionListenerWidgetDefaultSelectedT!( Dg, T )( dg, args ); +} + + +