Mercurial > projects > dwt2
annotate org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CTabFolderListener.d @ 49:7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 12:59:54 +0100 |
parents | ddbfe84d86df |
children | 536e43f63c81 |
rev | line source |
---|---|
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 | |
48 | 20 version(Tango){ |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
21 import tango.core.Traits; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
22 import tango.core.Tuple; |
48 | 23 } else { // Phobos |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
24 import std.traits; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
25 import std.typetuple; |
48 | 26 } |
25 | 27 |
28 /** | |
29 * Classes which implement this interface provide a method | |
30 * that deals with events generated in the CTabFolder. | |
31 * <p> | |
32 * After creating an instance of a class that : | |
33 * this interface it can be added to a CTabFolder using the | |
34 * <code>addCTabFolderListener</code> method and removed using | |
35 * the <code>removeCTabFolderListener</code> method. When a | |
36 * tab item is closed, the itemClosed method will be invoked. | |
37 * </p> | |
38 * | |
39 * @see CTabFolderEvent | |
40 */ | |
41 public interface CTabFolderListener : SWTEventListener { | |
42 | |
43 /** | |
44 * Sent when the user clicks on the close button of an item in the CTabFolder. The item being closed is specified | |
45 * in the event.item field. Setting the event.doit field to false will stop the CTabItem from closing. | |
46 * When the CTabItem is closed, it is disposed. The contents of the CTabItem (see CTabItem.setControl) will be | |
47 * made not visible when the CTabItem is closed. | |
48 * | |
49 * @param event an event indicating the item being closed | |
50 * | |
51 * @see CTabItem#setControl | |
52 */ | |
53 public void itemClosed(CTabFolderEvent event); | |
54 } | |
55 | |
56 | |
57 | |
58 /// Helper class for the dgListener template function | |
59 private class _DgCTabFolderListenerT(Dg,T...) : CTabFolderListener { | |
60 | |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
61 version(Tango){ |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
62 alias ParameterTupleOf!(Dg) DgArgs; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
63 static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), |
25 | 64 "Delegate args not correct" ); |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
65 } else { // Phobos |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
66 alias ParameterTypeTuple!(Dg) DgArgs; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
67 static assert( is(DgArgs == TypeTuple!(CTabFolderEvent,T)), |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
68 "Delegate args not correct" ); |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
69 } |
25 | 70 |
71 Dg dg; | |
72 T t; | |
73 | |
74 private this( Dg dg, T t ){ | |
75 this.dg = dg; | |
76 static if( T.length > 0 ){ | |
77 this.t = t; | |
78 } | |
79 } | |
80 | |
81 void itemClosed( CTabFolderEvent e ){ | |
82 dg(e,t); | |
83 } | |
84 } | |
85 | |
86 /++ | |
87 + dgListener creates a class implementing the Listener interface and delegating the call to | |
88 + handleEvent to the users delegate. This template function will store also additional parameters. | |
89 + | |
90 + Examle of usage: | |
91 + --- | |
92 + void handleTextEvent (Event e, int inset ) { | |
93 + // ... | |
94 + } | |
95 + text.addListener (SWT.FocusOut, dgListener( &handleTextEvent, inset )); | |
96 + --- | |
97 +/ | |
98 CTabFolderListener dgCTabFolderListener( Dg, T... )( Dg dg, T args ){ | |
99 return new _DgCTabFolderListenerT!( Dg, T )( dg, args ); | |
100 } | |
101 | |
102 | |
103 |