Xfce
Foundation Classes |
|||
« Main Page | Index | |||
The Button WidgetTable of ContentsButtonsThe button widget is a simple widget that emits several signals in response to user action. Generally it is used to attach a function to that is called when the button is pressed. The various signals and how to use them are outlined below.A button can be created with one of the following constructors: Button(); The first constructor creates an empty button which can hold any valid child widget. The second constructors create a button that displays a Gtk::Image. The third constructor creates a button that displays a text label. If 'use_underline' is true the string is parsed for an underscore preceding the mnemonic character. The fourth constructor creates a button that displays a Gtk::Image and a text label. If 'horizontal' is true the text is displayed beside the image; otherwise its displayed underneath. The fifth constructor creates a button that displays a stock image and its label. If you create an empty button you can call the following set methods to set the button contents: void set_label(const String& label); You can set and retrieve the button relief style by calling the following methods, respectively: void set_relief(Gtk::ReliefStyle
newstyle); The 'newstyle' argument can be one of the following values from the Gtk::ReliefStyle enum:
void set_focus_on_click(bool
focus_on_click); If 'focus_on_click' is set to true, the button grabs the focus when clicked with the mouse. If the button's child widget is of type GTK_TYPE_MISC (an image or label) or GTK_TYPE_ALIGNMENT you can set its vertical and horizontal alignment, by calling: void set_alignment(float xalign, float
yalign); You can connect callback slots to one or more button signals using the following Gtk::Button proxy signal functions:
Image Button ExampleHere's an example of a button that displays
and image with a text label beside it, using the fourth constructor
above. The header file for this example is <buttons.hh>:
#include <xfc/main.hh> and the source file is <buttons.cc>: #include "buttons.hh" Compiling Image Button
If you compiled and installed XFC yourself, you will find the source
code for Image Button in the
<examples/buttons> source directory along with a Makefile. If
XFC came pre-installed, or you installed it from an RPM package, you
will
find the source code in the
</usr/share/doc/xfcui-X.X/examples/buttons> subdirectory. In
this case you will have to create the Makefile yourself (replace X.X
with the
version number of the libXFCui library you have installed). |
Copyright © 2004-2005 The XFC Development Team | Top |
XFC
4.4 |