⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calculator.c

📁 mtk工具箱,计算器的详细设计,可以由此入手了解mtk的
💻 C
📖 第 1 页 / 共 5 页
字号:
            gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - 4, CALC_OPERAND2_Y);
        }
        else
        {
            gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
        }
    #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
        gui_print_character(CALC_SYM_ZERO);
    }
    else
    {
        if (g_calc_cntx->Operator == CALC_OP_EQUAL)
        {
            op = CALC_SYM_EQUAL;

            temp_int = (S32) g_calc_cntx->Operand1;
            if (temp_int == g_calc_cntx->Operand1)
            {
                sprintf(ansii_str, "%d", temp_int);
                AnsiiToUnicodeString((S8*) uni_s, (S8*) ansii_str);
            }
            else
            {
                CalcDouble2String(g_calc_cntx->Operand1, uni_s, CALC_MAX_DIGITS);
                g_calc_cntx->Operand1 = gui_atof((UI_string_type) uni_s);
            }
            w = gui_get_string_width((UI_string_type) uni_s);

        #if defined(__MMI_TOUCH_CALCULATOR__)
            if (r2lMMIFlag)
            {
                gui_move_text_cursor(
                    calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                    calculator_keypad.operand2_y);
            }
            else
            {
                gui_move_text_cursor(
                    calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                    calculator_keypad.operand2_y);
            }
        #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
            if (r2lMMIFlag)
            {
                gui_move_text_cursor(
                    CALC_SCR_X + CALC_SCR_WIDTH - 4,
                    CALC_OPERAND2_Y);
            }
            else
            {
                gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
            }
        #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
            gui_print_text((UI_string_type) uni_s);
        }
        else if (g_calc_cntx->Operator == CALC_OP_NONE)
        {
            if (g_calc_cntx->CurrHilite < CALC_OP_EQUAL)    /* +,-,*,/ */
            {
                switch (g_calc_cntx->CurrHilite)
                {
                    case CALC_OP_PLUS:
                        op = CALC_SYM_PLUS;
                        break;
                    case CALC_OP_MINUS:
                        op = CALC_SYM_MINUS;
                        break;
                    case CALC_OP_MULT:
                        op = CALC_SYM_MUL;
                        break;
                    case CALC_OP_DIV:
                        op = CALC_SYM_DIV;
                        break;
                    default:
                        break;
                }

                temp_res = gui_atof((UI_string_type) g_calc_cntx->Operand2Buf);
                CalcDouble2String(temp_res, uni_s, CALC_MAX_DIGITS);

                w = gui_get_string_width((UI_string_type) uni_s);

            #if defined(__MMI_TOUCH_CALCULATOR__)
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                        calculator_keypad.operand2_y);
                }
                else
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                        calculator_keypad.operand2_y);
                }
            #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        CALC_SCR_X + CALC_SCR_WIDTH - 4,
                        CALC_OPERAND1_Y);
                }
                else
                {
                    gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND1_Y);
                }
            #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                gui_print_text((UI_string_type) uni_s);

                w = gui_get_character_width(CALC_SYM_ZERO);
            #if defined(__MMI_TOUCH_CALCULATOR__)
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                        calculator_keypad.operand2_y);
                }
                else
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                        calculator_keypad.operand2_y);
                }
            #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        CALC_SCR_X + CALC_SCR_WIDTH - 4,
                        CALC_OPERAND2_Y);
                }            
                else
                {
                    gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
                }
            #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 

                gui_print_character(CALC_SYM_ZERO);
            }
            else
            {
                op = CALC_SYM_NULL;
                if (g_calc_cntx->Operand2Buf[0] == CALC_SYM_NULL)
                {
                    w = gui_get_character_width(CALC_SYM_ZERO);

                #if defined(__MMI_TOUCH_CALCULATOR__)
                    if (r2lMMIFlag)
                    {
                        gui_move_text_cursor(
                            calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                            calculator_keypad.operand2_y);
                    }
                    else
                    {
                        gui_move_text_cursor(
                            calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                            calculator_keypad.operand2_y);
                    }
                #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                    if (r2lMMIFlag)
                    {
                        gui_move_text_cursor(
                            CALC_SCR_X + CALC_SCR_WIDTH - 4,
                            CALC_OPERAND2_Y);
                    }     
                    else
                    {
                        gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
                    }
                #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                    gui_print_character(CALC_SYM_ZERO);
                }
                else
                {
                    w = gui_get_string_width(g_calc_cntx->Operand2Buf);

                #if defined(__MMI_TOUCH_CALCULATOR__)
                    if (r2lMMIFlag)
                    {
                        gui_move_text_cursor(
                            calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                            calculator_keypad.operand2_y);
                    }
                    else
                    {
                        gui_move_text_cursor(
                            calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                            calculator_keypad.operand2_y);
                    }
                #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                    if (r2lMMIFlag)
                    {
                        gui_move_text_cursor(
                            CALC_SCR_X + CALC_SCR_WIDTH - 4,
                            CALC_OPERAND2_Y);
                    }         
                    else
                    {
                        gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
                    }
                #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                    gui_print_text(g_calc_cntx->Operand2Buf);
                }
            }
        }
        else
        {
            switch (g_calc_cntx->Operator)
            {
                case CALC_OP_PLUS:
                    op = CALC_SYM_PLUS;
                    break;
                case CALC_OP_MINUS:
                    op = CALC_SYM_MINUS;
                    break;
                case CALC_OP_MULT:
                    op = CALC_SYM_MUL;
                    break;
                case CALC_OP_DIV:
                    op = CALC_SYM_DIV;
                    break;
                default:
                    break;
            }

            CalcDouble2String(g_calc_cntx->Operand1, uni_s, CALC_MAX_DIGITS);
            g_calc_cntx->Operand1 = gui_atof((UI_string_type) uni_s);

            w = gui_get_string_width((UI_string_type) uni_s);
        #if defined(__MMI_TOUCH_CALCULATOR__)
            if (r2lMMIFlag)
            {
                gui_move_text_cursor(
                    calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                    calculator_keypad.operand1_y);
            }
            else
            {
                gui_move_text_cursor(
                    calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                    calculator_keypad.operand1_y);
            }
        #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
            if (r2lMMIFlag)
            {
                gui_move_text_cursor(
                    CALC_SCR_X + CALC_SCR_WIDTH - 4,
                    CALC_OPERAND1_Y);
            }        
            else
            {
                gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND1_Y);
            }
        #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
            gui_print_text((UI_string_type) uni_s);

            w = gui_get_string_width(g_calc_cntx->Operand2Buf);
            if (g_calc_cntx->Operand2Buf[0] == CALC_SYM_NULL)
            {
                w = gui_get_character_width(CALC_SYM_ZERO);
            #if defined(__MMI_TOUCH_CALCULATOR__)
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                        calculator_keypad.operand2_y);
                }
                else
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                        calculator_keypad.operand2_y);
                }
            #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        CALC_SCR_X + CALC_SCR_WIDTH - 4,
                        CALC_OPERAND2_Y);
                }
                else
                {
                    gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
                }
            #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 

                gui_print_character(CALC_SYM_ZERO);
            }
            else
            {
            #if defined(__MMI_TOUCH_CALCULATOR__)
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - 4,
                        calculator_keypad.operand2_y);
                }
                else
                {
                    gui_move_text_cursor(
                        calculator_keypad.result_area_x + CALC_TOUCH_RESULT_AREA_WIDTH - w - 4,
                        calculator_keypad.operand2_y);
                }
            #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                if (r2lMMIFlag)
                {
                    gui_move_text_cursor(
                        CALC_SCR_X + CALC_SCR_WIDTH - 4,
                        CALC_OPERAND2_Y);
                }   
                else
                {
                    gui_move_text_cursor(CALC_SCR_X + CALC_SCR_WIDTH - w - 4, CALC_OPERAND2_Y);
                }
            #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
                gui_print_text(g_calc_cntx->Operand2Buf);
            }
        }
    #ifndef __MMI_SLIM_CALCULATOR__
        /* memory field */
        CalcDouble2String(g_calc_cntx->MemValue, uni_memory, CALC_MAX_DIGITS);
        g_calc_cntx->MemValue = gui_atof((UI_string_type) uni_memory);
        UCS2Strcat((S8*) uni_memory, (S8*) (L" "));
        w = gui_get_string_width((UI_string_type) uni_memory);
    #if defined(__MMI_TOUCH_CALCULATOR__)
        if (r2lMMIFlag)
        {
            gui_move_text_cursor(
                calculator_keypad.result_area_x + calculator_keypad.mem_x1 - 4,
                calculator_keypad.mem_y1);
        }    
        else
        {
            gui_move_text_cursor(
                calculator_keypad.result_area_x + calculator_keypad.mem_x1 - w - 4,
                calculator_keypad.mem_y1);
        }
    #else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
        if (r2lMMIFlag)
        {
            gui_move_text_cursor(CALC_SCR_X + CALC_MEM_X2 - 4, CALC_MEM_Y1);
        }    
        else
        {
            gui_move_text_cursor(CALC_SCR_X + CALC_MEM_X2 - w - 4, CALC_MEM_Y1);
        }
    #endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
        gui_print_text((UI_string_type) uni_memory);
    #endif /* __MMI_SLIM_CALCULATOR__ */ 
    }   /* if(g_calc_cntx->ResultState == RESULT_EXCEED) */

    /* operator */
#if defined(__MMI_TOUCH_CALCULATOR__)        
    if (r2lMMIFlag)
    {
        gui_move_text_cursor(calculator_keypad.operator_x + CALC_RESERVED_SPACE_FOR_OPERATOR, calculator_keypad.operator_y);
    }
    else
    {
        gui_move_text_cursor(calculator_keypad.operator_x, calculator_keypad.operator_y);
    }
#else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
    if (r2lMMIFlag)
    {
       gui_move_text_cursor(CALC_OPERATOR_X + CALC_RESERVED_SPACE_FOR_OPERATOR, CALC_OPERATOR_Y);
    }
    else
    {
        gui_move_text_cursor(CALC_OPERATOR_X, CALC_OPERATOR_Y);
    }
#endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
    gui_print_character((UI_character_type) op);

    if (g_calc_cntx->RSKState == CALC_RSK_CLEAR)
    {
        CalcSetRSKClear();
    }
    else
    {
        CalcSetRSKBack();
    }

    show_softkey_background();
    show_left_softkey();
    show_right_softkey();

    gui_unlock_double_buffer();
#if defined(__MMI_TOUCH_CALCULATOR__)
    gui_BLT_double_buffer(
        TOUCH_CALC_SCREEN_X,
        TOUCH_CALC_SCREEN_Y,
        TOUCH_CALC_SCREEN_X + TOUCH_CALC_SCREEN_WIDTH - 1,
        TOUCH_CALC_SCREEN_Y + TOUCH_CALC_SCREEN_HEIGHT - 1);
#else /* defined(__MMI_TOUCH_CALCULATOR__) */ 
    gui_BLT_double_buffer(CALC_SCR_X, CALC_SCR_Y, CALC_SCR_X + CALC_SCR_WIDTH - 1, CALC_SCR_Y + CALC_SCR_HEIGHT - 1);
#endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
}

/* 041205 Calvin added */
#if defined(__MMI_TOUCH_CALCULATOR__) /* && defined(__MMI_MAINLCD_240X320__) */ /* 060105 Calvin modified */
extern MMI_ID_TYPE idle_screen_wallpaper_ID;
extern gdi_handle wgui_base_layer;
extern gdi_handle wgui_layer_1;
#endif /* defined(__MMI_TOUCH_CALCULATOR__) */ 
/* Calvin end */


/*****************************************************************************
 * FUNCTION
 *  CalcRedraw
 * DESCRIPTION

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -