示例#1
0
struct tab* tab_init(void)
{
    struct tab * addr;

    /* 分配存储空间 */
    addr = (struct tab *)malloc(sizeof(struct tab));

    if(addr == NULL) {
        EGUI_PRINT_SYS_ERROR("fail to malloc");
        return NULL;
    }

    if(NULL == (addr = widget_init_common(WIDGET_POINTER(addr), 0))) {
        return NULL;
    }
    /* struct tab 的成员 */
    addr->name = "struct tab";

    /* 用全局样式对象初始化tab样式 */
    tab_init_with_default_style(addr);

    addr->border_size = 0;

    addr->header = tab_header_init();
    addr->header->parent_tab = addr;
    object_attach_child(OBJECT_POINTER(addr),
            OBJECT_POINTER(addr->header));

    return addr;
}
示例#2
0
文件: panel.c 项目: hanguangyi/egui
void * panel_init(si_t id)
{
    struct panel * addr;

    /* 分配存储空间 */
    addr = (struct panel *)malloc(sizeof(struct panel));

    if(addr == NULL)
    {
        EGUI_PRINT_SYS_ERROR("fail to malloc");
        return NULL;
    }

    if(!(addr=widget_init_common(WIDGET_POINTER(addr), id))) {
        return NULL;
    }

    addr->name = "struct panel";

    /* 用全局样式对象初始化panel样式 */
    panel_init_with_default_style(addr);

	/* 默认的回调函数 */
    addr->callback = panel_default_callback ;

    return addr;
}
示例#3
0
void *shortcut_init(si_t id)
{
    struct shortcut * addr;

    /* 分配存储空间 */
    addr = (struct shortcut *)malloc(sizeof(struct shortcut));

    if(addr == NULL)
    {
        EGUI_PRINT_SYS_ERROR("fail to malloc");
        return NULL;
    }

    if(!(addr=widget_init_common(WIDGET_POINTER(addr), id))) {
        return NULL;
    }
    addr->name = "struct shortcut";

	addr->img_field.x = 0;
	addr->img_field.y = 0;
	addr->img_field.width = 0;
	addr->img_field.height = 0;

	addr->text_field.x = 0;
	addr->text_field.y = 0;
	addr->text_field.width = 0;
	addr->text_field.height = 0;

	addr->is_text_visiable = 0;

	addr->flag = 0;
	
	addr->position_x=0;
	addr->position_y=0;
	addr->last_do_time.tv_sec=0;
	addr->last_do_time.tv_usec=0;
	
	memset(addr->img_path , 0 ,sizeof(char)*255);
	memset(addr->img_normal_path , 0 ,sizeof(char)*255);
	memset(addr->img_select_path , 0 ,sizeof(char)*255);
	memset(addr->text , 0, sizeof(char)*255);
    /* 默认的回调函数 */
    addr->callback = shortcut_default_callback;

    return addr;
}
示例#4
0
struct spinbox* spinbox_init(si_t minval, si_t maxval, si_t initval)
{
    struct spinbox * addr;

    /* 分配存储空间 */
    addr = (struct spinbox *)malloc(sizeof(struct spinbox));

    if(addr == NULL)
    {
        EGUI_PRINT_SYS_ERROR("fail to malloc");

        return NULL;
    }

    if(NULL == (addr = widget_init_common(WIDGET_POINTER(addr), 0))) {
        return NULL;
    }
    /* struct spinbox 的成员 */
    addr->name = "struct spinbox";

    /* 用全局样式对象初始化spinbox样式 */
    spinbox_init_with_default_style(addr);
	
    /* 默认的回调函数 */
    addr->callback = spinbox_default_callback;

    addr->maxval = maxval;
    addr->minval = minval;
    addr->value = initval;

    /* 25 should be enough for 64-bit integers. */
    addr->text_number = text_line_init(25, 0);
    text_line_set_bounds(addr->text_number,
            0, 0,
            addr->area.width-addr->area.height, addr->area.height);
    addr->button_up = button_init("^");
    addr->button_up->custom_data = addr;
    addr->button_up->callback = spinbox_button_callback;
    button_set_bounds(addr->button_up,
            addr->area.width-addr->area.height+1, 0,
            addr->area.height, addr->area.height/2);
    addr->button_down = button_init("v");
    addr->button_down->custom_data = addr;
    addr->button_down->callback = spinbox_button_callback;
    button_set_bounds(addr->button_down,
            addr->area.width-addr->area.height+1, addr->area.height/2+1,
            addr->area.height, addr->area.height/2);

    text_line_clear_keybd_type(addr->text_number);
    text_line_set_keybd_type(addr->text_number, TEXT_LINE_KEYBOARD_TYPE_NUMBER);
    sprintf(text_line_get_buf(addr->text_number),
            "%ld", addr->value);
    text_line_register_move_handler(addr->text_number, WIDGET_POINTER(addr),
            TEXT_LINE_EVENT_CURRENT_CHANGE, spinbox_text_event_handler);

    object_attach_child(OBJECT_POINTER(addr), OBJECT_POINTER(addr->text_number));
    object_attach_child(OBJECT_POINTER(addr), OBJECT_POINTER(addr->button_up));
    object_attach_child(OBJECT_POINTER(addr), OBJECT_POINTER(addr->button_down));

    list_init(&addr->subscribe_info_list);

    return addr;
}