|
自繪制控件
如果現有控件中找不到符合要求的怎么辦?用DM_CATEGORY_CONTROLLED_AREA。此控件由你自己繪制,觸摸
屏幕操作也由控件自己處理。
下面我們為新模板加上一個自畫區域,并將此區域的觸摸屏操作用文本顯示出來。
修改模板數據庫:
const U8 category888[] =
{
DM_BASE_LAYER_START,
DM_CATEGORY_CONTROLLED_AREA, //將自畫區域放在前面,這樣就不防礙后面控件顯示及操作
DM_LIST1,
DM_BUTTON_BAR1,
};
const S16 coordinate_set888[] =
{
DM_FULL_SCREEN_COORDINATE_FLAG,
DM_FULL_SCREEN_COORDINATE_FLAG, //此控件為全屏大小
, MMI_CONTENT_Y + 5, 136, MMI_CONTENT_HEIGHT - 40, DM_NO_FLAGS,
DM_DEFAULT_BUTTON_BAR_FLAG, MMI_SOFTKEY_WIDTH
};
修改CategoryScreen:
//將當前觸摸屏操作以文本形式顯示出來
void DrawCate888PenStatus(U8* event_type, mmi_pen_point_struct point)
{
S32 x, y;
color text_color = {255, 0, 0, 100};
gdi_layer_lock_frame_buffer();
gui_reset_clip();
gui_set_text_color(text_color);
x = 20;
y = 170;
gui_move_text_cursor(x, y);
gui_fill_rectangle(0, y - 3, UI_device_width - 1, y + 20 + 3, UI_COLOR_WHITE);
gui_printf((UI_string_type)"%s {%d, %d}",event_type, point.x, point.y);
gdi_layer_unlock_frame_buffer();
gui_BLT_double_buffer(0, y, UI_device_width - 1, y + 20);
}
//繪制自畫區域
void DrawCate888CategoryControlArea(dm_coordinates *coordinate)
{
mmi_pen_point_struct point = {-1, -1};
DrawCate888PenStatus("Pen None", point);
}
//觸摸筆按下響應函數
MMI_BOOL Cate888CategoryControlAreaPenDownHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen Down", point);
return TRUE;
}
//觸摸筆放開響應函數
MMI_BOOL Cate888CategoryControlAreaPenUpHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen Up", point);
return TRUE;
}
//觸摸筆移動響應函數
MMI_BOOL Cate888CategoryControlAreaPenMoveHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen Move", point);
return TRUE;
}
//觸摸筆重復響應函數
MMI_BOOL Cate888CategoryControlAreaPenRepeatHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen Repeat", point);
return TRUE;
}
//觸摸筆長按響應函數
MMI_BOOL Cate888CategoryControlAreaPenLongTapHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen LongTap", point);
return TRUE;
}
//觸摸筆中止響應函數
MMI_BOOL Cate888CategoryControlAreaPenAbortHandler(mmi_pen_point_struct point)
{
DrawCate888PenStatus("Pen Abort", point);
return TRUE;
}
void ShowCategory888Screen(
U16 left_softkey, U16 left_softkey_icon, U16 right_softkey, U16 right_softkey_icon,
S32 number_of_items, U16 *list_of_items, U16 *list_of_icons,
S32 highlighted_item, U8 *history_buffer)
{
… …
//初始化自畫區域
dm_register_category_controlled_callback(DrawCate888CategoryControlArea); //注冊自畫區域繪制函數
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆按下響應函數
Cate888CategoryControlAreaPenDownHandler, MMI_PEN_EVENT_DOWN);
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆放開響應函數
Cate888CategoryControlAreaPenUpHandler, MMI_PEN_EVENT_UP);
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆移動響應函數
Cate888CategoryControlAreaPenMoveHandler, MMI_PEN_EVENT_MOVE);
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆重復響應函數
Cate888CategoryControlAreaPenRepeatHandler, MMI_PEN_EVENT_REPEAT);
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆長按響應函數
Cate888CategoryControlAreaPenLongTapHandler, MMI_PEN_EVENT_LONG_TAP);
wgui_register_category_screen_control_area_pen_handlers(//注冊自畫區域觸摸筆中止響應函數
Cate888CategoryControlAreaPenAbortHandler, MMI_PEN_EVENT_ABORT);
gdi_layer_unlock_frame_buffer();
ExitCategoryFunction = ExitCategory888Screen;
… …
dm_redraw_category_screen();
|
|