示例#1
0
文件: d4d_base.c 项目: Learnee/eGUI
/**************************************************************************/ /*!
* @brief   Function inits the eGUI itself including all low level drivers.
* @param   pInitScreen - the first initialized screen. Could be NULL in case that no screen should be initialized after startup.
* @return  result of init operation. D4D_TRUE - everything runs OK, D4D_FALSE initialization failed.
* @note    This function initialized complete eGUI, after this function runs,
*           the HW is ready and all internal variables are also prepared to run eGUI.
*          Must be run as a First function of eGUI in project.
*******************************************************************************/
D4D_BOOL D4D_Init(D4D_SCREEN* pInitScreen)
{
  if(!D4D_LCD_Init()) // Init hardware of LCD
    return D4D_FALSE;

  d4d_screenHistoryIndex = 0;

  #ifdef D4D_LLD_TCH
    d4d_TouchScreen_Status = 0;
    d4d_LastTouchedObj = NULL;
  #endif

  #ifdef D4D_LLD_MOUSE
    D4D_MouseInit();
  #endif

  // In case that the external font is enabled, just initialize it
  #if (D4D_EXTSRC_FILE_ENABLE != D4D_FALSE) && (D4D_FNT_EXTSRC_SUPPORT != D4D_FALSE)
    // one time initialization
    if(D4D_ExtFntInit() == D4D_FALSE)
      return D4D_FALSE;
  #endif

  d4d_systemFlags = 0;

  D4D_ClearKeysBuffer();
  if(pInitScreen)
    D4D_ActivateScreen(pInitScreen, D4D_FALSE);

  return D4D_TRUE;
}
示例#2
0
/**************************************************************//*!
*
* Change the active screen
*
******************************************************************/
static void D4D_ChangeScreen(D4D_SCREEN* pNewScreen, D4D_SCREEN* pOldScreen)
{    
    D4D_SCREEN_DATA* pData;
    D4D_MESSAGE tmp_msg;

    if(pNewScreen == NULL)
      return;
    
    if(pOldScreen == pNewScreen)
      return;
    
    tmp_msg.pScreen = pOldScreen;
    
    if(pOldScreen != NULL)
    {
      D4D_SetObjectFlags(pOldScreen->pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);
      
      tmp_msg.nMsgId = D4D_MSG_KILLFOCUS;
      tmp_msg.pObject = pOldScreen->pData->focusedObject;
      D4D_SendMessage(&tmp_msg);
              
      // Draw NC screen area as an inactivate
      D4D_DrawScreenNC(pOldScreen, D4D_FALSE);
      
      // call de-activate event
      if(pOldScreen->OnDeactivate != NULL)
          pOldScreen->OnDeactivate();       
    }

    // invalidate the new screen (global complete redraw, not individual objects)
    D4D_InvalidateScreen(pNewScreen, D4D_TRUE);
    
    // if this is the first time activating 
    pData = pNewScreen->pData;  
    
    // Init the screen
    D4D_InitScreen(pNewScreen);
    
    D4D_SetObjectFlags(pData->focusedObject, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);
    
    // Send to the object Focus message
    tmp_msg.pScreen = pNewScreen;
    tmp_msg.nMsgId = D4D_MSG_SETFOCUS;
    tmp_msg.pObject = pData->focusedObject;
    D4D_SendMessage(&tmp_msg);          
  
    // inform the screen it has been activated
    if(pNewScreen->OnActivate)
        pNewScreen->OnActivate();
    
    D4D_ClearKeysBuffer();
  
  #ifdef D4D_LLD_TCH  
    d4d_LastTouchedObj = NULL;
  #endif
  
    // finish all action for previous screen
    D4D_MouseChangedScreen();     
}