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 	/**
87 	 * Sets our main struct and passes it to the parent class.
88 	 */
89 	public this (GtkCheckButton* gtkCheckButton, bool ownedRef = false)
90 	{
91 		this.gtkCheckButton = gtkCheckButton;
92 		super(cast(GtkToggleButton*)gtkCheckButton, ownedRef);
93 	}
94 
95 	/**
96 	 * Creates a new GtkCheckButton with a GtkLabel to the right of it.
97 	 * If mnemonic is true the label
98 	 * will be created using gtk_label_new_with_mnemonic(), so underscores
99 	 * in label indicate the mnemonic for the check button.
100 	 * Params:
101 	 *  label = The text of the button, with an underscore in front of the
102 	 *  mnemonic character
103 	 *  mnemonic = true if the button has an mnemnonic
104 	 * Throws: ConstructionException GTK+ fails to create the object.
105 	 */
106 	public this (string label, bool mnemonic=true)
107 	{
108 		GtkCheckButton* p;
109 
110 		if ( mnemonic )
111 		{
112 			// GtkWidget* gtk_check_button_new_with_mnemonic  (const gchar *label);
113 			p = cast(GtkCheckButton*)gtk_check_button_new_with_mnemonic(Str.toStringz(label));
114 		}
115 		else
116 		{
117 			// GtkWidget* gtk_check_button_new_with_label (const gchar *label);
118 			p = cast(GtkCheckButton*)gtk_check_button_new_with_label(Str.toStringz(label));
119 		}
120 
121 		if(p is null)
122 		{
123 			throw new ConstructionException("null returned by gtk_check_button_new_");
124 		}
125 
126 		this(p);
127 	}
128 
129 	/** */
130 	public this(string label, void delegate(CheckButton) onClicked, bool mnemonic=true)
131 	{
132 		this(label, mnemonic);
133 		addOnClicked(cast(void delegate(Button))onClicked);
134 	}
135 
136 	/**
137 	 */
138 
139 	/** */
140 	public static GType getType()
141 	{
142 		return gtk_check_button_get_type();
143 	}
144 
145 	/**
146 	 * Creates a new #GtkCheckButton.
147 	 *
148 	 * Returns: a #GtkWidget.
149 	 *
150 	 * Throws: ConstructionException GTK+ fails to create the object.
151 	 */
152 	public this()
153 	{
154 		auto p = gtk_check_button_new();
155 
156 		if(p is null)
157 		{
158 			throw new ConstructionException("null returned by new");
159 		}
160 
161 		this(cast(GtkCheckButton*) p);
162 	}
163 }