root/dwt/custom/CTabFolderListener.d

Revision 311:02332a154347, 2.8 kB (checked in by Frank Benoit <benoit@tionex.de>, 4 months ago)

Improved Listeners access functions.

Line 
1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  * Port to the D programming language:
11  *     Frank Benoit <benoit@tionex.de>
12  *******************************************************************************/
13 module dwt.custom.CTabFolderListener;
14
15 import dwt.internal.DWTEventListener;
16 import dwt.custom.CTabFolderEvent;
17
18 import tango.core.Traits;
19 import tango.core.Tuple;
20
21 /**
22  * Classes which implement this interface provide a method
23  * that deals with events generated in the CTabFolder.
24  * <p>
25  * After creating an instance of a class that :
26  * this interface it can be added to a CTabFolder using the
27  * <code>addCTabFolderListener</code> method and removed using
28  * the <code>removeCTabFolderListener</code> method. When a
29  * tab item is closed, the itemClosed method will be invoked.
30  * </p>
31  *
32  * @see CTabFolderEvent
33  */
34 public interface CTabFolderListener : DWTEventListener {
35
36 /**
37  * Sent when the user clicks on the close button of an item in the CTabFolder.  The item being closed is specified
38  * in the event.item field. Setting the event.doit field to false will stop the CTabItem from closing.
39  * When the CTabItem is closed, it is disposed.  The contents of the CTabItem (see CTabItem.setControl) will be
40  * made not visible when the CTabItem is closed.
41  *
42  * @param event an event indicating the item being closed
43  *
44  * @see CTabItem#setControl
45  */
46 public void itemClosed(CTabFolderEvent event);
47 }
48
49
50
51 /// Helper class for the dgListener template function
52 private class _DgCTabFolderListenerT(Dg,T...) : CTabFolderListener {
53
54     alias ParameterTupleOf!(Dg) DgArgs;
55     static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)),
56                 "Delegate args not correct" );
57
58     Dg dg;
59     T  t;
60
61     private this( Dg dg, T t ){
62         this.dg = dg;
63         static if( T.length > 0 ){
64             this.t = t;
65         }
66     }
67
68     void itemClosed( CTabFolderEvent e ){
69         dg(e,t);
70     }
71 }
72
73 /++
74  + dgListener creates a class implementing the Listener interface and delegating the call to
75  + handleEvent to the users delegate. This template function will store also additional parameters.
76  +
77  + Examle of usage:
78  + ---
79  + void handleTextEvent (Event e, int inset ) {
80  +     // ...
81  + }
82  + text.addListener (DWT.FocusOut, dgListener( &handleTextEvent, inset ));
83  + ---
84  +/
85 CTabFolderListener dgCTabFolderListener( Dg, T... )( Dg dg, T args ){
86     return new _DgCTabFolderListenerT!( Dg, T )( dg, args );
87 }
Note: See TracBrowser for help on using the browser.