void BAbstractSpinner::Draw(BRect updateRect) { _DrawLabel(updateRect); _DrawTextView(updateRect); fIncrement->Invalidate(); fDecrement->Invalidate(); }
/********************************************************************* * * _DrawDiagramAt */ static void _DrawDiagramAt(GUI_MEMDEV_Handle hMem, int xPos, int yPos, int * py, int xBlend) { GUI_MEMDEV_Handle hMemOld; GUI_RECT Rect; int IndexBmBar; int ySizeBar; int i; hMemOld = GUI_MEMDEV_Select(hMem); // // Draw blue background // GUI_SetColor(0x4a2210); GUI_FillRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); // // Draw grid lines // GUI_SetColor(0x774830); for (i = 0; i < 12; i++) { GUI_DrawHLine(yPos + 6 + i * 10, xPos + 2, xPos + GRAPH_WIDTH - 2); } // // Draw bars // for (i = 0; i < 10; i++) { IndexBmBar = (i < 6) ? i / 2 : 4 - (i / 2); ySizeBar = *(py + i); GUI_DrawBitmapMag(_apBmBar[IndexBmBar], xPos + 8 + i * 16, yPos + GRAPH_HEIGHT - ySizeBar - 6, 1, ySizeBar); } // // Draw alpha effect // Rect.x0 = xPos; Rect.x1 = xPos + 3; Rect.y0 = yPos; Rect.y1 = yPos + GRAPH_HEIGHT; GUI_SetClipRect(&Rect); GUI_SetColor(0xd99100); GUI_SetAlpha(168); GUI_FillRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); GUI_SetClipRect(NULL); GUI_FillRect(xPos + 4, yPos + 1, xPos + xBlend, yPos + GRAPH_HEIGHT - 1); GUI_SetAlpha(0); // // Draw orange frame // GUI_SetColor(0x0094f3); GUI_DrawRoundedRect(xPos, yPos, xPos + GRAPH_WIDTH, yPos + GRAPH_HEIGHT, 4); // // Label // _DrawLabel(hMem, xPos, yPos); GUI_MEMDEV_CopyToLCD(hMem); GUI_MEMDEV_Select(hMemOld); }
/********************************************************************* * * _DemoBarGraph */ static void _DemoBarGraph(void) { GUI_MEMDEV_Handle hMem; int ayOrg[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 }; int ayCur[] = { 10, 20, 40, 50, 90, 100, 80, 30, 20, 10 }; int aAdd[GUI_COUNTOF(ayOrg)]; int NextState; int TimeStart; int xPosGraph; int yPosGraph; int AddBlend; int NumItems; int TimeDiff; int TimeStep; int Blend; int xSize; int ySize; int i; // // Initialize values; // AddBlend = 1; Blend = 64; NumItems = GUI_COUNTOF(ayOrg); xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); xPosGraph = (xSize - GRAPH_WIDTH) / 2; yPosGraph = (ySize - GRAPH_HEIGHT) / 2; // // Create MEMDEV // hMem = GUI_MEMDEV_Create(xPosGraph, yPosGraph, GRAPH_WIDTH + 7 + 1, GRAPH_HEIGHT + 1); if (hMem == 0) { return; } GUI_MEMDEV_CopyFromLCD(hMem); for (i = 0; i < NumItems; i++) { aAdd[i] = (i & 1) * 2 - 1; } _DrawLabel(0, xPosGraph, yPosGraph); TimeStart = GUIDEMO_GetTime(); do { TimeDiff = GUIDEMO_GetTime() - TimeStart; _DrawDiagramAt(hMem, xPosGraph, yPosGraph, ayCur, Blend); Blend += AddBlend; if ((Blend >= 164) || (Blend <= 8)) { AddBlend = -AddBlend; } for (i = 0; i < NumItems; i++) { *(ayCur + i) += *(aAdd + i); if ((*(ayCur + i) > (*(ayOrg + i) + 10)) || (*(ayCur + i) < (*(ayOrg + i) - 10))) { *(aAdd + i) = -*(aAdd + i); } } TimeStep = GUIDEMO_GetTime() - TimeStart; if ((TimeStep - TimeDiff) < TIME_STEP) { GUI_Delay(TIME_STEP - (TimeStep - TimeDiff)); } else { GUI_Exec(); } NextState = GUIDEMO_CheckCancel(); } while ((TimeDiff < SHOW_TIME) && (NextState == 0)); GUI_MEMDEV_Delete(hMem); }