Mtk功能机,画界面的函数集

2018-11-25  本文已影响0人  Guoke24

第一次接触c语言开发的项目,故需要做一些笔记。

//画 出 空 白 屏 幕
static void ibox_scan_receipt_test_clean(void)
{
    
    S32 x1,y1,x2,y2;// 用两个坐标点来确定操作区域的位置
    x1 = 0;
    x2 = UI_device_width - 1;
    y1 = MMI_status_bar_height + MMI_title_height;// 状 态 栏 高 度 + title ,即 保留 状态栏 和 title
    //y1 = 0; // 整 块 屏 幕 选 这 个 值
    y2 = UI_device_height - 1;

// 不 加 这 行 无 效
#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_lock_double_buffer();
#endif 

    gdi_layer_push_and_set_clip(x1, y1, x2, y2); // 裁 剪 一 片 区 域
    gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT); //给 该 区 域 设 置 透 明 色

    // 此处可以添加画内容的代码,不添加即为空白屏幕
    
    gdi_layer_pop_clip();// 把 剪 裁 的 区 域 贴 到 屏 幕 上

#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_unlock_double_buffer();
    gui_BLT_double_buffer(x1, y1, x2, y2);
#endif 

}
// ------------
// 字符串id,需要声明在:plutommi\mmi\IBOXPay\IBOXPayRes\IBOXPayRes.res
// 定义在:plutommi\Customer\CustResource\PLUTO_MMI\ref_list.txt
static U16 s_scan_rece_string_id[] = {IBOXPAY_STR_ID_FLASH_PAY,IBOXPAY_STR_ID_QRCODE_PAY,
                                 IBOXPAY_STR_ID_SCAN_PAY};
// 画 出 菜 单
static void ibox_scan_receipt_test_draw_menu(int isFull)
{
    //画出菜单试试
    S32 x, y, x1, x2, y1, y2;
    S32 string_w, string_h;
    U16 menu_count;
    U16 i;
    U8 c_num[10] = {0};
    U8 w_num[20] = {0};
    U8 w_text[80] = {0};

    x1 = 0;
    x2 = UI_device_width - 1;
    y1 = MMI_status_bar_height + MMI_title_height;// 状态栏高度 加上 title高度
    if(isFull == 1){
        y1 = 0;
    }
    y2 = UI_device_height - 1;

    x = IBOX_LIST_MENU_START_GAP_X;
    y = y1 + IBOX_LIST_MENU_START_GAP_Y;

#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_lock_double_buffer();
#endif 

    gdi_layer_push_and_set_clip(x1, y1, x2, y2); // 裁剪
    gdi_draw_solid_rect(x1, y1, x2, y2, GDI_COLOR_TRANSPARENT); //白色
    gui_set_text_color(*(current_MMI_theme->list_normal_text_color)); // 字体颜色
    string_h = gui_get_string_height((UI_string_type)GetString(s_scan_rece_string_id[0])); // 文字高度
    menu_count = ARRAY_SIZE(s_scan_rece_string_id); // 行数

    // 循环地画出多行的菜单
    for (i=0; i<menu_count; i++)
    {
        memset(c_num, 0, sizeof(c_num)); // c_num 序号
        memset(w_num, 0, sizeof(w_num)); // w_num 序号
        memset(w_text, 0, sizeof(w_text)); // w_text 菜单项文字
        
        y = (y1 + IBOX_LIST_MENU_START_GAP_Y) + (string_h + IBOX_LIST_MENU_ITME_GAP) * i; // 计算y轴坐标

        sprintf(c_num,"%d. ", (i+1)); // 序号 以 “1.”的格式,输出到变量 c_num
        mmi_asc_to_ucs2((CHAR*)w_num, (CHAR*)c_num); // c_num asc格式转换为ucs格式 w_num
        mmi_ucs2cpy((CHAR*)w_text, (CHAR*)w_num); // 序号 填入 变量w_text
        mmi_ucs2cat((CHAR*)w_text, (CHAR*)GetString(s_scan_rece_string_id[i]));// 菜单项文字 追加填入到 变量w_text
        
        gui_move_text_cursor(x, y); // 坐标移动到新位置
        gui_print_text((UI_string_type)w_text); // 输出文字
    }


    gdi_layer_pop_clip();// 把剪裁的区域贴到屏幕上

#if(UI_DOUBLE_BUFFER_SUPPORT)
    gui_unlock_double_buffer();
    gui_BLT_double_buffer(x1, y1, x2, y2);
#endif 
}
// ------------
// 图片id,需要声明在:plutommi\mmi\IBOXPay\IBOXPayRes\IBOXPayRes.res
// <IMAGE id="IMAGE_ID_ACTIVATION_LOG">CUST_IMG_PATH"\\\\MainLCD\\\\Active\\\\poweronoff\\\\logo.bmp"</IMAGE>
// 画 出 二维码
static void ibox_scan_receipt_test_draw_qcode(void)
{
    int img_start_x, img_start_y;
    S32 img_width, img_height;
    
    char *qrcode = "ABCDFEGH";

    bool isEncodeSuccess = EncodeData( qrcode ); // 产生二维码编码
    
    //qrcode_printf("#### %s##%04d##%s##%s ###", get_log_time(), __LINE__, __FUNCTION__, __FILE__);
    if (!isEncodeSuccess) // 产生编码不成功,退出
    {
        //print_text_string(-1, "Generate QRcode failed");
        return;
    }
    
    // 清  空  屏  幕  空  间  , 打  点
    gdi_draw_solid_rect(0, 0, UI_device_width - 1, UI_device_height - 1, GDI_COLOR_WHITE);
    
    // 设 置 二 维 码 x 坐标 , 无 效 , Print_2DCode 函 数 内 会 重 置
    //qr_startX = (UI_device_width - 1) / 2 - qrcode_width / 2 ;  

    // 画  出  二  维  码
    Print_2DCode();

    //  get 图  片  大 小
    gdi_image_get_dimension_id(IMAGE_ID_ACTIVATION_LOG, &img_width, &img_height);
    
    // 设 置 二 维 码 中 间 图 片 的 位 置
    img_start_x = qr_startX + qrcode_width / 2 - img_width / 2;
    //img_start_x = qr_startX + qrcode_width  - img_width / 2;
    img_start_y = qr_startY + qrcode_width / 2 - img_height / 2;

    // 画  出  图  片
    gdi_image_draw_id(img_start_x, img_start_y, IMAGE_ID_ACTIVATION_LOG);

    // 刷  新  屏  幕
    gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
}
// ------------
// 画 一 些 东 西
static void ibox_scan_receipt_test_draw_something(void)
{
    // 红 色 文 字
    gui_move_text_cursor(50,100);
    gui_set_text_color(UI_COLOR_RED);
    gui_print_text((UI_string_type)GetString(IBOXPAY_STR_ID_SCAN_PAY));

    gui_draw_rectangle(30,30,UI_device_width - 30,UI_device_height - 30,UI_COLOR_RED);// 边 框

    // 黑 色 文 字
    gui_move_text_cursor(50,130);
    gui_set_text_color(UI_COLOR_BLACK);
    gui_print_bordered_text((UI_string_type)GetString(IBOXPAY_STR_ID_SCAN_PAY));

    // 画  出  图  片
    gdi_image_draw_id(100, 200, IMAGE_ID_ACTIVATION_LOG);

    // 刷  新  屏  幕
    gui_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
}
上一篇下一篇

猜你喜欢

热点阅读