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 gtkc.gtk;
34 public  import gtkc.gtktypes;
35 
36 
37 /**
38  * A #GtkCheckButton places a discrete #GtkToggleButton next to a widget,
39  * (usually a #GtkLabel). See the section on #GtkToggleButton widgets for
40  * more information about toggle/check buttons.
41  * 
42  * The important signal ( #GtkToggleButton::toggled ) is also inherited from
43  * #GtkToggleButton.
44  * 
45  * # CSS nodes
46  * 
47  * |[<!-- language="plain" -->
48  * checkbutton
49  * ├── check
50  * ╰── <child>
51  * ]|
52  * 
53  * A GtkCheckButton with indicator (see gtk_toggle_button_set_mode()) has a
54  * main CSS node with name checkbutton and a subnode with name check.
55  * 
56  * |[<!-- language="plain" -->
57  * button.check
58  * ├── check
59  * ╰── <child>
60  * ]|
61  * 
62  * A GtkCheckButton without indicator changes the name of its main node
63  * to button and adds a .check style class to it. The subnode is invisible
64  * in this case.
65  */
66 public class CheckButton : ToggleButton
67 {
68 	/** the main Gtk struct */
69 	protected GtkCheckButton* gtkCheckButton;
70 
71 	/** Get the main Gtk struct */
72 	public GtkCheckButton* getCheckButtonStruct(bool transferOwnership = false)
73 	{
74 		if (transferOwnership)
75 			ownedRef = false;
76 		return gtkCheckButton;
77 	}
78 
79 	/** the main Gtk struct as a void* */
80 	protected override void* getStruct()
81 	{
82 		return cast(void*)gtkCheckButton;
83 	}
84 
85 	protected override void setStruct(GObject* obj)
86 	{
87 		gtkCheckButton = cast(GtkCheckButton*)obj;
88 		super.setStruct(obj);
89 	}
90 
91 	/**
92 	 * Sets our main struct and passes it to the parent class.
93 	 */
94 	public this (GtkCheckButton* gtkCheckButton, bool ownedRef = false)
95 	{
96 		this.gtkCheckButton = gtkCheckButton;
97 		super(cast(GtkToggleButton*)gtkCheckButton, ownedRef);
98 	}
99 
100 	/**
101 	 * Creates a new GtkCheckButton with a GtkLabel to the right of it.
102 	 * If mnemonic is true the label
103 	 * will be created using gtk_label_new_with_mnemonic(), so underscores
104 	 * in label indicate the mnemonic for the check button.
105 	 * Params:
106 	 *  label = The text of the button, with an underscore in front of the
107 	 *  mnemonic character
108 	 *  mnemonic = true if the button has an mnemnonic
109 	 * Throws: ConstructionException GTK+ fails to create the object.
110 	 */
111 	public this (string label, bool mnemonic=true)
112 	{
113 		GtkCheckButton* p;
114 		
115 		if ( mnemonic )
116 		{
117 			// GtkWidget* gtk_check_button_new_with_mnemonic  (const gchar *label);
118 			p = cast(GtkCheckButton*)gtk_check_button_new_with_mnemonic(Str.toStringz(label));
119 		}
120 		else
121 		{
122 			// GtkWidget* gtk_check_button_new_with_label (const gchar *label);
123 			p = cast(GtkCheckButton*)gtk_check_button_new_with_label(Str.toStringz(label));
124 		}
125 		
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by gtk_check_button_new_");
129 		}
130 		
131 		this(p);
132 	}
133 	
134 	/** */
135 	public this(string label, void delegate(CheckButton) onClicked, bool mnemonic=true)
136 	{
137 		this(label, mnemonic);
138 		addOnClicked(cast(void delegate(Button))onClicked);
139 	}
140 
141 	/**
142 	 */
143 
144 	/** */
145 	public static GType getType()
146 	{
147 		return gtk_check_button_get_type();
148 	}
149 
150 	/**
151 	 * Creates a new #GtkCheckButton.
152 	 *
153 	 * Returns: a #GtkWidget.
154 	 *
155 	 * Throws: ConstructionException GTK+ fails to create the object.
156 	 */
157 	public this()
158 	{
159 		auto p = gtk_check_button_new();
160 		
161 		if(p is null)
162 		{
163 			throw new ConstructionException("null returned by new");
164 		}
165 		
166 		this(cast(GtkCheckButton*) p);
167 	}
168 }