Mercurial > projects > dwt2
annotate org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CTabFolder2Listener.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, 2004 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.CTabFolder2Listener; | |
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 methods | |
30 * that deal with the events that are generated by the CTabFolder | |
31 * control. | |
32 * <p> | |
33 * After creating an instance of a class that : | |
34 * this interface it can be added to a CTabFolder using the | |
35 * <code>addCTabFolder2Listener</code> method and removed using | |
36 * the <code>removeCTabFolder2Listener</code> method. When | |
37 * events occurs in a CTabFolder the appropriate method | |
38 * will be invoked. | |
39 * </p> | |
40 * | |
41 * @see CTabFolder2Adapter | |
42 * @see CTabFolderEvent | |
43 * | |
44 * @since 3.0 | |
45 */ | |
46 public interface CTabFolder2Listener : SWTEventListener { | |
47 public enum { | |
48 MINIMIZE, | |
49 MAXIMIZE, | |
50 SHOWLIST, | |
51 RESTORE, | |
52 CLOSE | |
53 } | |
54 | |
55 /** | |
56 * Sent when the user clicks on the close button of an item in the CTabFolder. | |
57 * The item being closed is specified in the event.item field. | |
58 * Setting the event.doit field to false will stop the CTabItem from closing. | |
59 * When the CTabItem is closed, it is disposed. The contents of the | |
60 * CTabItem (see CTabItem.setControl) will be made not visible when | |
61 * the CTabItem is closed. | |
62 * | |
63 * @param event an event indicating the item being closed | |
64 */ | |
65 public void close(CTabFolderEvent event); | |
66 | |
67 /** | |
68 * Sent when the user clicks on the minimize button of a CTabFolder. | |
69 * The state of the CTabFolder does not change automatically - it | |
70 * is up to the application to change the state of the CTabFolder | |
71 * in response to this event using CTabFolder.setMinimized(true). | |
72 * | |
73 * @param event an event containing information about the minimize | |
74 * | |
75 * @see CTabFolder#getMinimized() | |
76 * @see CTabFolder#setMinimized(bool) | |
77 * @see CTabFolder#setMinimizeVisible(bool) | |
78 */ | |
79 public void minimize(CTabFolderEvent event); | |
80 | |
81 /** | |
82 * Sent when the user clicks on the maximize button of a CTabFolder. | |
83 * The state of the CTabFolder does not change automatically - it | |
84 * is up to the application to change the state of the CTabFolder | |
85 * in response to this event using CTabFolder.setMaximized(true). | |
86 * | |
87 * @param event an event containing information about the maximize | |
88 * | |
89 * @see CTabFolder#getMaximized() | |
90 * @see CTabFolder#setMaximized(bool) | |
91 * @see CTabFolder#setMaximizeVisible(bool) | |
92 */ | |
93 public void maximize(CTabFolderEvent event); | |
94 | |
95 /** | |
96 * Sent when the user clicks on the restore button of a CTabFolder. | |
97 * This event is sent either to restore the CTabFolder from the | |
98 * minimized state or from the maximized state. To determine | |
99 * which restore is requested, use CTabFolder.getMinimized() or | |
100 * CTabFolder.getMaximized() to determine the current state. | |
101 * The state of the CTabFolder does not change automatically - it | |
102 * is up to the application to change the state of the CTabFolder | |
103 * in response to this event using CTabFolder.setMaximized(false) | |
104 * or CTabFolder.setMinimized(false). | |
105 * | |
106 * @param event an event containing information about the restore | |
107 * | |
108 * @see CTabFolder#getMinimized() | |
109 * @see CTabFolder#getMaximized() | |
110 * @see CTabFolder#setMinimized(bool) | |
111 * @see CTabFolder#setMinimizeVisible(bool) | |
112 * @see CTabFolder#setMaximized(bool) | |
113 * @see CTabFolder#setMaximizeVisible(bool) | |
114 */ | |
115 public void restore(CTabFolderEvent event); | |
116 | |
117 /** | |
118 * Sent when the user clicks on the chevron button of the CTabFolder. | |
119 * A chevron appears in the CTabFolder when there are more tabs | |
120 * than can be displayed at the current widget size. To select a | |
121 * tab that is not currently visible, the user clicks on the | |
122 * chevron and selects a tab item from a list. By default, the | |
123 * CTabFolder provides a list of all the items that are not currently | |
124 * visible, however, the application can provide its own list by setting | |
125 * the event.doit field to <code>false</code> and displaying a selection list. | |
126 * | |
127 * @param event an event containing information about the show list | |
128 * | |
129 * @see CTabFolder#setSelection(CTabItem) | |
130 */ | |
131 public void showList(CTabFolderEvent event); | |
132 } | |
133 | |
134 | |
135 | |
136 /// Helper class for the dgListener template function | |
137 private class _DgCTabFolder2ListenerT(Dg,T...) : CTabFolder2Listener { | |
138 | |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
139 version(Tango){ |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
140 alias ParameterTupleOf!(Dg) DgArgs; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
141 static assert( is(DgArgs == Tuple!(CTabFolderEvent,T)), |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
142 "Delegate args not correct: "~DgArgs.stringof~" vs. (Event,"~T.stringof~")" ); |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
143 } else { // Phobos |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
144 alias ParameterTypeTuple!(Dg) DgArgs; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
145 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
|
146 "Delegate args not correct: "~DgArgs.stringof~" vs. (Event,"~T.stringof~")" ); |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
147 } |
25 | 148 |
149 Dg dg; | |
150 T t; | |
151 int type; | |
152 | |
153 private this( int type, Dg dg, T t ){ | |
154 this.type = type; | |
155 this.dg = dg; | |
156 static if( T.length > 0 ){ | |
157 this.t = t; | |
158 } | |
159 } | |
160 | |
161 void itemClosed( CTabFolderEvent e ){ | |
162 dg(e,t); | |
163 } | |
164 public void close(CTabFolderEvent e){ | |
165 if( type is CTabFolder2Listener.CLOSE ){ | |
166 dg(e,t); | |
167 } | |
168 } | |
169 public void minimize(CTabFolderEvent e){ | |
170 if( type is CTabFolder2Listener.MINIMIZE ){ | |
171 dg(e,t); | |
172 } | |
173 } | |
174 public void maximize(CTabFolderEvent e){ | |
175 if( type is CTabFolder2Listener.MAXIMIZE ){ | |
176 dg(e,t); | |
177 } | |
178 } | |
179 public void restore(CTabFolderEvent e){ | |
180 if( type is CTabFolder2Listener.RESTORE ){ | |
181 dg(e,t); | |
182 } | |
183 } | |
184 public void showList(CTabFolderEvent e){ | |
185 if( type is CTabFolder2Listener.SHOWLIST ){ | |
186 dg(e,t); | |
187 } | |
188 } | |
189 } | |
190 | |
191 /++ | |
192 + dgListener creates a class implementing the Listener interface and delegating the call to | |
193 + handleEvent to the users delegate. This template function will store also additional parameters. | |
194 + | |
195 + Examle of usage: | |
196 + --- | |
197 + void handleTextEvent ( Event e, int inset ) { | |
198 + // ... | |
199 + } | |
200 + text.addListener (SWT.FocusOut, dgListener( &handleTextEvent, inset )); | |
201 + --- | |
202 +/ | |
203 CTabFolder2Listener dgCTabFolder2Listener( Dg, T... )( int type, Dg dg, T args ){ | |
204 return new _DgCTabFolder2ListenerT!( Dg, T )( type, dg, args ); | |
205 } | |
206 | |
207 | |
208 |