nana::gui::button
Description
a button widget.
Model
of
Widget Window
Public base classes
class widget_object<widget_tag>: public widget
Typedefs
C++03 typedefs
struct state
{
enum t{normal, focused, highlight,
pressed, disabled};
}; |
Defines the state of button actions. |
C++11 typedefs
enum class state
{
normal, focused, highlight, pressed, disabled
}; |
Defines the state of button actions. |
Members
button() |
The construction. |
button(nana::gui::window wd, bool visible) |
Creates a button. |
button(nana::gui::window wd, const nana::string& text, bool visible = true) |
Ditto. |
button(nana::gui::window wd, const nana::char_t* text, bool visible = true) |
Ditto. |
button(nana::gui::window wd, const rectangle& r = rectangle(), bool visible = true) |
Creates a button with a specified rectangle. |
void icon(const nana::paint::image&) |
Sets an icon image. |
void image(const nana::char_t* file) |
Sets a background image. |
void image(const nana::paint::image& imgobj) |
Sets a background image. |
void image_valid_area(nana::arrange arg, const nana::rectangle& r) |
Sets an area of the image which is painted as background. |
void image_stretch(nana::arrange arg, int beg, int end) |
Sets the stretch part of image. The image is stretched when the size of button
is changed. |
void enable_pushed(bool eb) |
Enables or disables the pushed state of the button. |
bool pushed() const |
Returns the pushed state of the button. |
void pushed(bool ps) |
Sets the pushed state. |
void omitted(bool eb) |
Enables/Disables omitting displaying the caption if the text is too long. |
void enable_focus_color(bool eb) |
Enables/Disables showing the caption with a special color to indicate the button
is focused. |
C++03 members
void image_enable(state::t, bool) |
Enables/disables a state. The button will be drawn defaulty if the state is
disabled. |
void image_join(state::t to, state::t from) |
The state from joins the state to. |
C++11 members
void image_enable(state, bool) |
Enables/disables a state. the button will be drawn defaultly if the state is disabled. |
void image_join(state to, state from) |
The state from joins the state to. |
File
nana/gui/widgets/button.hpp
Notes
1. The background image of button horizontally split into 5 parts and each part
indicates one state. If the background of button is some area in the image, the
area can be specified by using image_valid_area(). For example. There is an
image that size is 520 * 70 pixels, and a button background image is just 470 *
23 pixels at position (0, 0).
int main()
{
nana::gui::form form;
nana::gui::button btn(form, 5, 5, 94, 23);
btn.image(STR("button_image.bmp"));
btn.image_valid_area(nana::arrange::horizontal, nana::rectangle(0, 0, 94 * 5,
23));
form.show();
nana::gui::exec();
}
The button splits the area of image into 5 parts for each state. The order of
parts are same with the order of definition of elements of enum in type
state(refers to Typedefs).
2, A image state can be disabled by calling image_enable() method. If a state is
disabled, the button would averagely split the area of image into parts for each
enabled state.
None..
Move to The Nana Programmer's Guide Main Page |