-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpm_switch_button.h
More file actions
74 lines (57 loc) · 1.57 KB
/
Copy pathpm_switch_button.h
File metadata and controls
74 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* File : pm_switch_button.h
* COPYRIGHT (C) 2012-2017, Shanghai Real-Thread Technology Co., Ltd
*
* Change Logs:
* Date Author Notes
* 2017-11-05 realthread the first version
*/
#pragma once
#include <vector>
#include <pm_widget.h>
#include <pm_image.h>
#include "sigslot.h"
#include <pm_timer.h>
namespace Persimmon
{
class SwitchButton : public Widget
{
public:
SwitchButton(const Rect& rect);
virtual ~SwitchButton();
void setSwitchBackImage(Image *norImg, Image *selImg)
{
if (norBackImage)
delete norBackImage;
if (selBackImage)
delete selBackImage;
norBackImage = norImg;
selBackImage = selImg;
}
void setSwitchSliderImage(Image *norImg, Image *selImg)
{
if (norSliderImage)
delete norSliderImage;
if (selSliderImage)
delete selSliderImage;
norSliderImage = norImg;
selSliderImage = selImg;
}
void selectEnable(bool sel = true)
{
select = sel;
}
Signal<bool> clicked;
virtual bool handleGestureEvent(struct rtgui_event_gesture *, const struct rtgui_gesture *); //´¥ÃþÊÖÊÆÊ¼þ´¦Àíº¯Êý
virtual void render(struct rtgui_dc* dc, const Point &dcPoint = Point(),
const Rect &srcRect = Rect(),
RenderFlag flags = DrawNormal);
private:
void onAnimation(void);
Image *norBackImage, *selBackImage;
Image *norSliderImage, *selSliderImage;
int index;
bool select, animation;
Timer *animationTimer;
};
}