-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpm_numerical.h
More file actions
85 lines (68 loc) · 1.81 KB
/
pm_numerical.h
File metadata and controls
85 lines (68 loc) · 1.81 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
75
76
77
78
79
80
81
82
83
84
85
/*
* File : pm_numerical.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 "resource.h"
namespace Persimmon
{
class Numerical : public Widget
{
public:
enum NUM_ALIGN //对齐方式,默认纵向居中,横向有靠左,靠右,居中
{
ALIGN_LEFT = 0x00,
ALIGN_RIGHT = 0x01,
ALIGN_CENTER = 0x02,
};
Numerical(const Rect& rect);
virtual ~Numerical();
void addImgPath(const char *img) //添加数字图片对应路径,从0 - 9 按顺序添加
{
imgPath.push_back(rt_strdup(img));
}
void setNumWidth(int width) //设置数字图片,所占宽度
{
numWidth = width;
}
void setDigit(int digit) //设置数值位数显示,高位填0
{
this->digit = digit;
}
void setNumericalUnit(Image *image) //设置单位显示
{
if (unit)
delete unit;
unit = image;
}
void setNumericalMinus(Image *image) //设置支持显示负号
{
if (minus)
delete minus;
minus = image;
}
void setNumAlign(enum NUM_ALIGN algn = ALIGN_CENTER) //设置对齐方式
{
numAlgn = algn;
}
void setNumerical(int value) //设置显示数值
{
numerical = value;
}
virtual void render(struct rtgui_dc* dc, const Point &dcPoint = Point(),
const Rect &srcRect = Rect(),
RenderFlag flags = DrawNormal);
private:
enum NUM_ALIGN numAlgn;
std::vector<char *> imgPath;
Image *unit, *minus;
int numerical, numWidth, digit;
};
}