Example #1
0
static void _rtgui_filelist_view_constructor(struct rtgui_filelist_view *view)
{
    /* default rect */
    struct rtgui_rect rect = {0, 0, 200, 200};

    /* set default widget rect and set event handler */
    rtgui_object_set_event_handler(RTGUI_OBJECT(view), rtgui_filelist_view_event_handler);
    rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);

    RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

    view->current_item = 0;
    view->items_count = 0;
    view->page_items = 0;

    view->on_changed = RT_NULL;
    view->current_directory = RT_NULL;
    view->pattern = RT_NULL;
    RTGUI_WIDGET_BACKGROUND(view) = white;
    RTGUI_WIDGET_TEXTALIGN(view) = RTGUI_ALIGN_CENTER_VERTICAL;

    _instance_count++;
    if (_instance_count == 1)
    {
        file_image = rtgui_image_create_from_mem("xpm", (rt_uint8_t *)file_xpm,
                                                 sizeof(file_xpm), RT_TRUE);
        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_digtube_constructor(struct rtgui_digtube * digtube)
{
    RTGUI_WIDGET_TEXTALIGN(digtube) = RTGUI_ALIGN_CENTER;

	/* init widget and set event handler */
	rtgui_object_set_event_handler(RTGUI_OBJECT(digtube), rtgui_digtube_event_handler);
}
Example #4
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 #5
0
struct rtgui_panel* apps_list_create(struct rtgui_panel* panel)
{
	struct rtgui_rect rect;

	RT_ASSERT(panel != RT_NULL);

	if (app_default_icon == RT_NULL)
	{
		app_default_icon = rtgui_image_create_from_mem("xpm", (const rt_uint8_t*)exec_xpm, sizeof(exec_xpm), RT_FALSE);
	}
	if (app_close == RT_NULL)
	{
		app_close = rtgui_image_create_from_mem("xpm", (const rt_uint8_t *)close_xpm, sizeof(close_xpm), RT_FALSE);
	}

	rtgui_widget_get_extent(RTGUI_WIDGET(panel), &rect);

	/* create application list */
	rtgui_rect_inflate(&rect, -15);

	app_list = rtgui_listctrl_create(RTGUI_CONTAINER(panel), (rt_uint32_t)app_items, app_count, 15,15,RC_W(rect)-30,RC_H(rect)-30, _app_info_draw);
	rtgui_listctrl_set_itemheight(app_list, app_default_icon->h + 2);
	rtgui_listctrl_set_onitem(app_list, _handle_app_activate);
	rtgui_object_set_event_handler(RTGUI_OBJECT(app_list), apps_listctrl_event_handler);

	//rtgui_container_add_child(RTGUI_CONTAINER(panel), RTGUI_WIDGET(app_list));

	return RTGUI_PANEL(panel);
}
Example #6
0
static void app_mainmenu_init(void)
{
    struct rtgui_image *bg_image;
    rtgui_rect_t rect;

    /* create main window of Application Manager */
    win = rtgui_mainwin_create(RT_NULL, "mainmenu", RTGUI_WIN_STYLE_MAINWIN);
    if (win != RT_NULL)
    {
        rtgui_object_set_event_handler(RTGUI_OBJECT(win), mainmenu_event_handler);
        rtgui_widget_get_rect(RTGUI_WIDGET(win), &rect);

#ifdef RT_USING_MODULE 
        mainmenu_scan_apps();
#endif
        /* create background image */
        bg_image = rtgui_image_create("/resource/bg_image.jpg", RT_TRUE);
        if (bg_image == RT_NULL)
        {
            rt_kprintf("open \"/resource/bg_image.jpg\" failed\n");
        }
        ycircle_image = rtgui_image_create("/resource/ycircle.png", RT_TRUE);
        gcircle_image = rtgui_image_create("/resource/gcircle.png", RT_TRUE);
        app_list = app_list_create(&rect, items, ITEM_MAX, 2, 5, bg_image);
        rtgui_image_destroy(bg_image);
        app_list_draw(app_list);
        app_list_draw_pagemark(app_list);
        app_list->on_select = exec_internal_app;
        rtgui_win_show(win, RT_FALSE);
        /* set as main window */
        rtgui_app_set_main_win(rtgui_app_self(), win);
    }
}
Example #7
0
File: server.c Project: eyeye/RTGUI
/**
 * rtgui server thread's entry
 */
static void rtgui_server_entry(void *parameter)
{
#ifdef _WIN32_NATIVE
    /* set the server thread to highest */
    HANDLE hCurrentThread = GetCurrentThread();
    SetThreadPriority(hCurrentThread, THREAD_PRIORITY_HIGHEST);
#endif

    /* create rtgui server application */
    rtgui_server_application = rtgui_app_create("rtgui");
    if (rtgui_server_application == RT_NULL)
        return;

    rtgui_object_set_event_handler(RTGUI_OBJECT(rtgui_server_application),
                                   rtgui_server_event_handler);
    /* init mouse and show */
    rtgui_mouse_init();
#ifdef RTGUI_USING_MOUSE_CURSOR
    rtgui_mouse_show_cursor();
#endif

    rtgui_app_run(rtgui_server_application);

    rtgui_app_destroy(rtgui_server_application);
    rtgui_server_application = RT_NULL;
}
Example #8
0
static void _rtgui_win_constructor(rtgui_win_t *win)
{
    RTGUI_WIDGET(win)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    win->parent_window = RT_NULL;
    /* init window attribute */
    win->on_activate   = RT_NULL;
    win->on_deactivate = RT_NULL;
    win->on_close      = RT_NULL;
    win->on_key        = RT_NULL;
    win->title         = RT_NULL;
    win->modal_code    = RTGUI_MODAL_OK;

    /* initialize last mouse event handled widget */
    win->last_mevent_widget = RT_NULL;
    win->focused_widget	= RT_NULL;

    /* set window hide */
    RTGUI_WIDGET_HIDE(RTGUI_WIDGET(win));

    /* set window style */
    win->style = RTGUI_WIN_STYLE_DEFAULT;

    win->flag  = RTGUI_WIN_FLAG_INIT;

    rtgui_object_set_event_handler(RTGUI_OBJECT(win), rtgui_win_event_handler);

    /* init user data */
    win->user_data = 0;
}
Example #9
0
void calibration_entry(void* parameter)
{
    rt_device_t device;
    struct rtgui_rect rect;
    struct setup_items setup;

    device = rt_device_find("touch");
    if (device == RT_NULL) return; /* no this device */

    calibration_ptr = (struct calibration_session*)
        rt_malloc(sizeof(struct calibration_session));
    rt_memset(calibration_ptr, 0, sizeof(struct calibration_data));
    calibration_ptr->device = device;
    
    rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION, 
        (void*)calibration_data_post);
    
    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);
    
    /* set screen rect */
    calibration_ptr->width = rect.x2;
    calibration_ptr->height = rect.y2;

    calibration_ptr->app = rtgui_app_create("calibration");
    if (calibration_ptr->app != RT_NULL)
    {
        /* create calibration window */
        calibration_ptr->win = rtgui_win_create(RT_NULL,
            "calibration", &rect, 
            RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER | 
            RTGUI_WIN_STYLE_ONTOP | RTGUI_WIN_STYLE_DESTROY_ON_CLOSE);
        if (calibration_ptr->win != RT_NULL)
        {   			
            rtgui_object_set_event_handler(RTGUI_OBJECT(calibration_ptr->win),
                calibration_event_handler);
            rtgui_win_show(calibration_ptr->win, RT_TRUE);
        }
        
        rtgui_app_destroy(calibration_ptr->app);
    }

    /* set calibration data */
    rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION_DATA, 
        &calibration_ptr->data);

    //save setup
    setup.touch_min_x = calibration_ptr->data.min_x;
    setup.touch_max_x = calibration_ptr->data.max_x;
    setup.touch_min_y = calibration_ptr->data.min_y;
    setup.touch_max_y = calibration_ptr->data.max_y;
    setup_save(&setup);
    
    /* recover to normal */
    rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL);

    /* release memory */
    rt_free(calibration_ptr);
    calibration_ptr = RT_NULL;
}
Example #10
0
static void _rtgui_plot_constructor(struct rtgui_plot *plot)
{
    plot->base_x = plot->base_y = 0;
    plot->ptype = RTGUI_PLOT_TYPE_SCAN;
    plot->scale_x = plot->scale_y = 1;

    rtgui_object_set_event_handler(RTGUI_OBJECT(plot), rtgui_plot_event_handler);
}
rtgui_container_t *demo_view_benchmark(void)
{
	srand(100);
	container = demo_view("绘图测试");
	rtgui_object_set_event_handler(RTGUI_OBJECT(container), benchmark_event_handler);

	return container;
}
Example #12
0
static void _rtgui_label_constructor(rtgui_label_t *label)
{
	RTGUI_WIDGET_TEXTALIGN(label) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
	/* init widget and set event handler */
	rtgui_object_set_event_handler(RTGUI_OBJECT(label), rtgui_label_event_handler);

	/* set field */
	label->text = RT_NULL;
}
rtgui_container_t *demo_view_benchmark(void)
{
	srand(100);
	container = demo_view("绘图测试");
	RTGUI_WIDGET(container)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_object_set_event_handler(RTGUI_OBJECT(container), benchmark_event_handler);
	rtgui_widget_set_onshow(RTGUI_WIDGET(container), _benchmark_onshow);

	return container;
}
Example #14
0
static void _rtgui_staticline_constructor(rtgui_staticline_t *staticline)
{
	/* init widget and set event handler */
	rtgui_rect_t rect = {0, 0, 100, 2};

	rtgui_widget_set_rect(RTGUI_WIDGET(staticline), &rect);
	staticline->orient= RTGUI_HORIZONTAL;

	rtgui_object_set_event_handler(RTGUI_OBJECT(staticline), rtgui_staticline_event_handler);
}
/* 自定义控件的构造函�?*/
static void _rtgui_mywidget_constructor(rtgui_mywidget_t *mywidget)
{
	/* 默认这个控件接收聚焦 */
	RTGUI_WIDGET(mywidget)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	/* 初始化控件并设置事件处理函数 */
	rtgui_object_set_event_handler(RTGUI_OBJECT(mywidget), rtgui_mywidget_event_handler);

	/* 初始状态时OFF */
	mywidget->status = MYWIDGET_STATUS_OFF;
}
/* 创建用于DC操作演示用的视图 */
rtgui_container_t *demo_view_instrument_panel(void)
{
    rtgui_container_t *container;

    container = demo_view("instrument panel Demo");
    if (container != RT_NULL)
        /* 设置成自己的事件处理函数 */
        rtgui_object_set_event_handler(RTGUI_OBJECT(container), instrument_panel_event_handler);

    return container;
}
static void _rtgui_iconbox_constructor(rtgui_iconbox_t *iconbox)
{
	/* init widget and set event handler */
	RTGUI_WIDGET(iconbox)->flag |= RTGUI_WIDGET_FLAG_TRANSPARENT;
	rtgui_object_set_event_handler(RTGUI_OBJECT(iconbox), rtgui_iconbox_event_handler);

	/* set proper of control */
	iconbox->image = RT_NULL;
	iconbox->selected = RT_FALSE;
	iconbox->text = RT_NULL;
	iconbox->text_position = RTGUI_ICONBOX_TEXT_BELOW;
}
Example #18
0
void picture_show(void)
{
    /* create application */
    struct rtgui_app *app;
    struct rtgui_rect rect1;
    struct rtgui_win *win_main;
    rtgui_timer_t *timer;
    
    app = rtgui_app_create(rt_thread_self(), "gui_app");
    if (app == RT_NULL)
    {
        rt_kprintf("Create application \"gui_app\" failed!\n");
        return;
    }

    rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);

    /* 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;
    }

    /* create container in main window */
    container = rtgui_container_create();
    if (container == RT_NULL)
    {
        rt_kprintf("Create container failed!\n");
        return;
    }

    rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
    rtgui_object_set_event_handler(RTGUI_OBJECT(container), picture_view_event_handler);
    rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(container));

    timer = rtgui_timer_create(500, RT_TIMER_FLAG_PERIODIC, timeout, RT_NULL);
    rtgui_timer_start(timer);
    
    rtgui_win_set_onkey(win_main, onkey_handle);
    rtgui_win_show(win_main, RT_FALSE);

    /* show next picture */
    picture_show_next();

    rtgui_app_run(app);
    rtgui_app_destroy(app);
}
Example #19
0
static void _rtgui_checkbox_constructor(rtgui_checkbox_t *box)
{
	/* init widget and set event handler */
	RTGUI_WIDGET(box)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_checkbox_event_handler);

	/* set status */
	box->status_down = RTGUI_CHECKBOX_STATUS_UNCHECKED;
	box->on_button = RT_NULL;

	/* set default gc */
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
}
static void _rtgui_textview_constructor(rtgui_textview_t *textview)
{
	/* init widget and set event handler */
	rtgui_object_set_event_handler(RTGUI_OBJECT(textview), rtgui_textview_event_handler);
	RTGUI_WIDGET(textview)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

	/* set field */
	textview->line_count = 0;
	textview->lines = RT_NULL;

	textview->line_current = -1;
	textview->line_page_count = 1;
}
Example #21
0
static void _rtgui_notebook_constructor(struct rtgui_notebook *notebook)
{
	notebook->flag    = 0;
	notebook->childs  = RT_NULL;
	notebook->count   = 0;
	notebook->current = 0;

	notebook->tab_h = RTGUI_NOTEBOOK_TAB_DEFAULT_HEIGHT;
	notebook->tab_w = RTGUI_NOTEBOOK_TAB_DEFAULT_WIDTH;

	RTGUI_WIDGET(notebook)->gc.textalign = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
	rtgui_object_set_event_handler(RTGUI_OBJECT(notebook), rtgui_notebook_event_handler);
}
Example #22
0
static void _rtgui_progressbar_constructor(rtgui_progressbar_t *bar)
{
    rtgui_rect_t rect = {0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT};

    rtgui_object_set_event_handler(RTGUI_OBJECT(bar), rtgui_progressbar_event_handler);
    rtgui_widget_set_rect(RTGUI_WIDGET(bar), &rect);

    bar->orient = RTGUI_HORIZONTAL;
    bar->range = RTGUI_PROGRESSBAR_DEFAULT_RANGE;
    bar->position = 0;

    /* set gc */
    RTGUI_WIDGET_TEXTALIGN(bar) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
static void _rtgui_combobox_constructor(rtgui_combobox_t *box)
{
    rtgui_rect_t rect = {0, 0, RTGUI_COMBOBOX_WIDTH, RTGUI_COMBOBOX_HEIGHT};

    /* init widget and set event handler */
    rtgui_object_set_event_handler(RTGUI_OBJECT(box), rtgui_combobox_event_handler);
    rtgui_widget_set_rect(RTGUI_WIDGET(box), &rect);

    RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(box)) = RTGUI_ALIGN_CENTER_VERTICAL;

    box->pd_pressed = RT_FALSE;
    box->current_item = 0;
    box->on_selected = RT_NULL;
    box->pd_win    = RT_NULL;
}
Example #24
0
static void _rtgui_radiobox_constructor(rtgui_radiobox_t *radiobox)
{
    rtgui_rect_t rect = {0, 0, RTGUI_RADIOBOX_DEFAULT_WIDTH, RTGUI_RADIOBOX_DEFAULT_HEIGHT};

    /* init widget and set event handler */
    RTGUI_WIDGET(radiobox)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    RTGUI_WIDGET_TEXTALIGN(radiobox) = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_CENTER_VERTICAL;
    rtgui_widget_set_rect(RTGUI_WIDGET(radiobox), &rect);
    rtgui_object_set_event_handler(RTGUI_OBJECT(radiobox), rtgui_radiobox_event_handler);

    /* set proper of control */
    radiobox->items = RT_NULL;
    radiobox->item_count = 0;
    radiobox->item_selection = -1;
    radiobox->orient = RTGUI_HORIZONTAL;
}
Example #25
0
static void _rtgui_listctrl_constructor(struct rtgui_listctrl *ctrl)
{
    /* set default widget rect and set event handler */
    rtgui_object_set_event_handler(RTGUI_OBJECT(ctrl), rtgui_listctrl_event_handler);

    RTGUI_WIDGET(ctrl)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

    ctrl->current_item = -1;
    ctrl->item_height = rtgui_theme_get_selected_height();
    ctrl->items_count = 0;
    ctrl->page_items = 0;
    ctrl->on_item = 0;
    ctrl->on_item_draw = RT_NULL;

    RTGUI_WIDGET_BACKGROUND(ctrl) = white;
    RTGUI_WIDGET_TEXTALIGN(ctrl) = RTGUI_ALIGN_CENTER_VERTICAL;
}
Example #26
0
static void _rtgui_app_constructor(struct rtgui_app *app)
{
    /* set event handler */
    rtgui_object_set_event_handler(RTGUI_OBJECT(app),
                                   rtgui_app_event_handler);

    app->name           = RT_NULL;
    app->icon           = RT_NULL;
    /* set EXITED so we can destroy an application that just created */
    app->state_flag     = RTGUI_APP_FLAG_EXITED;
    app->ref_count      = 0;
    app->exit_code      = 0;
    app->tid            = RT_NULL;
    app->mq             = RT_NULL;
    app->main_object    = RT_NULL;
    app->on_idle        = RT_NULL;
}
Example #27
0
static void _rtgui_scrollbar_constructor(rtgui_scrollbar_t *bar)
{
	/* set event handler */
	rtgui_object_set_event_handler(RTGUI_OBJECT(bar), rtgui_scrollbar_event_handler);

	bar->status = 0;
	bar->value = 0;

	bar->thumb_w = 16;
	bar->thumb_len = 16;

	bar->widget_link = RT_NULL;
	bar->on_scroll = RT_NULL;

	bar->orient = RTGUI_HORIZONTAL;
	/* set gc */
	RTGUI_WIDGET_TEXTALIGN(bar) = RTGUI_ALIGN_CENTER;
}
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);

	/* 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;
}
static void _rtgui_button_constructor(rtgui_button_t *button)
{
	/* init widget and set event handler */
	RTGUI_WIDGET(button)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
	rtgui_object_set_event_handler(RTGUI_OBJECT(button), rtgui_button_event_handler);

	/* un-press button */
	button->flag = 0;

	/* set flag and on_button event handler */
	button->pressed_image = RT_NULL;
	button->unpressed_image = RT_NULL;
	button->on_button = RT_NULL;

	/* set gc */
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(button)) = default_foreground;
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(button)) = RTGUI_RGB(212, 208, 200);
	RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(button)) = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
}
Example #30
0
static void _rtgui_list_view_constructor(struct rtgui_list_view *view)
{
    /* default rect */
    struct rtgui_rect rect = {0, 0, 200, 200};

    /* set default widget rect and set event handler */
    rtgui_object_set_event_handler(RTGUI_OBJECT(view), rtgui_list_view_event_handler);
    rtgui_widget_set_rect(RTGUI_WIDGET(view), &rect);

    RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;

    view->flag = RTGUI_LIST_VIEW_LIST;
    view->current_item = 0;
    view->items_count = 0;
    view->page_items = 0;

    RTGUI_WIDGET_BACKGROUND(view) = white;
    RTGUI_WIDGET_TEXTALIGN(view) = RTGUI_ALIGN_CENTER_VERTICAL;
}