-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcard.h
102 lines (80 loc) · 2.33 KB
/
card.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* File : card.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 <pm_container.h>
#include <sigslot.h>
namespace Persimmon
{
class Card : public Container
{
typedef Container super;
public:
enum type
{
VERTICAL = 0,
HORIZONTAL = 1 << 0,
CYCLE = 1 << 1,
};
DEFINE_CLASS_ENUM_FLAG_OPERATORS(type);
Card (const Rect& rect, enum type tp = HORIZONTAL);
Card (Image *dot_nor, Image *dot_sel, const Rect& rect, enum type tp = HORIZONTAL);
virtual ~Card();
virtual void addChild(Widget* widget);
virtual void removeChild(Widget* widget);
void setDotIndicator(Image *dot_nor, Image *dot_sel)
{
if (this->dot_nor)
delete this->dot_nor;
if (this->dot_sel)
delete this->dot_sel;
this->dot_nor = dot_nor;
this->dot_sel = dot_sel;
}
void selectCardPage(int index);
int getCurrentCardPage()
{
return currentIndex;
}
int pageCount(void)
{
return children.size();
}
void setActiveValue(unsigned int value)
{
activeValue = value;
}
void setMinMovePitch(unsigned int value)
{
minMovePitch = value;
}
virtual void render(struct rtgui_dc* dc, const Point &dcPoint = Point(),
const Rect &srcRect = Rect(),
RenderFlag flags = DrawNormal);
virtual bool handleGestureEvent(struct rtgui_event_gesture *gev,
const struct rtgui_gesture *gest);
virtual Widget* getMouseOwner(int x, int y);
Signal<int> changed;
Signal<void> moveing;
protected:
enum type mtype;
int currentIndex, old_pitch;
struct rtgui_dc *mvdc;
bool old_mvnext, is_in_animation, is_moveing, is_boundary;
Image *dot_nor, *dot_sel;
private:
void moveCard(struct rtgui_event_gesture* event, const struct rtgui_gesture *gesture);
struct rtgui_dc* getAnimationDC(bool left);
struct rtgui_dc* getAnimationDC(int first, int last);
void renderIndicator(struct rtgui_dc *dc, const Point &point);
unsigned int activeValue, minMovePitch;
};
}