Btk
button.hpp
1
#if !defined(_BTK_BUTTON_HPP_)
2
#define _BTK_BUTTON_HPP_
3
#include "widget.hpp"
4
#include "pixels.hpp"
5
#include "themes.hpp"
6
#include "font.hpp"
7
#include "defs.hpp"
8
namespace
Btk
{
9
class
MouseEvent;
14
class
BTKAPI
AbstructButton
:
public
Widget
{
15
public
:
16
//Process event
17
bool
handle(
Event
&);
18
protected
:
19
virtual
void
onclick(
const
MouseEvent
&) = 0;
20
virtual
void
onenter();
21
virtual
void
onleave();
22
bool
is_entered;
//< Is mouse on the button?
23
bool
is_pressed;
//< Is mouse pressed the button?
24
Theme
*theme;
//< current theme
25
};
30
class
BTKAPI
Button
:
public
AbstructButton
{
31
public
:
32
Button
(
Container
&);
33
Button
(
Container
&,std::string_view text);
34
Button
(
Container
&,
int
x,
int
y,
int
w,
int
h);
35
~
Button
();
36
void
draw(Renderer &);
37
template
<
class
...T>
38
void
on_click(T &&...args){
39
clicked.connect(std::forward<T>(args)...);
40
};
41
Signal<void()>
&sig_click(){
42
return
clicked;
43
};
44
void
set_text(std::string_view text);
45
protected
:
46
void
onclick(
const
MouseEvent
&);
47
void
onleave();
48
49
Signal<void()>
clicked;
50
51
//Button text
52
std::string btext;
53
PixBuf
textbuf;
54
Texture
texture;
55
Font
textfont;
56
};
57
};
58
59
60
#endif // _BTK_BUTTON_HPP_
Btk::Texture
Definition:
pixels.hpp:191
Btk::AbstructButton
Basic button.
Definition:
button.hpp:14
Btk::Signal< void()>
Btk::Widget
Definition:
widget.hpp:219
Btk
This header include many useful containers.
Definition:
async.hpp:7
Btk::Theme
Definition:
themes.hpp:9
Btk::MouseEvent
A event about mouse click.
Definition:
event.hpp:106
Btk::Font
Font Class.
Definition:
font.hpp:26
Btk::PixBuf
Definition:
pixels.hpp:32
Btk::Event
A base event of all events.
Definition:
event.hpp:17
Btk::Button
A simple pushbutton.
Definition:
button.hpp:30
Btk::Container
A Container of Widget.
Definition:
widget.hpp:108
include
Btk
button.hpp
Generated by
1.8.13