25
|
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 org.eclipse.swt.custom.CTabFolderListener;
|
|
14
|
|
15 import java.lang.all;
|
|
16
|
|
17 import org.eclipse.swt.internal.SWTEventListener;
|
|
18 import org.eclipse.swt.custom.CTabFolderEvent;
|
|
19
|
|
20 import tango.core.Traits;
|
|
21 import tango.core.Tuple;
|
|
22
|
|
23 /**
|
|
24 * Classes which implement this interface provide a method
|
|
25 * that deals with events generated in the CTabFolder.
|
|
26 * <p>
|
|
27 * After creating an instance of a class that :
|
|
28 * this interface it can be added to a CTabFolder using the
|
|
29 * <code>addCTabFolderListener</code> method and removed using
|
|
30 * the <code>removeCTabFolderListener</code> method. When a
|
|
31 * tab item is closed, the itemClosed method will be invoked.
|
|
32 * </p>
|
|
33 *
|
|
34 * @see CTabFolderEvent
|
|
35 */
|
|
36 public interface CTabFolderListener : SWTEventListener {
|
|
37
|
|
38 /**
|
|
39 * Sent when the user clicks on the close button of an item in the CTabFolder. The item being closed is specified
|
|
40 * in the event.item field. Setting the event.doit field to false will stop the CTabItem from closing.
|
|
41 * When the CTabItem is closed, it is disposed. The contents of the CTabItem (see CTabItem.setControl) will be
|
|
42 * made not visible when the CTabItem is closed.
|
|
43 *
|
|
44 * @param event an event indicating the item being closed
|
|
45 *
|
|
46 * @see CTabItem#setControl
|
|
47 */
|
|
48 public void itemClosed(CTabFolderEvent event);
|
|
49 }
|
|
50
|
|
51
|
|
52
|
|
53 /// Helper class for the dgListener template function
|
|
54 private class _DgCTabFolderListenerT(Dg,T...) : CTabFolderListener {
|
|
55
|
|
56 alias ParameterTupleOf!(Dg) DgArgs;
|
|
57 static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)),
|
|
58 "Delegate args not correct" );
|
|
59
|
|
60 Dg dg;
|
|
61 T t;
|
|
62
|
|
63 private this( Dg dg, T t ){
|
|
64 this.dg = dg;
|
|
65 static if( T.length > 0 ){
|
|
66 this.t = t;
|
|
67 }
|
|
68 }
|
|
69
|
|
70 void itemClosed( CTabFolderEvent e ){
|
|
71 dg(e,t);
|
|
72 }
|
|
73 }
|
|
74
|
|
75 /++
|
|
76 + dgListener creates a class implementing the Listener interface and delegating the call to
|
|
77 + handleEvent to the users delegate. This template function will store also additional parameters.
|
|
78 +
|
|
79 + Examle of usage:
|
|
80 + ---
|
|
81 + void handleTextEvent (Event e, int inset ) {
|
|
82 + // ...
|
|
83 + }
|
|
84 + text.addListener (SWT.FocusOut, dgListener( &handleTextEvent, inset ));
|
|
85 + ---
|
|
86 +/
|
|
87 CTabFolderListener dgCTabFolderListener( Dg, T... )( Dg dg, T args ){
|
|
88 return new _DgCTabFolderListenerT!( Dg, T )( dg, args );
|
|
89 }
|
|
90
|
|
91
|
|
92
|