Example #1
0
static void _rtgui_fileview_constructor(rtgui_fileview_t *fview)
{
	/* set default widget rect and set event handler */
	rtgui_widget_set_event_handler(fview, rtgui_fileview_event_handler);
	rtgui_widget_set_onunfocus(fview, rtgui_fileview_onunfocus);

	RTGUI_WIDGET_FLAG(fview) |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	fview->first_item = 0;
	fview->now_item = 0;
	fview->item_count = 0;
	fview->item_per_page = 0;

	fview->current_dir = RT_NULL;
	fview->pattern = RT_NULL;
	RTGUI_WIDGET_BC(fview) = theme.blankspace;
	RTGUI_WIDGET_TEXTALIGN(fview) = RTGUI_ALIGN_CENTER_VERTICAL;
	
	if(theme.style == RTGUI_BORDER_UP)
		rtgui_widget_set_border_style(fview,RTGUI_BORDER_DOWN);
	else if(theme.style == RTGUI_BORDER_EXTRA)
		rtgui_widget_set_border_style(fview,RTGUI_BORDER_SUNKEN);

	fview->on_item = RT_NULL;
	fview->dlg = RT_NULL;

	if(file_image==RT_NULL)
		file_image = rtgui_image_create_from_mem("xpm",(rt_uint8_t*)file_xpm, sizeof(file_xpm), RT_TRUE);
	if(folder_image==RT_NULL)
		folder_image = rtgui_image_create_from_mem("xpm",(rt_uint8_t*)folder_xpm, sizeof(folder_xpm), RT_TRUE);
}
Example #2
0
static void _rtgui_textbox_constructor(rtgui_textbox_t *box)
{
	rtgui_rect_t rect;

	RTGUI_WIDGET_FLAG(RTGUI_WIDGET(box)) |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_textbox_event_handler);
	rtgui_widget_set_onfocus(RTGUI_WIDGET(box), rtgui_textbox_onfocus);
	rtgui_widget_set_onunfocus(RTGUI_WIDGET(box), rtgui_textbox_onunfocus);
#ifndef RTGUI_USING_SMALL_SIZE
	rtgui_widget_set_onkey(RTGUI_WIDGET(box), rtgui_textbox_onkey);
#endif

	RTGUI_WIDGET_FOREGROUND(box) = black;
	RTGUI_WIDGET_BACKGROUND(box) = white;
	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(box) = RTGUI_ALIGN_CENTER_VERTICAL;
	/* set proper of control */
	box->caret_timer = RT_NULL;
	box->caret = RT_NULL;

	box->line = box->line_begin = box->position = 0;
	box->flag = RTGUI_TEXTBOX_SINGLE;
	/* allocate default line buffer */
	box->text = RT_NULL;
	rtgui_textbox_set_mask_char(box, '*');

	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(box), "H", &rect);
	box->font_width = rtgui_rect_width(rect);
	box->on_enter = RT_NULL;
	box->dis_length = 0;
	box->first_pos = 0;
}
Example #3
0
void rtgui_anim_stop(struct rtgui_animation *anim)
{
    RT_ASSERT(anim);

    anim->state = _ANIM_STOPPED;
    RTGUI_WIDGET_FLAG(anim->parent) &= ~RTGUI_WIDGET_FLAG_IN_ANIM;
    rtgui_timer_stop(anim->timer);
}
Example #4
0
void rtgui_anim_start(struct rtgui_animation *anim)
{
    RT_ASSERT(anim);

    if (anim->state == _ANIM_STOPPED)
    {
        anim->state = _ANIM_RUNNING;
        RTGUI_WIDGET_FLAG(anim->parent) |= RTGUI_WIDGET_FLAG_IN_ANIM;
        rtgui_timer_start(anim->timer);
    }
}
Example #5
0
static void app_lcd(void *parameter)
{
    /* create application */
	struct rtgui_app *app;
    struct rtgui_rect rect1 = {0, 0, 240, 320};
    struct rtgui_button* btn;
    struct rtgui_label *lb;

	app = rtgui_app_create("lcd_app");

    if (!app)
    {
        rt_kprintf("Create application \"lcd_app\" failed!\n");
        return;
    }

    /* create main window */
    win_main = rtgui_win_create(RT_NULL, "main",
                    &rect1,
                    RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
    if (win_main == RT_NULL)
    {
        rt_kprintf("Create window \"main\" failed!\n");
        rtgui_app_destroy(app);
        return;
    }
    RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(win_main)) = green;

    rect1.x1 = rect1.y1 = 50;
    rect1.x2 -= 50;
    rect1.y2 -= 50;
    lb = rtgui_label_create("I am a transparent label!!!!!!!!!");
    rtgui_widget_set_rect(RTGUI_WIDGET(lb), &rect1);
    RTGUI_WIDGET_FLAG(RTGUI_WIDGET(lb)) |= RTGUI_WIDGET_FLAG_TRANSPARENT;

    rect1.x1 += 20;
    rect1.y1 += 20;
	notebook = rtgui_notebook_create(&rect1, 0);
    /* create lable in main container */
    btn = rtgui_button_create("Here I am.");
    rtgui_notebook_add(notebook, "btn A", RTGUI_WIDGET(btn));
    rtgui_button_set_onbutton(btn, remove_myself);
    btn = rtgui_button_create("There I am.");
    rtgui_notebook_add(notebook, "btn B", RTGUI_WIDGET(btn));

    rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(lb));
	rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(notebook));

    rtgui_win_show(win_main, RT_FALSE);

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
Example #6
0
static void _rtgui_terminal_constructor(rtgui_terminal_t *tma)
{
	/* init widget and set event handler */
	rtgui_widget_set_event_handler(tma, rtgui_terminal_event_handler);
	RTGUI_WIDGET_TEXTALIGN(tma) = RTGUI_ALIGN_LEFT;
	RTGUI_WIDGET_FLAG(tma) |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	/* set field */
	tma->item_count = 0;
	tma->first_item = 0;
	tma->now_item = 0;
	tma->old_item = 0;
	tma->item_per_page = 0;

	tma->lines = RT_NULL;
}
Example #7
0
File: edit.c Project: amsl/RTGUI
void _rtgui_edit_constructor(struct rtgui_edit *edit)
{
	rtgui_rect_t font_rect;
	RTGUI_WIDGET_FLAG(edit) |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	rtgui_widget_set_event_handler(edit, rtgui_edit_event_handler);
	rtgui_widget_set_onfocus(edit, rtgui_edit_onfocus);
	rtgui_widget_set_onunfocus(edit, rtgui_edit_onunfocus);
	
	RTGUI_WIDGET_FC(edit) = theme.foreground;
	RTGUI_WIDGET_BC(edit) = theme.blankspace;
	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(edit) = RTGUI_ALIGN_CENTER_VERTICAL;
	/* set proper of control */
	edit->caret_timer = RT_NULL;
	edit->caret = RT_NULL;

	edit->tabsize = 4;
	edit->margin  = 1;
	edit->max_rows = edit->max_cols = 0;
	edit->visual.x = edit->visual.y = 0;
	edit->upleft.x = edit->upleft.y = 0;
	edit->row_per_page = edit->col_per_page = 0;

	edit->update_buf = RT_NULL;
	edit->flag = RTGUI_EDIT_NONE;
#ifdef RTGUI_EDIT_USING_SCROLL
	edit->flag |= RTGUI_EDIT_VSCROLL;
	edit->flag |= RTGUI_EDIT_HSCROLL;
#endif
	/* allocate default line buffer */
	edit->bzsize = 16;
	
	rtgui_font_get_metrics(RTGUI_WIDGET_FONT(edit), "H", &font_rect);
	edit->font_width = rtgui_rect_width(font_rect);
	edit->font_height = rtgui_rect_height(font_rect);

	edit->dbl_buf = rtgui_dc_buffer_create(edit->font_width*2+1, edit->font_height+1);
	
	edit->head = RT_NULL;
	edit->tail = RT_NULL;
	edit->first_line = RT_NULL;
#ifdef RTGUI_EDIT_USING_SCROLL	
	edit->hscroll = RT_NULL;
	edit->vscroll = RT_NULL;
#endif
}
Example #8
0
static void _rtgui_combo_constructor(rtgui_combo_t *cbo)
{
	RTGUI_WIDGET_FLAG(cbo) |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	cbo->style = RTGUI_COMBO_STYLE_DOWNARROW_UP;
	cbo->lbox = RT_NULL;
	cbo->tbox = RT_NULL;
	if(theme.style == RTGUI_BORDER_UP)
		rtgui_widget_set_border_style(cbo,RTGUI_BORDER_DOWN);
	else if(theme.style == RTGUI_BORDER_EXTRA)
		rtgui_widget_set_border_style(cbo,RTGUI_BORDER_SUNKEN);
	rtgui_widget_set_event_handler(cbo, rtgui_combo_event_handler);

	RTGUI_WIDGET_BC(cbo) = theme.blankspace;
	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(cbo) = RTGUI_ALIGN_CENTER_VERTICAL;
	cbo->on_selected = RT_NULL;
}