summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/TDEShortcut.java
blob: 3a0ee12f501d7fa84e21eb4311d4747624a02cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

import org.kde.qt.Qt;
import org.kde.qt.TQKeySequence;
import org.kde.qt.QtSupport;

/**

 The TDEShortcut class is used to represent a keyboard shortcut to an action.
 A shortcut is normally a single key with modifiers, such as Ctrl+V.
 A TDEShortcut object may also contain an alternate key which will also
 activate the action it's associated to, as long as no other actions have
 defined that key as their primary key.  Ex: Ctrl+V;Shift+Insert.
 This can be used to add additional accelerators to a TDEAction.  For example,
 the below code binds the escape key to the close action.
 <pre>
  TDEAction closeAction = KStdAction.close( this, SLOT("close()"), actionCollection() );
  TDEShortcut closeShortcut = closeAction.shortcut();
  closeShortcut.append( KKey(Key_Escape));
  closeAction.setShortcut(closeShortcut);
 </pre>
 Note that a shortcut cannot have more than 2 key combinations associated with it, so the above
 code would not do anything (and append() would return false) if the closeAction already had
 an key and alternate key.
		@short    The TDEShortcut class is used to represent a keyboard shortcut to an action.

*/
public class TDEShortcut implements QtSupport {
	private long _qt;
	private boolean _allocatedInJavaWorld = true;
	protected TDEShortcut(Class dummy){}

	/**	
		 The maximum number of key sequences that can be contained in
		 a TDEShortcut.
		         		@short    The maximum number of key sequences that can be contained in  a TDEShortcut.
	*/
	public static final int MAX_SEQUENCES = 2;

	/**	
		 Creates a new null shortcut.
				@short    Creates a new null shortcut.
		@see #null
		@see #isNull
		@see #clear
	*/
	public TDEShortcut() {
		newTDEShortcut();
	}
	private native void newTDEShortcut();
	/**	
		 Creates a new shortcut with the given Qt key code
		 as the only key sequence.
			@param keyQt the qt keycode
				@short    Creates a new shortcut with the given Qt key code  as the only key sequence.
		@see org.kde.qt.Qt#Key
	*/
	public TDEShortcut(int keyQt) {
		newTDEShortcut(keyQt);
	}
	private native void newTDEShortcut(int keyQt);
	/**	
		 Creates a new shortcut that contains only the given qt key
		 sequence.
			@param keySeq the qt key sequence to add
			 		@short    Creates a new shortcut that contains only the given qt key  sequence.
	*/
	public TDEShortcut(TQKeySequence keySeq) {
		newTDEShortcut(keySeq);
	}
	private native void newTDEShortcut(TQKeySequence keySeq);
	/**	
		 Creates a new shortcut that contains only the given key
		 in its only sequence.
			@param key the key to add
			 		@short    Creates a new shortcut that contains only the given key  in its only sequence.
	*/
	public TDEShortcut(KKey key) {
		newTDEShortcut(key);
	}
	private native void newTDEShortcut(KKey key);
	/**	
		 Creates a new shortcut that contains only the given key
		 sequence.
			@param keySeq the key sequence to add
			 		@short    Creates a new shortcut that contains only the given key  sequence.
	*/
	public TDEShortcut(KKeySequence keySeq) {
		newTDEShortcut(keySeq);
	}
	private native void newTDEShortcut(KKeySequence keySeq);
	/**	
		 Copies the given shortcut.
			@param shortcut the shortcut to add
			 		@short    Copies the given shortcut.
	*/
	public TDEShortcut(TDEShortcut shortcut) {
		newTDEShortcut(shortcut);
	}
	private native void newTDEShortcut(TDEShortcut shortcut);
	/**	
		 Creates a new key sequence that contains the given key sequence.
		 The description consists of semicolon-separated keys as
		 used in KKeySequence.KKeySequence(String).
			@param shortcut the description of the key
				@short    Creates a new key sequence that contains the given key sequence.
		@see KKeySequence#KKeySequence(const
	*/
	public TDEShortcut(String shortcut) {
		newTDEShortcut(shortcut);
	}
	private native void newTDEShortcut(String shortcut);
	/**	
		 Clears the shortcut. The shortcut is null after calling this
		 function.
				@short    Clears the shortcut.
		@see #isNull
	*/
	public native void clear();
	/**	
		 Initializes the shortcut with the given Qt key code
		 as the only key sequence.
			@param keyQt the qt keycode
				@short    Initializes the shortcut with the given Qt key code  as the only key sequence.
		@see org.kde.qt.Qt#Key
	*/
	public native boolean init(int keyQt);
	/**	
		 Initializes the shortcut with the given qt key sequence.
			@param keySeq the qt key sequence to add
			 		@short    Initializes the shortcut with the given qt key sequence.
	*/
	public native boolean init(TQKeySequence keySeq);
	/**	
		 Initializes the shortcut with the given key as its only sequence.
			@param key the key to add
			 		@short    Initializes the shortcut with the given key as its only sequence.
	*/
	public native boolean init(KKey key);
	/**	
		 Initializes the shortcut with the given qt key sequence.
			@param keySeq the qt key sequence to add
			 		@short    Initializes the shortcut with the given qt key sequence.
	*/
	public native boolean init(KKeySequence keySeq);
	/**	
		 Copies the given shortcut.
			@param shortcut the shortcut to add
			 		@short    Copies the given shortcut.
	*/
	public native boolean init(TDEShortcut shortcut);
	/**	
		 Initializes the key sequence with the given key sequence.
		 The description consists of semicolon-separated keys as
		 used in KKeySequence.KKeySequence(String).
			@param shortcut the description of the key
				@short    Initializes the key sequence with the given key sequence.
		@see KKeySequence#KKeySequence(const
	*/
	public native boolean init(String shortcut);
	/**	
		 Returns the number of sequences that are in this
		 shortcut.
				@return the number of sequences
 MAX_SEQUENCES
	 
		@short    Returns the number of sequences that are in this  shortcut.
	*/
	public native int count();
	/**	
		 Returns the <code>i</code>'th key sequence of this shortcut.
			@param i the number of the key sequence to retrieve
				@return the <code>i</code>'th sequence or KKeySequence.null() if
         there are less than <code>i</code> key sequences
 MAX_SEQUENCES
	 
		@short    Returns the <code>i</code>'th key sequence of this shortcut.
	*/
	public native KKeySequence seq(int i);
	/**	
		 Returns the key code of the first key sequence, or
		 null if there is no first key sequence.
				@return the key code of the first sequence's first key

		@short    Returns the key code of the first key sequence, or  null if there is no first key sequence.
		@see org.kde.qt.Qt#Key
		@see KKeySequence#keyCodeQt
	*/
	public native int keyCodeQt();
	/**	
		 Returns true if the shortcut is null (after clear() or empty
		 constructor).
				@return true if the shortcut is null

		@short    Returns true if the shortcut is null (after clear() or empty  constructor).
		@see #clear
		@see #null
	*/
	public native boolean isNull();
	/**	
		 Compares this object with the given shortcut. Returns a negative
		 number if the given shortcut is larger, 0 if they are equal and
		 a positive number this shortcut is larger. Shortcuts are
		 compared by comparing the individual key sequences, starting from the
		 beginning until an unequal key sequences has been found. If a shortcut
		 contains more key sequences, it is considered larger.
			@param shortcut the shortcut to compare to
				@return a negative number if the given TDEShortcut is larger, 0 if
 they are equal and a positive number this TDEShortcut is larger

		@short    Compares this object with the given shortcut.
		@see KKey#compare
		@see KKeyShortcut#compare
	*/
	public native int compare(TDEShortcut shortcut);
	/**	
		 Compares the sequences of both shortcuts.
				@short    Compares the sequences of both shortcuts.
		@see #compare
	*/
	public native boolean op_equals(TDEShortcut cut);
	/**	
		 Compares the sequences of both shortcuts.
				@short    Compares the sequences of both shortcuts.
		@see #compare
	*/
	public native boolean op_not_equals(TDEShortcut cut);
	/**	
		 Compares the sequences of both shortcuts.
				@short    Compares the sequences of both shortcuts.
		@see #compare
	*/
	public native boolean op_lt(TDEShortcut cut);
	/**	
		 Checks whether this shortcut contains a sequence that starts
		 with the given key.
			@param key the key to check
				@return true if a key sequence starts with the key
	 
		@short    Checks whether this shortcut contains a sequence that starts  with the given key.
	*/
	public native boolean contains(KKey key);
	/**	
		 Checks whether this shortcut contains the given sequence.
			@param keySeq the key sequence to check
				@return true if the shortcut has the given key sequence
	 
		@short    Checks whether this shortcut contains the given sequence.
	*/
	public native boolean contains(KKeySequence keySeq);
	/**	
		 Sets the <code>i</code> 'th key sequence of the shortcut. You can not introduce
		 gaps in the list of sequences, so you must use an <code>i</code> <= count().
		 Also note that the maximum number of key sequences is MAX_SEQUENCES.
			@param i the position of the new key sequence(0 <= i <= count(), 0 <= i < MAX_SEQUENCES)
			@param keySeq the key sequence to set
				@return true if successful, false otherwise
	 
		@short    Sets the <code>i</code> 'th key sequence of the shortcut.
	*/
	public native boolean setSeq(int i, KKeySequence keySeq);
	/**	
		 Appends the given key sequence.  This sets it as either the keysequence or
		 the alternate keysequence.  If the shortcut already has MAX_SEQUENCES
		 sequences then this call does nothing, and returns false.
			@param keySeq the key sequence to add
				@return true if successful, false otherwise

		@short    Appends the given key sequence.
		@see #setSeq
	*/
	public native boolean append(KKeySequence keySeq);
	/**	
		 Removes the given key sequence from this shortcut
			@param keySeq the key sequence to remove
				@short    Removes the given key sequence from this shortcut
	*/
	public native void remove(KKeySequence keySeq);
	/**	
		 Appends the given key
			@param spec the key to add
				@return true if successful, false otherwise

		@short    Appends the given key 
		@see #setSeq
		@see MAX_SEQUENCES
	*/
	public native boolean append(KKey spec);
	/**	
		 Appends the sequences from the given shortcut.
			@param cut the shortcut to append
				@return true if successful, false otherwise

		@short    Appends the sequences from the given shortcut.
		@see MAX_SEQUENCES
	*/
	public native boolean append(TDEShortcut cut);
	/**	
		 Returns a description of the shortcut as semicolon-separated
		 ket sequences, as returned by KKeySequence.toString().
				@return the string represenation of this shortcut

		@short    Returns a description of the shortcut as semicolon-separated  ket sequences, as returned by KKeySequence.toString().
		@see KKey#toString
		@see KKeySequence#toString
	*/
	public native String toString();
	/**	
				 		@short
	*/
	public native String toStringInternal(TDEShortcut pcutDefault);
	public native String toStringInternal();
	/**	
		 Returns a null shortcut.
				@return the null shortcut

		@short    Returns a null shortcut.
		@see #isNull
		@see #clear
	*/
	public static native TDEShortcut nil();
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
}