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