2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_BUTTON_H
4 #define _GTKMM_BUTTON_H
12 * Copyright (C) 1998-2002 The gtkmm Development Team
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Library General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with this library; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <gtkmm/bin.h>
30 #include <gtkmm/stockid.h>
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GtkButton GtkButton;
35 typedef struct _GtkButtonClass GtkButtonClass;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
40 { class Button_Class; } // namespace Gtk
44 namespace Stock { struct BuiltinStockID; }
47 /** A widget that creates a signal when clicked on.
49 * This widget is generally used with a signal handler that is called when the button is pressed.
50 * It can hold any valid child widget. The most commonly used child is the Gtk::Label.
55 class Button : public Bin
58 #ifndef DOXYGEN_SHOULD_SKIP_THIS
59 typedef Button CppObjectType;
60 typedef Button_Class CppClassType;
61 typedef GtkButton BaseObjectType;
62 typedef GtkButtonClass BaseClassType;
63 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
67 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70 friend class Button_Class;
71 static CppClassType button_class_;
74 Button(const Button&);
75 Button& operator=(const Button&);
78 explicit Button(const Glib::ConstructParams& construct_params);
79 explicit Button(GtkButton* castitem);
81 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS
85 static GType get_type() G_GNUC_CONST;
86 static GType get_base_type() G_GNUC_CONST;
89 ///Provides access to the underlying C GtkObject.
90 GtkButton* gobj() { return reinterpret_cast<GtkButton*>(gobject_); }
92 ///Provides access to the underlying C GtkObject.
93 const GtkButton* gobj() const { return reinterpret_cast<GtkButton*>(gobject_); }
97 //C++ methods used to invoke GTK+ virtual functions:
100 //GTK+ Virtual Functions (override these to change behaviour):
102 //Default Signal Handlers::
103 virtual void on_pressed();
104 virtual void on_released();
105 virtual void on_clicked();
106 virtual void on_enter();
107 virtual void on_leave();
108 virtual void on_activate();
115 /** Create an empty button.
116 * With an empty button, you can Gtk::Button::add() a widget
117 * such as a Gtk::Pixmap or Gtk::Box.
119 * If you just wish to add a Gtk::Label,
121 * use the Gtk::Button(const Glib::ustring& label) ctor
127 /** Simple Push Button with label.
128 * Create a button with the given label inside. You won't be able
129 * to add a widget in this button since it already has a Gtk::Label
132 explicit Button(const Glib::ustring& label, bool mnemonic = false);
133 explicit Button(const StockID& stock_id);
147 void set_relief(ReliefStyle newstyle);
149 ReliefStyle get_relief() const;
152 /** Sets the text of the label of the button to @a str . This text is
153 * also used to select the stock item if set_use_stock()
156 * This will also clear any previously set labels.
157 * @param label A string.
159 void set_label(const Glib::ustring& label);
161 /** Fetches the text from the label of the button, as set by
162 * set_label(). If the label text has not
163 * been set the return value will be <tt>0</tt>. This will be the
164 * case if you create an empty button with new() to
165 * use as a container.
166 * @return The text of the label widget. This string is owned
167 * by the widget and must not be modified or freed.
169 Glib::ustring get_label() const;
171 /** If true, an underline in the text of the button label indicates
172 * the next character should be used for the mnemonic accelerator key.
173 * @param use_underline <tt>true</tt> if underlines in the text indicate mnemonics.
175 void set_use_underline(bool use_underline = true);
177 /** Returns whether an embedded underline in the button label indicates a
178 * mnemonic. See set_use_underline().
179 * @return <tt>true</tt> if an embedded underline in the button label
180 * indicates the mnemonic accelerator keys.
182 bool get_use_underline() const;
184 /** If true, the label set on the button is used as a
185 * stock id to select the stock item for the button.
186 * @param use_stock <tt>true</tt> if the button should use a stock item.
188 void set_use_stock(bool use_stock = true);
190 /** Returns whether the button label is a stock item.
191 * @return <tt>true</tt> if the button label is used to
192 * select a stock item instead of being
193 * used directly as the label text.
195 bool get_use_stock() const;
198 /** Sets whether the button will grab focus when it is clicked with the mouse.
199 * Making mouse clicks not grab focus is useful in places like toolbars where
200 * you don't want the keyboard focus removed from the main area of the
204 * @param focus_on_click Whether the button grabs focus when clicked with the mouse.
206 void set_focus_on_click(bool focus_on_click = true);
208 /** Returns whether the button grabs focus when it is clicked with the mouse.
209 * See set_focus_on_click().
210 * @return <tt>true</tt> if the button grabs focus when it is clicked with
215 bool get_focus_on_click() const;
218 /** Sets the alignment of the child. This property has no effect unless
219 * the child is a Gtk::Misc or a Gtk::Aligment.
222 * @param xalign The horizontal position of the child, 0.0 is left aligned,
223 * 1.0 is right aligned.
224 * @param yalign The vertical position of the child, 0.0 is top aligned,
225 * 1.0 is bottom aligned.
227 void set_alignment(float xalign, float yalign);
229 /** Gets the alignment of the child in the button.
232 * @param xalign Return location for horizontal alignment.
233 * @param yalign Return location for vertical alignment.
235 void get_alignment(float& xalign, float& yalign);
238 /** Set the image of @a button to the given widget. Note that
239 * it depends on the show-button-images setting whether the
240 * image will be displayed or not.
243 * @param image A widget to set as the image for the button.
245 void set_image(Widget& image);
247 /** Gets the widget that is currenty set as the image of @a button .
248 * This may have been explicitly set by set_image()
249 * or constructed by new_from_stock().
255 /** Gets the widget that is currenty set as the image of @a button .
256 * This may have been explicitly set by set_image()
257 * or constructed by new_from_stock().
261 const Widget* get_image() const;
264 Glib::SignalProxy0< void > signal_pressed();
267 Glib::SignalProxy0< void > signal_released();
270 Glib::SignalProxy0< void > signal_clicked();
273 Glib::SignalProxy0< void > signal_enter();
276 Glib::SignalProxy0< void > signal_leave();
279 Glib::SignalProxy0< void > signal_activate();
282 /** Text of the label widget inside the button
284 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
285 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
286 * the value of the property changes.
288 Glib::PropertyProxy<Glib::ustring> property_label() ;
290 /** Text of the label widget inside the button
292 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
293 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
294 * the value of the property changes.
296 Glib::PropertyProxy_ReadOnly<Glib::ustring> property_label() const;
298 /** The border relief style.
300 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
301 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
302 * the value of the property changes.
304 Glib::PropertyProxy<ReliefStyle> property_relief() ;
306 /** The border relief style.
308 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
309 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
310 * the value of the property changes.
312 Glib::PropertyProxy_ReadOnly<ReliefStyle> property_relief() const;
316 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
317 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
318 * the value of the property changes.
320 Glib::PropertyProxy<bool> property_use_underline() ;
324 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
325 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
326 * the value of the property changes.
328 Glib::PropertyProxy_ReadOnly<bool> property_use_underline() const;
332 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
333 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
334 * the value of the property changes.
336 Glib::PropertyProxy<bool> property_use_stock() ;
340 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
341 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
342 * the value of the property changes.
344 Glib::PropertyProxy_ReadOnly<bool> property_use_stock() const;
346 /** Whether the button grabs focus when it is clicked with the mouse.
348 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
349 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
350 * the value of the property changes.
352 Glib::PropertyProxy<bool> property_focus_on_click() ;
354 /** Whether the button grabs focus when it is clicked with the mouse.
356 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
357 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
358 * the value of the property changes.
360 Glib::PropertyProxy_ReadOnly<bool> property_focus_on_click() const;
362 /** Horizontal position of child in available space. 0.0 is left aligned
364 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
365 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
366 * the value of the property changes.
368 Glib::PropertyProxy<float> property_xalign() ;
370 /** Horizontal position of child in available space. 0.0 is left aligned
372 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
373 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
374 * the value of the property changes.
376 Glib::PropertyProxy_ReadOnly<float> property_xalign() const;
378 /** Vertical position of child in available space. 0.0 is top aligned
380 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
381 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
382 * the value of the property changes.
384 Glib::PropertyProxy<float> property_yalign() ;
386 /** Vertical position of child in available space. 0.0 is top aligned
388 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
389 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
390 * the value of the property changes.
392 Glib::PropertyProxy_ReadOnly<float> property_yalign() const;
394 /** Child widget to appear next to the button text.
396 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
397 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
398 * the value of the property changes.
400 Glib::PropertyProxy<Gtk::Widget*> property_image() ;
402 /** Child widget to appear next to the button text.
404 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
405 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
406 * the value of the property changes.
408 Glib::PropertyProxy_ReadOnly<Gtk::Widget*> property_image() const;
413 /*! A Gtk::Button example.
414 * Example 1: @link book/buttons/button/buttons.h @endlink
415 * Example 2: @link book/buttons/button/buttons.cc @endlink
416 * Example 3: @link book/buttons/button/main.cc @endlink
424 /** @relates Gtk::Button
425 * @param object The C instance
426 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
427 * @result A C++ instance that wraps this C instance.
429 Gtk::Button* wrap(GtkButton* object, bool take_copy = false);
431 #endif /* _GTKMM_BUTTON_H */