alternative to assert
[gtkD.git] / src / gtk / AccelLabel.d
blob7d7fdfd2a478628d795877890453b43356dcf045
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkAccelLabel.html
26 * outPack = gtk
27 * outFile = AccelLabel
28 * strct = GtkAccelLabel
29 * realStrct=
30 * ctorStrct=
31 * clss = AccelLabel
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_accel_label_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gobject.Closure
47 * - gtk.Widget
48 * structWrap:
49 * - GClosure* -> Closure
50 * - GtkWidget* -> Widget
51 * local aliases:
54 module gtk.AccelLabel;
56 private import gtk.gtktypes;
58 private import lib.gtk;
60 private import glib.Str;
61 private import gobject.Closure;
62 private import gtk.Widget;
64 /**
65 * Description
66 * The GtkAccelLabel widget is a subclass of GtkLabel that also displays an
67 * accelerator key on the right of the label text, e.g. 'Ctl+S'.
68 * It is commonly used in menus to show the keyboard short-cuts for commands.
69 * The accelerator key to display is not set explicitly.
70 * Instead, the GtkAccelLabel displays the accelerators which have been added to
71 * a particular widget. This widget is set by calling
72 * gtk_accel_label_set_accel_widget().
73 * For example, a GtkMenuItem widget may have an accelerator added to emit the
74 * "activate" signal when the 'Ctl+S' key combination is pressed.
75 * A GtkAccelLabel is created and added to the GtkMenuItem, and
76 * gtk_accel_label_set_accel_widget() is called with the GtkMenuItem as the
77 * second argument. The GtkAccelLabel will now display 'Ctl+S' after its label.
78 * Note that creating a GtkMenuItem with gtk_menu_item_new_with_label() (or
79 * one of the similar functions for GtkCheckMenuItem and GtkRadioMenuItem)
80 * automatically adds a GtkAccelLabel to the GtkMenuItem and calls
81 * gtk_accel_label_set_accel_widget() to set it up for you.
82 * A GtkAccelLabel will only display accelerators which have GTK_ACCEL_VISIBLE
83 * set (see GtkAccelFlags).
84 * A GtkAccelLabel can display multiple accelerators and even signal names,
85 * though it is almost always used to display just one accelerator key.
86 * Example1.Creating a simple menu item with an accelerator key.
87 * GtkWidget *save_item;
88 * GtkAccelGroup *accel_group;
89 * /+* Create a GtkAccelGroup and add it to the window. +/
90 * accel_group = gtk_accel_group_new ();
91 * gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
92 * /+* Create the menu item using the convenience function. +/
93 * save_item = gtk_menu_item_new_with_label ("Save");
94 * gtk_widget_show (save_item);
95 * gtk_container_add (GTK_CONTAINER (menu), save_item);
96 * /+* Now add the accelerator to the GtkMenuItem. Note that since we called
97 * gtk_menu_item_new_with_label() to create the GtkMenuItem the
98 * GtkAccelLabel is automatically set up to display the GtkMenuItem
99 * accelerators. We just need to make sure we use GTK_ACCEL_VISIBLE here. +/
100 * gtk_widget_add_accelerator (save_item, "activate", accel_group,
101 * GDK_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
103 private import gtk.Label;
104 public class AccelLabel : Label
107 /** the main Gtk struct */
108 protected GtkAccelLabel* gtkAccelLabel;
111 public GtkAccelLabel* getAccelLabelStruct()
113 return gtkAccelLabel;
117 /** the main Gtk struct as a void* */
118 protected void* getStruct()
120 return cast(void*)gtkAccelLabel;
124 * Sets our main struct and passes it to the parent class
126 public this (GtkAccelLabel* gtkAccelLabel)
128 super(cast(GtkLabel*)gtkAccelLabel);
129 this.gtkAccelLabel = gtkAccelLabel;
137 * Creates a new GtkAccelLabel.
138 * string:
139 * the label string. Must be non-NULL.
140 * Returns:
141 * a new GtkAccelLabel.
143 public this (char[] string)
145 // GtkWidget* gtk_accel_label_new (const gchar *string);
146 this(cast(GtkAccelLabel*)gtk_accel_label_new(Str.toStringz(string)) );
150 * Sets the closure to be monitored by this accelerator label. The closure
151 * must be connected to an accelerator group; see gtk_accel_group_connect().
152 * accel_label:
153 * a GtkAccelLabel
154 * accel_closure:
155 * the closure to monitor for accelerator changes.
157 public void setAccelClosure(Closure accelClosure)
159 // void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, GClosure *accel_closure);
160 gtk_accel_label_set_accel_closure(gtkAccelLabel, (accelClosure is null) ? null : accelClosure.getClosureStruct());
164 * Fetches the widget monitored by this accelerator label. See
165 * gtk_accel_label_set_accel_widget().
166 * accel_label:
167 * a GtkAccelLabel
168 * Returns:
169 * the object monitored by the accelerator label,
170 * or NULL.
172 public Widget getAccelWidget()
174 // GtkWidget* gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label);
175 return new Widget( gtk_accel_label_get_accel_widget(gtkAccelLabel) );
179 * Sets the widget to be monitored by this accelerator label.
180 * accel_label:
181 * a GtkAccelLabel
182 * accel_widget:
183 * the widget to be monitored.
185 public void setAccelWidget(Widget accelWidget)
187 // void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label, GtkWidget *accel_widget);
188 gtk_accel_label_set_accel_widget(gtkAccelLabel, (accelWidget is null) ? null : accelWidget.getWidgetStruct());
192 * Returns the width needed to display the accelerator key(s).
193 * This is used by menus to align all of the GtkMenuItem widgets, and shouldn't
194 * be needed by applications.
195 * accel_label:
196 * a GtkAccelLabel.
197 * Returns:
198 * the width needed to display the accelerator key(s).
200 public uint getAccelWidth()
202 // guint gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label);
203 return gtk_accel_label_get_accel_width(gtkAccelLabel);
207 * Recreates the string representing the accelerator keys.
208 * This should not be needed since the string is automatically updated whenever
209 * accelerators are added or removed from the associated widget.
210 * accel_label:
211 * a GtkAccelLabel.
212 * Returns:
213 * always returns FALSE.
214 * Property Details
215 * The "accel-closure" property
216 * "accel-closure" GClosure : Read / Write
217 * The closure to be monitored for accelerator changes.
219 public int refetch()
221 // gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label);
222 return gtk_accel_label_refetch(gtkAccelLabel);