LCUI_API int LCUIString_Cmp( LCUI_String *str1, LCUI_String *str2 ) { if( !str2 ) { return -1; } return _LCUIString_Cmp( str1, str2->string ); }
/* 通过名字查找输入法信息 */ static LCUIIME_Info* LCUIIME_FindByName( const char *name ) { int n, i; LCUIIME_Info *ptr; n = Queue_GetTotal( &imelist ); for( i=0; i<n; ++i ) { ptr = Queue_Get( &imelist, i ); if( !ptr ) { continue; } if( _LCUIString_Cmp( &ptr->name, name ) == 0 ) { return ptr; } } return NULL; }
/* 获取样式类的句柄 */ LCUI_API LCUI_StyleClass* StyleLib_GetStyleClass( LCUI_StyleLibrary *lib, const char *class_name ) { int i, total; LCUI_StyleClass *p; total = Queue_GetTotal( &lib->style_classes ); for(i=0; i<total; ++i) { p = (LCUI_StyleClass*)Queue_Get( &lib->style_classes, i ); if( !p ) { continue; } if( _LCUIString_Cmp( &p->class_name, class_name) == 0 ) { return p; } } return NULL; }
LCUI_API LCUI_StyleAttr* StyleLib_GetStyleAttr( LCUI_StyleClass *style_class, const char *pseudo_class_name, const char *attr_name ) { int i, total; LCUI_StyleAttr *p; if( !style_class ) { return NULL; } /* 先在记录中查找是否有已存在的同名属性 */ total = Queue_GetTotal( &style_class->style_attr ); for( i=0; i<total; ++i ) { p = (LCUI_StyleAttr*)Queue_Get( &style_class->style_attr, i ); if( !p ) { continue; } if( _LCUIString_Cmp( &p->attr_name, attr_name ) == 0 ) { return p; } } return NULL; }
/* 更新复选框的图形数据 */ static void CheckBox_ExecDraw(LCUI_Widget *widget) { LCUI_Graph *p; LCUI_CheckBox *check_box; check_box = Widget_GetPrivData(widget); if(_LCUIString_Cmp(&widget->style_name, "custom") == 0) { /* 如果为自定义风格,那就使用用户指定的图形,具体可参考按钮部件的处理方法 */ if( !widget->enabled ) { widget->state = WIDGET_STATE_DISABLE; } switch(widget->state){ case WIDGET_STATE_NORMAL: if( check_box->on ) { p = &check_box->img_on_normal; } else { p = &check_box->img_off_normal; } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_OVERLAY : if( check_box->on ) { p = &check_box->img_on_over; } else { p = &check_box->img_off_over; } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_ACTIVE : if( check_box->on ) { p = &check_box->img_on_down; } else { p = &check_box->img_off_down; } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_DISABLE : if( check_box->on ) { p = &check_box->img_on_disable; } else { p = &check_box->img_off_disable; } PictureBox_SetImage(check_box->imgbox, p); break; default : break; } } else {/* 如果按钮的风格为缺省 */ _LCUIString_Copy(&widget->style_name, "default"); if( !widget->enabled ) { widget->state = WIDGET_STATE_DISABLE; } /* 先释放PictureBox部件中保存的图形数据的指针 */ p = PictureBox_GetImage(check_box->imgbox); Graph_Free(p); /* 由于本函数在退出后,使用局部变量保存的图形数据会无效,因此,申请内存空间来储存 */ p = (LCUI_Graph*)calloc(1,sizeof(LCUI_Graph)); switch(widget->state) { case WIDGET_STATE_NORMAL: if( check_box->on ) { Load_Graph_Default_CheckBox_On_Normal(p); } else { Load_Graph_Default_CheckBox_Off_Normal(p); } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_OVERLAY : if( check_box->on ) { Load_Graph_Default_CheckBox_On_Selected(p); } else { Load_Graph_Default_CheckBox_Off_Selected(p); } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_ACTIVE : if( check_box->on ) { Load_Graph_Default_CheckBox_On_Selected(p); } else { Load_Graph_Default_CheckBox_Off_Selected(p); } PictureBox_SetImage(check_box->imgbox, p); break; case WIDGET_STATE_DISABLE : if( check_box->on ) { Load_Graph_Default_CheckBox_On_Disabled(p); } else { Load_Graph_Default_CheckBox_Off_Disabled(p); } PictureBox_SetImage(check_box->imgbox, p); break; default : break; } } }
/* 更新单选框的图形数据 */ static void RadioButton_ExecUpdate( LCUI_Widget widget ) { int img_id; LCUI_Graph *img_ptr; LCUI_RadioButton *radio_button; radio_button = (LCUI_RadioButton*)Widget_GetPrivData(widget); /* 如果为自定义风格,那就使用用户指定的图形 */ if( _LCUIString_Cmp(&widget->style_name, "custom") == 0 ) { if(widget->enabled == FALSE) { widget->state = WIDGET_STATE_DISABLE; } switch(widget->state) { case WIDGET_STATE_NORMAL: if(radio_button->on) { img_ptr = &radio_button->img_on_normal; } else { img_ptr = &radio_button->img_off_normal; } break; case WIDGET_STATE_OVERLAY : if(radio_button->on) { img_ptr = &radio_button->img_on_over; } else { img_ptr = &radio_button->img_off_over; } break; case WIDGET_STATE_ACTIVE : if(radio_button->on) { img_ptr = &radio_button->img_on_down; } else { img_ptr = &radio_button->img_off_down; } break; case WIDGET_STATE_DISABLE : if(radio_button->on) { img_ptr = &radio_button->img_on_disable; } else { img_ptr = &radio_button->img_off_disable; } break; default:return; } PictureBox_SetImage(radio_button->imgbox, img_ptr); } _LCUIString_Copy( &widget->style_name, "default" ); if( !widget->enabled ) { widget->state = WIDGET_STATE_DISABLE; } switch(widget->state) { case WIDGET_STATE_NORMAL: if(radio_button->on) { img_id = IMG_ON_NORMAL; } else { img_id = IMG_OFF_NORMAL; } break; case WIDGET_STATE_OVERLAY : if(radio_button->on) { img_id = IMG_ON_SELECTED; } else { img_id = IMG_OFF_SELECTED; } break; case WIDGET_STATE_ACTIVE : case WIDGET_STATE_DISABLE : default: return; } img_ptr = PictureBox_GetImage( radio_button->imgbox ); Graph_Free( img_ptr ); img_ptr = (LCUI_Graph*)calloc( 1, sizeof(LCUI_Graph) ); RadioButton_LoadDefaultGraph( img_ptr, img_id ); PictureBox_SetImage( radio_button->imgbox, img_ptr ); }