#include "include.h" #define TRACE_EN 1 #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif //创建一个文本框 compo_textbox_t *compo_textbox_create(compo_form_t *frm, u16 max_word_cnt) { compo_textbox_t *textbox = compo_create(frm, COMPO_TYPE_TEXTBOX); void *page = widget_page_create(frm->page); textbox->page = page; widget_set_align_center(page, false); //前景颜色 widget_rect_t *rect = widget_rect_create(page); widget_set_align_center(rect, false); widget_set_visible(rect, false); textbox->bg = rect; // widget_set_location(rect, 40, 160, 240, 100); // widget_rect_set_color(rect, COLOR_DIMGRAY); //前景文本 void *txt = widget_text_create(page, max_word_cnt); textbox->txt = txt; //widget_text_set_color(txt, COLOR_DARKGRAY); //widget_set_align_center(page, false); //widget_set_location(page, 40, 160, 240, 100); //widget_set_location(txt, 0, 0, 240, 100); //widget_text_set_wordwrap(txt, true); //widget_set_location(page, 0, 0, 320, 385); //widget_page_scale_to(page, 366, 440); return textbox; } //设置文本框内容 void compo_textbox_set(compo_textbox_t *textbox, const char *text) { widget_text_set(textbox->txt, text); } //设置文本框的坐标及大小 void compo_textbox_set_location(compo_textbox_t *textbox, s16 x, s16 y, s16 width, s16 height) { widget_set_location(textbox->page, x, y, width, height); widget_set_size(textbox->bg, width, height); widget_set_size(textbox->txt, width, height); } //设置文本框的坐标 void compo_textbox_set_pos(compo_textbox_t *textbox, s16 x, s16 y) { widget_set_pos(textbox->txt, x, y); } //设置文本框是否自动换行 void compo_textbox_set_wordwrap(compo_textbox_t *textbox, bool wordwrap) { widget_text_set_wordwrap(textbox->txt, wordwrap); } //设置文本框文字的颜色 void compo_textbox_set_forecolor(compo_textbox_t *textbox, u16 color) { widget_rect_set_color(textbox->txt, color); } //设置文本框的透明度 void compo_textbox_set_alpha(compo_textbox_t *textbox, u8 alpha) { widget_set_alpha(textbox->txt, alpha); }