Ejemplo n.º 1
0
void SetActuatorButtonState(const D4D_OBJECT* pThis, D4D_BOOL state, uint8_t idx)
{
    if(actuator_views_state[idx]==state){
        return; // already up to date
    }

    D4D_SetText(pThis, state ? "ON" : "OFF");

    D4D_COLOR bg, fg;
    if (D4D_IsEnabled(pThis)) {
        bg = state ? color_scheme_device.bckg : color_scheme_device.bckgDis;
        fg = state ? color_scheme_device.fore : color_scheme_device.foreDis;
    }
    else {
        bg = INACTIVE_BG_COLOR;
        fg = INACTIVE_FG_LOW_COLOR;
    }

    pThis->clrScheme->bckg = bg;
    pThis->clrScheme->bckgDis = bg;
    pThis->clrScheme->bckgCapture = bg;
    pThis->clrScheme->bckgFocus = bg;
    pThis->clrScheme->fore = fg;
    pThis->clrScheme->foreDis = fg;
    pThis->clrScheme->foreCapture = fg;
    pThis->clrScheme->foreFocus = fg;

    actuator_views_state[idx] = state;
    D4D_InvalidateObject(pThis, D4D_TRUE);
}
Ejemplo n.º 2
0
static void D4D_MenuOnKeyDown(D4D_MESSAGE* pMsg)
{
  if(D4D_GetCapturedObject() == pMsg->pObject)
  {
    if(pMsg->prm.key == D4D_KEY_SCANCODE_DOWN)
    {
      D4D_MenuFocusNextItem(pMsg->pObject);
      D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);

    } else if(pMsg->prm.key == D4D_KEY_SCANCODE_UP)
    {
      D4D_MenuFocusPreviousItem(pMsg->pObject);
      D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);
    }
  }
}
Ejemplo n.º 3
0
/**************************************************************************/ /*!
* @brief   The function sets the range of scroll bar scale
* @param   pObj - pointer to the scroll_bar object.
* @param   minimum - minimum value of scroll bar
* @param   maximum - maximum value of scroll bar
* @return  none
* @note    none
*******************************************************************************/
void D4D_ScrlBrSetRange(D4D_OBJECT_PTR pObj, D4D_INDEX minimum, D4D_INDEX maximum)
{
  D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pObj);
  D4D_SCRLBAR_DATA* pData = pScrlBr->pData;


  if(maximum < minimum)
    return;

  pData->minimum = minimum;
  pData->maximum = maximum;

  if(pData->step > pData->maximum)
    pData->step = 1;

  if(pData->page > pData->maximum)
    pData->page = 0;

  if(pData->position > pData->maximum)
    pData->position = pData->maximum;

  if(pData->position < pData->minimum)
    pData->position = pData->minimum;

  D4D_InvalidateObject(pObj, D4D_FALSE);
}
Ejemplo n.º 4
0
void D4D_CnslScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position)
{
    D4D_UNUSED(old_position);
    D4D_UNUSED(new_position);

    D4D_InvalidateObject(D4D_GetParentObject(pThis), D4D_FALSE);

    D4D_GET_CONSOLE_DATA(D4D_GetParentObject(pThis))->flags |= (D4D_CNSL_FLAGS_REDRAWALL);
}
Ejemplo n.º 5
0
void D4D_MenuScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position)
{
  D4D_MENU* pMenu = D4D_GET_MENU(D4D_GetParentObject(pThis));

  D4D_UNUSED(old_position);
  pMenu->pData->page_ix = (D4D_MENU_INDEX)new_position;

  D4D_InvalidateObject(D4D_GetParentObject(pThis), D4D_FALSE);
}
Ejemplo n.º 6
0
static void D4D_MenuOnInit(D4D_MESSAGE* pMsg)
{
  // init screen pointer of child objects
  D4D_GET_MENU_SCROLL_BAR_HOR(pMsg->pObject)->pData->pScreen = pMsg->pObject->pData->pScreen;

  (void)D4D_MenuScrollBarSetup(pMsg->pObject);

  // set flag to redraw screen
  D4D_InvalidateObject(pMsg->pObject, D4D_TRUE);
}
Ejemplo n.º 7
0
static void D4D_CheckBoxOnKeyDown(D4D_MESSAGE* pMsg)    
{
    D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pMsg->pObject);
    
    // invoke "Click" event when enter key is pressed
    if(pMsg->prm.key == D4D_KEY_SCANCODE_ENTER)
    {      
      *pStatus |= D4D_CHECKBOX_STATUS_PRESSED_MASK;
      D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);
    }
}
Ejemplo n.º 8
0
static void D4D_TextBoxOnInit(D4D_OBJECT* pObject)
{
  D4D_TEXTBOX* pTextBox = D4D_GET_TEXTBOX(pObject);

  pTextBox->pData->firstShowedCharIx = 0;

  (void)D4D_TextBoxScrollBarSetup(pObject);

  // set flag to redraw screen
  D4D_InvalidateObject(pObject, D4D_TRUE);
}
Ejemplo n.º 9
0
void D4D_ScrlBrOnMessage(D4D_MESSAGE* pMsg)
{
  D4D_OBJECT* pThis = pMsg->pObject;
#if defined(D4D_LLD_TCH) || defined(D4D_LLD_MOUSE)
  D4D_POINT touchClickPoint;
#endif
  switch(pMsg->nMsgId)
  {
    case D4D_MSG_DRAW:
      D4D_ScrlBrOnDraw(pMsg);
      break;

    case D4D_MSG_KEYDOWN:
      D4D_ScrlBrOnKeyDown(pMsg);
      break;

#ifdef D4D_LLD_MOUSE
    case D4D_MSG_MOUSE_BTN_LEFT_UP:
        touchClickPoint = D4D_GetMouseCoordinates(pMsg->pObject);
        D4D_ScrlBrOnTouch(pMsg, &touchClickPoint);
      break;

    case D4D_MSG_MOUSE_BTN_WHEEL_UP:
      D4D_ScrlBrChangePosition(pThis, -1);
      break;

    case D4D_MSG_MOUSE_BTN_WHEEL_DOWN:
      D4D_ScrlBrChangePosition(pThis, 1);
      break;
#endif

#ifdef D4D_LLD_TCH
    case D4D_MSG_TOUCHED:
    case D4D_MSG_TOUCH_AUTO:
      touchClickPoint = D4D_GetTouchScreenCoordinates(pMsg->pObject);
      D4D_ScrlBrOnTouch(pMsg, &touchClickPoint);
      break;
#endif

    case D4D_MSG_KILLFOCUS:
      D4D_CaptureKeys(NULL);
    case D4D_MSG_SETFOCUS:
    case D4D_MSG_SETCAPTURE:
    case D4D_MSG_KILLCAPTURE:
      D4D_InvalidateObject(pThis, D4D_FALSE);
      break;


    default:
      // call the default behavior of all objects
      D4D_ObjOnMessage(pMsg);
  }
}
Ejemplo n.º 10
0
void D4D_TextBoxScrollBarsFeedBack(D4D_OBJECT* pThis, D4D_INDEX old_position, D4D_INDEX new_position)
{
  D4D_TXTBX_DATA* pData = D4D_GET_TEXTBOX_DATA(D4D_GetParentObject(pThis));

  D4D_UNUSED(old_position);

  // compute the start char of current screen
  pData->firstShowedCharIx = D4D_TextBoxFindLineStartChar(D4D_GetParentObject(pThis), new_position);

  // set flag to redraw screen
  D4D_InvalidateObject(D4D_GetParentObject(pThis), D4D_FALSE);
  pData->redrawText = D4D_TRUE;
}
Ejemplo n.º 11
0
void ScrStartup_OnMain()
{    
    uint32_t elapsed = model.elapsed();
    if (elapsed>2000) {                        
        if (model.fadeColorUpdate(min(255lu, ((elapsed-2000)*255)/(3000)))) {
            uint8_t c = model.fadeColor();
            scrStartup_version.clrScheme->fore = D4D_COLOR_RGB(c,c,c);            
            D4D_InvalidateObject(&scrStartup_version, D4D_FALSE);
        }
    }
    if (model.timeout() || model.touched())
        uiController.notifyStartupComplete();
}
Ejemplo n.º 12
0
/**************************************************************************/ /*!
* @brief   The function change the text in main object text buffer
* @param   pObject - pointer to object
* @param   pText - pointer to new string
* @return  None
* @note    The function change the text in the object text buffer if the object has it.
*******************************************************************************/
void D4D_SetText(D4D_OBJECT_PTR pObject, D4D_TCHAR* pText) 
{
  D4D_STRING* p_TextBuff = NULL;
  
  if(pObject->pObjFunc->GetTextBuffer)
    p_TextBuff = pObject->pObjFunc->GetTextBuffer((D4D_OBJECT*)pObject);
  
  if(p_TextBuff)
  {
    D4D_ChangeText(p_TextBuff, pText, 0);  
    D4D_InvalidateObject(pObject, D4D_FALSE);
  }

}
Ejemplo n.º 13
0
void D4D_ComboBoxButtonFeedBack(D4D_OBJECT* pThis)
{
  D4D_OBJECT* pParent = D4D_GetParentObject(pThis);
  D4D_OBJECT* pListBoxObject = D4D_GET_COMBO_BOX_LIST_BOX(pParent);

  if(D4D_IsVisible(pListBoxObject))
  {
    D4D_ComboBoxStornoSelection(pParent);
  }else
  {
    D4D_ShowObject(pListBoxObject, D4D_TRUE);
    D4D_CaptureKeys(pListBoxObject);
    D4D_InvalidateObject(pParent, D4D_TRUE);
  }
}
Ejemplo n.º 14
0
void D4D_PrgrsBarSetBarColor(D4D_OBJECT_PTR pThis, D4D_COLOR color)
{
    D4D_PROGRESS_BAR* pPrgrsBar = D4D_GET_PROGRESS_BAR(pThis);
    D4D_PROGRESS_BAR_DATA* pData = pPrgrsBar->pData;

    if(pThis->initFlags & (D4D_PRGRS_BAR_F_BAR_AUTOCOLOR | D4D_PRGRS_BAR_F_BAR_SCALECOLOR))
      return;
    
    if(pData->colorBar == color)
        return ;
    
    // remember new color
    pData->colorBar = color;
    
    D4D_InvalidateObject(pThis, D4D_FALSE);    
}
Ejemplo n.º 15
0
/**************************************************************************/ /*!
* @brief   Function sets object text properties
* @param   pObject - pointer to object that has to have changed text properties
* @param   property - new text properties
* @return  none
* @note    Function sets the text properties of major object string.
*******************************************************************************/
void D4D_SetTextProperties(D4D_OBJECT_PTR pObject, D4D_TEXT_PROPERTIES property)
{
  D4D_STRING* p_TextBuff = NULL;

  if(pObject->pObjFunc->GetTextBuffer)
    p_TextBuff = pObject->pObjFunc->GetTextBuffer((D4D_OBJECT*)pObject);

  if(p_TextBuff)
  {
    if(p_TextBuff->str_properties->text_properties == property)
      return;     // There is no change needed

    p_TextBuff->str_properties->text_properties = property;
    D4D_InvalidateObject(pObject, D4D_FALSE);
  }
}
Ejemplo n.º 16
0
/**************************************************************************/ /*!
* @brief   Function Sets the slider bar color
* @param   pThis - pointer to the slider object
* @param   color - new slider bar color
* @return  none
* @note    none
*******************************************************************************/
void D4D_SldrSetBarColor(D4D_OBJECT_PTR pThis, D4D_COLOR color)
{
    D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
    D4D_SLIDER_DATA* pData = pSldr->pData;

    if(pThis->initFlags & (D4D_SLDR_F_BAR_AUTOCOLOR | D4D_SLDR_F_BAR_SCALECOLOR))
      return;

    if(pData->colorBar == color)
        return ;

    // remember new color
    pData->colorBar = color;

    D4D_InvalidateObject(pThis, D4D_FALSE);
}
Ejemplo n.º 17
0
/**************************************************************************/ /*!
* @brief   The function sets the step and page of scroll bar scale
* @param   pObj - pointer to the scroll_bar object.
* @param   page - page value of scroll bar
* @param   step - step value of scroll bar
* @return  none
* @note    none
*******************************************************************************/
void D4D_ScrlBrSetStep(D4D_OBJECT_PTR pObj, D4D_INDEX page, D4D_INDEX step)
{
  D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pObj);
  D4D_SCRLBAR_DATA* pData = pScrlBr->pData;


  if(step > (pData->maximum - pData->minimum))
    return;

  if(page > (pData->maximum - pData->minimum))
    return;

  pData->step = step;
  pData->page = page;

  D4D_InvalidateObject(pObj, D4D_FALSE);
}
Ejemplo n.º 18
0
static void D4D_ConsoleTimeTick(D4D_MESSAGE* pMsg)
{

    D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pMsg->pObject);

    pCnsl->pData->tickCounter++;
    if(pCnsl->pData->tickCounter >= D4D_CNSL_CURSOR_BLINK_TICK_COUNTER)
    {
        pCnsl->pData->tickCounter = 0;
        pCnsl->pData->flags |= D4D_CNSL_FLAGS_REDRAWCURSOR;
        D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);

        if(pCnsl->pData->flags & D4D_CNSL_FLAGS_CURSORSTATE)
            pCnsl->pData->flags &= ~D4D_CNSL_FLAGS_CURSORSTATE;
        else
            pCnsl->pData->flags |= D4D_CNSL_FLAGS_CURSORSTATE;
    }
}
Ejemplo n.º 19
0
/*-----------------------------------------------------------------------------
* FUNCTION:    ScreenScrSvr_MovePicture
* SCOPE:       Screen saver screen related function - local
* DESCRIPTION: Local function to move the screen saver picture
*
* PARAMETERS:  none
*              
* RETURNS:     none
*-----------------------------------------------------------------------------*/
static void ScreenScrSvr_MovePicture(void)
{  
  D4D_SIZE pictSize = D4D_GetBmpSize(((D4D_PICTURE*)scrsvr_picLogo.pParam)->pBmp);
  
  // Move the picture on new position
  oldPos = scrsvr_picLogo.position;
  
  if(((oldPos.x + dx + pictSize.cx + 1) >= screen_scrsvr.size.cx) || ((oldPos.x + dx) < 0))
    dx *= -1;
    
  scrsvr_picLogo.position.x = oldPos.x + dx;
  
  if(((oldPos.y + dy + pictSize.cy + 1) >= screen_scrsvr.size.cy) || ((oldPos.y + dy) < 0))
    dy *= -1;
    
  scrsvr_picLogo.position.y = oldPos.y + dy;
  
  D4D_InvalidateObject(&scrsvr_picLogo, D4D_TRUE);
}
Ejemplo n.º 20
0
/**************************************************************************/ /*!
* @brief   Function Sets the the check box value
* @param   pThis - pointer to the check box object that should be sets. 
* @param   value - new value of check box
* @return  none.
* @note    This sets the value of check box.
*******************************************************************************/ 
void D4D_CheckBoxSetValue(D4D_OBJECT_PTR pThis, D4D_BOOL value)
{
  D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pThis);
  D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pThis);
  
  if(((*pStatus & D4D_CHECKBOX_STATUS_CHECKED_MASK) && value) || (!(*pStatus & D4D_CHECKBOX_STATUS_CHECKED_MASK) && !value))
    return ;
  
  // remember new value
  if(value)
    *pStatus |= D4D_CHECKBOX_STATUS_CHECKED_MASK;
  else
    *pStatus &= ~D4D_CHECKBOX_STATUS_CHECKED_MASK;
  
  D4D_InvalidateObject(pThis, D4D_TRUE);

  // notify user that the value has changed        
  if(pCheckB->OnChange)
    pCheckB->OnChange((D4D_OBJECT*)pThis);
}
Ejemplo n.º 21
0
/**************************************************************************/ /*!
* @brief   The function clear whole console data
* @param   pObj - pointer to the console object
* @return  none
* @note    It's take something like software reset to default state of console.
*******************************************************************************/
void D4D_CnslClearAll(D4D_OBJECT_PTR pObj) {
    D4D_CONSOLE* pCnsl = D4D_GET_CONSOLE(pObj);
    D4D_CNSL_DATA* pData = pCnsl->pData;

    LWord i,i_max;

    // Init the text array
    i_max = (LWord)(pCnsl->txtArrSize.cy * (pCnsl->txtArrSize.cx + 1));

    for(i=0; i<i_max; i++)
        pCnsl->pTxtArr[i] = 0;

    pData->cursorPos.x =0;
    pData->cursorPos.y =0;

    pData->flags &= ~D4D_CNSL_FLAGS_CHECKLINE;
    pData->flags |= D4D_CNSL_FLAGS_REDRAWALL;
    D4D_InvalidateObject(pObj, D4D_FALSE);

}
Ejemplo n.º 22
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);
    }
}
Ejemplo n.º 23
0
/**************************************************************************/ /*!
* @brief   The function sets the scroll bar position
* @param   pObj - pointer to the scroll_bar object.
* @param   position -  value of scroll bar position
* @return  none
* @note    none
*******************************************************************************/
void D4D_ScrlBrSetPosition(D4D_OBJECT_PTR pObj, D4D_INDEX position)
{
  D4D_SCROLL_BAR* pScrlBr = D4D_GET_SCROLL_BAR(pObj);
  D4D_SCRLBAR_DATA* pData = pScrlBr->pData;
  D4D_INDEX old_pos = pData->position;

  if(position > (D4D_INDEX)(pData->maximum - pData->page))
    pData->position = (D4D_INDEX)(pData->maximum - pData->page);
  else if(position < pData->minimum)
    pData->position = pData->minimum;
  else
    pData->position = position;

  if(pData->position == old_pos)
    return;

  if(pScrlBr->OnChange != NULL)
    pScrlBr->OnChange((D4D_OBJECT*)pObj, old_pos, pData->position);

  D4D_InvalidateObject(pObj, D4D_FALSE);

}
Ejemplo n.º 24
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);
   }
 }
Ejemplo n.º 25
0
void D4D_PrgrsBarSetValue(D4D_OBJECT_PTR pThis, D4D_PROGRESS_BAR_VALUE value)
{
    D4D_PROGRESS_BAR* pPrgrsBar = D4D_GET_PROGRESS_BAR(pThis);
    D4D_PROGRESS_BAR_DATA* pData = pPrgrsBar->pData;       
    
    if(pData->value == value)
        return ;
    
    if(pData->value <= value)
      pPrgrsBar->pData->drawActiveOnly = D4D_TRUE;
    else
      pPrgrsBar->pData->drawActiveOnly = D4D_FALSE;
    
    // remember new value
    pData->value = value;
    
    if(pThis->initFlags & (D4D_PRGRS_BAR_F_BAR_AUTOCOLOR | D4D_PRGRS_BAR_F_BAR_SCALECOLOR))
    {
      pData->colorBar = D4D_PrgrsBarComputeColorBar((D4D_OBJECT*)pThis, value);
    }
    
    D4D_InvalidateObject(pThis, D4D_FALSE);
}
Ejemplo n.º 26
0
static void D4D_MenuOnKeyUp(D4D_MESSAGE* pMsg)
{
    D4D_MENU* pMenu = D4D_GET_MENU(pMsg->pObject);

    if(pMsg->prm.key == D4D_KEY_SCANCODE_ENTER)
    {
      if(D4D_GetCapturedObject() != pMsg->pObject)
      {
        D4D_CaptureKeys(pMsg->pObject);
      }else
      {
        if(pMenu->OnClicked)
          pMenu->OnClicked(pMsg->pObject, pMenu->pData->ix);

        D4D_InvalidateObject(pMsg->pObject, D4D_FALSE);
      }
    }

    if(pMsg->prm.key == D4D_KEY_SCANCODE_ESC)
    {
      D4D_CaptureKeys(NULL);
    }
}
Ejemplo n.º 27
0
/**************************************************************************/ /*!
* @brief   Function sets the new bitmap of icon by icon index
* @param   pThis - pointer to the icon object that should be sets. 
* @param   index - index of new bitmpa that should be shown
* @return  none
* @note    none
*******************************************************************************/
void D4D_IconSetIndex(D4D_OBJECT_PTR pThis, D4D_ICON_INDEX index)
{
    D4D_ICON* pIcon = D4D_GET_ICON(pThis);
    D4D_ICON_DATA* pData = pIcon->pData;

    if(pData->index == index)
        return ;
    
    if(D4D_IconGetBmpCount(pThis) == 0)  // There is no loaded bitmaps - go out
        return;
    
    if(index >= D4D_IconGetBmpCount(pThis))  // If value is bigger then count of BMPs
        return;
    
    // remember new value
    pData->index = index;
    
    D4D_InvalidateObject(pThis, D4D_TRUE);

    // notify user that the value has changed        
    if(pIcon->OnValueChanged)
        pIcon->OnValueChanged((D4D_OBJECT*)pThis);
}
Ejemplo n.º 28
0
/**************************************************************************/ /*!
* @brief   Function Sets the slider value
* @param   pThis - pointer to the slider object
* @param   value - new value of slider
* @return  none.
* @note    The values must fit in to slider linits, if not is limit to valid range
*******************************************************************************/
void D4D_SldrSetValue(D4D_OBJECT_PTR pThis, D4D_SLIDER_VALUE value)
{
    D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
    D4D_SLIDER_DATA* pData = pSldr->pData;

    // keep value within limits

    value = D4D_LimitS8(value, pData->limits.valueMin, pData->limits.valueMax);

    if(pData->value == value)
        return ;

    // remember new value
    pData->value = value;

    if(pThis->initFlags & (D4D_SLDR_F_BAR_AUTOCOLOR | D4D_SLDR_F_BAR_SCALECOLOR))
      pData->colorBar = D4D_SldrComputeColorBar((D4D_OBJECT*)pThis, value);

    D4D_InvalidateObject(pThis, D4D_FALSE);

    // notify user that the value has changed
    if(pSldr->OnValueChanged)
        pSldr->OnValueChanged((D4D_OBJECT*)pThis);
}
Ejemplo n.º 29
0
static void D4D_CheckBoxOnKeyUp(D4D_MESSAGE* pMsg)    
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pThis);
  
  // invoke "Click" event when enter key is pressed
  if(pMsg->prm.key == D4D_KEY_SCANCODE_ENTER)
  {
    if(*pStatus & D4D_CHECKBOX_STATUS_PRESSED_MASK)
    {
      D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pMsg->pObject);
      *pStatus &= ~D4D_CHECKBOX_STATUS_PRESSED_MASK;      
  
      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(pThis);            
    }
    D4D_InvalidateObject(pThis, D4D_FALSE); 
  } 
}
Ejemplo n.º 30
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);
    }
  }
}