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

📄 oskernel.c

📁 好记星的控件,包括button,list,对文件操作
💻 C
📖 第 1 页 / 共 4 页
字号:

            // 优先事件处理
            if ( g_fpKernelEventPrev )
            {
                if ( g_fpKernelEventPrev ( aEvent[0], aEvent[1] ) )
                    continue;
            }

            // 处理按键事件
            if ( (aEvent[0] == EVENT_KEY) || (aEvent[0] == EVENT_KEYREPEAT)|| (aEvent[0] == EVENT_KEYUP))
            {
                if (OsKnlKeyBeepHook(aEvent[0],aEvent[1]))
                    aEvent[0] = EVENT_NOTHING;

                if ( _GuiModelHandleKey(aEvent[0], aEvent[1]) )
                    aEvent[0] = EVENT_NOTHING;
            }
			// 处理显示事件
			else if ( aEvent[0] == EVENT_DRAW )
			{	// 谢永良 add 2006.1.11
				_GuiModelDraw();
			}
            // 其它事件
            else
            {
                if ( _GuiModelHandleEvent( aEvent[0], aEvent[1] ) )
                    aEvent[0] = EVENT_NOTHING;
            }

           // 滞后事件处理
            if ( (aEvent[0] != EVENT_NOTHING) && (g_fpKernelEventBehind != NULL) )
                g_fpKernelEventBehind ( aEvent[0], aEvent[1] );
        }
    }

    // 计算当前模板中GUI控件个数,并从总GUI控件个数中减去它
    uCount = 0;
    while ( g_pCurrGuiModel->uReserveMark != NULL )
    {
        uCount++;
        g_pCurrGuiModel->uReserveMark = NULL;
        g_pCurrGuiModel++;
    }
    g_uTotalGuiCount -= uCount;
    // 恢复前一GUI模板
    g_pCurrGuiModel = pPrevGuiModel;

    //==============================
    // Dec Hel ID Level
    DecGuiHelpLevel();

#ifdef GUI_INIT_DRAW_FG_EN
    // After this GUI Draw is Disable
    // Here can not disable, because the GUI Group is not present
    //_GuiFlagSet(XX,
    //           g_uTotalGuiCount-1,GUI_DRAW_STATUS_DIS);

#endif
    
    // (恢复方向键和和发音相关的INDICATOR)

    nExitCode = g_nKnlExitCode;
    // 如果是关机退出、热键退出或退出到主界面,应该再退出上一级APGUI
    //if( (g_nKnlExitCode >= 0) && (g_nKnlExitCode < 100) && (g_nKnlExitCode != EXIT_CODE_NORMAL) )
    if ( (g_nKnlExitCode >= EXIT_CODE_FORCE_START) && (g_nKnlExitCode <= EXIT_CODE_FORCE_END) )
    {
        g_nKnlExitStatus = KNLEXITSTATUS_ASK;
        //g_nKnlExitCode = g_nKnlExitCode;
    }
    else
        g_nKnlExitCode = EXIT_CODE_NORMAL;


	// fOR memory check
#ifdef	_WIN32
	MemCheckEnd();
#endif

    // 返回退出代码
    return nExitCode;
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelInitialize(VOID)                              */
/* DESCRIPTION:初始化AP及其控件                                            */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/****************************************************************************/
static  VOID _GuiModelInitialize(VOID)
{
    APGUI_STRUCT_MODEL  *pGui;

    // 先初始化AP的内部控件
    pGui = (APGUI_STRUCT_MODEL*)(g_pCurrGuiModel + 1);
    while( pGui->uReserveMark != 0 )
    {
        pGui->fpHandleFunc( pGui, EVENT_INITIALIZE, 0 );
        pGui++;
    }

    // 再初始化输入法
    //dennyhan changed the following to IME structure
    if ( ((IMEGUI_STRUCT*)g_pCurrGuiModel)->uCurrentIme )
    {
        UINT  uEvent, uParam;
        uEvent = EVENT_INITIALIZE;
        uParam = 0;
        //dennyhan changed the following to IME structure
		//IMeManager( (APGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
        IMeManager( (IMEGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
    }

    // 最后初始化AP
    g_pCurrGuiModel->fpHandleFunc( (APGUI_STRUCT_MODEL*)g_pCurrGuiModel, EVENT_INITIALIZE, 0 );
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelExitAp(INT nExitCode)                         */
/* DESCRIPTION:退出AP                                                      */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/****************************************************************************/
static  VOID _GuiModelExitAp(INT nExitCode)
{
    INT     nRet;

    // 询问AP是否退出
    nRet = g_pCurrGuiModel->fpHandleFunc( (APGUI_STRUCT_MODEL*)g_pCurrGuiModel, EVENT_EXIT, nExitCode );
    if ( nRet == 0 )
        ExitAp(nExitCode);
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelDestroyAp(VOID)                               */
/* DESCRIPTION:销毁AP                                                      */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/****************************************************************************/
static  VOID _GuiModelDestroyAp(VOID)
{
    APGUI_STRUCT_MODEL  *pGui;

    // 依次将销毁消息发给AP和其控件进行处理
    pGui = (APGUI_STRUCT_MODEL*)g_pCurrGuiModel;
    while( pGui->uReserveMark != 0 )
    {
        pGui->fpHandleFunc( pGui, EVENT_DESTROY, 0 );
        pGui++;
    }
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelDraw(VOID)                                    */
/* DESCRIPTION:显示当前AP                                                  */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/****************************************************************************/
static  VOID _GuiModelDraw(VOID)
{
    APGUI_STRUCT_MODEL  *pGui;

    // 禁止刷新屏幕
    GraphDisableRefresh();

    // 依次将消息发给AP和其控件进行处理
    pGui = (APGUI_STRUCT_MODEL*)g_pCurrGuiModel;
    
    while( pGui->uReserveMark != 0 )
    {
        pGui->fpHandleFunc( pGui, EVENT_DRAW, 0 );
        pGui++;
    }

    // 如果有输入法,最后将显示消息发给输入法处理
    //dennyhan changed the followi1ng to IME structure
    if ( ((IMEGUI_STRUCT*)g_pCurrGuiModel)->uCurrentIme )
    {
        UINT  uEvent, uParam;
        uEvent = EVENT_DRAW;
        uParam = 0;
        //dennyhan changed the following to IME structure
        //IMeManager( (APGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
        IMeManager( (IMEGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
    }

    // 允许刷新屏幕
    GraphEnableRefresh();
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelDraw_All(VOID)                                */
/* DESCRIPTION:显示当前AP                                                  */
/* INPUTS:     NONE                                                        */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/*  DennyHan    2006.05.24          Check Init Flag                         */
/****************************************************************************/
static  VOID _GuiModelDraw_All(VOID)
{
    APGUI_STRUCT_MODEL  *pGui;

    // 禁止刷新屏幕
    GraphDisableRefresh();

    // 依次将消息发给AP和其控件进行处理
    pGui = (APGUI_STRUCT_MODEL*)g_pCurrGuiModel;

    if ( (pGui->uWidth < LCD_SCREEN_WIDTH) || (pGui->uHeight < LCD_SCREEN_HEIGHT) )
    {
        //pGui = (APGUI_STRUCT_MODEL*)g_aGuiBuffer;
        // 从后往前找到一个能显示全屏的窗口
        while ( (pGui->uWidth < LCD_SCREEN_WIDTH) || (pGui->uHeight < LCD_SCREEN_HEIGHT) )
            pGui--;
    }
    
#ifdef GUI_INIT_DRAW_FG_EN    
    // Seek Again Here:  ??????

#endif    

    while( pGui->uReserveMark != 0 )
    {
    #ifdef GUI_INIT_DRAW_FG_EN
        if (   _GuiFlagGet( pGui - (APGUI_STRUCT_MODEL*)g_aGuiBuffer)
            ==  GUI_DRAW_STATUS_EN )
        {
            pGui->fpHandleFunc( pGui, EVENT_DRAW, 0 );
        }
    #else
        pGui->fpHandleFunc( pGui, EVENT_DRAW, 0 );
    #endif        
        pGui++;    
    }

    // 如果有输入法,最后将显示消息发给输入法处理
    //dennyhan changed the following to IME structure
    if ( ((IMEGUI_STRUCT*)g_pCurrGuiModel)->uCurrentIme )
    {
        UINT  uEvent, uParam;
        uEvent = EVENT_DRAW;
        uParam = 0;
        //dennyhan changed the following to IME structure
        //IMeManager( (APGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
    #ifdef GUI_INIT_DRAW_FG_EN
        if (   _GuiFlagGet( g_pCurrGuiModel - (APGUI_STRUCT_MODEL*)g_aGuiBuffer)
            ==  GUI_DRAW_STATUS_EN )
        {
            IMeManager( (IMEGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam);
        }
    #else
        IMeManager( (IMEGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam );
    #endif
    }

    // 允许刷新屏幕
    GraphEnableRefresh();
}

/****************************************************************************/
/* FUNCTION:   VOID _GuiModelHandleKey(UINT uEvent, UINT uParam)           */
/* DESCRIPTION:GUI模板处理按健事件                                         */
/* INPUTS:     uEvent - 要处理的按键事件类型                               */
/*              uParam - 要处理的按键键值                                   */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */
/****************************************************************************/
/*    NAME         DATE               REMARKS                               */
/* ==========  ============   ==============================================*/
/*   谢永良     2005-03-31          创建                                    */
/****************************************************************************/
static  BOOL _GuiModelHandleKey(UINT uEvent, UINT uParam)
{
    uParam &= 0x7FFFFFFF;


    // 先将按键事件发给输入法处理
    //dennyhan changed the following to IME structure
    if ( (((IMEGUI_STRUCT*)g_pCurrGuiModel)->uCurrentIme != NULL) )
    {
        //dennyhan changed the following to IME structure
        //IMeManager( (APGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam);
        IMeManager( (IMEGUI_STRUCT*)g_pCurrGuiModel, &uEvent, &uParam);
        if ( uEvent == EVENT_NOTHING )
            return TRUE;
    }

    if ( _GuiModelHandleEvent(uEvent, uParam) )
        return TRUE;

    return FALSE;
}

/****************************************************************************/
/* FUNCTION:   INT _GuiModelHandleEvent(UINT uEvent, UINT uParam)          */
/* DESCRIPTION:GUI模板通用事件处理                                         */
/* INPUTS:     uEvent - 要处理的事件                                       */
/*              uParam - 对应事件的参数                                     */
/* OUTPUTS:    NONE                                                        */
/* RETURN:     NONE                                                        */

⌨️ 快捷键说明

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