1 /* $Id: button.hg,v 1.10 2006/08/21 19:07:14 jjongsma Exp $ */
5 * Copyright (C) 1998-2002 The gtkmm Development Team
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <gtkmm/bin.h>
23 #include <gtkmm/stockid.h>
25 _PINCLUDE(gtkmm/private/bin_p.h)
31 namespace Stock { struct BuiltinStockID; }
34 /** A widget that creates a signal when clicked on.
36 * This widget is generally used with a signal handler that is called when the button is pressed.
37 * It can hold any valid child widget. The most commonly used child is the Gtk::Label.
41 class Button : public Bin
43 _CLASS_GTKOBJECT(Button,GtkButton,GTK_BUTTON,Gtk::Bin,GtkBin)
46 /** Create an empty button.
47 * With an empty button, you can Gtk::Button::add() a widget
48 * such as a Gtk::Pixmap or Gtk::Box.
50 * If you just wish to add a Gtk::Label,
52 * use the Gtk::Button(const Glib::ustring& label) ctor
58 /** Simple Push Button with label.
59 * Create a button with the given label inside. You won't be able
60 * to add a widget in this button since it already has a Gtk::Label
63 explicit Button(const Glib::ustring& label, bool mnemonic = false);
65 /** Creates a new Button containing the image and text from a stock item.
66 * Stock ids have identifiers like Gtk::Stock::OK and Gtk::Stock::APPLY.
67 * @param stock_id The stock item.
69 explicit Button(const StockID& stock_id);
72 _WRAP_METHOD(void pressed(), gtk_button_pressed)
73 _WRAP_METHOD(void released(),gtk_button_released)
74 _WRAP_METHOD(void clicked(), gtk_button_clicked)
75 _WRAP_METHOD(void enter(), gtk_button_enter)
76 _WRAP_METHOD(void leave(), gtk_button_leave)
78 _WRAP_METHOD(void set_relief(ReliefStyle newstyle), gtk_button_set_relief)
79 _WRAP_METHOD(ReliefStyle get_relief() const, gtk_button_get_relief)
81 _WRAP_METHOD(void set_label(const Glib::ustring& label), gtk_button_set_label)
82 _WRAP_METHOD(Glib::ustring get_label() const, gtk_button_get_label)
83 _WRAP_METHOD(void set_use_underline(bool use_underline = true), gtk_button_set_use_underline)
84 _WRAP_METHOD(bool get_use_underline() const, gtk_button_get_use_underline)
85 _WRAP_METHOD(void set_use_stock(bool use_stock = true), gtk_button_set_use_stock)
86 _WRAP_METHOD(bool get_use_stock() const, gtk_button_get_use_stock)
88 _WRAP_METHOD(void set_focus_on_click(bool focus_on_click = true), gtk_button_set_focus_on_click)
89 _WRAP_METHOD(bool get_focus_on_click() const, gtk_button_get_focus_on_click)
91 _WRAP_METHOD(void set_alignment(float xalign, float yalign), gtk_button_set_alignment)
92 _WRAP_METHOD(void get_alignment(float& xalign, float& yalign), gtk_button_get_alignment)
94 _WRAP_METHOD(void set_image(Widget& image), gtk_button_set_image)
95 _WRAP_METHOD(Widget* get_image(), gtk_button_get_image)
96 _WRAP_METHOD(const Widget* get_image() const, gtk_button_get_image, constversion)
98 _WRAP_METHOD(void set_image_position(PositionType position), gtk_button_set_image_position)
99 _WRAP_METHOD(PositionType get_image_position() const, gtk_button_get_image_position)
101 _WRAP_SIGNAL(void pressed(), "pressed")
102 _WRAP_SIGNAL(void released(), "released")
103 _WRAP_SIGNAL(void clicked(), "clicked")
104 _WRAP_SIGNAL(void enter(), "enter")
105 _WRAP_SIGNAL(void leave(), "leave")
106 _WRAP_SIGNAL(void activate(), "activate")
108 _WRAP_PROPERTY("label", Glib::ustring)
109 _WRAP_PROPERTY("relief", ReliefStyle)
110 _WRAP_PROPERTY("use-underline", bool)
111 _WRAP_PROPERTY("use-stock", bool)
112 _WRAP_PROPERTY("focus-on-click", bool)
113 _WRAP_PROPERTY("xalign", float)
114 _WRAP_PROPERTY("yalign", float)
115 _WRAP_PROPERTY("image", Gtk::Widget*)
116 _WRAP_PROPERTY("image-position", PositionType)
119 /*! A Gtk::Button example.
120 * Example 1: @link book/buttons/button/buttons.h @endlink
121 * Example 2: @link book/buttons/button/buttons.cc @endlink
122 * Example 3: @link book/buttons/button/main.cc @endlink