コード例 #1
0
ファイル: d4d_progress_bar.c プロジェクト: ErichStyger/eGUI
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);
                
   }
コード例 #2
0
ファイル: d4d_screen.c プロジェクト: ErichStyger/eGUI
/**************************************************************//*!
*
* Redraw non client screen area - Header, background, title, etc.
*
******************************************************************/
static void D4D_DrawScreenNC(D4D_SCREEN* pScreen, D4D_BOOL active)
{
  D4D_CLR_SCHEME *pScheme = D4D_ScreenGetScheme(pScreen);
  D4D_COLOR clr;
  D4D_GEOMETRY contentGeom;
  D4D_POINT tmpPoint;
  D4D_SIZE tmpSize;
  
  contentGeom.pnt = pScreen->position;
  contentGeom.sz = pScreen->size;
  
  if(pScreen->flags & D4D_SCR_F_BEVEL)
  {
    contentGeom.pnt.x += D4D_BEVEL_WIDTH;
    contentGeom.pnt.y += D4D_BEVEL_WIDTH;
    contentGeom.sz.cx -= 2*D4D_BEVEL_WIDTH;
    contentGeom.sz.cy -= 2*D4D_BEVEL_WIDTH;
    
  }else if(pScreen->flags & D4D_SCR_F_OUTLINE)
  {
    contentGeom.pnt.x++;
    contentGeom.pnt.y++;
    contentGeom.sz.cx -= 2;
    contentGeom.sz.cy -= 2;      
  }
  
  if(active)
  {    
    if(pScreen->flags & D4D_SCR_F_BCKG)
    {    
      D4D_FillRRect(&contentGeom.pnt, &contentGeom.sz, pScheme->screen.desktop, pScreen->radius);
    }
    
    if(pScreen->flags & D4D_SCR_F_BEVEL)
    {
      D4D_Bevel(&(pScreen->position), &(pScreen->size), pScheme->screen.outline, D4D_BEVEL_RAISED, pScreen->radius);
    }else if(pScreen->flags & D4D_SCR_F_OUTLINE)
    {
      D4D_RRect(&(pScreen->position), &(pScreen->size), D4D_LINE_THIN, pScheme->screen.outline, pScreen->radius);
    }
  }

  if(pScreen->flags & D4D_SCR_F_TITLEBAR)
  {
    
    clr = pScheme->screen.title_bar;
    
    if(!active)
      clr = D4D_GetGreyScale(clr);    
    
    tmpSize = contentGeom.sz;
    tmpSize.cy = D4D_GetScrHeaderSize(pScreen);
    
    if(tmpSize.cy)
      tmpSize.cy--;

    D4D_FillRRect(&contentGeom.pnt, &tmpSize, clr, pScreen->radius);    
  }

  if(pScreen->pIcon != NULL)
  {
    tmpPoint = contentGeom.pnt;
    tmpPoint.x += D4D_SCR_TITLE_OFF_X;
    tmpPoint.y += (D4D_COOR)((D4D_GetScrHeaderSize(pScreen) - D4D_GetBmpHeight(pScreen->pIcon)) / 2);
    
    D4D_DrawRBmp(&tmpPoint, pScreen->pIcon, (D4D_BOOL)!active, pScreen->radius);  
  }

  if(pScreen->textBuff.pText)
  {        
    tmpPoint = contentGeom.pnt;
    tmpPoint.x += D4D_GetScrHeaderTitleOffset(pScreen);
    tmpPoint.y += (D4D_COOR)((D4D_GetScrHeaderSize(pScreen) - D4D_GetFontHeight(pScreen->textBuff.fontId)) / 2);
    
    clr = pScheme->screen.title_text;
    
    if(!active)
      clr = D4D_GetGreyScale(clr);    
    
    D4D_DrawText(&tmpPoint, &pScreen->textBuff, clr, 0);
    }

  if(pScreen->flags & D4D_SCR_F_EXIT)
  {
    clr = pScheme->screen.exitBtnFore;
    
    if(!active)
      clr = D4D_GetGreyScale(clr);
    
    if(D4D_GetScrHeaderExitBtnCoor(pScreen, &tmpPoint, &tmpSize))
    {         
      D4D_RBox(&tmpPoint, &tmpSize, D4D_LINE_THIN, clr, pScheme->screen.exitBtnBckg, pScreen->radius);
      
      tmpPoint.x += D4D_SCR_EXITBTN_CROSS_SIZE;
      tmpPoint.y += D4D_SCR_EXITBTN_CROSS_SIZE;    
#if D4D_ROUND_CORNER_ENABLE != D4D_FALSE    
      tmpPoint.x += (D4D_COOR)(pScreen->radius / 2);
      tmpPoint.y += (D4D_COOR)(pScreen->radius / 2);
#endif      
      
      D4D_MoveTo(&tmpPoint);
      tmpPoint.x += tmpSize.cx - (2 * D4D_SCR_EXITBTN_CROSS_SIZE);
      tmpPoint.y += tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE);
#if D4D_ROUND_CORNER_ENABLE != D4D_FALSE    
      tmpPoint.x -= (D4D_COOR)(pScreen->radius);
      tmpPoint.y -= (D4D_COOR)(pScreen->radius);
#endif        
      
      D4D_LineTo(&tmpPoint, D4D_LINE_THIN, clr);
      
      tmpPoint.y -= tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE);    
#if D4D_ROUND_CORNER_ENABLE != D4D_FALSE    
      tmpPoint.y += (D4D_COOR)(pScreen->radius);
#endif       
      D4D_MoveTo(&tmpPoint);
      tmpPoint.x -= tmpSize.cx - (2 * D4D_SCR_EXITBTN_CROSS_SIZE);
      tmpPoint.y += tmpSize.cy - (2 * D4D_SCR_EXITBTN_CROSS_SIZE);    
#if D4D_ROUND_CORNER_ENABLE != D4D_FALSE    
      tmpPoint.x += (D4D_COOR)(pScreen->radius);
      tmpPoint.y -= (D4D_COOR)(pScreen->radius);
#endif 
      D4D_LineTo(&tmpPoint, D4D_LINE_THIN, clr);
    }
  }
}
コード例 #3
0
ファイル: d4d_slider.c プロジェクト: Learnee/eGUI
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);

    }

}