Tearsback's picture
download
raw
4.94 kB
/*********************************************************************************************************
* ģ�����ƣ�TextWidget.c
* ժ Ҫ��Text�ؼ�ģ��
* ��ǰ�汾��1.0.0
* �� �ߣ�Leyutek(COPYRIGHT 2018 - 2021 Leyutek. All rights reserved.)
* ������ڣ�2021��07��01��
* �� �ݣ�
* ע �⣺
**********************************************************************************************************
* ȡ���汾��
* �� �ߣ�
* ������ڣ�
* �޸����ݣ�
* �޸��ļ���
*********************************************************************************************************/
/*********************************************************************************************************
* ����ͷ�ļ�
*********************************************************************************************************/
#include "TextWidget.h"
#include "gd32f450x_conf.h"
#include "TLILCD.h"
#include "stdio.h"
/*********************************************************************************************************
* �궨��
*********************************************************************************************************/
/*********************************************************************************************************
* ö�ٽṹ�嶨��
*********************************************************************************************************/
/*********************************************************************************************************
* �ڲ�����
*********************************************************************************************************/
/*********************************************************************************************************
* �ڲ���������
*********************************************************************************************************/
static void SetText(void* dev, const char* string); //������ʾ����
/*********************************************************************************************************
* �ڲ�����ʵ��
*********************************************************************************************************/
/*********************************************************************************************************
* �������ƣ�SetText
* �������ܣ�������ʾ����
* ���������dev���ؼ��ṹ���ַ��string����ʾ����
* ���������void
* �� �� ֵ��0-�ɹ�����������-����ʧ��
* �������ڣ�2021��07��01��
* ע �⣺
*********************************************************************************************************/
static void SetText(void* dev, const char* string)
{
u16* color;
u16 x0, y0, x1, y1;
StructTextWidget* text;
u16 x, y, i;
text = (StructTextWidget*)dev;
x0 = text->x0;
y0 = text->y0;
x1 = x0 + text->width;
y1 = y0 + text->height;
color = text->background;
LCDColorFillPixel(x0, y0, x1 - 1, y1 - 1, color);
//�ж��Dz��ǷǷ��ַ�!
i = 0;
x = x0;
y = y0;
while((*(string + i) <= '~') && (*(string + i) >= ' '))
{
if(x > x1)
{
x = x0;
y = y + text->size;
}
if(y > (y1 - text->size))
{
break;
}
LCDShowChar(x, y, LCD_FONT_24, LCD_TEXT_TRANS, text->color, NULL, *(string + i));
x += text->size / 2;
i++;
}
}
/*********************************************************************************************************
* API����ʵ��
*********************************************************************************************************/
/*********************************************************************************************************
* �������ƣ�CreateTextWidget
* �������ܣ�����text�ؼ�
* ���������void
* ���������void
* �� �� ֵ��0-�ɹ�����������-����ʧ��
* �������ڣ�2021��07��01��
* ע �⣺
*********************************************************************************************************/
u8 CreateTextWidget(StructTextWidget* text)
{
u16 x, y, i;
//�������
if((0 == text->width) || (0 == text->height))
{
return 1;
}
//�����Сϵͳ������
if(!(12 == text->size || 16 == text->size || 24 == text->size))
{
return 1;
}
//�ؼ�̫�󣬱����������޷����������еı������ص�
if((text->width * text->height) > TEXT_WIDGET_BUF_SIZE)
{
return 1;
}
//���������浽������
i = 0;
for(y = text->y0; y < (text->y0 + text->height); y++)
{
for(x = text->x0; x < (text->x0 + text->width); x++)
{
text->background[i] = LCDReadPoint(x, y);
i++;
}
}
//����setText����ָ�����ݣ�ʹ���û�����ͨ���ṹ���ԱsetText�޸���ʾ����
text->setText = SetText;
return 0;
}

Xet Storage Details

Size:
4.94 kB
·
Xet hash:
98ea04ec32992b0afec1af59196daa44669255628916bde920530abfe09e6699

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.