1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.CheckButton;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtk.Button;
31 private import gtk.ToggleButton;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * A #GtkCheckButton places a discrete #GtkToggleButton next to a widget,
40  * (usually a #GtkLabel). See the section on #GtkToggleButton widgets for
41  * more information about toggle/check buttons.
42  * 
43  * The important signal ( #GtkToggleButton::toggled ) is also inherited from
44  * #GtkToggleButton.
45  * 
46  * # CSS nodes
47  * 
48  * |[<!-- language="plain" -->
49  * checkbutton
50  * ├── check
51  * ╰── <child>
52  * ]|
53  * 
54  * A GtkCheckButton with indicator (see gtk_toggle_button_set_mode()) has a
55  * main CSS node with name checkbutton and a subnode with name check.
56  * 
57  * |[<!-- language="plain" -->
58  * button.check
59  * ├── check
60  * ╰── <child>
61  * ]|
62  * 
63  * A GtkCheckButton without indicator changes the name of its main node
64  * to button and adds a .check style class to it. The subnode is invisible
65  * in this case.
66  */
67 public class CheckButton : ToggleButton
68 {
69 	/** the main Gtk struct */
70 	protected GtkCheckButton* gtkCheckButton;
71 
72 	/** Get the main Gtk struct */
73 	public GtkCheckButton* getCheckButtonStruct(bool transferOwnership = false)
74 	{
75 		if (transferOwnership)
76 			ownedRef = false;
77 		return gtkCheckButton;
78 	}
79 
80 	/** the main Gtk struct as a void* */
81 	protected override void* getStruct()
82 	{
83 		return cast(void*)gtkCheckButton;
84 	}
85 
86 	protected override void setStruct(GObject* obj)
87 	{
88 		gtkCheckButton = cast(GtkCheckButton*)obj;
89 		super.setStruct(obj);
90 	}
91 
92 	/**
93 	 * Sets our main struct and passes it to the parent class.
94 	 */
95 	public this (GtkCheckButton* gtkCheckButton, bool ownedRef = false)
96 	{
97 		this.gtkCheckButton = gtkCheckButton;
98 		super(cast(GtkToggleButton*)gtkCheckButton, ownedRef);
99 	}
100 
101 	/**
102 	 * Creates a new GtkCheckButton with a GtkLabel to the right of it.
103 	 * If mnemonic is true the label
104 	 * will be created using gtk_label_new_with_mnemonic(), so underscores
105 	 * in label indicate the mnemonic for the check button.
106 	 * Params:
107 	 *  label = The text of the button, with an underscore in front of the
108 	 *  mnemonic character
109 	 *  mnemonic = true if the button has an mnemnonic
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this (string label, bool mnemonic=true)
113 	{
114 		GtkCheckButton* p;
115 
116 		if ( mnemonic )
117 		{
118 			// GtkWidget* gtk_check_button_new_with_mnemonic  (const gchar *label);
119 			p = cast(GtkCheckButton*)gtk_check_button_new_with_mnemonic(Str.toStringz(label));
120 		}
121 		else
122 		{
123 			// GtkWidget* gtk_check_button_new_with_label (const gchar *label);
124 			p = cast(GtkCheckButton*)gtk_check_button_new_with_label(Str.toStringz(label));
125 		}
126 
127 		if(p is null)
128 		{
129 			throw new ConstructionException("null returned by gtk_check_button_new_");
130 		}
131 
132 		this(p);
133 	}
134 
135 	/** */
136 	public this(string label, void delegate(CheckButton) onClicked, bool mnemonic=true)
137 	{
138 		this(label, mnemonic);
139 		addOnClicked(cast(void delegate(Button))onClicked);
140 	}
141 
142 	/**
143 	 */
144 
145 	/** */
146 	public static GType getType()
147 	{
148 		return gtk_check_button_get_type();
149 	}
150 
151 	/**
152 	 * Creates a new #GtkCheckButton.
153 	 *
154 	 * Returns: a #GtkWidget.
155 	 *
156 	 * Throws: ConstructionException GTK+ fails to create the object.
157 	 */
158 	public this()
159 	{
160 		auto p = gtk_check_button_new();
161 
162 		if(p is null)
163 		{
164 			throw new ConstructionException("null returned by new");
165 		}
166 
167 		this(cast(GtkCheckButton*) p);
168 	}
169 }