/*********************************************************************
*
*       _WIDGET_EFFECT_3D1L_DrawDownRect
*/
static void _WIDGET_EFFECT_3D1L_DrawDownRect(const GUI_RECT* pRect) {
  GUI_RECT r;
  r = *pRect;
  /* Draw the upper left sides */
  LCD_SetColor(0x606060);
  GUI_DrawHLine(r.y0, r.x0, r.x1 - 1);
  GUI_DrawVLine(r.x0, r.y0 + 1, r.y1 - 1);
  /* Draw the lower right sides */
  LCD_SetColor(0xE7E7E7);
  GUI_DrawHLine(r.y1, r.x0, r.x1);
  GUI_DrawVLine(r.x1, r.y0, r.y1 - 1);
}
Exemple #2
0
/*********************************************************************
*
*       _InitContext
*
* Purpose
*   Initializes the given context.
*
* Special considerations
*   Make sure that no GUI functions are called, because locking is
*   not allowed here (GUITASK_INIT not yet called).
*/
static void _InitContext(GUI_CONTEXT* pContext) {
    /* memset(..,0,..) is not required, as this function is called only at startup of the GUI when data is 0 */
#if GUI_SUPPORT_DEVICES
    pContext->pDeviceAPI   = LCD_aAPI[0]; /* &LCD_L0_APIList; */
#endif
    pContext->pClipRect_HL = &GUI_Context.ClipRect;
    LCD_L0_GetRect(&pContext->ClipRect);
#if GUI_SUPPORT_AA
    pContext->pLCD_HL      = &_HL_APIList;
#endif
    pContext->pAFont       = GUI_DEFAULT_FONT;
    pContext->pClipRect_HL = &GUI_Context.ClipRect;
    pContext->PenSize      = 1;
    /* Variables in WM module */
#if GUI_WINSUPPORT
    pContext->hAWin    = WM_GetDesktopWindow();
#endif
    /* Variables in GUI_AA module */
#if GUI_SUPPORT_AA
    pContext->AA_Factor = 3;
#endif
    pContext->Color   = GUI_INVALID_COLOR;
    pContext->BkColor = GUI_INVALID_COLOR;
    LCD_SetBkColor(GUI_DEFAULT_BKCOLOR);
    LCD_SetColor(GUI_DEFAULT_COLOR);
#if GUI_SUPPORT_UNICODE
    pContext->pUC_API = &GUI_UC_None;
#endif
}
Exemple #3
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(TEXT_Handle hObj, TEXT_Obj* pObj) {
  const char * s;
  GUI_RECT Rect;
  GUI_USE_PARA(hObj);
  LCD_SetColor(pObj->Props.TextColor);
  GUI_SetFont    (pObj->Props.pFont);
  /* Fill with parents background color */
  #if !TEXT_SUPPORT_TRANSPARENCY   /* Not needed any more, since window is transparent*/
    if (pObj->Props.BkColor == GUI_INVALID_COLOR) {
      LCD_SetBkColor(WIDGET__GetBkColor(hObj));
    } else {
      LCD_SetBkColor(pObj->Props.BkColor);
    }
    GUI_Clear();
  #else
    if (!WM_GetHasTrans(hObj)) {
      LCD_SetBkColor(pObj->Props.BkColor);
      GUI_Clear();
    }
  #endif
  /* Show the text */
  if (pObj->hpText) {
    s = (const char*) GUI_ALLOC_h2p(pObj->hpText);
    GUI_SetTextMode(GUI_TM_TRANS);
    WM_GetClientRect(&Rect);
    GUI_DispStringInRectWrap(s, &Rect, pObj->Align, pObj->Props.WrapMode);
  }
}
/*********************************************************************
*
*       _WIDGET_EFFECT_Simple_DrawDownRect
*/
static void _WIDGET_EFFECT_Simple_DrawDownRect(const GUI_RECT* pRect) {
  GUI_CONTEXT Context;
  GUI_SaveContext(&Context);
  LCD_SetColor(GUI_BLACK);
  GUI_DrawRect(pRect->x0, pRect->y0, pRect->x1, pRect->y1);          /* Draw rectangle around it */
  GUI_RestoreContext(&Context);
}
Exemple #5
0
/*********************************************************************
*
*       _DrawPart
*/
static void _DrawPart(const PROGBAR_Obj* pObj, int Index,
										  int xText, int yText, const char* pText) {
  LCD_SetBkColor(pObj->BarColor[Index]);
  LCD_SetColor(pObj->TextColor[Index]);
  GUI_Clear();
  GUI_GotoXY(xText, yText);
  GUI_DispString(pText);
}
/*********************************************************************
*
*       GUI_SetColor
*/
void GUI_SetColor(GUI_COLOR color) 
{
  GUI_LOCK();
  {
    LCD_SetColor(color);
  } 
  GUI_UNLOCK();
}
/*********************************************************************
*
*       _WritePixelsGray
*/
static void _WritePixelsGray(const U8*p, int x0, int y0, int xSize) {
  U8 u;
  while (xSize) {
    u = *p++;
    LCD_SetColor(u * (U32)0x10101);
    LCD_DrawPixel(x0++, y0);
    xSize--;
  }
}
/*********************************************************************
*
*       _WritePixelsRGB
*/
static void _WritePixelsRGB(const U8*p, int x0, int y0, int xSize) {
  U8 r,g,b;
  while (xSize) {
    r = *p++;
    g = *p++;
    b = *p++;
    LCD_SetColor(r | (g << 8) | (U32)((U32)b << 16));
    LCD_DrawPixel(x0++, y0);
    xSize--;
  }
}
Exemple #9
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(DROPDOWN_Handle hObj) {
  int Border;
  GUI_RECT r;
  const char* s;
  int InnerSize, ColorIndex;
  DROPDOWN_Obj* pObj;
  int TextBorderSize;
  /* Do some initial calculations */
  pObj = DROPDOWN_H2P(hObj);
  Border = pObj->Widget.pEffect->EffectSize;
  TextBorderSize = pObj->Props.TextBorderSize;
  GUI_SetFont(pObj->Props.pFont);
  ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1;
  s = _GetpItem(pObj, pObj->Sel);
  WM_GetClientRect(&r);
  GUI__ReduceRect(&r, &r, Border);
  InnerSize = r.y1 - r.y0 + 1;
  /* Draw the 3D effect (if configured) */
  WIDGET__EFFECT_DrawDown(&pObj->Widget);
  /* Draw the outer text frames */
  r.x1 -= InnerSize;     /* Spare square area to the right */
  LCD_SetColor(pObj->Props.aBackColor[ColorIndex]);
  /* Draw the text */
  LCD_SetBkColor(pObj->Props.aBackColor[ColorIndex]);
  GUI_FillRectEx(&r);
  r.x0 += TextBorderSize;
  r.x1 -= TextBorderSize;
  LCD_SetColor  (pObj->Props.aTextColor[ColorIndex]);
  GUI_DispStringInRect(s, &r, pObj->Props.Align);/**/
  /* Draw arrow */
  WM_GetClientRect(&r);
  GUI__ReduceRect(&r, &r, Border);
  r.x0 = r.x1 + 1 - InnerSize;
  LCD_SetColor(0xc0c0c0);
  GUI_FillRectEx(&r);
  LCD_SetColor(GUI_BLACK);
  _DrawTriangleDown((r.x1 + r.x0) / 2, r.y0 + 5, (r.y1 - r.y0 - 8) / 2);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
}
Exemple #10
0
static void _InitContext(GUI_CONTEXT* pContext) {
  #if GUI_SUPPORT_MEMDEV
    GUI_SelectLCD();
  #else
    LCD_SetClipRectMax();
  #endif
  pContext->pLCD_HL      = &LCD_HL_APIList;
  pContext->pAFont       = GUI_DEFAULT_FONT;
  pContext->pClipRect_HL = &GUI_Context.ClipRect;
  pContext->PenSize      = 1;
  /* Variables in WM module */
  #if GUI_WINSUPPORT
    pContext->hAWin    = WM_GetDesktopWindow();
  #endif
  /* Variables in GUI_AA module */
  pContext->AA_Factor = 3;
  LCD_SetBkColor(GUI_DEFAULT_BKCOLOR);
  LCD_SetColor(GUI_DEFAULT_COLOR);
}
/*
 * \brief Draws a rectangle with fill inside on LCD, at the given coordinates.
 *
 * \param x      X-coordinate of upper-left rectangle corner.
 * \param y      Y-coordinate of upper-left rectangle corner.
 * \param width  Rectangle width in pixels.
 * \param height  Rectangle height in pixels.
 * \param color  Rectangle color.
 */
extern void LCDD_DrawRectangleWithFill( uint32_t dwX, uint32_t dwY, uint32_t dwWidth, uint32_t dwHeight, uint32_t dwColor )
{
    uint32_t size, blocks;

    CheckBoxCoordinates(&dwX, &dwY, &dwWidth, &dwHeight);
    LCD_SetColor(dwColor);
    ILI9488_SetWindow( dwX, dwY, dwWidth, dwHeight ) ;

    size = (dwWidth - dwX + 1) * (dwHeight - dwY + 1);

    /* Send pixels blocks => one LCD IT / block */
    blocks = size / LCD_DATA_CACHE_SIZE;

    ILI9488_WriteRAM_Prepare() ;

    while (blocks--)
    {
        ILI9488_WriteRAMBuffer(gLcdPixelCache, LCD_DATA_CACHE_SIZE);
    }
    /* Send remaining pixels */
    ILI9488_WriteRAMBuffer(gLcdPixelCache, size % LCD_DATA_CACHE_SIZE);
    ILI9488_SetWindow( 0, 0, BOARD_LCD_WIDTH, BOARD_LCD_HEIGHT ) ;
    //    LCD_SetCursor( 0, 0 ) ;
}
Exemple #12
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(SCROLLBAR_Obj* pObj) {
  int ArrowSize, ArrowOff;
  SCROLLBAR_POSITIONS Pos;
  GUI_RECT r, rClient;
  /*
    Get / calc position info
  */
  _CalcPositions(pObj, &Pos);
  WIDGET__GetClientRect(&pObj->Widget, &rClient);
  r = rClient;
  ArrowSize = ((r.y1 - r.y0) /3) - 1;
  ArrowOff = 3 + ArrowSize+ ArrowSize/3;
  /*
    Draw left Arrow
  */
  LCD_SetColor(pObj->aColor[0]);
  r = rClient;
  r.x0 = Pos.x0_LeftArrow;
  r.x1 = Pos.x1_LeftArrow;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  LCD_SetColor(pObj->aBkColor[1]);
  _DrawTriangle(&pObj->Widget, r.x0 + ArrowOff, (r.y1 - r.y0) >> 1, ArrowSize, -1);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw the thumb area which is not covered by the thumb
  */
  LCD_SetColor(pObj->aBkColor[0]);
  r.x0 = Pos.x1_LeftArrow + 1;
  r.x1 = Pos.x0_Thumb - 1;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  r = rClient;
  r.x0 = Pos.x1_Thumb + 1;
  r.x1 = Pos.x0_RightArrow - 1;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  /*
    Draw Thumb
  */
  r = rClient;
  r.x0 = Pos.x0_Thumb;
  r.x1 = Pos.x1_Thumb;
  LCD_SetColor(pObj->aColor[0]);
  WIDGET__FillRectEx(&pObj->Widget, &r);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw right Arrow
  */
  LCD_SetColor(pObj->aColor[0]);
  r.x0 = Pos.x0_RightArrow;
  r.x1 = Pos.x1_RightArrow;
  WIDGET__FillRectEx(&pObj->Widget, &r);
  LCD_SetColor(pObj->aBkColor[1]);
  _DrawTriangle(&pObj->Widget, r.x1 - ArrowOff, (r.y1 - r.y0) >> 1, ArrowSize, 1);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &r);
  /*
    Draw overlap area (if any ...)
  */
  if (Pos.x1_RightArrow != Pos.x1) {
    r.x0 = Pos.x1_RightArrow + 1;
    r.x1 = Pos.x1;
    LCD_SetColor(pObj->aColor[0]);
    WIDGET__FillRectEx(&pObj->Widget, &r);
  }
}
Exemple #13
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, WM_MESSAGE* pMsg) {
  const GUI_ARRAY* pRow;
  GUI_RECT ClipRect, Rect;
  int NumRows, NumVisRows, NumColumns;
  int LBorder, RBorder, EffectSize;
  int xPos, yPos, Width, RowDistY;
  int Align, i, j, EndRow;
  /* Init some values */
  NumColumns = HEADER_GetNumItems(pObj->hHeader);
  NumRows    = GUI_ARRAY_GetNumItems(&pObj->RowArray);
  NumVisRows = _GetNumVisibleRows(hObj, pObj);
  RowDistY   = LISTVIEW__GetRowDistY(pObj);
  LBorder    = pObj->LBorder;
  RBorder    = pObj->RBorder;
  EffectSize = pObj->Widget.pEffect->EffectSize;
  yPos       = HEADER_GetHeight(pObj->hHeader) + EffectSize;
  EndRow     = pObj->ScrollStateV.v + (((NumVisRows + 1) > NumRows) ? NumRows : NumVisRows + 1);
  /* Calculate clipping rectangle */
  ClipRect = *(const GUI_RECT*)pMsg->Data.p;
  GUI_MoveRect(&ClipRect, -pObj->Widget.Win.Rect.x0, -pObj->Widget.Win.Rect.y0);
  WM_GetInsideRectExScrollbar(hObj, &Rect);
  GUI__IntersectRect(&ClipRect, &Rect);
  /* Set drawing color, font and text mode */
  LCD_SetColor(pObj->Props.aTextColor[0]);
  GUI_SetFont(pObj->Props.pFont);
  GUI_SetTextMode(GUI_TM_TRANS);
  /* Do the drawing */
  for (i = pObj->ScrollStateV.v; i < EndRow; i++) {
    pRow = (const GUI_ARRAY*)GUI_ARRAY_GetpItem(&pObj->RowArray, i);
    if (pRow) {
      Rect.y0 = yPos;
      /* Break when all other rows are outside the drawing area */
      if (Rect.y0 > ClipRect.y1) {
        break;
      }
      Rect.y1 = yPos + RowDistY - 1;
      /* Make sure that we draw only when row is in drawing area */
      if (Rect.y1 >= ClipRect.y0) {
        int ColorIndex;
        /* Set background color */
        if (i == pObj->Sel) {
          ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1;
        } else {
          ColorIndex = 0;
        }
        LCD_SetBkColor(pObj->Props.aBkColor[ColorIndex]);
        /* Iterate over all columns */
        if (pObj->ShowGrid) {
          Rect.y1--;
        }
        xPos = EffectSize - pObj->ScrollStateH.v;
        for (j = 0; j < NumColumns; j++) {
          Width   = HEADER_GetItemWidth(pObj->hHeader, j);
          Rect.x0 = xPos;
          /* Break when all other columns are outside the drawing area */
          if (Rect.x0 > ClipRect.x1) {
            break;
          }
          Rect.x1 = xPos + Width - 1;
          /* Make sure that we draw only when column is in drawing area */
          if (Rect.x1 >= ClipRect.x0) {
            LISTVIEW_ITEM * pItem;
            pItem = (LISTVIEW_ITEM *)GUI_ARRAY_GetpItem(pRow, j);
            if (pItem->hItemInfo) {
              LISTVIEW_ITEM_INFO * pItemInfo;
              pItemInfo = (LISTVIEW_ITEM_INFO *)GUI_ALLOC_h2p(pItem->hItemInfo);
              LCD_SetBkColor(pItemInfo->aBkColor[ColorIndex]);
              LCD_SetColor(pItemInfo->aTextColor[ColorIndex]);
            } else {
              LCD_SetColor(pObj->Props.aTextColor[ColorIndex]);
            }
            /* Clear background */
            GUI_ClearRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
            /* Draw text */
            Rect.x0 += LBorder;
            Rect.x1 -= RBorder;
            Align = *((int*)GUI_ARRAY_GetpItem(&pObj->AlignArray, j));
            GUI_DispStringInRect(pItem->acText, &Rect, Align);
            if (pItem->hItemInfo) {
              LCD_SetBkColor(pObj->Props.aBkColor[ColorIndex]);
            }
          }
          xPos += Width;
        }
        /* Clear unused area to the right of items */
        if (xPos <= ClipRect.x1) {
          GUI_ClearRect(xPos, Rect.y0, ClipRect.x1, Rect.y1);
        }
      }
      yPos += RowDistY;
    }
  }
  /* Clear unused area below items */
  if (yPos <= ClipRect.y1) {
    LCD_SetBkColor(pObj->Props.aBkColor[0]);
    GUI_ClearRect(ClipRect.x0, yPos, ClipRect.x1, ClipRect.y1);
  }
  /* Draw grid */
  if (pObj->ShowGrid) {
    LCD_SetColor(pObj->Props.GridColor);
    yPos = HEADER_GetHeight(pObj->hHeader) + EffectSize - 1;
    for (i = 0; i < NumVisRows; i++) {
      yPos += RowDistY;
      /* Break when all other rows are outside the drawing area */
      if (yPos > ClipRect.y1) {
        break;
      }
      /* Make sure that we draw only when row is in drawing area */
      if (yPos >= ClipRect.y0) {
        GUI_DrawHLine(yPos, ClipRect.x0, ClipRect.x1);
      }
    }
    xPos = EffectSize - pObj->ScrollStateH.v;
    for (i = 0; i < NumColumns; i++) {
      xPos += HEADER_GetItemWidth(pObj->hHeader, i);
      /* Break when all other columns are outside the drawing area */
      if (xPos > ClipRect.x1) {
        break;
      }
      /* Make sure that we draw only when column is in drawing area */
      if (xPos >= ClipRect.x0) {
        GUI_DrawVLine(xPos, ClipRect.y0, ClipRect.y1);
      }
    }
  }
  /* Draw the effect */
  WIDGET__EFFECT_DrawDown(&pObj->Widget);
}
Exemple #14
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(EDIT_Obj* pObj, EDIT_Handle hObj) {
  GUI_RECT rFillRect, rInside, rText, rInvert;
  const char GUI_UNI_PTR * pText = NULL;
  int IsEnabled, CursorWidth = 0;
  IsEnabled = WM__IsEnabled(hObj);
  /* Set colors and font */
  LCD_SetBkColor(pObj->Props.aBkColor[IsEnabled]);
  LCD_SetColor(pObj->Props.aTextColor[0]);
  GUI_SetFont(pObj->Props.pFont);
  /* Calculate size */
  WIDGET__GetInsideRect(&pObj->Widget, &rFillRect);
  if (pObj->hpText) {
    pText = (const char*) GUI_ALLOC_h2p(pObj->hpText);
  }
  rInside = rFillRect;
  rInside.x0 += pObj->Props.Border + EDIT_XOFF;
  rInside.x1 -= pObj->Props.Border + EDIT_XOFF;
  GUI__CalcTextRect(pText, &rInside, &rText, pObj->Props.Align);
  /* Calculate position and size of cursor */
  if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
    int NumChars;
    CursorWidth = ((pObj->XSizeCursor > 0) ? (pObj->XSizeCursor) : (1));
    NumChars    = GUI__GetNumChars(pText);
    if (pText) {
      U16 Char;
      int i, IsRTL = 0;
      if ((pObj->EditMode != GUI_EDIT_MODE_INSERT) || (pObj->SelSize)) {
        if (pObj->CursorPos < NumChars) {
          if (pObj->SelSize) {
            CursorWidth = 0;
            for (i = pObj->CursorPos; i < (int)(pObj->CursorPos + pObj->SelSize); i++) {
              Char = GUI__GetCursorCharacter(pText, i, NumChars, 0);
              CursorWidth += GUI_GetCharDistX(Char);
            }
            if (!CursorWidth) {
              CursorWidth = 1;
            }
          } else {
            Char = GUI__GetCursorCharacter(pText, pObj->CursorPos, NumChars, &IsRTL);
            CursorWidth = GUI_GetCharDistX(Char);
          }
        }
      }
      rInvert = rText;
      if (IsRTL) {
        rInvert.x0 -= CursorWidth;
      }
      rInvert.x0 += GUI__GetCursorPosX(pText, pObj->CursorPos, NumChars);
    }
  }
  /* WM loop */
  WM_ITERATE_START(NULL) {
    /* Set clipping rectangle */
    WM_SetUserClipRect(&rFillRect);
    /* Display text */
    WIDGET__FillStringInRect(pText, &rFillRect, &rInside, &rText);
    /* Display cursor if needed */
    if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
      GUI_InvertRect(rInvert.x0, rInvert.y0, rInvert.x0 + CursorWidth - 1, rInvert.y1);
    }
    WM_SetUserClipRect(NULL);
    /* Draw the 3D effect (if configured) */
    WIDGET__EFFECT_DrawDown(&pObj->Widget);
  } WM_ITERATE_END();
}
Exemple #15
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(BUTTON_Obj* pObj, BUTTON_Handle hObj) {
  const char* s = NULL;
  unsigned int Index;
  int State, PressedState, ColorIndex;
  GUI_RECT rClient, rInside;
  State = pObj->Widget.State;
  PressedState = (State & BUTTON_STATE_PRESSED) ? 1 : 0;
  ColorIndex   = (WM__IsEnabled(hObj)) ? PressedState : 2;
  GUI_SetFont(pObj->Props.pFont);
  GUI_DEBUG_LOG("BUTTON: Paint(..)\n");
  if (pObj->hpText) {
    s = (const char*) GUI_ALLOC_h2p(pObj->hpText);
  }
  GUI_GetClientRect(&rClient);
  /* Start drawing */
  rInside = rClient;
/* Draw the 3D effect (if configured) */
  #if BUTTON_USE_3D
  {
    int EffectSize;
    if ((PressedState) == 0) {
      pObj->Widget.pEffect->pfDrawUp();  /* _WIDGET_EFFECT_3D_DrawUp(); */
      EffectSize = pObj->Widget.pEffect->EffectSize;
    } else {
      LCD_SetColor(0x000000);
      GUI_DrawRect(rClient.y0, rClient.x0, rClient.x1, rClient.y1);
      EffectSize = 1;
    }
    GUI__ReduceRect(&rInside, &rInside, EffectSize); 
  }
  #endif
  /* Draw background */
  LCD_SetBkColor (pObj->Props.aBkColor[ColorIndex]);
  LCD_SetColor   (pObj->Props.aTextColor[ColorIndex]);
  WM_SetUserClipRect(&rInside);
  GUI_Clear();
  /* Draw bitmap.
     If we have only one, we will use it.
     If we have to we will use the second one (Index 1) for the pressed state
  */
  if (ColorIndex < 2) {
    Index = (pObj->ahDrawObj[BUTTON_BI_PRESSED] && PressedState) ? BUTTON_BI_PRESSED : BUTTON_BI_UNPRESSED;
  } else {
    Index = pObj->ahDrawObj[BUTTON_BI_DISABLED] ? BUTTON_BI_DISABLED : BUTTON_BI_UNPRESSED;
  }
  GUI_DRAW__Draw(pObj->ahDrawObj[Index], 0, 0);
/* Draw the actual button (background and text) */  
  {
    GUI_RECT r;
    r = rInside;
    #if BUTTON_USE_3D
      if (PressedState) {
        GUI_MoveRect(&r, BUTTON_3D_MOVE_X,BUTTON_3D_MOVE_Y);
      }
    #endif
    GUI_SetTextMode(GUI_TM_TRANS);
    GUI_DispStringInRect(s, &r, pObj->Props.Align);
  }
  /* Draw focus */
  if (State & BUTTON_STATE_FOCUS) {
    LCD_SetColor(pObj->Props.FocusColor);
    GUI_DrawFocusRect(&rClient, 2);
  }
  WM_SetUserClipRect(NULL);
}
Exemple #16
0
 /**********************************************************
  *                 _Paint
  *
  */
static void _Paint(SLIDER_Obj* pObj, WM_HWIN hObj)
{
   GUI_RECT r, rFocus, rSlider, rSlot;
   GUI_COLOR  SlotColor, SliderColor;
   int x0, xSize,  Range, NumTicks,hasFocus;
   WIDGET__GetClientRect(&pObj->Widget, &rFocus);
   GUI__ReduceRect(&r, &rFocus, 1);
   NumTicks  = pObj->NumTicks;
   xSize  = r.x1 - r.x0 + 1 - pObj->Width;
   x0     = r.x0 + pObj->Width / 2;
   Range  = pObj->Max - pObj->Min;
   
   if(Range == 0)
   {
      Range  = 1;
   }
   
   
   if(pObj->Widget.State & WIDGET_STATE_FOCUS)
   {
      LCD_SetColor(pObj->aBkColor[1]);
      SlotColor  = pObj->aColor[1];
      SliderColor  = pObj->aColor[3];
      
      hasFocus  = 1;
   }
   else
   {
      LCD_SetColor(pObj->aBkColor[0]);
      SlotColor  = pObj->aColor[0];
      SliderColor  = pObj->aColor[2];
      hasFocus  = 0;
   }
   
   GUI_Clear();
   GUI_FillRectEx(&rFocus);
   
   rSlider     = r;
   rSlider.y0  = 5;
   rSlider.x0  = x0 + (U32)xSize * (U32)(pObj->v - pObj->Min) / Range - pObj->Width / 2;
   rSlider.x1  = rSlider.x0 + pObj->Width;    
   
   LCD_SetColor(SlotColor);
   rSlot.x0  = x0;
   rSlot.x1  = x0 + xSize;
   rSlot.y0  = (rSlider.y0 + rSlider.y1) / 2 - 1;
   rSlot.y1  = rSlot.y0 + 3; 
   GUI_FillRectEx(&rSlot);
   
   if(hasFocus)
   {
      LCD_SetColor(GUI_WHITE);
      GUI_DrawRect(rSlot.x0-1, rSlot.y0-1, rSlot.x1+1,rSlot.y1+1);   
   }
    
   LCD_SetColor(SliderColor);   
   GUI_FillCircle(rSlider.x0+pObj->Width/2,(rSlider.y0+rSlider.y1)/2 , pObj->Width/2);  
   
   
   if(NumTicks > 0)
   {
      LCD_SetColor(GUI_BLACK);
      GUI_SetFont(GUI_FONT_16B_1);
      GUI_SetTextMode(GUI_TM_TRANS);
      GUI_DispDecAt(pObj->v, rSlider.x0+pObj->Width/2-3,(rSlider.y0+rSlider.y1)/2-8, 1);
   }
}
Exemple #17
0
/*********************************************************************
*
*       _OnPaint
*
* Purpose:
*   Paints the RADIO button.
*   The button can actually consist of multiple buttons (NumItems).
*   The focus rectangle will be drawn on top of the text if any text is set,
*   otherwise around the entire buttons.
*/
static void _OnPaint(RADIO_Handle hObj, RADIO_Obj* pObj) {
  const GUI_BITMAP* pBmRadio;
  const GUI_BITMAP* pBmCheck;
  const char* pText;
  GUI_FONTINFO FontInfo;
  GUI_RECT Rect, r, rFocus = {0};
  int i, y, HasFocus, FontDistY;
  U8 SpaceAbove, CHeight, FocusBorder;

  /* Init some data */
  WIDGET__GetClientRect(&pObj->Widget, &rFocus);
  HasFocus  = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 1 : 0;
  pBmRadio  = pObj->apBmRadio[WM__IsEnabled(hObj)];
  pBmCheck  = pObj->pBmCheck;
  rFocus.x1 = pBmRadio->XSize + RADIO_BORDER * 2 - 1;
  rFocus.y1 = pObj->Height + ((pObj->NumItems - 1) * pObj->Spacing) - 1;

  /* Select font and text color */
  LCD_SetColor(pObj->TextColor);
  GUI_SetFont(pObj->pFont);
  GUI_SetTextMode(GUI_TM_TRANS);

  /* Get font infos */
  GUI_GetFontInfo(pObj->pFont, &FontInfo);
  FontDistY   = GUI_GetFontDistY();
  CHeight     = FontInfo.CHeight;
  SpaceAbove  = FontInfo.Baseline - CHeight;
  Rect.x0     = pBmRadio->XSize + RADIO_BORDER * 2 + 2;
  Rect.y0     = (CHeight <= pObj->Height) ? ((pObj->Height - CHeight) / 2) : 0;
  Rect.y1     = Rect.y0 + CHeight - 1;
  FocusBorder = (FontDistY <= 12) ? 2 : 3;
  if (Rect.y0 < FocusBorder) {
    FocusBorder = Rect.y0;
  }

  /* Clear inside ... Just in case      */
  /* Fill with parents background color */
#if WM_SUPPORT_TRANSPARENCY
  if (!WM_GetHasTrans(hObj))
#endif
  {
    if (pObj->BkColor != GUI_INVALID_COLOR) {
      LCD_SetBkColor(pObj->BkColor);
    } else {
      LCD_SetBkColor(RADIO_DEFAULT_BKCOLOR);
    }
    GUI_Clear();
  }

  /* Iterate over all items */
  for (i = 0; i < pObj->NumItems; i++) {
    y = i * pObj->Spacing;
    /* Draw the radio button bitmap */
    GUI_DrawBitmap(pBmRadio, RADIO_BORDER, RADIO_BORDER + y);
    /* Draw the check bitmap */
    if (pObj->Sel == i) {
      GUI_DrawBitmap(pBmCheck, RADIO_BORDER +  (pBmRadio->XSize - pBmCheck->XSize) / 2, 
                               RADIO_BORDER + ((pBmRadio->YSize - pBmCheck->YSize) / 2) + y);
    }
    /* Draw text if available */
    pText = (const char*)GUI_ARRAY_GetpItem(&pObj->TextArray, i);
    if (pText) {
      if (*pText) {
        r = Rect;
        r.x1 = r.x0 + GUI_GetStringDistX(pText) - 2;
        GUI_MoveRect(&r, 0, y);
        GUI_DispStringAt(pText, r.x0, r.y0 - SpaceAbove);
        /* Calculate focus rect */
        if (HasFocus && (pObj->Sel == i)) {
          _ResizeRect(&rFocus, &r, FocusBorder);
        }
      }
    }
  }

  /* Draw the focus rect */
  if (HasFocus) {
    LCD_SetColor(GUI_BLACK);
    WIDGET__DrawFocusRect(&pObj->Widget, &rFocus, 0);
  }
}
Exemple #18
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, WM_MESSAGE* pMsg) {
  const LISTVIEW_ROW* pRow;
  GUI_RECT ClipRect, Rect;
  int NumRows, NumVisRows, NumColumns;
  int LBorder, RBorder, EffectSize;
  int xPos, yPos, Width, RowDistY;
  int Align, i, j, EndRow;
  /* Init some values */
  NumColumns = LISTVIEW__GetNumColumns(pObj);
  NumRows    = LISTVIEW__GetNumRows(pObj);
  NumVisRows = _GetNumVisibleRows(hObj, pObj);
  RowDistY   = LISTVIEW__GetRowDistY(pObj);
  LBorder    = pObj->LBorder;
  RBorder    = pObj->RBorder;
  EffectSize = pObj->Widget.pEffect->EffectSize;
  yPos       = HEADER_GetHeight(pObj->hHeader) + EffectSize;
  /* Calculate clipping rectangle */
  ClipRect = *(const GUI_RECT*)pMsg->Data.p;
  GUI_MoveRect(&ClipRect, -pObj->Widget.Win.Rect.x0, -pObj->Widget.Win.Rect.y0);
  WM_GetInsideRectExScrollbar(hObj, &Rect);
  GUI__IntersectRect(&ClipRect, &Rect);
  /* Set drawing color, font and text mode */
  LCD_SetColor(pObj->Props.aTextColor[0]);
  GUI_SetFont(pObj->Props.pFont);
  GUI_SetTextMode(GUI_TM_TRANS);
  /* Sort before drawing, because scroll position may change */
  if (pObj->hSort && (pObj->SortIndex >= 0)) {
    LISTVIEW_SORT * pSort;
    pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(pObj->hSort);
    if (pSort->fpSort(hObj)) {
      return; /* Return on error */
    }
  }
  /* Calculate end row after sorting, because scroll position may have changed */
  EndRow = pObj->ScrollStateV.v + (((NumVisRows + 1) > NumRows) ? NumRows : NumVisRows + 1);
  /* Do the drawing */
  for (i = pObj->ScrollStateV.v; i < EndRow; i++) {
    pRow = _GetpRow(pObj, i);
    if (pRow) {
      Rect.y0 = yPos;
      /* Break when all other rows are outside the drawing area */
      if (Rect.y0 > ClipRect.y1) {
        break;
      }
      Rect.y1 = yPos + RowDistY - 1;
      /* Make sure that we draw only when row is in drawing area */
      if (Rect.y1 >= ClipRect.y0) {
        int ColorIndex;
        /* Set background color */
        if (pRow->Disabled) {
          ColorIndex = LISTVIEW_CI_DISABLED;
        } else if (i == pObj->Sel) {
          ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? LISTVIEW_CI_SELFOCUS : LISTVIEW_CI_SEL;
        } else {
          ColorIndex = LISTVIEW_CI_UNSEL;
        }
        LCD_SetBkColor(pObj->Props.aBkColor[ColorIndex]);
        /* Iterate over all columns */
        if (pObj->ShowGrid) {
          Rect.y1--;
        }
        xPos = EffectSize - pObj->ScrollStateH.v;
        for (j = 0; j < NumColumns; j++) {
          Width   = HEADER_GetItemWidth(pObj->hHeader, j);
          Rect.x0 = xPos;
          /* Break when all other columns are outside the drawing area */
          if (Rect.x0 > ClipRect.x1) {
            break;
          }
          Rect.x1 = xPos + Width - 1;
          /* Make sure that we draw only when column is in drawing area */
          if (Rect.x1 >= ClipRect.x0) {
            LISTVIEW_COLUMN* pColumn;
            LISTVIEW_CELL* pCell;
            pCell = (LISTVIEW_CELL*)GUI_ARRAY_GetpItem(&pRow->CellArray, j);
            if (pCell) {
              if (pCell->hCellInfo) {
                LISTVIEW_CELL_INFO* pCellInfo;
                pCellInfo = (LISTVIEW_CELL_INFO*) GUI_ALLOC_h2p(pCell->hCellInfo);
                LCD_SetBkColor(pCellInfo->aBkColor[ColorIndex]);
                LCD_SetColor(pCellInfo->aTextColor[ColorIndex]);
              } else {
                LCD_SetColor(pObj->Props.aTextColor[ColorIndex]);
              }
              /* Clear background */
              GUI_ClearRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1);
              /* Draw text */
              Rect.x0 += LBorder;
              Rect.x1 -= RBorder;
              pColumn = (LISTVIEW_COLUMN*) GUI_ARRAY_GetpItem(&pObj->ColumnArray, j);
              Align = pColumn->Align;
              GUI_DispStringInRect(pCell->acText, &Rect, Align);
              if (pCell->hCellInfo) {
                LCD_SetBkColor(pObj->Props.aBkColor[ColorIndex]);
              }
            }
          }
          xPos += Width;
        }
        /* Clear unused area to the right of items */
        if (xPos <= ClipRect.x1) {
          GUI_ClearRect(xPos, Rect.y0, ClipRect.x1, Rect.y1);
        }
      }
      yPos += RowDistY;
    }
  }
  /* Clear unused area below items */
  if (yPos <= ClipRect.y1) {
    LCD_SetBkColor(pObj->Props.aBkColor[0]);
    GUI_ClearRect(ClipRect.x0, yPos, ClipRect.x1, ClipRect.y1);
  }
  /* Draw grid */
  if (pObj->ShowGrid) {
    LCD_SetColor(pObj->Props.GridColor);
    yPos = HEADER_GetHeight(pObj->hHeader) + EffectSize - 1;
    for (i = 0; i < NumVisRows; i++) {
      yPos += RowDistY;
      /* Break when all other rows are outside the drawing area */
      if (yPos > ClipRect.y1) {
        break;
      }
      /* Make sure that we draw only when row is in drawing area */
      if (yPos >= ClipRect.y0) {
        GUI_DrawHLine(yPos, ClipRect.x0, ClipRect.x1);
      }
    }
    xPos = EffectSize - pObj->ScrollStateH.v;
    for (i = 0; i < NumColumns; i++) {
      xPos += HEADER_GetItemWidth(pObj->hHeader, i);
      /* Break when all other columns are outside the drawing area */
      if (xPos > ClipRect.x1) {
        break;
      }
      /* Make sure that we draw only when column is in drawing area */
      if (xPos >= ClipRect.x0) {
        GUI_DrawVLine(xPos, ClipRect.y0, ClipRect.y1);
      }
    }
  }
  /* Draw the effect */
  WIDGET__EFFECT_DrawDown(&pObj->Widget);
}
Exemple #19
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(CHECKBOX_Obj* pObj, CHECKBOX_Handle hObj) {
  GUI_RECT RectBox = {0};
  int ColorIndex, EffectSize, Index;
  EffectSize = pObj->Widget.pEffect->EffectSize;
  ColorIndex = WM__IsEnabled(hObj);
  /* Clear inside ... Just in case      */
  /* Fill with parents background color */
#if WM_SUPPORT_TRANSPARENCY
  if (!WM_GetHasTrans(hObj))
#endif
  {
    if (pObj->Props.BkColor == GUI_INVALID_COLOR) {
      LCD_SetBkColor(WIDGET__GetBkColor(hObj));
    } else {
      LCD_SetBkColor(pObj->Props.BkColor);
    }
    GUI_Clear();
  }
  /* Get size from bitmap */
  RectBox.x1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->XSize - 1 + 2 * EffectSize;
  RectBox.y1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->YSize - 1 + 2 * EffectSize;
  WM_SetUserClipRect(&RectBox);
  /* Clear inside  ... Just in case */
  LCD_SetBkColor(pObj->Props.aBkColorBox[ColorIndex]);
  GUI_Clear();
  Index = pObj->CurrentState * 2 + ColorIndex;
  if (pObj->Props.apBm[Index]) {
    GUI_DrawBitmap(pObj->Props.apBm[Index], EffectSize, EffectSize);
  }
  /* Draw the effect arround the box */
  WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &RectBox);
  WM_SetUserClipRect(NULL);
  /* Draw text if needed */
  if (pObj->hpText) {
    const char * s;
    GUI_RECT RectText;
    /* Draw the text */
    s = (const char *) GUI_ALLOC_h2p(pObj->hpText);
    WM_GetClientRect(&RectText);
    RectText.x0 += RectBox.x1 + 1 + pObj->Props.Spacing;
    GUI_SetTextMode(GUI_TM_TRANS);
    LCD_SetColor(pObj->Props.TextColor);
    GUI_SetFont(pObj->Props.pFont);
    GUI_DispStringInRect(s, &RectText, pObj->Props.Align);
    /* Draw focus rectangle */
    if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
      int xSizeText = GUI_GetStringDistX(s);
      int ySizeText = GUI_GetFontSizeY();
      GUI_RECT RectFocus = RectText;
      switch (pObj->Props.Align & ~(GUI_TA_HORIZONTAL)) {
      case GUI_TA_VCENTER:
        RectFocus.y0 = (RectText.y1 - ySizeText + 1) / 2;
        break;
      case GUI_TA_BOTTOM:
        RectFocus.y0 = RectText.y1 - ySizeText;
        break;
      }
      switch (pObj->Props.Align & ~(GUI_TA_VERTICAL)) {
      case GUI_TA_HCENTER:
        RectFocus.x0 += ((RectText.x1 - RectText.x0) - xSizeText) / 2;
        break;
      case GUI_TA_RIGHT:
        RectFocus.x0 += (RectText.x1 - RectText.x0) - xSizeText;
        break;
      }
      RectFocus.x1 = RectFocus.x0 + xSizeText - 1;
      RectFocus.y1 = RectFocus.y0 + ySizeText - 1;
      LCD_SetColor(pObj->Props.FocusColor);
      GUI_DrawFocusRect(&RectFocus, -1);
    }
  }
}
Exemple #20
0
/*********************************************************************
*
*       LISTBOX_OwnerDraw
*/
int LISTBOX_OwnerDraw(const WIDGET_ITEM_DRAW_INFO* pDrawItemInfo) {
  switch (pDrawItemInfo->Cmd) {
    case WIDGET_ITEM_GET_XSIZE: {
      LISTBOX_Obj* pObj;
      const GUI_FONT GUI_UNI_PTR* pOldFont;
      const char* s;
      int DistX;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      pOldFont = GUI_SetFont(pObj->Props.pFont);
      s = LISTBOX__GetpString(pObj, pDrawItemInfo->ItemIndex);
      DistX = GUI_GetStringDistX(s);
      GUI_SetFont(pOldFont);
      return DistX;
    }
    case WIDGET_ITEM_GET_YSIZE: {
      LISTBOX_Obj* pObj;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      return GUI_GetYDistOfFont(pObj->Props.pFont) + pObj->ItemSpacing;
    }
    case WIDGET_ITEM_DRAW: {
      LISTBOX_Obj* pObj;
      LISTBOX_ITEM* pItem;
      WM_HMEM hItem;
      GUI_RECT r;
      int FontDistY;
      int ItemIndex = pDrawItemInfo->ItemIndex;
      const char* s;
      int ColorIndex;
      char IsDisabled;
      char IsSelected;
      pObj = LISTBOX_H2P(pDrawItemInfo->hWin);
      hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, ItemIndex);
      pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem);
      WM_GetInsideRect(&r);
      FontDistY = GUI_GetFontDistY();
      /* Calculate color index */
      IsDisabled = (pItem->Status & LISTBOX_ITEM_DISABLED) ? 1 : 0;
      IsSelected = (pItem->Status & LISTBOX_ITEM_SELECTED) ? 1 : 0;
      if (pObj->Flags & LISTBOX_SF_MULTISEL) {
        if (IsDisabled) {
          ColorIndex = 3;
        } else {
          ColorIndex = (IsSelected) ? 2 : 0;
        }
      } else {
        if (IsDisabled) {
          ColorIndex = 3;
        } else {
          if (ItemIndex == pObj->Sel) {
            ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1;
          } else {
            ColorIndex = 0;
          }
        }
      }
      /* Display item */
      LCD_SetBkColor(pObj->Props.aBackColor[ColorIndex]);
      LCD_SetColor  (pObj->Props.aTextColor[ColorIndex]);
      s = LISTBOX__GetpString(pObj, ItemIndex);
      GUI_SetTextMode(GUI_TM_TRANS);
      GUI_Clear();
      GUI_DispStringAt(s, pDrawItemInfo->x0 + 1, pDrawItemInfo->y0);
      /* Display focus rectangle */
      if ((pObj->Flags & LISTBOX_SF_MULTISEL) && (ItemIndex == pObj->Sel)) {
        GUI_RECT rFocus;
        rFocus.x0 = pDrawItemInfo->x0;
        rFocus.y0 = pDrawItemInfo->y0;
        rFocus.x1 = r.x1;
        rFocus.y1 = pDrawItemInfo->y0 + FontDistY - 1;
        LCD_SetColor(GUI_WHITE - pObj->Props.aBackColor[ColorIndex]);
        GUI_DrawFocusRect(&rFocus, 0);
      }
      return 0;
    }
  }
  return 0;
}
/*********************************************************************
*
*       _DrawBitmap
*/
static void _DrawBitmap(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag, tLCDDEV_Index2Color * pfIndex2Color) {
  const U32 * pData;
  int y, OldIndex, Mag, BytesPerLine, UseDrawBitmap = 0;
  U32 PrevColor;
  GUI_USE_PARA(pLogPal);
  OldIndex = LCD_GetColorIndex();
  PrevColor = GUI_INVALID_COLOR;
  pData = (const U32 *)pPixel;
  Mag = (xMag | yMag);
  BytesPerLine = xsize * 4;
  /* Check if bitmaps color format fits to the current color conversion */
  if (Mag == 1) {
    #if GUI_SUPPORT_MEMDEV
    if (!GUI_Context.hDevData) {
    #else
    {
    #endif
      if (LCD_GetpfIndex2ColorEx(GUI_Context.SelLayer) == pfIndex2Color) {
        UseDrawBitmap = 1;
      }
    }
  }
  if (UseDrawBitmap) {
    LCD_DrawBitmap(x0, y0, xsize, ysize, 1, 1, 24, BytesPerLine, pPixel, 0);
  } else {
    if (Mag == 1) {
      /* Perform clipping */
      int x1, y1, Diff;
      y1 = y0 + ysize - 1;
      x1 = x0 + xsize - 1;
      /* Clip Y */
      if (y0 < GUI_Context.ClipRect.y0) {
        Diff = GUI_Context.ClipRect.y0 - y0;
        y0   = GUI_Context.ClipRect.y0;
        #if GUI_SUPPORT_LARGE_BITMAPS                       /* Required only for 16 bit CPUs if some bitmaps are >64kByte */
          pData += (U32)Diff * (U32)BytesPerLine / 4;
        #else
          pData += (unsigned)Diff * (unsigned)BytesPerLine / 4;
        #endif
        ysize -= Diff;
      }
      Diff = y1 - GUI_Context.ClipRect.y1;
      if (Diff > 0) {
        ysize -= Diff;
      }
      if (ysize <=0) {
		    return;
      }
      /* Clip right side */
      Diff = x1 - GUI_Context.ClipRect.x1;
      if (Diff > 0) {
        xsize -= Diff;
      }
      /* Clip left side */
      if (x0 < GUI_Context.ClipRect.x0) {
        Diff = GUI_Context.ClipRect.x0 - x0;
			  xsize -= Diff;
        pData += Diff; 
        x0 += Diff; 
      }
      if (xsize <=0) {
		    return;
      }
      /* Simple, unmagnified output using LCD_L0_SetPixel() */
      for (y = 0; y < ysize; y++) {
        int x;
        const U32 * p = pData;
        for (x = 0; x < xsize; x++) {
          U32 Color;
          Color = *p++;
          if (Color != PrevColor) {
            LCD_SetColor(pfIndex2Color(Color));
            PrevColor = Color;
          }
          LCDDEV_L0_SetPixelIndex(x + x0, y + y0, LCD_COLORINDEX);
        }
        pData += BytesPerLine / 4;
      }
    } else {
      /* Magnified output using LCD_FillRect() */
      int x,y;
      int yi;
      for (y = y0, yi = 0; yi < ysize; yi++, y += yMag, pPixel += BytesPerLine) {
        int yMax;
        yMax = y + yMag - 1;
        /* Draw if within clip area */
        if ((yMax >= GUI_Context.ClipRect.y0) && (y <= GUI_Context.ClipRect.y1)) {
          int xi;
          const U32 GUI_UNI_PTR * p = pData;
          for (x = x0, xi = 0; xi < xsize; xi++, x += xMag) {
            U32 Color;
            Color = *p++;
            if (Color != PrevColor) {
              LCD_SetColor(pfIndex2Color(Color));
              PrevColor = Color;
            }
            LCD_FillRect(x, y, x + xMag - 1, yMax);
          }
        }
        pData += BytesPerLine / 4;
      }
    }
    GUI_SetColorIndex(OldIndex);
  }
}

/*********************************************************************
*
*       _DrawBitmap_565
*/
static void _DrawBitmap_888(int x0, int y0, int xsize, int ysize, const U8 GUI_UNI_PTR * pPixel, const LCD_LOGPALETTE GUI_UNI_PTR * pLogPal, int xMag, int yMag) {
  _DrawBitmap(x0, y0, xsize, ysize, pPixel, pLogPal, xMag, yMag, GUI_BitmapMethods888.pfIndex2Color);
}
Exemple #22
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(SLIDER_Obj* pObj, WM_HWIN hObj) {
  GUI_RECT r, rFocus, rSlider, rSlot;
  int x0, xsize, i, Range, NumTicks;
  WIDGET__GetClientRect(&pObj->Widget, &rFocus);
  GUI__ReduceRect(&r, &rFocus, 1);
  NumTicks = pObj->NumTicks;
  xsize    = r.x1 - r.x0  + 1 - pObj->Width;
  x0       = r.x0 + pObj->Width / 2;
  Range    = pObj->Max - pObj->Min;
  if (Range == 0) {
    Range = 1;
  }
  /* Fill with parents background color */
  #if !SLIDER_SUPPORT_TRANSPARENCY   /* Not needed any more, since window is transparent*/
    if (pObj->Props.BkColor == GUI_INVALID_COLOR) {
      LCD_SetBkColor(WIDGET__GetBkColor(hObj));
    } else {
      LCD_SetBkColor(pObj->Props.BkColor);
    }
    GUI_Clear();
  #else
    if (!WM_GetHasTrans(hObj)) {
      LCD_SetBkColor(pObj->Props.BkColor);
      GUI_Clear();
    }
  #endif
  /* Calculate Slider position */
  rSlider    = r;
  rSlider.y0 = 5;
  rSlider.x0 = x0 + (U32)xsize * (U32)(pObj->v - pObj->Min) / Range - pObj->Width / 2;
  rSlider.x1 = rSlider.x0 + pObj->Width;
  /* Calculate Slot position */
  rSlot.x0 = x0;
  rSlot.x1 = x0 + xsize;
  rSlot.y0 = (rSlider.y0 + rSlider.y1) / 2 - 1;
  rSlot.y1 = rSlot.y0 + 3;
  WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &rSlot);        /* Draw slot */
  /* Draw the ticks */
  if (NumTicks < 0) {
    NumTicks = Range + 1;
    if (NumTicks > (xsize / 5)) {
      NumTicks = 11;
    }
  }
  if (NumTicks > 1) {
    LCD_SetColor(GUI_BLACK);
    for (i = 0; i < NumTicks; i++) {
      int x = x0 + xsize * i / (NumTicks - 1);
      WIDGET__DrawVLine(&pObj->Widget, x, 1, 3);
    }
  }
  /* Draw the slider itself */
  LCD_SetColor(pObj->Props.Color);
  WIDGET__FillRectEx(&pObj->Widget, &rSlider);
  LCD_SetColor(GUI_BLACK);
  WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &rSlider);
  /* Draw focus */
  if (pObj->Widget.State & WIDGET_STATE_FOCUS) {
    LCD_SetColor(pObj->Props.FocusColor);
    WIDGET__DrawFocusRect(&pObj->Widget, &rFocus, 0);
  }
}