Exemplo n.º 1
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); 
    }    
}
Exemplo n.º 2
0
/*******************************************************
*
* COMBO_BOX Child Object CallBack function from button
*
*******************************************************/
Byte D4D_ComboBoxButtonMsgFeedBack(D4D_MESSAGE* pMsg)
{
  if(pMsg->nMsgId == D4D_MSG_DRAW && bmp_arrow.pParam)
  {
    D4D_COLOR color = D4D_ObjectGetBckgColor(pMsg->pObject, pMsg->prm.draw);

    ((Word*)(bmp_arrow.pParam))[0] = D4D_COLOR_RGB565(D4D_COLOR_GET_R(color), D4D_COLOR_GET_G(color), D4D_COLOR_GET_B(color));

    color = D4D_ObjectGetForeColor(pMsg->pObject, pMsg->prm.draw);

    ((Word*)(bmp_arrow.pParam))[1] = D4D_COLOR_RGB565(D4D_COLOR_GET_R(color), D4D_COLOR_GET_G(color), D4D_COLOR_GET_B(color));
  }

  return D4D_MSG_NOSKIP;
}
Exemplo n.º 3
0
static void D4D_LabelOnDraw(D4D_MESSAGE* pMsg)
{
    D4D_OBJECT* pThis = pMsg->pObject;
    D4D_LABEL* pLbl = D4D_GET_LABEL(pThis);
    D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
    D4D_COLOR clrT, clrB;

    D4D_LblValue2Coor(pThis);

    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 text
    if(pLbl->textBuff.pText)
      D4D_DrawTextRRect(&_calc.contentGeom.pnt, &_calc.contentGeom.sz, &pLbl->textBuff, clrT, clrB, pThis->radius);
}
Exemplo n.º 4
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));
    
}
Exemplo n.º 5
0
static void D4D_ScrlBrOnDraw(D4D_MESSAGE* pMsg)
{
  D4D_OBJECT* pThis = pMsg->pObject;
  D4D_OBJECT_DRAWFLAGS draw = pMsg->prm.draw;
  D4D_COLOR clrT, clrB;
  D4D_POINT tmp_point;
  D4D_SIZE tmp_size;

  D4D_ScrlBrValue2Coor(pThis);

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

  // draw the rectangle around the text
  if(draw & D4D_OBJECT_DRAWFLAGS_COMPLETE)
    D4D_FillRRect(&_calc.position, &pThis->size, clrB, pThis->radius);

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

      tmp_point = _calc.contentGeom.pnt;

      if(pThis->size.cx > pThis->size.cy)
      {
        // horizontal scroll bar
        // draw first arrow button left

        tmp_size.cx = tmp_size.cy = _calc.contentGeom.sz.cy;

        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.x += (D4D_COOR)(_calc.contentGeom.sz.cx - _calc.contentGeom.sz.cy);
        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cy / 8);
        tmp_point.y += (D4D_COOR)(_calc.contentGeom.sz.cy / 2);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cy / 2) - 2),D4D_DIR_LEFT,clrT);

        // draw second arrow button right
        tmp_point.x = (D4D_COOR)(_calc.contentGeom.pnt.x + _calc.contentGeom.sz.cx - _calc.contentGeom.sz.cy / 8);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cy / 2) - 2),D4D_DIR_RIGHT,clrT);

      }else
      {
        // vertical scroll bar
        tmp_size.cx = tmp_size.cy = _calc.contentGeom.sz.cx;

        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.y += (D4D_COOR)(_calc.contentGeom.sz.cy - _calc.contentGeom.sz.cx);
        D4D_RRect(&tmp_point, &tmp_size, D4D_LINE_THIN, clrT, _calc.scrollRadius);

        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.contentGeom.sz.cx / 8);
        tmp_point.x += (D4D_COOR)(_calc.contentGeom.sz.cx / 2);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cx / 2) - 2),D4D_DIR_UP,clrT);

        // draw second arrow button right
        tmp_point.y = (D4D_COOR)(_calc.contentGeom.pnt.y + _calc.contentGeom.sz.cy - _calc.contentGeom.sz.cx / 8);
        D4D_ScrlBrDrawArrow( &tmp_point,(D4D_COOR)((_calc.contentGeom.sz.cx / 2) - 2),D4D_DIR_DOWN,clrT);
      }
    }

  D4D_FillRect(&_calc.refreshPos, &_calc.refreshSize, clrB);
  D4D_FillRRect(&_calc.scrollPos, &_calc.scrollSize, clrT, _calc.scrollRadius);

}
Exemplo n.º 6
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);

    }

}