<html> <head><title>Gtk-- Reference: Gtk::Button</title></head> <body bgcolor="#F0F0F0" text="#000000" link="#0000FF" vlink="#000077" alink="#FF0000"> <table align=center border=0 cellspacing=10> <tr> <td><a href="class_index.html">Class Index</a></td> <td><a href="cross_index.html">Cross Index</a></td> <td><a href="name_index.html">Namespace Index</a></td> </table> <h1 align=center>Class Gtk::Button</h1><p> <b> Toplevel Button</b><br> Contained in: <a href="Gtk.html">Gtk</a><br> Derived from: <a href="Gtk%3A%3ABin.html">Gtk::Bin</a> <br> Derived by: <a href="Gtk::OptionMenu.html">Gtk::OptionMenu</a> <a href="Gtk::ToggleButton.html">Gtk::ToggleButton</a> <p> #include <gtk--/button.h> <p> <hr noshade> <table border=0> <tr><td colspan=3><h3>public function member index:</h3></td> <tr valign=top><td align=right><tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#398"><tt><font color=blue><b>Button</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>explicit</tt> </tt> </td><td align=right><a href="Gtk%3A%3AButton.html#399"><tt><font color=blue><b>Button</b></font></tt></a></td><td><tt>(<tt>const</tt> <tt><font color=navy>string</font></tt>& <tt><font color=blue>label</font></tt>, <tt><font color=purple>gfloat</font></tt> <tt><font color=blue>x</font></tt>=0.5, <tt><font color=purple>gfloat</font></tt> <tt><font color=blue>y</font></tt>=0.5)</tt>;</td> <tr valign=top><td align=right><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#404"><tt><font color=blue><b>clicked</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#405"><tt><font color=blue><b>enter</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt><font color=navy>GtkReliefStyle</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#401"><tt><font color=blue><b>get_relief</b></font></tt></a></td><td><tt>() <tt>const</tt></tt>;</td> <tr valign=top><td align=right><tt><tt><font color=navy>GtkButton</font></tt>*</tt> </td><td align=right><a href="Gtk%3A%3AButton.html#394"><tt><font color=blue><b>gtkobj</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>const</tt> <tt><font color=navy>GtkButton</font></tt>*</tt> </td><td align=right><a href="Gtk%3A%3AButton.html#395"><tt><font color=blue><b>gtkobj</b></font></tt></a></td><td><tt>() <tt>const</tt></tt>;</td> <tr valign=top><td align=right><tt><tt>static</tt> <tt><font color=purple>bool</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#396"><tt><font color=blue><b>isA</b></font></tt></a></td><td><tt>(<a href="Gtk%3A%3AObject.html"><tt><font color=navy><b>Object</b></font></tt></a>* <tt><font color=blue>object</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#406"><tt><font color=blue><b>leave</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#402"><tt><font color=blue><b>pressed</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#403"><tt><font color=blue><b>released</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#400"><tt><font color=blue><b>set_relief</b></font></tt></a></td><td><tt>(<tt><font color=navy>GtkReliefStyle</font></tt> <tt><font color=blue>newstyle</font></tt>)</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> </tt> </td><td align=right><a href="Gtk%3A%3AButton.html#397"><tt><font color=blue><b>~Button</b></font></tt></a></td><td><tt>()</tt>;</td> <tr><td> </td><tr><td colspan=3><h3>protected function member index:</h3></td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#409"><tt><font color=blue><b>clicked_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#410"><tt><font color=blue><b>enter_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#411"><tt><font color=blue><b>leave_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#407"><tt><font color=blue><b>pressed_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr valign=top><td align=right><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> </td><td align=right><a href="Gtk%3A%3AButton.html#408"><tt><font color=blue><b>released_impl</b></font></tt></a></td><td><tt>()</tt>;</td> <tr><td> </td></table> <hr noshade> <h2>Description:</h2> The button widget is a rectangular clickable widget. You can decorate it with images, text, or whatever you like.<br> <p> <hr noshade> <h2>Function Member Descriptions:</h2> <a name="398"><font size=+1><b>Gtk::Button::Button</b></font></a> - Create an empty button.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt></tt> <a href="Gtk%3A%3AButton.html#398"><tt><font color=blue><b>Button</b></font></tt></a><tt>()</tt>;<br><blockquote> With an empty button, you can <tt><tt><font color=navy><b>Gtk_Button</b></font></tt>::<tt><font color=blue><b>add</b></font></tt></tt> a widget such as a <tt><a href="Gtk.html"><tt><font color=navy><b>Gtk</b></font></tt></a>::<a href="Gtk%3A%3APixmap.html"><tt><font color=navy><b>Pixmap</b></font></tt></a></tt> or <tt><a href="Gtk.html"><tt><font color=navy><b>Gtk</b></font></tt></a>::<a href="Gtk%3A%3ABox.html"><tt><font color=navy><b>Box</b></font></tt></a></tt>. <P> If you just wish to add a <tt><a href="Gtk.html"><tt><font color=navy><b>Gtk</b></font></tt></a>::<a href="Gtk%3A%3ALabel.html"><tt><font color=navy><b>Label</b></font></tt></a></tt>, you may want to use the {Button(const string &label)} ctor directly instead.</blockquote> <br><br> <a name="399"><font size=+1><b>Gtk::Button::Button</b></font></a> - Simple Push Button with label.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>explicit</tt> </tt> <a href="Gtk%3A%3AButton.html#399"><tt><font color=blue><b>Button</b></font></tt></a><tt>(<tt>const</tt> <tt><font color=navy>string</font></tt>& <tt><font color=blue>label</font></tt>, <tt><font color=purple>gfloat</font></tt> <tt><font color=blue>x</font></tt>=0.5, <tt><font color=purple>gfloat</font></tt> <tt><font color=blue>y</font></tt>=0.5)</tt>;<br><blockquote> Create a button with the given label inside. You won't be able to add a widget in this button since it already has a <tt><font color=navy><b>Gtk_Label</b></font></tt> in it.</blockquote> <br><br> <a name="404"><font size=+1><b>Gtk::Button::clicked</b></font></a> - Emitted on button press and release.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#404"><tt><font color=blue><b>clicked</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#409"><tt><font color=blue><b>clicked_impl</b></font></tt></a><tt>()</tt>;<br><blockquote> Triggered when the user has pressed and released the mouse button This is the signal you most likely want to connect.</blockquote> <br><br> <a name="405"><font size=+1><b>Gtk::Button::enter</b></font></a> - Triggered when the mouse cursor enters the button<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#405"><tt><font color=blue><b>enter</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#410"><tt><font color=blue><b>enter_impl</b></font></tt></a><tt>()</tt>;<br><br> <a name="401"><font size=+1><b>Gtk::Button::get_relief</b></font></a> - Return the button's relief style. (see <tt><tt><font color=navy><b>Gtk_Button</b></font></tt>::<tt><font color=blue><b>set_relief</b></font></tt></tt>)<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt><font color=navy>GtkReliefStyle</font></tt></tt> <a href="Gtk%3A%3AButton.html#401"><tt><font color=blue><b>get_relief</b></font></tt></a><tt>() <tt>const</tt></tt>;<br><br> <a name="394"><font size=+1><b>Gtk::Button::gtkobj</b></font></a> - Returns the underlaying gtk+ object.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt><font color=navy>GtkButton</font></tt>*</tt> <a href="Gtk%3A%3AButton.html#394"><tt><font color=blue><b>gtkobj</b></font></tt></a><tt>()</tt>;<br><br> <a name="396"><font size=+1><b>Gtk::Button::isA</b></font></a> - Returns true if object is this type.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>static</tt> <tt><font color=purple>bool</font></tt></tt> <a href="Gtk%3A%3AButton.html#396"><tt><font color=blue><b>isA</b></font></tt></a><tt>(<a href="Gtk%3A%3AObject.html"><tt><font color=navy><b>Object</b></font></tt></a>* <tt><font color=blue>object</font></tt>)</tt>;<br><br> <a name="406"><font size=+1><b>Gtk::Button::leave</b></font></a> - Triggered when the mouse cursor leaves the button<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#406"><tt><font color=blue><b>leave</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#411"><tt><font color=blue><b>leave_impl</b></font></tt></a><tt>()</tt>;<br><br> <a name="402"><font size=+1><b>Gtk::Button::pressed</b></font></a> - Emited on button press.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#402"><tt><font color=blue><b>pressed</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#407"><tt><font color=blue><b>pressed_impl</b></font></tt></a><tt>()</tt>;<br><blockquote> Triggered when the button is pressed (e.g. the mouse button is still down, it hasn't been released yet, see next signal)</blockquote> <br><br> <a name="403"><font size=+1><b>Gtk::Button::released</b></font></a> - Triggered when the user has released the mouse button<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt>emitable</tt> <tt>signal</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#403"><tt><font color=blue><b>released</b></font></tt></a><tt>()</tt>;<br><tt><tt>virtual</tt> <tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#408"><tt><font color=blue><b>released_impl</b></font></tt></a><tt>()</tt>;<br><br> <a name="400"><font size=+1><b>Gtk::Button::set_relief</b></font></a> - Set the button's relief style.<br> <hr size="1" width="70%" align="left" noshade="noshade"><tt><tt><font color=purple>void</font></tt></tt> <a href="Gtk%3A%3AButton.html#400"><tt><font color=blue><b>set_relief</b></font></tt></a><tt>(<tt><font color=navy>GtkReliefStyle</font></tt> <tt><font color=blue>newstyle</font></tt>)</tt>;<br><blockquote> This effects how the button looks. GtkReliefStyle can be one of <tt><font color=green>GTK_RELIEF_NORMAL</font></tt>, <tt><font color=green>GTK_RELIEF_HALF</font></tt>, or <tt><font color=green>GTK_RELIEF_NONE</font></tt>. <pre> //This program shows the differences in button styles. <P> #include <gtk--/button.h> #include <gtk--/window.h> #include <gtk--/box.h> #include <gtk--/main.h> <P> //This custom window will contain 3 buttons, one of //each style. class custom_window : public Gtk::Window { Gtk::Button normal, half, none; Gtk::HBox some_hbox; public: custom_window(); }; <P> //The constructor. Creates the window adds the buttons, //and sets their style. custom_window::custom_window() : Gtk::Window(GTK_WINDOW_TOPLEVEL), some_hbox(true, 2), normal("Normal"), half("Half"), none("None") { normal.set_relief(GTK_RELIEF_NORMAL); half.set_relief(GTK_RELIEF_HALF); none.set_relief(GTK_RELIEF_NONE); some_hbox.pack_start(normal, true, true, 0); some_hbox.pack_start(half, true, true, 0); some_hbox.pack_start(none, true, true, 0); add(some_hbox); show_all(); } <P> int main(int argc, char *argv[]) { Gtk::Main main_runner(argc, argv); custom_window some_window; main_runner.run(); } </pre></blockquote> <br><br> <hr noshade> </html>