📄 widget_ctk.c
字号:
* HDIa_widgetExtCreateTextViewSeparator
* DESCRIPTION
*
* PARAMETERS
* modId [IN]
* text [IN]
* str_title [IN]
* img_title [IN]
* RETURNS
*
*****************************************************************************/
MsfWindowHandle HDIa_widgetExtCreateTextViewSeparator(
MSF_UINT8 modId,
const kal_uint8 *text,
ctk_string_id str_title,
ctk_image_id img_title)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_screen_handle scrid;
ctk_layout_handle layoutid;
ctk_pcategory_create_struct layout_create;
widget_ctk_text_view_struct *context;
MsfWindowHandle ctk;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
WAP_DBG_ASSERT(widget_ctk_appid);
/* Create CTK screen */
scrid = widget_ctk_screen_create();
ctk_screen_set_on_post_close_handler(scrid, widget_ctk_text_view_on_post_close);
/* Set context */
context = MSF_MEM_ALLOC(modId, sizeof(widget_ctk_text_view_struct));
context->modId = modId;
context->str_title = str_title;
context->img_title = img_title;
context->text = widget_ucs2_strdup(modId, text);
context->flags = WIDGET_CTK_TEXT_VIEW_DRAW_SEPARATOR;
ctk_screen_set_local_data(scrid, context);
/* Create Layout */
CTK_INIT_STRUCT(layout_create);
layout_create.pcat_show_fp = widget_ctk_show_text_view;
layoutid = ctk_pcategory_create(widget_ctk_appid, &layout_create);
ctk_screen_attach_layout(scrid, layoutid);
/* create MsfWindow */
ctk = HDIa_widgetCtkCreate(modId, scrid);
_CTK(ctk)->ctk_predefined_type = WIDGET_CTK_PREDEFINED_TEXT_VIEW;
return ctk;
}
/*************************************************************************
* Please wait
*************************************************************************/
typedef struct
{
MSF_UINT8 modId;
ctk_string_id prompt_string;
} widget_ctk_wait_view_struct;
/* Callback function of displaying Category9 */
/*****************************************************************************
* FUNCTION
* widget_ctk_show_wait_view
* DESCRIPTION
*
* PARAMETERS
* layoutid [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_show_wait_view(ctk_layout_handle layoutid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_screen_handle scrid = ctk_layout_get_parent_screen(layoutid);
widget_ctk_wait_view_struct *context = (widget_ctk_wait_view_struct*) ctk_screen_get_local_data(scrid);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ShowCategory9Screen(context->prompt_string, SAT_WAIT_IMAGE_ID, NULL);
}
/*****************************************************************************
* FUNCTION
* widget_ctk_wait_view_on_post_close
* DESCRIPTION
*
* PARAMETERS
* scrid [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_wait_view_on_post_close(ctk_screen_handle scrid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
widget_ctk_wait_view_struct *context = (widget_ctk_wait_view_struct*) ctk_screen_get_local_data(scrid);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MSF_MEM_FREE(context->modId, context);
}
/*****************************************************************************
* FUNCTION
* HDIa_widgetExtCreateWaitView
* DESCRIPTION
* Create a "please wait" screen
* PARAMETERS
* modId [IN]
* prompt_string [IN]
* RETURNS
* handle of the created MsfWindow
*****************************************************************************/
MsfWindowHandle HDIa_widgetExtCreateWaitView(MSF_UINT8 modId, ctk_string_id prompt_string)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_screen_handle scrid;
ctk_layout_handle layoutid;
ctk_pcategory_create_struct layout_create;
MsfWindowHandle ctk;
widget_ctk_wait_view_struct *context;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Create CTK screen */
scrid = widget_ctk_screen_create();
ctk_screen_set_on_post_close_handler(scrid, widget_ctk_wait_view_on_post_close);
context = MSF_MEM_ALLOC(modId, sizeof(widget_ctk_wait_view_struct));
context->modId = modId;
context->prompt_string = prompt_string;
ctk_screen_set_local_data(scrid, context);
/* Create Layout */
CTK_INIT_STRUCT(layout_create);
layout_create.pcat_show_fp = widget_ctk_show_wait_view;
layoutid = ctk_pcategory_create(widget_ctk_appid, &layout_create);
ctk_screen_attach_layout(scrid, layoutid);
/* create MsfWindow */
ctk = HDIa_widgetCtkCreate(modId, scrid);
_CTK(ctk)->ctk_predefined_type = WIDGET_CTK_PREDEFINED_WAIT_VIEW;
_CTK(ctk)->ctk_flag |= WIDGET_CTK_FLAG_BACKLIGHT_ALWAYS_ON;
return ctk;
}
/*************************************************************************
* Progress view
*************************************************************************/
#define WIDGET_CTK_PROGRESS_BAR_UPDATE_NONE (0)
#define WIDGET_CTK_PROGRESS_BAR_UPDATE_REQ (1)
#define WIDGET_CTK_PROGRESS_BAR_UPDATE_DONE (2)
typedef struct
{
kal_uint8 update_state;
MSF_UINT8 modId;
ctk_string_id str_title;
ctk_image_id img_title;
MSF_UINT16 percent;
kal_uint8 *text1, *text2;
} widget_ctk_progress_view_struct;
/* Prevent reference of deallocated data */
/*****************************************************************************
* FUNCTION
* widget_ctk_progress_reset_title_if_necessary
* DESCRIPTION
*
* PARAMETERS
* context [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_progress_reset_title_if_necessary(widget_ctk_progress_view_struct *context)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (context->text1 && MMI_title_string == (UI_string_type) context->text1)
{
MMI_title_string = NULL;
}
}
/*****************************************************************************
* FUNCTION
* widget_ctk_show_progress_bar
* DESCRIPTION
*
* PARAMETERS
* layoutid [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_show_progress_bar(ctk_layout_handle layoutid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_screen_handle scrid = ctk_layout_get_parent_screen(layoutid);
widget_ctk_progress_view_struct *context = (widget_ctk_progress_view_struct*) ctk_screen_get_local_data(scrid);
ctk_string_id str1, str2;
ctk_image_id img1, img2;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* MMI categories typically require setting the softkey label before SetLeftSoftkeyFunction */
ctk_screen_get_LSK_label(scrid, &str1, &img1);
ctk_screen_get_RSK_label(scrid, &str2, &img2);
if (!ctk_screen_is_back_history(scrid) &&
context->update_state == WIDGET_CTK_PROGRESS_BAR_UPDATE_REQ)
{
UpdateCategory402Value(context->percent, context->text2);
context->update_state = WIDGET_CTK_PROGRESS_BAR_UPDATE_DONE;
}
else
{
/*
* Execute widget_ctk_show_progress_bar() first time
* after calling HDIa_widgetExtCreateProgressView() or
* goback history to progressView screen.
*/
ShowCategory402Screen(
(U8*)get_string(context->str_title),
widget_get_title_icon(context->img_title),
str1,
img1,
str2,
img2,
(context->text1) ? (U8*) context->text1 : (U8*) L"",
context->percent,
(context->text2) ? (U8*) context->text2 : (U8*) L"");
context->update_state = WIDGET_CTK_PROGRESS_BAR_UPDATE_DONE;
}
}
/*****************************************************************************
* FUNCTION
* widget_ctk_show_progress
* DESCRIPTION
*
* PARAMETERS
* layoutid [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_show_progress(ctk_layout_handle layoutid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
ctk_screen_handle scrid = ctk_layout_get_parent_screen(layoutid);
widget_ctk_progress_view_struct *context = (widget_ctk_progress_view_struct*) ctk_screen_get_local_data(scrid);
char percent[32];
kal_uint8 *percent_u;
ctk_string_id str1, str2;
ctk_image_id img1, img2;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ctk_screen_get_LSK_label(scrid, &str1, &img1);
ctk_screen_get_RSK_label(scrid, &str2, &img2);
#ifdef MMS_SUPPORT
if (context->percent == 0)
{
percent_u = (kal_uint8*) GetString(MEA_STR_ID_CONNECTING);
}
else
#endif /* MMS_SUPPORT */
{
sprintf(percent, "%d %%", context->percent);
percent_u = widget_ucs2_strdup_from_utf8(context->modId, (const kal_uint8*)percent);
}
/* Prevent title blinking */
gui_lock_double_buffer();
ShowCategory208Screen(
context->str_title,
widget_get_title_icon(context->img_title),
str1,
img1,
str2,
img2,
(S8*) percent_u,
IMG_NEW_SMS_SEND,
NULL);
#ifdef MMS_SUPPORT
/*
* original code: if (context->percent != 0)
*
* refer CR id [MAUI_00219542]
* In some strange situation, percent_u is the predefined string, but context->percent is 1.
*/
if (percent_u != (kal_uint8*) GetString(MEA_STR_ID_CONNECTING))
#endif /* MMS_SUPPORT */
{
MSF_MEM_FREE(context->modId, percent_u);
}
if (context->text1)
{
MMI_title_string = (UI_string_type) context->text1;
show_title_status_icon();
draw_title();
}
gui_unlock_double_buffer();
gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
}
/*****************************************************************************
* FUNCTION
* widget_ctk_progress_view_on_post_close
* DESCRIPTION
*
* PARAMETERS
* scrid [IN]
* RETURNS
* void
*****************************************************************************/
static void widget_ctk_progress_view_on_post_close(ctk_screen_handle scrid)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
widget_ctk_progress_view_struct *context = (widget_ctk_progress_view_struct*) ctk_screen_get_local_data(scrid);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
widget_ctk_progress_reset_title_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -