예제 #1
0
파일: d4d_menu.c 프로젝트: Gargy007/eGUI
static D4D_COOR D4D_GetTitleBarHeight(D4D_OBJECT* pThis)
{
  D4D_MENU* pMenu = D4D_GET_MENU(pThis);

  D4D_COOR bar_height = 0;

  if(pMenu->title_text.pText != NULL)
    bar_height = D4D_GetFontHeight(pMenu->title_text.fontId);

  if(pThis->initFlags & D4D_MENU_F_INDEX)
    if(D4D_GetFontHeight(pMenu->indexFontId) > bar_height)
      bar_height = D4D_GetFontHeight(pMenu->indexFontId);

  if(pMenu->pIcon != NULL)
    if(D4D_GetBmpHeight(pMenu->pIcon) > bar_height)
      bar_height = D4D_GetBmpHeight(pMenu->pIcon);

  if(bar_height)
  {
    bar_height += 3;

    #if D4D_ROUND_CORNER_ENABLE == D4D_TRUE
      bar_height += pThis->radius / 2;
    #endif
  }

  return bar_height;
}
예제 #2
0
파일: d4d_menu.c 프로젝트: Gargy007/eGUI
static D4D_SIZE D4D_GetIconsMaxSize(D4D_MENU *pMenu)
{
  Byte tmpB;
  D4D_SIZE tmpSize =  {0, 0};
  D4D_MENU_INDEX itemsCnt = D4D_GetItemsCount(pMenu);


  // compute max width of used Icons
  for(tmpB = 0; tmpB < itemsCnt; tmpB++)
  {
    if(pMenu->pItems[tmpB].pIcon != NULL)
    {
      if(D4D_GetBmpWidth(pMenu->pItems[tmpB].pIcon) > tmpSize.cx)
        tmpSize.cx = D4D_GetBmpWidth(pMenu->pItems[tmpB].pIcon);

      if(D4D_GetBmpHeight(pMenu->pItems[tmpB].pIcon) > tmpSize.cy)
        tmpSize.cy = D4D_GetBmpHeight(pMenu->pItems[tmpB].pIcon);
    }
  }
  return tmpSize;
}
예제 #3
0
/**************************************************************//*!
*
* Compute size of screen header 
*
******************************************************************/
D4D_COOR D4D_GetScrHeaderSize(D4D_SCREEN* pScreen)
{
  D4D_COOR tmp_size = 0;
  
  if(pScreen == NULL)
    return 0;
  
  if((pScreen->flags & D4D_SCR_F_TITLEBAR) || pScreen->textBuff.pText)
  {
    tmp_size = (D4D_COOR)(D4D_SCR_TITLE_OFF_Y * 2 + D4D_GetFontHeight(pScreen->textBuff.fontId));
  }

  if(pScreen->pIcon != NULL)
    if(tmp_size < (D4D_GetBmpHeight(pScreen->pIcon) + D4D_SCR_TITLE_OFF_Y * 2 + 1))
      tmp_size = (D4D_COOR)(D4D_GetBmpHeight(pScreen->pIcon) + D4D_SCR_TITLE_OFF_Y * 2 + 1);          
  
  if(pScreen->flags & D4D_SCR_F_TITLEBAR) 
    if(tmp_size < D4D_SCR_HEADER_SIZE_MIN_SIZE)
      tmp_size = D4D_SCR_HEADER_SIZE_MIN_SIZE;   
        
  return tmp_size;  
}
예제 #4
0
파일: d4d_menu.c 프로젝트: Gargy007/eGUI
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);
    }
  }
}
예제 #5
0
/**************************************************************//*!
*
* 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);
    }
  }
}