summaryrefslogtreecommitdiffstats
path: root/tdejava/koala/org/trinitydesktop/koala/TDEAction.java
blob: 1120265e5093e231ef412bbaad07ec53958c753c (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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
//Auto-generated by kalyptus. DO NOT EDIT.
package org.trinitydesktop.koala;

import org.trinitydesktop.qt.Qt;
import org.trinitydesktop.qt.TQMetaObject;
import org.trinitydesktop.qt.QtSupport;
import org.trinitydesktop.qt.TQObject;
import org.trinitydesktop.qt.TQPopupMenu;
import org.trinitydesktop.qt.TQIconSet;
import org.trinitydesktop.qt.TQWidget;
import org.trinitydesktop.qt.TQObject;

/**

 The TDEAction class (and derived and super classes) provides a way to
 easily encapsulate a "real" user-selected action or event in your
 program.
 For instance, a user may want to <code>paste</code> the contents of
 the clipboard or <code>scroll</code> <code>down</code> a document or <code>quit</code> the
 application.  These are all <code>actions</code> -- events that the
 user causes to happen.  The TDEAction class allows the developer to
 deal with these actions in an easy and intuitive manner.
 Specifically, the TDEAction class encapsulated the various attributes
 to an event/action.  For instance, an action might have an icon
 that goes along with it (a clipboard for a "paste" action or
 scissors for a "cut" action).  The action might have some text to
 describe the action.  It will certainly have a method or function
 that actually <code>executes</code> the action!  All these attributes
 are contained within the TDEAction object.
 The advantage of dealing with Actions is that you can manipulate
 the Action without regard to the GUI representation of it.  For
 instance, in the "normal" way of dealing with actions like "cut",
 you would manually insert a item for Cut into a menu and a button
 into a toolbar.  If you want to disable the cut action for a moment
 (maybe nothing is selected), you would have to hunt down the pointer
 to the menu item and the toolbar button and disable both
 individually.  Setting the menu item and toolbar item up uses very
 similar code - but has to be done twice!
 With the Action concept, you simply "plug" the Action into whatever
 GUI element you want.  The TDEAction class will then take care of
 correctly defining the menu item (with icons, accelerators, text,
 etc) or toolbar button.. or whatever.  From then on, if you
 manipulate the Action at all, the effect will propogate through all
 GUI representations of it.  Back to the "cut" example: if you want
 to disable the Cut Action, you would simply do
 'cutAction.setEnabled(false)' and the menuitem and button would
 instantly be disabled!
 This is the biggest advantage to the Action concept -- there is a
 one-to-one relationship between the "real" action and <code>all</code>
 GUI representations of it.
 TDEAction emits the activated() signal if the user activated the
 corresponding GUI element ( menu item, toolbar button, etc. )
 If you are in the situation of wanting to map the activated()
 signal of multiple action objects to one slot, with a special
 argument bound to each action, then you might consider using
 TQSignalMapper . A tiny example:
 <pre>
 TQSignalMapper desktopNumberMapper = new TQSignalMapper( this );
 connect( desktopNumberMapper, TQ_SIGNAL("mapped( int )"),
          this, TQ_SLOT("moveWindowToDesktop( int )") );
 for ( uint i = 0; i < numberOfDesktops; ++i ) {
     TDEAction desktopAction = new TDEAction( i18n( "Move Window to Desktop %i" ).arg( i ), ... );
     connect( desktopAction, TQ_SIGNAL("activated()"), desktopNumberMapper, TQ_SLOT("map()") );
     desktopNumberMapper.setMapping( desktopAction, i );
 }
 </pre>
 <li><b>General Usage:</b></li>
 The steps to using actions are roughly as follows

	<li>
	Decide which attributes you want to associate with a given
	     action (icons, text, keyboard shortcut, etc)
	</li>

	<li>
	Create the action using TDEAction (or derived or super class).
	</li>

	<li>
	"Plug" the Action into whatever GUI element you want.  Typically,
	      this will be a menu or toolbar.
	</li>
	 <li><b>Detailed Example:</b></li>
 Here is an example of enabling a "New [document]" action
 <pre>
 TDEAction newAct = new TDEAction(i18n("&New"), "filenew",
                               TDEStdAccel.shortcut(TDEStdAccel.New),
                               this, TQ_SLOT("fileNew()"),
                               actionCollection(), "new");
 </pre>
 This line creates our action.  It says that wherever this action is
 displayed, it will use "&New" as the text, the standard icon, and
 the standard shortcut.  It further says that whenever this action
 is invoked, it will use the fileNew() slot to execute it.
 <pre>
 TQPopupMenu file = new TQPopupMenu;
 newAct.plug(file);
 </pre>
 That just inserted the action into the File menu.  The point is, it's not
 important in which menu it is: all manipulation of the item is
 done through the newAct object.
 <pre>
 newAct.plug(toolBar());
 </pre>
 And this inserted the Action into the main toolbar as a button.
 That's it!
 If you want to disable that action sometime later, you can do so
 with
 <pre>
 newAct.setEnabled(false)
 </pre>
 and both the menuitem in File and the toolbar button will instantly
 be disabled.
 Do not delete a TDEAction object without unplugging it from all its
 containers. The simplest way to do that is to use the unplugAll()
 as in the following example:
 <pre>
 newAct.unplugAll();
 delete newAct;
 </pre>
 Normally you will not need to do this as TDEActionCollection manages
 everything for you.
 Note: if you are using a "standard" action like "new", "paste",
 "quit", or any other action described in the KDE UI Standards,
 please use the methods in the KStdAction class rather than
 defining your own.
 <li><b>Usage Within the XML Framework:</b></li>
 If you are using TDEAction within the context of the XML menu and
 toolbar building framework, then there are a few tiny changes.  The
 first is that you must insert your new action into an action
 collection.  The action collection (a TDEActionCollection) is,
 logically enough, a central collection of all of the actions
 defined in your application.  The XML UI framework code in KXMLGUI
 classes needs access to this collection in order to build up the
 GUI (it's how the builder code knows which actions are valid and
 which aren't).
 Also, if you use the XML builder framework, then you do not ever
 have to plug your actions into containers manually.  The framework
 does that for you.
 See {@link TDEActionSignals} for signals emitted by TDEAction
		@short Class to encapsulate user-driven action or event.
		@see KStdAction

*/
public class TDEAction extends TQObject  {
	protected TDEAction(Class dummy){super((Class) null);}
	/**
				@short
	*/
	public static final int UnknownActivation = 0;
	public static final int EmulatedActivation = 1;
	public static final int AccelActivation = 2;
	public static final int PopupMenuActivation = 3;
	public static final int ToolBarActivation = 4;

	public native TQMetaObject metaObject();
	public native String className();
	/**
		 Constructs an action with text, potential keyboard
		 shortcut, and a slot to call when this action is invoked by
		 the user.
			 If you do not want or have a keyboard shortcut,
		 set the <code>cut</code> param to 0.
			 This is the most common TDEAction used when you do not have a
		 corresponding icon (note that it won't appear in the current version
		 of the "Edit ToolBar" dialog, because an action needs an icon to be
		 plugged in a toolbar...).
			@param text The text that will be displayed.
			@param cut The corresponding keyboard shortcut.
			@param receiver The slot's parent.
			@param slot The slot to invoke to execute this action.
			@param parent This action's parent.
			@param name An internal name for this action.
		     		@short    Constructs an action with text, potential keyboard  shortcut, and a slot to call when this action is invoked by  the user.
	*/
	public TDEAction(String text, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name) {
		super((Class) null);
		newTDEAction(text,cut,receiver,slot,parent,name);
	}
	private native void newTDEAction(String text, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name);
	/**
		 Constructs an action with text, icon, potential keyboard
		 shortcut, and a slot to call when this action is invoked by
		 the user.
			 If you do not want or have a keyboard shortcut, set the
		 <code>cut</code> param to 0.
			 This is the other common TDEAction used.  Use it when you
		 <code>do</code> have a corresponding icon.
			@param text The text that will be displayed.
			@param pix The icon to display.
			@param cut The corresponding keyboard shortcut.
			@param receiver The slot's parent.
			@param slot The slot to invoke to execute this action.
			@param parent This action's parent.
			@param name An internal name for this action.
		     		@short    Constructs an action with text, icon, potential keyboard  shortcut, and a slot to call when this action is invoked by  the user.
	*/
	public TDEAction(String text, TQIconSet pix, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name) {
		super((Class) null);
		newTDEAction(text,pix,cut,receiver,slot,parent,name);
	}
	private native void newTDEAction(String text, TQIconSet pix, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name);
	/**
		 Constructs an action with text, icon, potential keyboard
		 shortcut, and a slot to call when this action is invoked by
		 the user.  The icon is loaded on demand later based on where it
		 is plugged in.
			 If you do not want or have a keyboard shortcut, set the
		 <code>cut</code> param to 0.
			 This is the other common TDEAction used.  Use it when you
		 <code>do</code> have a corresponding icon.
			@param text The text that will be displayed.
			@param pix The icon to display.
			@param cut The corresponding keyboard shortcut (shortcut).
			@param receiver The slot's parent.
			@param slot The slot to invoke to execute this action.
			@param parent This action's parent.
			@param name An internal name for this action.
		     		@short    Constructs an action with text, icon, potential keyboard  shortcut, and a slot to call when this action is invoked by  the user.
	*/
	public TDEAction(String text, String pix, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name) {
		super((Class) null);
		newTDEAction(text,pix,cut,receiver,slot,parent,name);
	}
	private native void newTDEAction(String text, String pix, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name);
	/**
		 The same as the above constructor, but with a KGuiItem providing
		 the text and icon.
			@param item The KGuiItem with the label and (optional) icon.
			@param cut The corresponding keyboard shortcut (shortcut).
			@param receiver The slot's parent.
			@param slot The slot to invoke to execute this action.
			@param parent This action's parent.
			@param name An internal name for this action.
		     		@short    The same as the above constructor, but with a KGuiItem providing  the text and icon.
	*/
	public TDEAction(KGuiItem item, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name) {
		super((Class) null);
		newTDEAction(item,cut,receiver,slot,parent,name);
	}
	private native void newTDEAction(KGuiItem item, TDEShortcut cut, TQObject receiver, String slot, TDEActionCollection parent, String name);
	/**
		 "Plug" or insert this action into a given widget.
			 This will
		 typically be a menu or a toolbar.  From this point on, you will
		 never need to directly manipulate the item in the menu or
		 toolbar.  You do all enabling/disabling/manipulation directly
		 with your TDEAction object.
			@param widget The GUI element to display this action
			@param index The position into which the action is plugged. If
		 this is negative, the action is inserted at the end.
		     		@short    "Plug" or insert this action into a given widget.
	*/
	public native int plug(TQWidget widget, int index);
	public native int plug(TQWidget widget);
	/**
		 "Unplug" or remove this action from a given widget.
			 This will typically be a menu or a toolbar.  This is rarely
		 used in "normal" application.  Typically, it would be used if
		 your application has several views or modes, each with a
		 completely different menu structure.  If you simply want to
		 disable an action for a given period, use setEnabled()
		 instead.
			@param w Remove the action from this GUI element.
		     		@short    "Unplug" or remove this action from a given widget.
	*/
	public native void unplug(TQWidget w);
	/**
		 returns whether the action is plugged into any container widget or not.
				@short    returns whether the action is plugged into any container widget or not.
	*/
	public native boolean isPlugged();
	/**
		 returns whether the action is plugged into the given container
		     		@short    returns whether the action is plugged into the given container
	*/
	public native boolean isPlugged(TQWidget container);
	/**
		 returns whether the action is plugged into the given container with the given, container specific, id (often
		 menu or toolbar id ) .
		     		@short    returns whether the action is plugged into the given container with the given, container specific, id (often  menu or toolbar id ) .
	*/
	public native boolean isPlugged(TQWidget container, int id);
	/**
		 returns whether the action is plugged into the given container with the given, container specific, representative
		 container widget item.
		     		@short    returns whether the action is plugged into the given container with the given, container specific, representative  container widget item.
	*/
	public native boolean isPlugged(TQWidget container, TQWidget _representative);
	public native TQWidget container(int index);
	public native int itemId(int index);
	public native TQWidget representative(int index);
	public native int containerCount();
	public native int tdeaccelCount();
	public native boolean hasIcon();
	public native boolean hasIconSet();
	public native String plainText();
	/**
		 Get the text associated with this action.
		     		@short    Get the text associated with this action.
	*/
	public native String text();
	/**
		 Get the keyboard shortcut associated with this action.
		     		@short    Get the keyboard shortcut associated with this action.
	*/
	public native TDEShortcut shortcut();
	/**
		 Get the default shortcut for this action.
		     		@short    Get the default shortcut for this action.
	*/
	public native TDEShortcut shortcutDefault();
	public native String shortcutText();
	public native void setShortcutText(String arg1);
	/**
		 Returns true if this action is enabled.
		     		@short    Returns true if this action is enabled.
	*/
	public native boolean isEnabled();
	/**
		 Returns true if this action's shortcut is configurable.
		     		@short    Returns true if this action's shortcut is configurable.
	*/
	public native boolean isShortcutConfigurable();
	public native String group();
	/**
		 Get the What's this text for the action.
		     		@short    Get the What's this text for the action.
	*/
	public native String whatsThis();
	/**
		 Get the tooltip text for the action.
		     		@short    Get the tooltip text for the action.
	*/
	public native String toolTip();
	/**
		 Get the TQIconSet from which the icons used to display this action will
		 be chosen.
			 In KDE4 set group default to TDEIcon.Small while removing the other
		 iconSet() function.
		     		@short    Get the TQIconSet from which the icons used to display this action will  be chosen.
	*/
	public native TQIconSet iconSet(int group, int size);
	public native TQIconSet iconSet(int group);
	/**
		 Remove in KDE4
		     		@short    Remove in KDE4
	*/
	public native TQIconSet iconSet();
	public native String icon();
	public native TDEActionCollection parentCollection();
	public native void unplugAll();
	public native String statusText();
	/**
		 Sets the text associated with this action. The text is used for menu
		 and toolbar labels etc.
		     		@short    Sets the text associated with this action.
	*/
	public native void setText(String text);
	/**
		 Sets the keyboard shortcut associated with this action.
		     		@short    Sets the keyboard shortcut associated with this action.
	*/
	public native boolean setShortcut(TDEShortcut arg1);
	public native void setGroup(String arg1);
	/**
		 Sets the What's this text for the action. This text will be displayed when
		 a widget that has been created by plugging this action into a container
		 is clicked on in What's this mode.
			 The What's this text can include TQML markup as well as raw text.
		     		@short    Sets the What's this text for the action.
	*/
	public native void setWhatsThis(String text);
	/**
		 Sets the tooltip text for the action.
		 This will be used as a tooltip for a toolbar button, as a
		 statusbar help-text for a menu item, and it also appears
		 in the toolbar editor, to describe the action.
			 For the tooltip to show up on the statusbar you will need to connect
		 a couple of the actionclass signals to the toolbar.
		 The easiest way of doing this is in your main window class, when you create
		 a statusbar.  See the TDEActionCollection class for more details.
			     		@short    Sets the tooltip text for the action.
		@see TDEActionCollection
	*/
	public native void setToolTip(String arg1);
	/**
		 Sets the TQIconSet from which the icons used to display this action will
		 be chosen.
		     		@short    Sets the TQIconSet from which the icons used to display this action will  be chosen.
	*/
	public native void setIconSet(TQIconSet iconSet);
	public native void setIcon(String icon);
	/**
		 Enables or disables this action. All uses of this action (eg. in menus
		 or toolbars) will be updated to reflect the state of the action.
		     		@short    Enables or disables this action.
	*/
	public native void setEnabled(boolean enable);
	/**
		 Calls setEnabled( !disable ).
				@short    Calls setEnabled( !disable ).
	*/
	public native void setDisabled(boolean disable);
	/**
		 Indicate whether the user may configure the action's shortcut.
		     		@short    Indicate whether the user may configure the action's shortcut.
	*/
	public native void setShortcutConfigurable(boolean arg1);
	/**
		 Emulate user's interaction programmatically, by activating the action.
		 The implementation simply emits activated().
		     		@short    Emulate user's interaction programmatically, by activating the action.
	*/
	public native void activate();
	/**
			 Generate a toolbar button id. Made public for reimplementations.
		     		@short
	*/
	public static native int getToolButtonID();
	protected native TDEToolBar toolBar(int index);
	protected native TQPopupMenu popupMenu(int index);
	protected native void removeContainer(int index);
	protected native int findContainer(TQWidget widget);
	protected native int findContainer(int id);
	protected native void plugMainWindowAccel(TQWidget w);
	protected native void addContainer(TQWidget parent, int id);
	protected native void addContainer(TQWidget parent, TQWidget representative);
	protected native void updateShortcut(int i);
	protected native void updateShortcut(TQPopupMenu menu, int id);
	protected native void updateGroup(int id);
	protected native void updateText(int i);
	protected native void updateEnabled(int i);
	protected native void updateIconSet(int i);
	protected native void updateIcon(int i);
	protected native void updateToolTip(int id);
	protected native void updateWhatsThis(int i);
	protected native String whatsThisWithIcon();
	/**
		 Return the underlying KGuiItem
				@short    Return the underlying KGuiItem
	*/
	protected native KGuiItem guiItem();
	protected native void slotDestroyed();
	protected native void slotKeycodeChanged();
	protected native void slotActivated();
	protected native void slotPopupActivated();
	protected native void slotButtonClicked(int arg1, int state);
	/** 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();
}