Exemple #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);
    }
}
Exemple #2
0
/**************************************************************************/ /*!
* @brief   Function find out if the object (including compounded objects) is focused
* @param   pObject - pointer to the object
* @return  <D4D_TRUE - object has focus, D4D_FALSE - object hasn't focus>.
* @note    This function gets the focused object and check if it belong this object or any other
*               object in compounded set.
*******************************************************************************/
D4D_BOOL D4D_IsMineFocus(D4D_OBJECT* pObject)
{
    D4D_OBJECT * pFocused;

    if(pObject == NULL)
        return D4D_FALSE;

    if((D4D_SCREEN*)(pObject->pData->pScreen) != D4D_GetActiveScreen())
        return D4D_FALSE;

    pFocused = (D4D_OBJECT*)D4D_GetFocusedObject((D4D_SCREEN*)(pObject->pData->pScreen));

    if(pFocused == pObject)
        return D4D_TRUE;

    if((pObject->pRelations) && (pFocused->pRelations))
    {
        // Lok for all parents - step by step
        while((pFocused = D4D_GetParentObject(pFocused)))
        {
            if(pObject == pFocused)
                return D4D_TRUE;
        }
    }

    return D4D_FALSE;
}
Exemple #3
0
  static void D4D_ScrlBrOnTouch(D4D_MESSAGE* pMsg, D4D_POINT* point)
  {
    D4D_OBJECT* pThis = pMsg->pObject;

    if(pThis->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_FASTTOUCH))
    {
      if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH))
      {
        D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pThis);
        D4D_SCRLBAR_DATA* pData = pScrlBr->pData;

        if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP)
          D4D_CaptureKeys(pThis);

        if(pThis->size.cx > pThis->size.cy)
        {
          if(point->x > ((pThis->size.cx / 2) + pThis->position.x))
            D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(pData->step));
          else
            D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(-1 * pData->step));
        }else
        {

          if(point->y > ((pThis->size.cy / 2) + pThis->position.y))
            D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(pData->step));
          else
            D4D_ScrlBrChangePosition(pThis, (D4D_INDEX_DELTA)(-1 * pData->step));
        }


      }
      if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP)
        D4D_FocusSet(pMsg->pScreen, pThis);
    }
  }
Exemple #4
0
static void D4D_SldrTouched(D4D_MESSAGE* pMsg, D4D_POINT* pPoint)
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);

  if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH))
  {
    D4D_FocusSet(pMsg->pScreen, pThis);

    if(D4D_GetCapturedObject() != pThis)
      D4D_CaptureKeys(pThis);

    if(pThis->size.cx > pThis->size.cy)
    {
      if(pPoint->x > ((pThis->size.cx / 2) + pThis->position.x))
        D4D_SldrChangeValue(pThis, pSldr->pData->limits.step);
      else
        D4D_SldrChangeValue(pThis, (D4D_SLIDER_VALUE)(-pSldr->pData->limits.step));
    }else
    {

      if(pPoint->y < ((pThis->size.cy / 2) + pThis->position.y))
        D4D_SldrChangeValue(pThis, pSldr->pData->limits.step);
      else
        D4D_SldrChangeValue(pThis, (D4D_SLIDER_VALUE)(-pSldr->pData->limits.step));
    }
  }else
    D4D_FocusSet(pMsg->pScreen, pThis);

}
Exemple #5
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);
    }
}
Exemple #6
0
 static void D4D_CheckBoxTouched(D4D_MESSAGE* pMsg)
 {  
   if(pMsg->pObject->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_FASTTOUCH))
   {
     if((D4D_GetFocusedObject(pMsg->pScreen) == pMsg->pObject) || (pMsg->pObject->pData->flags & D4D_OBJECT_F_FASTTOUCH))
     {               
       D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pMsg->pObject);
       D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pMsg->pObject);
       
       if(*pStatus & D4D_CHECKBOX_STATUS_CHECKED_MASK)
         *pStatus &= ~D4D_CHECKBOX_STATUS_CHECKED_MASK;
       else
         *pStatus |= D4D_CHECKBOX_STATUS_CHECKED_MASK;
       
       if(pCheckB->OnChange)
         pCheckB->OnChange(pMsg->pObject);
       
       D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);
     }                    
     D4D_FocusSet(pMsg->pScreen, pMsg->pObject);
   }
 }
Exemple #7
0
static void D4D_MenuOnTouch(D4D_MESSAGE* pMsg, D4D_POINT* pPoint)
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_MENU* pMenu = D4D_GET_MENU(pThis);

  if(pThis->pData->flags & D4D_OBJECT_F_TABSTOP)
  {
    if((D4D_GetFocusedObject(pMsg->pScreen) == pThis) || (pThis->pData->flags & D4D_OBJECT_F_FASTTOUCH))
    {
      D4D_FocusSet(pMsg->pScreen, pThis);

      D4D_MenuValue2Coor(pThis);

      if(pPoint->x < (pThis->position.x + pThis->size.cx - ((D4D_GET_MENU_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)? D4D_MENU_SCRLBR_WIDTH:0)))
      {
      // Select Menu Item
        D4D_COOR tmp_y;
        Byte tmpB;
        D4D_MENU_INDEX tmpItemsCnt = D4D_GetItemsCount(pMenu);

        tmp_y = (D4D_COOR)(pPoint->y - pThis->position.y);

	if(tmp_y <= _calc.titleBar_y)
        	return;

	tmp_y -= _calc.titleBar_y;

        // now is in tmp_y offset of y from title bar

        // Check the list
        for(tmpB = pMenu->pData->page_ix; tmpB < _calc.itemsCnt; tmpB++)
        {
          // Check end if list
          if((tmpB - pMenu->pData->page_ix) >= _calc.posCnt)
            break;

          if(tmp_y < _calc.textOff)
          {
            // founded touched line
            if(pMenu->pData->ix != tmpB)
            {
              // Touched line is not focused
              pMenu->pData->ix = (D4D_MENU_INDEX)tmpB;

            }else
            {
              if(pMenu->OnClicked)
                  pMenu->OnClicked(pThis, pMenu->pData->ix);
            }
            break;
          }
          tmp_y -= _calc.textOff;
        }
        D4D_InvalidateObject(pThis, D4D_FALSE);
      }
    }else
    {
      D4D_FocusSet(pMsg->pScreen, pThis);
    }
  }
}
Exemple #8
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);
      }
    }
}