/********************************************************************* * * _Paint */ static void _Paint(SLIDER_Obj* pObj/*, GUI_RECT*pRect*/) { int i; int xsize; int x0; GUI_RECT r, rFocus, rSlider, rSlot; WIDGET__GetClientRect(&pObj->Widget, &rFocus); GUI__ReduceRect(&r, &rFocus, 1); xsize = r.x1 - r.x0 + 1 - pObj->Width /*- 2*xSizeEffect*/; x0 = r.x0 + pObj->Width / 2; GUI_SetBkColor(pObj->aBkColor[0]); GUI_Clear(); /* Calculate Slider position */ rSlider = r; rSlider.y0 = 5; rSlider.x0 = x0 + xsize * (pObj->v - pObj->Min) / (pObj->Max - pObj->Min) - 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 */ GUI_SetColor(GUI_BLACK); for (i = 0; i <= pObj->NumSections; i++) { int x = x0 + xsize * i / pObj->NumSections; WIDGET__DrawVLine(&pObj->Widget, x, 1, 3); } /* Draw the slider itself */ GUI_SetColor(pObj->aColor[0]); WIDGET__FillRectEx(&pObj->Widget, &rSlider); GUI_SetColor(GUI_BLACK); WIDGET__EFFECT_DrawUpRect(&pObj->Widget, &rSlider); /* Draw focus */ if (pObj->Widget.State & WIDGET_STATE_FOCUS) { GUI_SetColor(GUI_BLACK); WIDGET__DrawFocusRect(&pObj->Widget, &rFocus, 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); } }
/********************************************************************* * * _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); } }
/********************************************************** * _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); } }
/********************************************************************* * * _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); } }