6253下的文件左边管理比较混乱(其他版本其实也很混乱)。总结来说,常用的坐标文件模板有两类。
1.模板坐标结构体。
MTK中大量使用了模板,即ShowCategories***。每个category_screen模板都有默认的坐标文件。下面以6253平台为例进行介绍。
很多函数中最终调用dm_redraw_category_screen()实现category_screen的重绘。即一般的showcategories函数最后部分会有类似如下代码:
dm_setup_category_functions(dm_redraw_category_screen, dm_get_category_history, dm_get_category_history_size);
dm_data.s32ScrId = (S32) GetActiveScreenId();
dm_data.s32CatId = MMI_CATEGORYXXX_ID;
dm_data.s32flags = DM_CLEAR_SCREEN_BACKGROUND;
dm_setup_data(&dm_data);
dm_redraw_category_screen();
跟踪函数dm_redraw_category_screen()会发现这样一条语句:
UICtrlAccessPtr_p = dm_search_coordinate_set(g_dm_data.s32ScrId);
其中g_dm_data.s32ScrId为通过dm_setup_data(&dm_data)实现的参数。UICtrlAccessPtr_p为S16指针,用于记录结构体地址。此函数旨在获取当前active窗体坐标结构体的首地址。再通过指针UICtrlAccessPtr_p即可实现灵活的结构体赋值与使用。
dm_search_coordinate_set()函数实现如下:
S16 *dm_search_coordinate_set(S32 ScrId)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
S32 StartIndex = 0;
S32 EndIndex = dm_get_coordinate_sets_count();
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
while (EndIndex >= StartIndex)
{
S32 MiddleIndex = (EndIndex + StartIndex) >> 1;
if (g_screenid_coordinate_sets_map[MiddleIndex].screen_id == ScrId)
{
return g_screenid_coordinate_sets_map[MiddleIndex].coordinate_set_p;
}
else if (g_screenid_coordinate_sets_map[MiddleIndex].screen_id > ScrId)
{
EndIndex = MiddleIndex - 1;
}
else
{
StartIndex = MiddleIndex + 1;
}
}
return NULL;
} /* end of dm_search_coordinate_set */
其返回值为结构体g_screenid_coordinate_sets_map[MiddleIndex].coordinate_set_p内容。
而此函数后面有语句UICtrlAccessPtr_p = dm_get_cat_scr_coordinates(UICtrlAccessPtr_p, &dm_cat_scr_info)获取窗体 MMI_CATEGORYXXX_ID的参数,这是因为很多category screen的尺寸不同于LCD尺寸。dm_get_cat_scr_coordinates()函数代码就不贴在这里了,可以自行查阅。其获取的到的结构体定义举例如下:
const S16 coordinate_set306[] =
{
/* Category Screen Coordinates */
DM_FULL_SCREEN_COORDINATE_FLAG,
/* Control area */
DM_FULL_SCREEN_COORDINATE_FLAG,
/* Stop Watch */
0, 0, MAIN_LCD_DEVICE_WIDTH, MAIN_LCD_DEVICE_HEIGHT - MMI_BUTTON_BAR_HEIGHT, DM_NO_FLAGS,
57,33, /* nWay_maintimer_start */
214, 62, /* nWay_maintimer_end */
31,84, /* nWay_dialog_start */
MAIN_LCD_DEVICE_WIDTH -40, 255, /* nWay_dialog_end */
21, /* Separator Height */
DM_DEFAULT_BUTTON_BAR_FLAG, MMI_SOFTKEY_WIDTH /* Button Bar */
};
此为stopwatch下的坐标文件。
当为stopwatch执行Redraw()函数时:
case DM_TYPICAL_STOPWATCH:
{
dm_setup_and_draw_typical_stopwatch(&UICtrlAccessPtr_p);
break;
}
dm_setup_and_draw_typical_stopwatch()函数内容如下:
S32 dm_setup_and_draw_typical_stopwatch(S16 **UICtrlAccessPtr_p)
{
#ifdef __MMI_STOPWATCH__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
dm_typical_stopwatch_info_struct dm_typical_stopwatch_info;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
*UICtrlAccessPtr_p = dm_get_typical_stopwatch_coordinates(*UICtrlAccessPtr_p, &dm_typical_stopwatch_info);
……
}
dm_get_typical_stopwatch_coordinates()函数的定义如下:
S16 *dm_get_typical_stopwatch_coordinates(
S16 *UICtrlAccessPtr_p,
dm_typical_stopwatch_info_struct *dm_typical_stopwatch_info)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
UICtrlAccessPtr_p = dm_get_coordinates(UICtrlAccessPtr_p, &dm_typical_stopwatch_info->coordinate);
dm_typical_stopwatch_info->typ_timer_x = *UICtrlAccessPtr_p;
UICtrlAccessPtr_p++;
dm_typical_stopwatch_info->typ_timer_y = *UICtrlAccessPtr_p;
UICtrlAccessPtr_p++;
dm_typical_stopwatch_info->typ_milsec_x = *UICtrlAccessPtr_p;
UICtrlAccessPtr_p++;
dm_typical_stopwatch_info->typ_milsec_y = *UICtrlAccessPtr_p;
UICtrlAccessPtr_p++;
dm_typical_stopwatch_info->typ_history_height = *UICtrlAccessPtr_p;
UICtrlAccessPtr_p++;
dm_typical_stopwatch_info->typ_timer_x += dm_typical_stopwatch_info->coordinate.s16X;
dm_typical_stopwatch_info->typ_timer_y += dm_typical_stopwatch_info->coordinate.s16Y;
dm_typical_stopwatch_info->typ_milsec_x += dm_typical_stopwatch_info->coordinate.s16X;
dm_typical_stopwatch_info->typ_milsec_y += dm_typical_stopwatch_info->coordinate.s16Y;
return UICtrlAccessPtr_p;
}
而dm_get_coordinates()用于查找任意control的坐标值。可通过指针UICtrlAccessPtr_p灵活实现dm_typical_stopwatch_info的赋值。同时dm_get_typical_stopwatch_coordinates()等函数又实现dm_typical_stopwatch_info->coordinate其他属性的赋值,如此最终获取了stopwatch坐标结构体的地址,实现了坐标赋值。
此方法实现相对复杂,但是应用灵活,扩展性好,实现过程也很巧妙。
2.类似vdorec的皮肤文件(按名字翻译,其实就是坐标结构体):resource_camera_skins.c
其坐标代码如下(部分):
vdorec_osd_vdorec_layout_struct g_vdorec_osd_cntx =
{
/****** bg ******/
{{0,0,0,0}, /* region 0 */
{0,0,0,0}, /* region 1 */
{0,0,0, 0}, /* region 2 */
{0, 0, 0, 0}}, /* region 3 */
/****** title ******/
{VIDEO_ALIGN_LEFT,VIDEO_ALIGN_CENTER,FALSE,FALSE,
{0,0,0,0},
{255,255,255,0,0,0,VIDEO_TEXT_STYLE_BORDER}},
/****** preview_wnd ******/
{{0,12,128,104}},
/****** panel ******/
{{2,2}, /* ev */
{48,2}, /* ev_inc */
{36,2}, /* ev_dec */
{75,2}, /* zoom */
{100,2}, /* zoom_inc */
{111,2}, /* zoom_dec */
{10,100}, /* timer */
{11,98}, /* timer_bg */
{50, 0}, /* progress bar */
{92,89}}, /* state */
/****** status ******/
{TRUE,
{FALSE, 106, 22}, /* video size*/
{FALSE, 106, 42}, /* video qty*/
{TRUE, 106, 62}, /* nigth icon */
{FALSE, 106, 82}, /* wb*/
{TRUE, 106, 0}, /* led highlight icon */
{TRUE, 106,0}, /* record aud icon */
{FALSE,106,0}, /* size limit icon */
{FALSE,106,0}}, /* time limit icon */
/****** softkey ******/
{TRUE, /* is_lsk_icon */
TRUE, /* is_rsk_icon */
TRUE, /* is_ck_icon */
{2,105}, /* icon_lsk_pos */
{103,105}, /* icon_rsk_pos */
{53,105}, /* icon_ck_pos */
{0,110,128,18},
{255,255,255,0,0,0,VIDEO_TEXT_STYLE_BORDER}, /* lsk */
{255,255,255,0,0,0,VIDEO_TEXT_STYLE_BORDER}}, /* rsk */
/****** hint ******/
{FALSE,{0,0,0,0},
{255,255,255,0,0,0,VIDEO_TEXT_STYLE_BORDER}} /* text_style */
};
其结构体结构可在代码中自行查找。
其使用过程相对明了。
声明本文件下的结构体: vdorec_context_struct g_vdorec_cntx;
使用即直接复制即可:
g_vdorec_cntx.preview_wnd_width = g_vdorec_osd_cntx.preview_wnd.rect.width;
g_vdorec_cntx.preview_wnd_height = g_vdorec_osd_cntx.preview_wnd.rect.height;
g_vdorec_cntx.preview_wnd_offset_x = g_vdorec_osd_cntx.preview_wnd.rect.offset_x;
g_vdorec_cntx.preview_wnd_offset_y = g_vdorec_osd_cntx.preview_wnd.rect.offset_y;
此方法实现相对简单。