167 lines
4.6 KiB
C
167 lines
4.6 KiB
C
#include "include.h"
|
||
|
||
#define TRACE_EN 0
|
||
|
||
#if TRACE_EN
|
||
#define TRACE(...) printf(__VA_ARGS__)
|
||
#else
|
||
#define TRACE(...)
|
||
#endif
|
||
|
||
/**
|
||
* @brief 创建一个图像框组件
|
||
* @param[in] frm : 窗体指针
|
||
* @param[in] res_addr : 图像资源地址
|
||
* @return 返回图像指针
|
||
**/
|
||
compo_picturebox_t *compo_picturebox_create(compo_form_t *frm, u32 res_addr)
|
||
{
|
||
compo_picturebox_t *picbox = compo_create(frm, COMPO_TYPE_PICTUREBOX);
|
||
void *img = widget_image_create(frm->page_body, res_addr);
|
||
picbox->img = img;
|
||
picbox->radix = 1;
|
||
return picbox;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像
|
||
用于改变图像组件中的图片
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] res_addr : 图像资源地址
|
||
**/
|
||
void compo_picturebox_set(compo_picturebox_t *picbox, u32 res_addr)
|
||
{
|
||
widget_image_set(picbox->img, res_addr);
|
||
}
|
||
|
||
/**
|
||
* @brief 剪切图像
|
||
用于剪切图像组件中的图片
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] index : 截取索引:第index张图
|
||
* @param[in] total_cnt : 总拼图数量
|
||
**/
|
||
void compo_picturebox_cut(compo_picturebox_t *picbox, u8 index, u8 total_cnt)
|
||
{
|
||
if (total_cnt == 0) {
|
||
halt(HALT_GUI_COMPO);
|
||
}
|
||
area_t area = widget_image_get_size(picbox->img);
|
||
widget_image_cut(picbox->img, 0, index * (area.hei / total_cnt), area.wid, area.hei / total_cnt);
|
||
picbox->radix = total_cnt;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框组件的坐标
|
||
注意:该设置默认的坐标是以中心点作为参考点
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] x : x轴坐标
|
||
* @param[in] y : y轴坐标
|
||
**/
|
||
void compo_picturebox_set_pos(compo_picturebox_t *picbox, s16 x, s16 y)
|
||
{
|
||
widget_set_pos(picbox->img, x, y);
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框组件的前景色
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] color : 前景色
|
||
**/
|
||
void compo_picturebox_set_color(compo_picturebox_t *picbox, u16 color)
|
||
{
|
||
widget_image_set_color(picbox->img, color);
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框组件的大小
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] width : 图像框宽度
|
||
* @param[in] height : 图像框高度
|
||
**/
|
||
void compo_picturebox_set_size(compo_picturebox_t *picbox, s16 width, s16 height)
|
||
{
|
||
widget_set_size(picbox->img, width, height);
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框的旋转角度
|
||
图片旋转时,需要经过转换工具勾上 旋转压缩 的选项
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] angle : 旋转的角度
|
||
**/
|
||
void compo_picturebox_set_rotation(compo_picturebox_t *picbox, s16 angle)
|
||
{
|
||
widget_image_set_rotation(picbox->img, angle);
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框的旋转中心点
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] x : x轴坐标
|
||
* @param[in] y : y轴坐标
|
||
**/
|
||
void compo_picturebox_set_rotation_center(compo_picturebox_t *picbox, s16 x, s16 y)
|
||
{
|
||
widget_image_set_rotation_center(picbox->img, x, y);
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图像框是否可见
|
||
* @param[in] picbox : 图像指针
|
||
* @param[in] visible : true 可见
|
||
false 不可见
|
||
**/
|
||
void compo_picturebox_set_visible(compo_picturebox_t *picbox, bool visible)
|
||
{
|
||
widget_set_visible(picbox->img, visible);
|
||
}
|
||
|
||
/**
|
||
* @brief 获取图像框的坐标和大小
|
||
* @param[in] picbox : 图像指针
|
||
* @return 返回图像的坐标和大小
|
||
**/
|
||
rect_t compo_picturebox_get_location(compo_picturebox_t *picbox)
|
||
{
|
||
rect_t rect = widget_get_location(picbox->img);
|
||
return rect;
|
||
}
|
||
|
||
/**
|
||
* @brief 设置图片透明度
|
||
* @param[in] picbox : 按钮指针
|
||
* @param[in] alpha : 透明度
|
||
**/
|
||
void compo_picturebox_set_alpha(compo_picturebox_t *picbox, u8 alpha)
|
||
{
|
||
widget_set_alpha(picbox->img, alpha);
|
||
}
|
||
/**
|
||
* @brief 创建一个图像框组件
|
||
* @param[in] frm : 窗体指针
|
||
* @param[in] res_addr : 图像资源地址
|
||
* @return 返回图像指针
|
||
**/
|
||
compo_picturebox_t *compo_picturebox_create_coordinate(compo_form_t *frm, u32 res_addr, s16 x, s16 y,u16 id,bool align_center)
|
||
{
|
||
compo_picturebox_t *picbox = compo_create(frm, COMPO_TYPE_PICTUREBOX);
|
||
void *img = widget_image_create(frm->page_body, res_addr);
|
||
picbox->img = img;
|
||
picbox->radix = 1;
|
||
widget_set_pos(picbox->img, x, y);
|
||
widget_set_align_center(picbox->img,align_center);
|
||
if(id!=0)
|
||
compo_setid(picbox, id);
|
||
return picbox;
|
||
}
|
||
|
||
/**
|
||
* @param[in] frm : 窗体指针
|
||
* @param[in] align_center :是否居中显示
|
||
**/
|
||
void compo_picturebox_center(compo_picturebox_t *picbox, bool align_center)
|
||
{
|
||
widget_set_align_center(picbox->img,align_center);
|
||
|
||
} |