|
|
|
|
Etk_Button
Detailed Description
The Etk_Button widget is a widget that emits a signal when it is pressed, released or clicked.
An Etk_Button usually contains only a label and an icon, but it can contain any type of widgets.
You can change the label of the button with etk_button_label_set(), and you can change its icon with etk_button_image_set(). You can also pack your own widget with etk_bin_child_set()
- Object Hierarchy:
-
- Signals:
- "pressed": Emitted when the button is pressed
Callback: Etk_Bool callback(Etk_Button *button, void *data)
button: the button which has been presseddata: the user data set when the callback has been connected to the signal
- "released": Emitted when the button is released
Callback: Etk_Bool callback(Etk_Button *button, void *data)
button: the button which has been releaseddata: the user data set when the callback has been connected to the signal
- "clicked": Emitted when the button is clicked (i.e. when the button is released, and if the mouse is still above it)
Callback: Etk_Bool callback(Etk_Button *button, void *data)
button: the button which has been clickeddata: the user data set when the callback has been connected to the signal
- Properties:
- "label": The text of the label of the button
Type: String (char *)Access: Read/WriteDefault Value: NULL
- "image": The image packed on the left of the label, inside the button
Type: Pointer (Etk_Image *)Access: Read/WriteDefault Value: NULL
- "style": The style of the button (icon, text, both vertically, both horizontally)
Type: Integer (Etk_Button_Style)Access: Read/WriteDefault Value: ETK_BUTTON_BOTH_HORIZ
- "stock_size": The stock-size of the image of the button
Type: Integer (Etk_Stock_Size)Access: Read/WriteDefault Value: ETK_STOCK_SMALL
- "xalign": The horizontal alignment of the child of the button, from 0.0 (left aligned) to 1.0 (right aligned)
Type: FloatAccess: Read/WriteDefault Value: 0.5
- "yalign": The vertical alignment of the child of the button, from 0.0 (top aligned) to 1.0 (bottom aligned)
Type: FloatAccess: Read/WriteDefault Value: 0.5
|
Data Structures |
struct | Etk_Button |
| [Widget] A widget that can be pressed, released or clicked More...
|
Defines |
#define | ETK_BUTTON_TYPE (etk_button_type_get()) |
#define | ETK_BUTTON(obj) (ETK_OBJECT_CAST((obj), ETK_BUTTON_TYPE, Etk_Button)) |
#define | ETK_IS_BUTTON(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_BUTTON_TYPE)) |
Enumerations |
enum | Etk_Button_Style {
ETK_BUTTON_ICON,
ETK_BUTTON_TEXT,
ETK_BUTTON_BOTH_HORIZ,
ETK_BUTTON_BOTH_VERT
} |
| The button's style (icon, text, both vertically, both horizontally). More...
|
Functions |
Etk_Widget * | etk_button_new (void) |
| Creates a new button.
|
Etk_Widget * | etk_button_new_with_label (const char *label) |
| Creates a new button with a label.
|
Etk_Widget * | etk_button_new_from_stock (Etk_Stock_Id stock_id) |
| Creates a new button with a label and an icon defined by a stock-id.
|
void | etk_button_press (Etk_Button *button) |
| Presses the button if it wasn't already pressed.
|
void | etk_button_release (Etk_Button *button) |
| Releases the button if it was pressed.
|
void | etk_button_click (Etk_Button *button) |
| Clicks on the button.
|
void | etk_button_label_set (Etk_Button *button, const char *label) |
| Sets the text of the button's label.
|
const char * | etk_button_label_get (Etk_Button *button) |
| Gets the text of the button's label.
|
void | etk_button_image_set (Etk_Button *button, Etk_Image *image) |
| Sets the image of the button.
|
Etk_Image * | etk_button_image_get (Etk_Button *button) |
| Gets the image of the button.
|
void | etk_button_set_from_stock (Etk_Button *button, Etk_Stock_Id stock_id) |
| Sets the label and the image of the button from a stock-id.
|
void | etk_button_style_set (Etk_Button *button, Etk_Button_Style style) |
| Sets the style of the button (icon, text, both vertically, both horizontally).
|
Etk_Button_Style | etk_button_style_get (Etk_Button *button) |
| Gets the style of the button.
|
void | etk_button_stock_size_set (Etk_Button *button, Etk_Stock_Size size) |
| Sets the stock-size of the button's image.
|
Etk_Stock_Size | etk_button_stock_size_get (Etk_Button *button) |
| Gets the stock-size of the button's image.
|
void | etk_button_alignment_set (Etk_Button *button, float xalign, float yalign) |
| Sets the alignment of the child of the button.
|
void | etk_button_alignment_get (Etk_Button *button, float *xalign, float *yalign) |
| Gets the alignment of the button's child.
|
Define Documentation
#define ETK_BUTTON_TYPE (etk_button_type_get()) |
Gets the type of a button
#define ETK_BUTTON |
( |
obj |
|
) |
(ETK_OBJECT_CAST((obj), ETK_BUTTON_TYPE, Etk_Button)) |
#define ETK_IS_BUTTON |
( |
obj |
|
) |
(ETK_OBJECT_CHECK_TYPE((obj), ETK_BUTTON_TYPE)) |
Enumeration Type Documentation
The button's style (icon, text, both vertically, both horizontally).
- Enumerator:
-
ETK_BUTTON_ICON |
Only the icon is visible |
ETK_BUTTON_TEXT |
Only the label is visible |
ETK_BUTTON_BOTH_HORIZ |
Both the icon and the label are visible, the icon is at the left of the label |
ETK_BUTTON_BOTH_VERT |
Both the icon and the label are visible, the icon is above the label |
Function Documentation
Creates a new button.
- Returns:
- Returns the new button
Etk_Widget * etk_button_new_with_label |
( |
const char * |
label |
) |
|
Creates a new button with a label.
- Returns:
- Returns the new button
Creates a new button with a label and an icon defined by a stock-id.
- Parameters:
-
| stock_id | the stock-id corresponding to the label and the icon to use |
- Returns:
- Returns the new button
- Note:
- For some stock-id, the label is empty
- See also:
- Etk_Stock
Presses the button if it wasn't already pressed.
- Parameters:
-
Releases the button if it was pressed.
- Parameters:
-
Clicks on the button.
- Parameters:
-
void etk_button_label_set |
( |
Etk_Button * |
button, |
|
|
const char * |
label | |
|
) |
| | |
Sets the text of the button's label.
- Parameters:
-
| button | a button |
| label | the text to set to the button's label |
const char * etk_button_label_get |
( |
Etk_Button * |
button |
) |
|
Gets the text of the button's label.
- Parameters:
-
- Returns:
- Returns the text of the button's label
Sets the image of the button.
- Parameters:
-
| button | a button |
| image | the image to set |
- Note:
- If the button already has an image, the current image will just be unpacked, it will not be destroyed
The image will be automatically shown, but you can still manually hide it with calling etk_widget_hide() after having called etk_button_image_set()
Gets the image of the button.
- Parameters:
-
- Returns:
- Returns the image of the button, or NULL if the button has no image
Sets the label and the image of the button from a stock-id.
- Parameters:
-
| button | a button |
| stock_id | the stock-id to use |
- Note:
- For some stock-id, the label is empty
Sets the style of the button (icon, text, both vertically, both horizontally).
- Parameters:
-
| button | a button |
| style | the style to give to the button |
Gets the style of the button.
- Parameters:
-
- Returns:
- Returns the button's style
Sets the stock-size of the button's image.
- Parameters:
-
| button | a button |
| size | the stock-size |
Gets the stock-size of the button's image.
- Parameters:
-
- Returns:
- Returns the stock-size of the button's image
void etk_button_alignment_set |
( |
Etk_Button * |
button, |
|
|
float |
xalign, |
|
|
float |
yalign | |
|
) |
| | |
Sets the alignment of the child of the button.
- Parameters:
-
| button | a button |
| xalign | the horizontal alignment (0.0 = left, 0.5 = center, 1.0 = right, ...) |
| yalign | the vertical alignment (0.0 = top, 0.5 = center, 1.0 = bottom, ...) |
- Note:
- It only has effect if the child is a label or an alignment
void etk_button_alignment_get |
( |
Etk_Button * |
button, |
|
|
float * |
xalign, |
|
|
float * |
yalign | |
|
) |
| | |
Gets the alignment of the button's child.
- Parameters:
-
| button | a button |
| xalign | the location where to store the horizontal alignment |
| yalign | the location where to store the vertical alignment |
|
|
|
|
|
|