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
/**************************************************************************/ /*!
* @brief   Function find out if the object is enabled or not
* @param   pObject - pointer to the object
* @return  <D4D_TRUE - object is enabled, D4D_FALSE - object is disabled>.
* @note    This function gets the current status of object enabled / disabled. The function control the
*               object itself and also all parents objects..
*******************************************************************************/
D4D_BOOL D4D_IsEnabled(D4D_OBJECT* pObject)
{
    if(!(pObject->pData->flags & D4D_OBJECT_F_ENABLED))
        return D4D_FALSE;

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

    return D4D_TRUE;
}
Ejemplo n.º 3
0
/**************************************************************************/ /*!
* @brief   The function set the obejct focus to new object
* @param   pScreen - the pointer to screen
* @param   pObject - the pointer to object that should be focused
* @return  None
* @note    In case that there is no other issue (obejct exists, visible, enable ...) the focus is changed to given one
*******************************************************************************/
void D4D_FocusSet(D4D_SCREEN* pScreen, D4D_OBJECT_PTR pObject)
{
    D4D_SCREEN_DATA* pData = pScreen->pData;
    D4D_OBJECT* pFocusedObj = pData->focusedObject;
    D4D_OBJECT* pNewFocus;
    
    if(pScreen == NULL)
      return;
    
    // check if object is really item of the current screen
    pNewFocus = D4D_FindObject(pScreen, pObject);
    if(pNewFocus == NULL)
      return;
    
    if(pNewFocus == pFocusedObj) // is selected object same as focused?
      return;
  
   if((pNewFocus->pData->flags & (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) != (D4D_OBJECT_F_TABSTOP | D4D_OBJECT_F_ENABLED)) // is this object selectable?
      return;
    
    if(!D4D_IsEnabled(pNewFocus))
      return;
    
    // invalidate object which is loosing focus
    D4D_SetObjectFlags(pFocusedObj, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);
    
    // invalidate object which is getting focus
    D4D_SetObjectFlags(pNewFocus, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);
    
    // move the focus
    pData->focusedObject = pNewFocus;
    
    // prepare message
    d4d_msg.pScreen = pScreen;
    d4d_msg.nMsgId = D4D_MSG_KILLFOCUS;
    d4d_msg.pObject = pFocusedObj;
    D4D_SendMessage(&d4d_msg);
    
    
    
    // prepare message
    d4d_msg.pScreen = pScreen;
    d4d_msg.nMsgId = D4D_MSG_SETFOCUS;
    d4d_msg.pObject = pNewFocus;
    D4D_SendMessage(&d4d_msg);
        
}
Ejemplo n.º 4
0
static void D4D_PrgrsBarOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis = pMsg->pObject;    
    D4D_PROGRESS_BAR* pPrgrsBar = D4D_GET_PROGRESS_BAR(pThis);
    D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis);
    D4D_COLOR clrBar = pPrgrsBar->pData->colorBar;
    D4D_COLOR clrBarBckg = pScheme_tmp->objectDepend.progressBar.barBckg;
    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
    D4D_COLOR clrT = D4D_ObjectGetForeColor(pThis, draw);
    D4D_COLOR clrB = D4D_ObjectGetBckgFillColor(pThis);
    
    #ifdef D4D_DEBUG
      // sanity check
      D4D_ASSERT(sizeof(_calc) <= D4D_SCRATCHPAD_SIZE);
    #endif
    
    // bar coordinate calculation
    D4D_PrgrsBarValue2Coor(pThis);

    // when background redraw is needed
    if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
      D4D_RBox(&_calc.position, &pThis->size, D4D_LINE_THIN, clrT, clrB, pThis->radius);
    
    // Draw the frame
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
      D4D_DrawFrame(pThis, clrT, clrB);
    
    // if progress_bar is disabled draw progress_bar in grey scale
    if(!D4D_IsEnabled(pThis))
    {
      clrBar = D4D_GetGreyScale(clrBar);
      clrBarBckg = D4D_GetGreyScale(clrBarBckg);        
    }
        
    if(!pPrgrsBar->pData->drawActiveOnly)
      D4D_FillRRectXY(_calc.resultC2, _calc.barXY.y, (D4D_COOR)(_calc.barXY.x + _calc.barSize.cx - 1), (D4D_COOR)(_calc.barXY.y + _calc.barSize.cy - 1), clrBarBckg, _calc.inner_radius);
    
    // draw active part of the bar
    if(pThis->initFlags & D4D_PRGRS_BAR_F_BAR_SCALECOLOR)
      D4D_FillRRectColorScaleXY(_calc.barXY.x, _calc.barXY.y, _calc.resultC1, (D4D_COOR)(_calc.barXY.y + _calc.barSize.cy - 1), pScheme_tmp->objectDepend.progressBar.barFore, clrBar, D4D_DIR_RIGHT, _calc.inner_radius);                      
    else
      D4D_FillRRectXY(_calc.barXY.x, _calc.barXY.y, _calc.resultC1, (D4D_COOR)(_calc.barXY.y + _calc.barSize.cy - 1), clrBar, _calc.inner_radius);
                
   }
Ejemplo n.º 5
0
/**************************************************************************/ /*!
* @brief   Function switch on capturing the keys to objects
* @param   pObj - pointer to the object. if the parameter is handled as NULL,
*                the function switch off the capturing the keys to object.
* @return  none.
* @note    This function sets the object to the capture keys state. In this state the object obtains all the
*               keys inputs including system navigation keys (escape, up, and down). In this state the object is using
*               capture colors from a color scheme. To switch off from this state the active screen has to be changed or
*               this function has to be called with the input parameter set to NULL.
*******************************************************************************/
void D4D_CaptureKeys(D4D_OBJECT_PTR  pObj)
{
    // NOTE: we need to send message, but we may just be in the middle of
    //       message processing (very likely). This may cause problem with
    //       the global d4d_msg object as we are changing it...
    //       We better use the temporary memory to instanitate the message

    D4D_MESSAGE* pMsg = (D4D_MESSAGE*) d4d_scratchPad;

    if(d4d_pKeysCapturer == pObj)
        return;

    pMsg->pScreen = D4D_GetActiveScreen();

    if(d4d_pKeysCapturer)
    {
        D4D_SetObjectFlags(d4d_pKeysCapturer, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);

        pMsg->nMsgId = D4D_MSG_KILLCAPTURE;
        pMsg->pObject = d4d_pKeysCapturer;
        D4D_SendMessage(pMsg);

        d4d_pKeysCapturer = NULL;
    }

    if(pObj != NULL)
    {
        if((pObj->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((D4D_OBJECT*)pObj))
            {
                D4D_FocusSet(D4D_GetActiveScreen(), pObj);

                d4d_pKeysCapturer = (D4D_OBJECT*) pObj;

                D4D_SetObjectFlags(d4d_pKeysCapturer, D4D_OBJECT_F_REDRAWSTATE, D4D_FALSE);

                pMsg->nMsgId = D4D_MSG_SETCAPTURE;
                pMsg->pObject = d4d_pKeysCapturer;
                D4D_SendMessage(pMsg);
            }
        }
    }
}
Ejemplo n.º 6
0
static void D4D_MenuOnDraw(D4D_MESSAGE* pMsg)
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_MENU* pMenu = D4D_GET_MENU(pThis);
  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
  D4D_COLOR clrT, clrB;
  D4D_POINT tmp_point;
  D4D_SIZE tmp_size;
  D4D_STRING tmp_txtbuff;
  D4D_STR_PROPERTIES tmp_str_prty;
  Byte tmpB;

  tmp_txtbuff.str_properties = &tmp_str_prty;
  tmp_txtbuff.printOff = 0;
  // Get background simple color
  clrT = D4D_ObjectGetForeFillColor(pThis);
  clrB = D4D_ObjectGetBckgFillColor(pThis);

  #ifdef D4D_DEBUG
    // sanity check
    D4D_ASSERT(sizeof(_calc) <= D4D_SCRATCHPAD_SIZE);
  #endif

  // Compute all tempoarary values
  D4D_MenuValue2Coor(pThis);

  // draw just a color rectangle instead of bitmap
  if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
  {
    D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);

    if(pMenu->pIcon != NULL)
    {
      tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 2);
      tmp_point.y =  (D4D_COOR)(_calc.contentGeom.pnt.y + ((_calc.titleBar_y - D4D_GetBmpHeight(pMenu->pIcon)) / 2));

      D4D_DrawRBmp(&tmp_point, pMenu->pIcon, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius);
    }

    if(pMenu->title_text.pText)
    {
      tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 4);

      #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE
      tmp_point.x += (D4D_COOR)(pThis->radius/2);
      #endif

      if(pMenu->pIcon != NULL)
        tmp_point.x += D4D_GetBmpHeight(pMenu->pIcon);

      tmp_point.y = _calc.contentGeom.pnt.y;

      tmp_size.cx = D4D_GetTextWidth(pMenu->title_text.fontId, pMenu->title_text.pText);
      tmp_size.cy = D4D_GetFontHeight(pMenu->title_text.fontId);

      D4D_DrawTextRect(&tmp_point, &tmp_size, &pMenu->title_text, clrT, clrB);
    }

    if(_calc.titleBar_y)
    {
      D4D_MoveToXY(_calc.contentGeom.pnt.x,\
        (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y));

      D4D_LineToXY((D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - 1),\
        (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y), D4D_LINE_THIN, clrT);
    }
  }

  // Draw the frame
  if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
    D4D_DrawFrame(pThis, clrT, clrB);

  if(pThis->initFlags & D4D_MENU_F_INDEX)
  {
    // Draw index counter
    tmp_txtbuff.printLen = (D4D_INDEX)((_calc.itemsCnt < 10)? 3:5);
    tmp_size.cx = (D4D_COOR)(tmp_txtbuff.printLen * D4D_GetFontWidth(pMenu->indexFontId) + 2);
    tmp_size.cy = (D4D_COOR)(_calc.titleBar_y - 2);
    tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - tmp_size.cx - 2);
    tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y);

    #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE
      tmp_size.cy -= (D4D_COOR)(pThis->radius / 2);
      tmp_point.x -= (D4D_COOR)(pThis->radius / 2);
      tmp_point.y += (D4D_COOR)(pThis->radius / 2);
    #endif

    tmp_txtbuff.pText = _calc.index_txt;
    tmp_txtbuff.fontId = pMenu->indexFontId;
    tmp_str_prty.font_properties = D4D_MENU_IX_FNT_PRTY_DEFAULT;
    tmp_str_prty.text_properties = D4D_MENU_IX_TXT_PRTY_DEFAULT;
    D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);
  }

  for(tmpB = 0; (tmpB < _calc.posCnt) && (tmpB + pMenu->pData->page_ix < _calc.itemsCnt); tmpB++)
  {
    if(((pMenu->pData->ix - pMenu->pData->page_ix) != tmpB) || (!D4D_IsEnabled(pThis)))
    {
      clrT = D4D_ObjectGetForeFillColor(pThis);
      clrB = D4D_ObjectGetBckgFillColor(pThis);
    }
    else
    {
      D4D_CLR_SCHEME *pScheme_tmp = D4D_ObjectGetScheme(pThis);
      clrT = pScheme_tmp->foreFocus;
      clrB = pScheme_tmp->bckgFocus;
    }

    // Draw menu item text
    if(pMenu->pItems[tmpB + pMenu->pData->page_ix].text.pText != NULL)
    {
      tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.maxIcon.cx + 4);
      tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 1 + (tmpB * _calc.textOff));

      tmp_size.cx = (D4D_COOR)(_calc.contentGeom.sz.cx - (_calc.maxIcon.cx + 6 + ((D4D_GET_MENU_SCROLL_BAR_HOR(pThis)->pData->flags & D4D_OBJECT_F_VISIBLE)? D4D_MENU_SCRLBR_WIDTH:0)));
      #if D4D_ROUND_CORNER_ENABLE != D4D_FALSE
        tmp_point.x += (D4D_COOR)(pThis->radius / 2);
        tmp_size.cx -= (D4D_COOR)(pThis->radius / 1);
      #endif
      tmp_size.cy = D4D_GetFontHeight(pMenu->itemsFontId); // to invoke autosize capability in axis Y

      tmp_txtbuff.pText = pMenu->pItems[tmpB + pMenu->pData->page_ix].text.pText;
      tmp_txtbuff.fontId = pMenu->itemsFontId;
      tmp_txtbuff.buffSize = 0;
      tmp_txtbuff.printLen = D4D_GetTextLength(tmp_txtbuff.pText);
      tmp_str_prty.font_properties = D4D_MENU_ITEM_FNT_PRTY_DEFAULT;
      tmp_str_prty.text_properties = D4D_MENU_ITEM_TXT_PRTY_DEFAULT;


      D4D_DrawTextRect(&tmp_point, &tmp_size, &tmp_txtbuff, clrT, clrB);
    }

    // Draw menu item icon
    if(_calc.maxIcon.cx)
    {
      tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + 3);

      if(_calc.maxIcon.cy < _calc.textOff)
        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 3 + (tmpB * _calc.textOff) + ((D4D_GetFontHeight(pMenu->itemsFontId) - _calc.maxIcon.cy) / 2));
      else
        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.titleBar_y + 3 + (tmpB * _calc.textOff));

      if(pMenu->pItems[tmpB + pMenu->pData->page_ix].pIcon != NULL)
        D4D_DrawRBmp(&tmp_point, pMenu->pItems[tmpB + pMenu->pData->page_ix].pIcon, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius);
      else
        D4D_FillRRect(&tmp_point, &_calc.maxIcon, D4D_ObjectGetBckgFillColor(pThis), pThis->radius);
    }
  }
}
Ejemplo n.º 7
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);
      }
    }
}
Ejemplo n.º 8
0
static void D4D_CheckBoxOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis = pMsg->pObject;
    D4D_CHECKBOX* pCheckB = D4D_GET_CHECKBOX(pThis);
    D4D_CHECKBOX_STATUS* pStatus = D4D_GET_CHECKBOX_STATUS(pThis);    
    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;    
    D4D_COLOR clrT, clrB;
    D4D_CLR_SCHEME* pScheme = D4D_ObjectGetScheme(pThis);
    D4D_BMP_PROPERTIES bmpProp;
    
    bmpProp = (D4D_ALIGN_V_CENTER_MASK | D4D_ALIGN_H_CENTER_MASK);
    
    D4D_CheckBoxValue2Coor(pThis);
    
    clrT = D4D_ObjectGetForeColor(pThis, draw);
    clrB = D4D_ObjectGetBckgFillColor(pThis);

    if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
      D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);  
   
    // Draw the frame
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
      D4D_DrawFrame(pThis, clrT, clrB);    
 
    // normal bitmap (also may be NULL if simple rect button is needed  
    if(*pStatus & D4D_CHECKBOX_STATUS_CHECKED_MASK)
    {
      if(pCheckB->pBmpChecked != NULL)         
        D4D_DrawRBmpRect(&_calc.BmpGeom.pnt, &_calc.BmpGeom.sz, pCheckB->pBmpChecked, bmpProp, pScheme->objectDepend.checkBox.iconBckg, (D4D_BOOL)!D4D_IsEnabled(pThis), _calc.iconRadius);  // draw the bitmap            
      else
      {
        D4D_POINT tmp_point = _calc.BmpGeom.pnt;
        D4D_SIZE tmp_size = _calc.BmpGeom.sz;
        if(tmp_size.cy - 2 > 0)
        {
          tmp_point.x++;
          tmp_point.y++;
          
          tmp_size.cx -= 2;
          tmp_size.cy -= 2;
          
          D4D_RBox(&tmp_point, &tmp_size, D4D_LINE_THICK, clrB, clrT, _calc.iconRadius);
        }
      }
    }    
    // no bitmap
    else
    {     
      if(pCheckB->pBmpUnChecked)
      {
        // draw the bitmap
        D4D_DrawRBmpRect(&_calc.BmpGeom.pnt, &_calc.BmpGeom.sz, pCheckB->pBmpUnChecked, bmpProp, pScheme->objectDepend.checkBox.iconBckg, (D4D_BOOL)!D4D_IsEnabled(pThis), _calc.iconRadius);   
      }else
      {        
        // draw just a color rectangle instead of bitmap
        
        D4D_FillRRect(&_calc.BmpGeom.pnt, &_calc.BmpGeom.sz, pScheme->objectDepend.checkBox.iconBckg, _calc.iconRadius);        
      }
    }
    
    if(pThis->initFlags & D4D_CHECKBOX_F_ICON_RECTANGLE)
      D4D_RRect(&_calc.BmpGeom.pnt, &_calc.BmpGeom.sz, D4D_LINE_THIN, clrT, _calc.iconRadius);        
    
    // draw the text
    if(pCheckB->textBuff.pText)
      D4D_DrawTextRect(&_calc.TxtGeom.pnt, &_calc.TxtGeom.sz, &pCheckB->textBuff, clrT, D4D_ObjectGetBckgColor(pThis, draw));
    
}
Ejemplo n.º 9
0
static void D4D_IconOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis  =  pMsg->pObject;
    D4D_ICON* pIcon = D4D_GET_ICON(pThis);    
    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
    D4D_COLOR clrT, clrB;
    D4D_BMP_PROPERTIES bmpProp;
    
    D4D_IconValue2Coor(pThis);
    
    bmpProp = (D4D_ALIGN_V_TOP_MASK | D4D_ALIGN_H_CENTER_MASK);    
    
    clrT = D4D_ObjectGetForeColor(pThis, draw);
    clrB = D4D_ObjectGetBckgColor(pThis, draw);
    
    // Draw the frame
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
      D4D_DrawFrame(pThis, clrT, clrB);

    // draw the bitmap        
    if(pIcon->pBmpX[pIcon->pData->index] != NULL)
      D4D_DrawRBmpRect(&_calc.contentGeom.pnt,&_calc.contentGeom.sz, pIcon->pBmpX[pIcon->pData->index], bmpProp, clrB, (D4D_BOOL)(!D4D_IsEnabled(pThis)), pThis->radius);
    
    // draw the text
    if(pIcon->textBuff.pText != NULL)
    {
      D4D_SIZE tmp_size;
      tmp_size.cx = D4D_GetTextWidth(pIcon->textBuff.fontId, pIcon->textBuff.pText);
      tmp_size.cy = D4D_GetFontHeight(pIcon->textBuff.fontId);
        
      D4D_DrawTextRect(&_calc.txtPos, &tmp_size, &pIcon->textBuff, clrT, clrB); 
    }    
}
Ejemplo n.º 10
0
static void D4D_SldrOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis = pMsg->pObject;
    D4D_SLIDER* pSldr = D4D_GET_SLIDER(pThis);
    D4D_COLOR clrT, clrB;
    D4D_COLOR clrBar = pSldr->pData->colorBar;
    D4D_COLOR clrBarBckg = D4D_ObjectGetScheme(pThis)->objectDepend.slider.barBckg;

    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;

    #ifdef D4D_DEBUG
      // sanity check
      D4D_ASSERT(sizeof(_calc) <= D4D_SCRATCHPAD_SIZE);
    #endif

    // bar coordinate calculation
    D4D_SldrValue2Coor(pThis);

    clrT = D4D_ObjectGetForeColor(pThis, draw);
    clrB = D4D_ObjectGetBckgColor(pThis, draw);

    // if slider is disabled draw slider in grey scale
    if(!D4D_IsEnabled(pThis))
    {
      clrBar = D4D_GetGreyScale(clrBar);
      clrBarBckg = D4D_GetGreyScale(clrBarBckg);
    }



    // when background redraw is needed
    if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
    {
      // draw the bitmap
      if(pSldr->pBmpBkgd != NULL)
          D4D_DrawRBmp(&_calc.position, pSldr->pBmpBkgd, (D4D_BOOL)!D4D_IsEnabled(pThis), pThis->radius);
      else
          D4D_FillRRect(&_calc.position, &pThis->size, D4D_ObjectGetBckgFillColor(pThis), pThis->radius);
    }

    // draw focus rectangle
    D4D_RRect(&_calc.position, &pThis->size, D4D_LINE_THIN, clrT, pThis->radius);

    // draw first inactive part
    D4D_FillRRect(&_calc.bar1Geom.pnt, &_calc.bar1Geom.sz, clrBarBckg, _calc.inner_radius);

    // draw last inactive part of the bar
    D4D_FillRRect(&_calc.bar3Geom.pnt, &_calc.bar3Geom.sz, clrBarBckg, _calc.inner_radius);

    // draw active part of the bar
    if(pThis->initFlags & D4D_SLDR_F_BAR_SCALECOLOR)
      D4D_FillRRectColorScale(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, D4D_COLOR_SLDR_BAR_START, clrBar, _calc.dir, _calc.bar_radius);
    else
      D4D_FillRRect(&_calc.bar2Geom.pnt, &_calc.bar2Geom.sz, clrBar, _calc.inner_radius);

    // Draw the frame
    if(draw & (D4D_OBJECT_DRAWFLAGS_COMPLETE | D4D_OBJECT_DRAWFLAGS_STATE))
      D4D_DrawFrame(pThis, clrT, clrB);


    // draw the text
    if(pSldr->textBuff.pText != NULL)
    {
      D4D_SIZE tmp_size;

      _calc.position.x += pSldr->txtOff.x;
      _calc.position.y += pSldr->txtOff.y;

      if(!pSldr->txtOff.x)
      {
        if(_calc.isHorizontal)
          _calc.position.x += (D4D_COOR) ((_calc.contentGeom.sz.cx - (D4D_COOR)(D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText))) / 2);
        else
          _calc.position.x += (D4D_COOR) (_calc.bar1Geom.pnt.x + 1);
      }

      if(!pSldr->txtOff.y)
        _calc.position.y += (D4D_COOR) (((_calc.contentGeom.sz.cy - D4D_GetFontHeight(pSldr->textBuff.fontId)) / 2) + 1);

      if(pThis->initFlags & D4D_SLDR_F_TEXT_AUTOCOLOR)
          clrT = (D4D_COLOR)(~clrBar);

      tmp_size.cx = D4D_GetTextWidth(pSldr->textBuff.fontId, pSldr->textBuff.pText);
      tmp_size.cy = D4D_GetFontHeight(pSldr->textBuff.fontId);


      D4D_DrawTextRect(&_calc.position, &tmp_size, &pSldr->textBuff, clrT, clrB);

    }

}