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 = {0, 0, RTGUI_TEXTBOX_DEFAULT_WIDTH, RTGUI_TEXTBOX_DEFAULT_HEIGHT};
	rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);

	RTGUI_WIDGET(box)->flag |= 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);

	/* set default text align */
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;

	/* set proper of control */
	box->caret_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC, 
		_rtgui_textbox_caret_timeout, box);

	box->line = box->line_begin = box->position = 0;
	box->flag = RTGUI_TEXTBOX_SINGLE;

	/* allocate default line buffer */
	box->text = RT_NULL;

	rtgui_font_get_metrics(RTGUI_WIDGET(box)->gc.font, "h", &rect);
	box->font_width = rtgui_rect_width(rect);
}
Example #3
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 #4
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 #5
0
static void _rtgui_slider_constructor(rtgui_slider_t *slider)
{
	rtgui_rect_t rect = {0, 0, RTGUI_SLIDER_DEFAULT_WIDTH, RTGUI_SLIDER_DEFAULT_HEIGHT};

	/* init widget and set event handler */
	RTGUI_WIDGET(slider)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_widget_set_rect(RTGUI_WIDGET(slider), &rect);
	rtgui_object_set_event_handler(RTGUI_OBJECT(slider), rtgui_slider_event_handler);
	rtgui_widget_set_onunfocus(RTGUI_WIDGET(slider), rtgui_slider_onunfocus);
	/* set proper of control */
	slider->min = RTGUI_SLIDER_DEFAULT_MIN;
	slider->max = RTGUI_SLIDER_DEFAULT_MAX;
	slider->value = RTGUI_SLIDER_DEFAULT_MIN;
	slider->orient = RTGUI_HORIZONTAL;

	slider->ticks = 10;
	slider->thumb_width = 8;
	slider->on_changed = RT_NULL;
}