Beispiel #1
0
/**************************************************************************/ /*!
* @brief   Function control visibility of object on screen.
* @param   pObject - pointer to the object.
* @param   bShow - <D4D_TRUE - visible, D4D_FALSE - hidden>
* @return  none.
* @note    This function control the visibility of object on screen. The hide action
*          force invalidate of whole screen.
*******************************************************************************/
void D4D_ShowObject(D4D_OBJECT_PTR pObject, D4D_BOOL bShow)
{
    if(bShow)
    {
        pObject->pData->flags |= D4D_OBJECT_F_VISIBLE;
        D4D_InvalidateObject(pObject, D4D_FALSE);
    }
    else
    {
        pObject->pData->flags &= ~D4D_OBJECT_F_VISIBLE;

        if(d4d_pKeysCapturer == pObject)
            D4D_CaptureKeys(NULL);


        if((D4D_OBJECT*)pObject == D4D_GetFocusedObject(pObject->pData->pScreen))
            D4D_FocusNextObject(pObject->pData->pScreen, D4D_FALSE);

        if(pObject->pRelations)
        {
            D4D_OBJECT* pParent = D4D_GetParentObject((D4D_OBJECT*)pObject);

            if(pParent)
                D4D_InvalidateObject(pParent, D4D_TRUE);
            else
                D4D_InvalidateScreen(pObject->pData->pScreen, D4D_TRUE);

        } else
            D4D_InvalidateScreen(pObject->pData->pScreen, D4D_TRUE);
    }
}
Beispiel #2
0
/**************************************************************************/ /*!
* @brief   The function inits the screen and its objects for first time case
* @param   pScreen - the pointer to screen
* @return  None
* @note    Initialize the the screen. This is keep as a public API to allow user application
*          initialize the screen before it native first use.
*******************************************************************************/
void D4D_InitScreen(D4D_SCREEN* pScreen)
{
  D4D_SCREEN_DATA* pData = pScreen->pData;
  D4D_OBJECT** pObj;
  D4D_MESSAGE localMsg;


  if(!pScreen)
    return;  

  // prepare message
  localMsg.pScreen = pScreen;
  localMsg.nMsgId = D4D_MSG_ONINIT;
  
  pObj = (D4D_OBJECT**) pScreen->pObjects;
  
  // init objects   
  while(*pObj != NULL)
  {  
    
    localMsg.pObject = *pObj;
    
    // initialize the pointers on this screen in all screen objects
    D4D_SetObjectScreenPointer(*pObj, pScreen);
    
    // send the ON INIT message
    D4D_SendMessageMask(&localMsg, 0, D4D_OBJECT_F_NOTINIT);    
    
    pObj++;
  }
  
  if(!(pData->flags & D4D_SCR_FINT_INITDONE))
  {
    pData->flags |= D4D_SCR_FINT_INITDONE;
    
    D4D_FocusNextObject(pScreen, D4D_TRUE);
    
    // user's screen initialization
    if(pScreen->OnInit)
        pScreen->OnInit();
    
    // Enable natively touch scren for screens if exit button is enabled
    if(pScreen->flags & D4D_SCR_F_EXIT)
      pData->flags |= D4D_SCR_FINT_TOUCHENABLE;   
  } 
}
Beispiel #3
0
/**************************************************************************/ /*!
* @brief   Function enables object
* @param   pObj - pointer to the object
* @param   bEnable - <D4D_TRUE - object enabled, D4D_FALSE - enabled disabled>
* @return  none.
* @note    This function sets the enabled property. When the object is enabled, it can accept all user
*       inputs and use normal colors. In the disable state the object is redrawn by grayscale colors and all user
*       inputs are ignored. The initialization state is set by parameter flags in the object declaration. This function
*       is targeted for using at run-time.
*******************************************************************************/
void D4D_EnableObject(D4D_OBJECT_PTR pObj, D4D_BOOL bEnable)
{
    //if(((pObj->pData->flags & D4D_OBJECT_F_ENABLED) && !bEnable) || (!(pObj->pData->flags & D4D_OBJECT_F_ENABLED) && bEnable))
    if(D4D_LOG_EXOR((pObj->pData->flags & D4D_OBJECT_F_ENABLED), bEnable))
    {
        if(bEnable)
            pObj->pData->flags |= D4D_OBJECT_F_ENABLED;
        else
        {
            pObj->pData->flags &= ~D4D_OBJECT_F_ENABLED;

            if((D4D_OBJECT*)pObj == d4d_pKeysCapturer)
                D4D_CaptureKeys(NULL);

            if((D4D_OBJECT*)pObj == D4D_GetFocusedObject(pObj->pData->pScreen))
                D4D_FocusNextObject(pObj->pData->pScreen, D4D_FALSE);
        }

        D4D_InvalidateObject(pObj, D4D_TRUE);
    }
}
Beispiel #4
0
/**************************************************************//*!
*
* Handle the keys (part of main poll call)
*
******************************************************************/
void D4D_HandleKeys(void)
{
    // get active screen
    D4D_SCREEN* pScreen = D4D_GetActiveScreen();
    D4D_OBJECT* pFocus;
    D4D_KEY_SCANCODE scanCode;
    D4D_BOOL tmp_release;

    // TODO what about sending keys to Child objects??

    // Check the buffer of input keys changes
    if(d4d_KeysBuff.writePos == d4d_KeysBuff.readPos)
      return;

    // Read the latest record in the buffer of input key event
    scanCode = d4d_KeysBuff.buff[d4d_KeysBuff.readPos++];

    // Check the overflow of the read pointer of readed input keys
    if(d4d_KeysBuff.readPos >= D4D_KEYS_BUFF_LENGTH)
        d4d_KeysBuff.readPos = 0;

    tmp_release = (D4D_BOOL)(scanCode & D4D_KEY_SCANCODE_RELEASEMASK);
    scanCode &= ~D4D_KEY_SCANCODE_RELEASEMASK;

    // do we handle the keys ourselves (to navigate across the screen) ?
    if(!d4d_pKeysCapturer)
    {
        if((scanCode & D4D_KEY_SCANCODE_RELEASEMASK) == 0)
        {
          // escape the screen?
          if(scanCode == D4D_KEY_SCANCODE_ESC)
          {
            if(tmp_release == 0)
              D4D_EscapeScreen();
            return;
          }
          // focus previous object on the screen?
          else if(scanCode ==  D4D_KEY_FUNC_FOCUS_PREV)
          {
            if(tmp_release == 0)
              D4D_FocusPrevObject(pScreen);
            return;
          }
          // focus next object on the screen?
          else if(scanCode ==  D4D_KEY_FUNC_FOCUS_NEXT)
          {
            if(tmp_release == 0)
              D4D_FocusNextObject(pScreen, D4D_FALSE);
            return;
          }
        }
    }

    // does the object get the key events?
    // yes, invoke the key events to the active object
    pFocus = (D4D_OBJECT*) (d4d_pKeysCapturer ? d4d_pKeysCapturer : D4D_GetFocusedObject(pScreen));
    if((pFocus->pData->flags & (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP)) == (D4D_OBJECT_F_VISIBLE | D4D_OBJECT_F_ENABLED | D4D_OBJECT_F_TABSTOP))
    {
      if(D4D_IsEnabled(pFocus))
      {
        // prepare the message
        d4d_msg.pScreen = pScreen;
        d4d_msg.pObject = pFocus;

        if(tmp_release == 0)
          d4d_msg.nMsgId = D4D_MSG_KEYDOWN;   // if key was pressed down?
        else
          d4d_msg.nMsgId = D4D_MSG_KEYUP;     // if key was released up?

        d4d_msg.prm.key = (D4D_KEY_SCANCODE)(scanCode & D4D_KEY_SCANCODE_KEYMASK);

        D4D_SendMessageBack(&d4d_msg);
      }
    }
}