static void Window_TitleBar_Init(LCUI_Widget *titlebar) /* 功能:初始化窗口标题栏 */ { LCUI_Graph img; LCUI_TitleBar *t; Graph_Init(&img); t = Widget_Create_PrivData(titlebar, sizeof(LCUI_TitleBar)); t->icon_box = Create_Widget("picture_box"); t->label = Create_Widget("label"); Widget_Container_Add(titlebar, t->icon_box); Widget_Container_Add(titlebar, t->label); Resize_Widget(t->icon_box, Size(18,18)); Set_PictureBox_Size_Mode(t->icon_box, SIZE_MODE_CENTER); Show_Widget(t->icon_box); Show_Widget(t->label); Set_Widget_Align(t->icon_box, ALIGN_MIDDLE_LEFT, Pos(0,0)); Set_Widget_Align(t->label, ALIGN_MIDDLE_LEFT, Pos(2,-2)); Load_Graph_Default_TitleBar_BG(&img); Set_Widget_Background_Image(titlebar, &img, LAYOUT_STRETCH); }
static void ProgressBar_Init(LCUI_Widget *widget) /* 功能:初始化进度条的数据结构体 */ { LCUI_ProgressBar *pb = (LCUI_ProgressBar*) Widget_Create_PrivData (widget, sizeof(LCUI_ProgressBar)); pb->thread = 0; Graph_Init(&pb->fore_graph); Graph_Init(&pb->flash_image); pb->img_move_speed = 200; pb->sleep_time = 100000; pb->max_value = 1; pb->value = 0; LCUI_Widget *f_pb, *img_pb; f_pb = Create_Widget("picture_box"); img_pb = Create_Widget("picture_box"); /* 以自己为容器,将这些部件放进去 */ Widget_Container_Add(f_pb, img_pb); Widget_Container_Add(widget, f_pb); /* 没有背景图时就填充背景色 */ Set_Widget_BG_Mode(widget, BG_MODE_FILL_BACKCOLOR); Set_Widget_Border(widget, RGB(50,50,50), Border(1,1,1,1)); Set_Widget_Style(widget, "classic"); /* 进度条为经典风格 */ Set_PictureBox_Size_Mode(f_pb, SIZE_MODE_STRETCH); Show_Widget(f_pb); Show_Widget(img_pb); pb->fore_pic_box = f_pb; pb->img_pic_box = img_pb; }
int main(int argc, char *argv[]) { int i; LCUI_Init( argc, argv ); LCUI_RGB color[6]={{255,255,255},{127,127,127}, {255,0,0}, {255,165,0}, {30,144,255}, {65,200,65} }; LCUI_Widget *window, *widget[6], *label[6]; window = Create_Widget( "window" ); for(i=0; i<6; ++i) { widget[i] = Create_Widget( NULL ); label[i] = Create_Widget( "label" ); Label_Text( label[i], "Area %d" , i); Widget_Container_Add( widget[i], label[i] ); Window_Client_Area_Add( window, widget[i] ); Resize_Widget( widget[i], Size(80,80) ); Set_Widget_PosType( widget[i], POS_TYPE_STATIC ); Set_Widget_Align( label[i], ALIGN_MIDDLE_CENTER, Pos(0,0) ); Set_Widget_Border( widget[i], RGB(0,0,0), Border(1,1,1,1) ); Set_Widget_BG_Mode( widget[i], BG_MODE_FILL_BACKCOLOR ); Set_Widget_Backcolor( widget[i], color[i] ); Show_Widget( label[i] ); Show_Widget( widget[i] ); } Set_Window_Title_Text( window, "测试部件布局-2" ); Resize_Widget( window, Size(320, 240) ); Show_Widget( window ); return LCUI_Main(); }
int main(int argc,char*argv[]) { /* 声明几个部件 */ LCUI_Widget *window, *label, *logo, *img; int width, height; /* 自定义默认字体文件位置 */ //Set_Default_Font("msyh.ttf"); /* 初始化LCUI */ LCUI_Init(argc, argv); /* 创建一个LCUI程序窗口 */ width = 320;//Get_Screen_Width(); /* 窗口的宽度 */ height = 240;//Get_Screen_Height();; /* 窗口的高度 */ /* 创建部件 */ window = Create_Widget("window"); label = Create_Widget("label"); logo = Create_Widget("picture_box"); img = Create_Widget("picture_box"); //Set_Widget_Border_Style(window, BORDER_STYLE_NONE); Resize_Widget(img, Size(180, 180)); Resize_Widget(logo, Size(128,128)); Resize_Widget(window, Size(width, height)); Set_Window_Title_Text(window, "LCUI"); Set_Widget_Backcolor(window, RGB(94,200,255)); Set_PictureBox_Size_Mode(logo, SIZE_MODE_CENTER); Set_PictureBox_Image_From_File(logo, "logo_128x128.png"); Set_Label_Text(label, "LCUI 正在载入..."); Set_Label_Font(label, 15, NULL); Set_Widget_Align(logo, ALIGN_MIDDLE_CENTER, Pos(0, -20)); Set_Widget_Align(label, ALIGN_MIDDLE_CENTER, Pos(0, +70)); /* 将这三个部件放入窗口客户区中 */ Window_Client_Area_Add(window, label); Window_Client_Area_Add(window, img); Window_Client_Area_Add(window, logo); pthread_t t; LCUI_Thread_Create(&t, NULL, change_graph, (void*)img); /* 显示部件以及窗口 */ Show_Widget(label); Show_Widget(logo); Show_Widget(window); LCUI_Main(); /* 进入主循环 */ return 0; }
int main(int argc,char*argv[]) /* 主函数,程序的入口 */ { LCUI_Widget *window, *label, *pic_box, *fore_box; /* 使用指向widget部件的指针 */ int width, height; /* 自定义默认字体文件位置 */ //Set_Default_Font("msyh.ttf"); /* 初始化LCUI */ LCUI_Init(argc, argv); /* 创建一个LCUI程序窗口 */ width = 320; /* 窗口的宽度 */ height = 240; /* 窗口的高度 */ /* 创建部件 */ window = Create_Widget("window"); label = Create_Widget("label"); pic_box = Create_Widget("picture_box"); fore_box = Create_Widget("picture_box"); Resize_Widget(fore_box, Size(190, 190)); Resize_Widget(pic_box, Size(135,135)); Resize_Widget(window, Size(width, height)); Set_Window_Title_Text(window, "头像"); LCUI_Graph pic; Graph_Init(&pic); Set_PictureBox_Size_Mode(pic_box, SIZE_MODE_STRETCH); Set_PictureBox_Image_From_File(pic_box, "image.jpg"); Set_PictureBox_Image_From_File(fore_box, "border.png"); Set_Label_Text(label, "蛋疼的头像"); Set_Label_Font(label, 16, NULL); Set_Widget_Align(pic_box, ALIGN_MIDDLE_CENTER, Pos(0, -20)); Set_Widget_Align(fore_box, ALIGN_MIDDLE_CENTER, Pos(0, -20)); Set_Widget_Align(label, ALIGN_MIDDLE_CENTER, Pos(0, +75)); Window_Client_Area_Add(window, label); Window_Client_Area_Add(window, pic_box); Window_Client_Area_Add(window, fore_box); Show_Widget(label); Show_Widget(pic_box); Show_Widget(fore_box); Show_Widget(window); return LCUI_Main(); }
/* * 创建一个部件,作为滚动条的容器 * 再创建一个部件,作为滚动条 * 限制滚动条的移动范围 * */ static void ScrollBar_Init( LCUI_Widget *widget ) { LCUI_ScrollBar *scrollbar; scrollbar = Widget_Create_PrivData(widget, sizeof(LCUI_ScrollBar)); scrollbar->data.max_num = 100; scrollbar->data.current_num = 100; scrollbar->data.max_size = 100; scrollbar->data.current_size = 100; scrollbar->direction = 0; scrollbar->callback_func = NULL; scrollbar->widget = Create_Widget("button"); /* 禁用部件的自动尺寸调整 */ Widget_AutoSize( scrollbar->widget, FALSE, 0 ); Widget_Container_Add( widget, scrollbar->widget ); Set_Widget_Size( scrollbar->widget, "100%", "100%" ); Limit_Widget_Pos( scrollbar->widget, Pos(0,0), Pos(0,0) ); Set_Widget_Border( widget, RGB(100,100,100), Border(1,1,1,1) ); Set_Widget_Padding( widget, Padding(1,1,1,1) ); Set_Widget_Backcolor( widget, RGB(200,200,200) ); Set_Widget_BG_Mode( widget, BG_MODE_FILL_BACKCOLOR ); Show_Widget( scrollbar->widget ); Widget_Drag_Event_Connect( scrollbar->widget, ScrollBar_Drag ); }
static void Window_Init(LCUI_Widget *win_p) /* * 功能:初始化窗口 * 说明:类似于构造函数 **/ { LCUI_Widget *titlebar; LCUI_Widget *client_area; LCUI_Widget *btn_close; LCUI_Window *win; win = (LCUI_Window*)Widget_Create_PrivData(win_p, sizeof(LCUI_Window)); win->hide_style = NONE; win->show_style = NONE; win->count = 0; win->init_align = ALIGN_MIDDLE_CENTER; /* 创建一个标题栏部件 */ titlebar = Create_Widget("titlebar"); /* 再创建一个客户区部件 */ client_area = Create_Widget(NULL); btn_close = Create_Widget("button"); static LCUI_Graph btn_highlight, btn_normal, btn_down; Graph_Init(&btn_down); Graph_Init(&btn_highlight); Graph_Init(&btn_normal); /* 载入默认图形 */ Load_Graph_Default_TitleBar_CloseBox_Normal(&btn_normal); Load_Graph_Default_TitleBar_CloseBox_Down(&btn_down); Load_Graph_Default_TitleBar_CloseBox_HighLight(&btn_highlight); /* 显示在左上角 */ Set_Widget_Align(btn_close, ALIGN_TOP_RIGHT, Pos(0, -2)); /* 将尺寸改成和图片一样 */ Resize_Widget(btn_close, Size(btn_normal.width, btn_normal.height)); Custom_Button_Style(btn_close, &btn_normal, &btn_highlight, &btn_down, NULL, NULL); /* 关联按钮的点击事件,当按钮被点击后,调用Quit_Window函数 */ Widget_Clicked_Event_Connect(btn_close, Quit_Parent_Window, NULL); Graph_Free(&btn_highlight); Graph_Free(&btn_down); Graph_Free(&btn_normal); win->client_area = client_area; win->titlebar = titlebar; win->btn_close = btn_close; /* 没有背景图就填充背景色 */ Set_Widget_BG_Mode(win_p, BG_MODE_FILL_BACKCOLOR); Set_Widget_Border_Style(win_p, BORDER_STYLE_STANDARD); /* 放入至容器 */ Widget_Container_Add(titlebar, btn_close); Widget_Container_Add(win_p, titlebar); Widget_Container_Add(win_p, client_area); Resize_Widget(win_p, Size(50, 50)); Show_Widget(btn_close); Widget_Drag_Event_Connect(titlebar, Move_Window); }
static void show_textbox_cursor( ) { if( !active_textbox ) { return; } LCUI_TextBox *tb; tb = Get_Widget_PrivData( active_textbox ); Show_Widget( tb->cursor ); }
int main(int argc, char*argv[]) /* 主函数,程序的入口 */ { LCUI_Init(argc, argv); LCUI_Widget *w1, *w2, *w3; /* 创建部件 */ w1 = Create_Widget("window"); w2 = Create_Widget("window"); w3 = Create_Widget("window"); /* 改变窗口的尺寸 */ Resize_Widget(w1, Size(320, 240)); Resize_Widget(w2, Size(200, 140)); Resize_Widget(w3, Size(120, 100)); Set_Window_Title_Text(w1, "窗口1"); Set_Window_Title_Text(w2, "窗口2"); Set_Window_Title_Text(w3, "窗口3"); Window_Client_Area_Add(w2, w3); Window_Client_Area_Add(w1, w2); Show_Widget(w1); Show_Widget(w2); Show_Widget(w3); LCUI_Main(); /* 进入主循环 */ return 0; }
static void Show_ProgressBar(LCUI_Widget *widget) /* 功能:在显示进度条时,处理其它操作 */ { LCUI_ProgressBar *pb = (LCUI_ProgressBar*)Get_Widget_PrivData(widget); if(Strcmp(&widget->style, "dynamic") == 0) { if(pb->thread == 0) { Show_Widget(pb->img_pic_box); LCUI_Thread_Create(&pb->thread, NULL, Move_Flash_Img, (void*)widget); } } else { Hide_Widget(pb->img_pic_box); if(pb->thread != 0) {/* 否则,如果线程ID不为0,就撤销线程 */ LCUI_Thread_Cancel(pb->thread); pb->thread = 0; } } }
void *change_graph(void *arg) /* 功能:改变显示的图形 */ { LCUI_Widget *widget = (LCUI_Widget *)arg; int i; LCUI_Graph frame, temp; Graph_Init(&frame);/* 初始化 */ Load_Image("ring.png", &frame);/* 载入之 */ /* 居中显示图形 */ Set_Widget_Align(widget, ALIGN_MIDDLE_CENTER, Pos(0, -20)); Set_PictureBox_Size_Mode(widget, SIZE_MODE_CENTER); Show_Widget(widget); while(1) { Set_PictureBox_Image_From_Graph(widget, &frame); for(i=10; i<=360; i+=10) { Rotate_Graph(&frame, i, &temp); Set_PictureBox_Image_From_Graph(widget, &temp); usleep(20000); } } LCUI_Thread_Exit(NULL); }
void Window_Widget_Auto_Size(LCUI_Widget *win_p) /* 功能:在窗口尺寸改变时自动改变标题栏和客户区的尺寸 */ { int x, y, width, height; LCUI_Widget *titlebar; LCUI_Widget *client_area; titlebar = Get_Window_TitleBar(win_p); client_area = Get_Window_Client_Area(win_p); /* 按不同的风格来处理 */ switch(Get_Widget_Border_Style(win_p)) { case BORDER_STYLE_NONE: /* 没有边框 */ /* 先计算坐标和尺寸 */ x = win_p->border.left; y = win_p->border.top; width = win_p->size.w - x - win_p->border.right; height = win_p->size.h - y - win_p->border.bottom; Move_Widget( client_area, Pos(x, y) );/* 调整位置 */ Resize_Widget( client_area, Size(width, height) );/* 调整大小 */ Hide_Widget( titlebar );/* 隐藏标题栏 */ Show_Widget( client_area );/* 客户区需要显示 */ break; case BORDER_STYLE_LINE_BORDER: /* 线条边框 */ Move_Widget( client_area, Pos(0, 0) ); Resize_Widget( client_area, Size(win_p->size.w, win_p->size.h) ); Hide_Widget( titlebar); Show_Widget( client_area); break; case BORDER_STYLE_STANDARD: /* 标准边框 */ /* * 说明:由于用户区的尺寸和位置的调整,需要确定标题栏的尺寸,因此, * 调用Exec_Resize_Widget()函数立刻调整标题栏尺寸,如果是调用 * Resize_Widget()函数,那么,确定的尺寸会有误,因为标题栏的尺 * 寸还是以前的尺寸。 * */ Set_Widget_Border(win_p, RGB(50,50,50), Border(1,1,1,1)); /* 先计算坐标和尺寸 */ x = win_p->border.left; y = win_p->border.top; width = win_p->size.w - x - win_p->border.right; height = win_p->size.h - y - win_p->border.bottom; Move_Widget(titlebar, Pos(x, y) ); Resize_Widget(titlebar, Size(width, 25)); Set_Widget_Align(client_area, ALIGN_BOTTOM_CENTER, Pos(0, y)); Resize_Widget(client_area, Size(width, height - 23)); /* 标题栏和客户区都需要显示 */ Show_Widget(titlebar); Show_Widget(client_area); break; default: // break; } }
int main(int argc, char*argv[]) { int mode; LCUI_Widget *window, *text[2], *tb_username, *tb_password; LCUI_Widget *area, *login_btn; LCUI_Widget *fore_pb, *back_pb; LCUI_Init(argc, argv); /* 创建所需的部件 */ window = Create_Widget("window"); area = Create_Widget(NULL); tb_password = Create_Widget("text_box"); tb_username = Create_Widget("text_box"); text[0] = Create_Widget("label"); text[1] = Create_Widget("label"); fore_pb = Create_Widget("picture_box"); back_pb = Create_Widget("picture_box"); login_btn = Create_Widget("button"); /* 设置界面上显示的文本 */ Set_Window_Title_Text(window, "用户登录"); Label_Text( text[0], "帐号:" ); Label_Text( text[1], "密码:" ); Set_Button_Text( login_btn, "登录" ); /* 调整部件的尺寸 */ Resize_Widget( login_btn, Size(50, 50) ); Resize_Widget( window, Size(320, 240) ); Resize_Widget( back_pb, Size(128, 128)); Resize_Widget( fore_pb, Size(95,95)); Resize_Widget( area, Size(225,50) ); /* 设置这两个图片框内显示的图片 */ Set_PictureBox_Size_Mode( back_pb, SIZE_MODE_STRETCH ); Set_PictureBox_Size_Mode( fore_pb, SIZE_MODE_STRETCH ); Set_PictureBox_Image_From_File( back_pb, "faceback.png" ); Set_PictureBox_Image_From_File( fore_pb, "image.jpg" ); /* 限制文本框内的字符总数为32个 */ TextBox_Text_Set_MaxLength( tb_username, 32 ); TextBox_Text_Set_MaxLength( tb_password, 32 ); tb_password->resize( tb_password, Size(125, 22) ); TextBox_Text_Set_PasswordChar( tb_password, L'●' ); /* 限制文本框输入的字符 */ mode = ONLY_0_TO_9 | ONLY_A_TO_Z | ONLY_a_TO_z | ONLY_UNDERLINE; TextBox_Text_Limit( tb_username, mode ); tb_username->resize( tb_username, Size(125, 22) ); /* 将部件添加至相应的容器中 */ Widget_Container_Add( area, text[0] ); Widget_Container_Add( area, text[1] ); Widget_Container_Add( area, login_btn ); Widget_Container_Add( back_pb, fore_pb ); Widget_Container_Add( area, tb_username ); Widget_Container_Add( area, tb_password ); Window_Client_Area_Add( window, back_pb ); Window_Client_Area_Add( window, area ); /* 设置部件的布局 */ area->set_align( area, ALIGN_MIDDLE_CENTER, Pos(0,60) ); login_btn->set_align( login_btn, ALIGN_MIDDLE_RIGHT, Pos(0,0) ); back_pb->set_align( fore_pb, ALIGN_MIDDLE_CENTER, Pos(-2,-2) ); back_pb->set_align( back_pb, ALIGN_MIDDLE_CENTER, Pos(0,-35) ); text[0]->set_align( text[0], ALIGN_MIDDLE_LEFT, Pos(0,-12) ); text[1]->set_align( text[1], ALIGN_MIDDLE_LEFT, Pos(0,12) ); tb_username->set_align( tb_username, ALIGN_MIDDLE_LEFT, Pos(35,-12) ); tb_password->set_align( tb_password, ALIGN_MIDDLE_LEFT, Pos(35,12) ); /* 设置边框 */ Set_Widget_Border( fore_pb, RGB(120,120,120), Border(1,1,1,1) ); /* 显示这些部件 */ Show_Widget( back_pb ); Show_Widget( fore_pb ); Show_Widget( login_btn ); Show_Widget( area ); tb_password->show( tb_password ); tb_username->show( tb_username ); text[0]->show( text[0] ); text[1]->show( text[1] ); window->show( window ); /* 进入主循环 */ return LCUI_Main(); }
static void TextBox_ScrollBar_Update_Size( LCUI_Widget *widget ) /* 更新滚动条的长度 */ { int tmp; char size_str[15]; LCUI_Size area_size, layer_size; LCUI_Widget *scrollbar[2], *label; LCUI_TextLayer *layer; label = TextBox_Get_Label( widget ); /* 获取文本图层 */ layer = TextBox_Get_TextLayer( widget ); /* 获取文本图层和文本框区域的尺寸 */ layer_size = TextLayer_Get_Size( layer ); area_size = Get_Container_Size( widget ); /* 获取纵向和横向滚动条 */ scrollbar[0] = TextBox_Get_Scrollbar( widget, 0 ); scrollbar[1] = TextBox_Get_Scrollbar( widget, 1 ); /* 如果文本图层高度超过显示区域 */ if( layer->enable_multiline && area_size.h > 0 && layer_size.h > area_size.h ) { tmp = area_size.w - Get_Widget_Width( scrollbar[0] ); snprintf( size_str, sizeof(size_str)-1, "%dpx", tmp ); Set_Widget_Size( label, size_str, NULL ); /* 修改滚动条中记录的最大值和当前值,让滚动条在更新后有相应的长度 */ ScrollBar_Set_MaxSize( scrollbar[0], layer_size.h ); ScrollBar_Set_CurrentSize( scrollbar[0], area_size.h ); Show_Widget( scrollbar[0] ); /* 如果横向滚动条可见 */ if( scrollbar[1]->visible ) { tmp = area_size.h - Get_Widget_Height( scrollbar[1] ); snprintf( size_str, sizeof(size_str)-1, "%dpx", tmp ); Set_Widget_Size( scrollbar[0], NULL, size_str ); } else { Set_Widget_Size( scrollbar[0], NULL, "100%" ); } } else { /* 不需要显示滚动条 */ Hide_Widget( scrollbar[0] ); Set_Widget_Size( label, "100%", NULL ); } /* 和上面的处理基本一样,这个是处理横向滚动条 */ if( layer->enable_multiline && area_size.w > 0 && layer_size.w > area_size.w ) { tmp = area_size.h - Get_Widget_Height( scrollbar[1] ); snprintf( size_str, sizeof(size_str)-1, "%dpx", tmp ); Set_Widget_Size( label, NULL, size_str ); ScrollBar_Set_MaxSize( scrollbar[1], layer_size.w ); ScrollBar_Set_CurrentSize( scrollbar[1], area_size.w ); Show_Widget( scrollbar[1] ); if( scrollbar[0]->visible ) { tmp = area_size.w - Get_Widget_Width( scrollbar[0] ); snprintf( size_str, sizeof(size_str)-1, "%dpx", tmp ); Set_Widget_Size( scrollbar[1], size_str, NULL ); } else { Set_Widget_Size( scrollbar[1], "100%", NULL ); } } else { Set_Widget_Size( label, NULL, "100%" ); Hide_Widget( scrollbar[1] ); } }
static void TextBox_Init( LCUI_Widget *widget ) /* 初始化文本框相关数据 */ { LCUI_TextBox *textbox; textbox = Widget_Create_PrivData(widget, sizeof(LCUI_TextBox)); textbox->text = Create_Widget( "label" ); textbox->cursor = Create_Widget( NULL ); textbox->scrollbar[0] = Create_Widget( "scrollbar" ); textbox->scrollbar[1] = Create_Widget( "scrollbar" ); /* 不可获得焦点 */ textbox->text->focus = FALSE; textbox->cursor->focus = FALSE; textbox->scrollbar[0]->focus = FALSE; textbox->scrollbar[1]->focus = FALSE; textbox->limit_mode = 0; textbox->block_size = 256; Label_AutoSize( textbox->text, FALSE, 0 ); Set_Widget_Size( textbox->text, "100%", "100%" ); /* 添加至相应的容器 */ Widget_Container_Add( textbox->text, textbox->cursor ); Widget_Container_Add( widget, textbox->text ); Widget_Container_Add( widget, textbox->scrollbar[0] ); Widget_Container_Add( widget, textbox->scrollbar[1] ); /* 设置滚动条的尺寸 */ Set_Widget_Size( textbox->scrollbar[0], "10px", NULL ); Set_Widget_Size( textbox->scrollbar[1], NULL, "10px" ); Set_Widget_Align( textbox->scrollbar[0], ALIGN_TOP_RIGHT, Pos(0,0) ); Set_Widget_Align( textbox->scrollbar[1], ALIGN_BOTTOM_LEFT, Pos(0,0) ); /* 滚动条设为横向 */ ScrollBar_Set_Direction( textbox->scrollbar[1], 1 ); /* 将回调函数与滚动条连接 */ ScrollBar_Connect( textbox->scrollbar[0], TextBox_VertScroll_TextLayer, widget ); ScrollBar_Connect( textbox->scrollbar[1], TextBox_HoriScroll_TextLayer, widget ); Show_Widget( textbox->text ); Queue_Init( &textbox->text_block_buff, sizeof(LCUI_TextBlock), destroy_textblock ); TextLayer_Using_StyleTags( Label_Get_TextLayer(textbox->text), FALSE ); Set_Widget_Padding( widget, Padding(2,2,2,2) ); Set_Widget_Backcolor( textbox->cursor, RGB(0,0,0) ); Set_Widget_BG_Mode( textbox->cursor, BG_MODE_FILL_BACKCOLOR ); Resize_Widget( textbox->cursor, Size(1, 14) ); /* 设置可点击区域的alpha值要满足的条件 */ Set_Widget_ClickableAlpha( textbox->cursor, 0, 1 ); Set_Widget_ClickableAlpha( textbox->text, 0, 1 ); /* 设定定时器,每1秒闪烁一次 */ if( __timer_id == -1 ) { __timer_id = set_timer( 500, blink_cursor, TRUE ); } Widget_Drag_Event_Connect( widget, TextBox_TextLayer_Click ); /* 关联 FOCUS_OUT 和 FOCUS_IN 事件 */ Widget_FocusOut_Event_Connect( widget, hide_textbox_cursor, NULL ); Widget_FocusIn_Event_Connect( widget, _put_textbox_cursor, NULL ); /* 关联按键输入事件 */ Widget_Keyboard_Event_Connect( widget, TextBox_Input ); /* 默认不启用多行文本模式 */ TextBox_Multiline( widget, FALSE ); }