alternative to assert
[gtkD.git] / gtkD / src / gtk / AccelLabel.d
blobb52d59fb74a6f726fa0d028b5c145223d1a0b467
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
52 * local aliases:
55 module gtk.AccelLabel;
57 version(noAssert)
59 version(Tango)
61 import tango.io.Stdout; // use the tango loging?
65 private import gtkc.gtktypes;
67 private import gtkc.gtk;
70 private import glib.Str;
71 private import gobject.Closure;
72 private import gtk.Widget;
77 /**
78 * Description
79 * The GtkAccelLabel widget is a subclass of GtkLabel that also displays an
80 * accelerator key on the right of the label text, e.g. 'Ctl+S'.
81 * It is commonly used in menus to show the keyboard short-cuts for commands.
82 * The accelerator key to display is not set explicitly.
83 * Instead, the GtkAccelLabel displays the accelerators which have been added to
84 * a particular widget. This widget is set by calling
85 * gtk_accel_label_set_accel_widget().
86 * For example, a GtkMenuItem widget may have an accelerator added to emit the
87 * "activate" signal when the 'Ctl+S' key combination is pressed.
88 * A GtkAccelLabel is created and added to the GtkMenuItem, and
89 * gtk_accel_label_set_accel_widget() is called with the GtkMenuItem as the
90 * second argument. The GtkAccelLabel will now display 'Ctl+S' after its label.
91 * Note that creating a GtkMenuItem with gtk_menu_item_new_with_label() (or
92 * one of the similar functions for GtkCheckMenuItem and GtkRadioMenuItem)
93 * automatically adds a GtkAccelLabel to the GtkMenuItem and calls
94 * gtk_accel_label_set_accel_widget() to set it up for you.
95 * A GtkAccelLabel will only display accelerators which have GTK_ACCEL_VISIBLE
96 * set (see GtkAccelFlags).
97 * A GtkAccelLabel can display multiple accelerators and even signal names,
98 * though it is almost always used to display just one accelerator key.
99 * Example1.Creating a simple menu item with an accelerator key.
100 * GtkWidget *save_item;
101 * GtkAccelGroup *accel_group;
102 * /+* Create a GtkAccelGroup and add it to the window. +/
103 * accel_group = gtk_accel_group_new ();
104 * gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
105 * /+* Create the menu item using the convenience function. +/
106 * save_item = gtk_menu_item_new_with_label ("Save");
107 * gtk_widget_show (save_item);
108 * gtk_container_add (GTK_CONTAINER (menu), save_item);
109 * /+* Now add the accelerator to the GtkMenuItem. Note that since we called
110 * gtk_menu_item_new_with_label() to create the GtkMenuItem the
111 * GtkAccelLabel is automatically set up to display the GtkMenuItem
112 * accelerators. We just need to make sure we use GTK_ACCEL_VISIBLE here. +/
113 * gtk_widget_add_accelerator (save_item, "activate", accel_group,
114 * GDK_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
116 private import gtk.Label;
117 public class AccelLabel : Label
120 /** the main Gtk struct */
121 protected GtkAccelLabel* gtkAccelLabel;
124 public GtkAccelLabel* getAccelLabelStruct()
126 return gtkAccelLabel;
130 /** the main Gtk struct as a void* */
131 protected void* getStruct()
133 return cast(void*)gtkAccelLabel;
137 * Sets our main struct and passes it to the parent class
139 public this (GtkAccelLabel* gtkAccelLabel)
141 version(noAssert)
143 if ( gtkAccelLabel is null )
145 int zero = 0;
146 version(Tango)
148 Stdout("struct gtkAccelLabel is null on constructor").newline;
150 else
152 printf("struct gtkAccelLabel is null on constructor");
154 zero = zero / zero;
157 else
159 assert(gtkAccelLabel !is null, "struct gtkAccelLabel is null on constructor");
161 super(cast(GtkLabel*)gtkAccelLabel);
162 this.gtkAccelLabel = gtkAccelLabel;
170 * Creates a new GtkAccelLabel.
171 * string:
172 * the label string. Must be non-NULL.
173 * Returns:
174 * a new GtkAccelLabel.
176 public this (char[] string)
178 // GtkWidget* gtk_accel_label_new (const gchar *string);
179 this(cast(GtkAccelLabel*)gtk_accel_label_new(Str.toStringz(string)) );
183 * Sets the closure to be monitored by this accelerator label. The closure
184 * must be connected to an accelerator group; see gtk_accel_group_connect().
185 * accel_label:
186 * a GtkAccelLabel
187 * accel_closure:
188 * the closure to monitor for accelerator changes.
190 public void setAccelClosure(Closure accelClosure)
192 // void gtk_accel_label_set_accel_closure (GtkAccelLabel *accel_label, GClosure *accel_closure);
193 gtk_accel_label_set_accel_closure(gtkAccelLabel, (accelClosure is null) ? null : accelClosure.getClosureStruct());
197 * Fetches the widget monitored by this accelerator label. See
198 * gtk_accel_label_set_accel_widget().
199 * accel_label:
200 * a GtkAccelLabel
201 * Returns:
202 * the object monitored by the accelerator label,
203 * or NULL.
205 public Widget getAccelWidget()
207 // GtkWidget* gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label);
208 return new Widget( gtk_accel_label_get_accel_widget(gtkAccelLabel) );
212 * Sets the widget to be monitored by this accelerator label.
213 * accel_label:
214 * a GtkAccelLabel
215 * accel_widget:
216 * the widget to be monitored.
218 public void setAccelWidget(Widget accelWidget)
220 // void gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label, GtkWidget *accel_widget);
221 gtk_accel_label_set_accel_widget(gtkAccelLabel, (accelWidget is null) ? null : accelWidget.getWidgetStruct());
225 * Returns the width needed to display the accelerator key(s).
226 * This is used by menus to align all of the GtkMenuItem widgets, and shouldn't
227 * be needed by applications.
228 * accel_label:
229 * a GtkAccelLabel.
230 * Returns:
231 * the width needed to display the accelerator key(s).
233 public uint getAccelWidth()
235 // guint gtk_accel_label_get_accel_width (GtkAccelLabel *accel_label);
236 return gtk_accel_label_get_accel_width(gtkAccelLabel);
240 * Recreates the string representing the accelerator keys.
241 * This should not be needed since the string is automatically updated whenever
242 * accelerators are added or removed from the associated widget.
243 * accel_label:
244 * a GtkAccelLabel.
245 * Returns:
246 * always returns FALSE.
247 * Property Details
248 * The "accel-closure" property
249 * "accel-closure" GClosure : Read / Write
250 * The closure to be monitored for accelerator changes.
252 public int refetch()
254 // gboolean gtk_accel_label_refetch (GtkAccelLabel *accel_label);
255 return gtk_accel_label_refetch(gtkAccelLabel);