Exemplo n.º 1
0
BOOL GradientRect(HDC hdc, const LPRECT lpRect, DWORD dwColor1, DWORD dwColor2, bool bVertical) { 
  TRIVERTEX vertex[2];
  vertex[0].x     = lpRect->left;
  vertex[0].y     = lpRect->top;
  vertex[0].Red   = GetRValue(dwColor1) << 8;
  vertex[0].Green = GetGValue(dwColor1) << 8;
  vertex[0].Blue  = GetBValue(dwColor1) << 8;
  vertex[0].Alpha = 0x0000;
  vertex[1].x     = lpRect->right;
  vertex[1].y     = lpRect->bottom;
  vertex[1].Red   = GetRValue(dwColor2) << 8;
  vertex[1].Green = GetGValue(dwColor2) << 8;
  vertex[1].Blue  = GetBValue(dwColor2) << 8;
  vertex[1].Alpha = 0x0000;
  GRADIENT_RECT gRect = {0, 1};
  return GdiGradientFill(hdc, vertex, 2, &gRect, 1, static_cast<ULONG>(bVertical));
}
Exemplo n.º 2
0
Arquivo: draw.c Projeto: GYGit/reactos
BOOL
MyDrawCaptionTemp(HWND hwnd, HDC hdc, const RECT *rect, HFONT hFont, HICON hIcon, LPCWSTR str, UINT uFlags, COLOR_SCHEME *scheme)
{
    //ULONG Height;
    //UINT VCenter, Padding;
    //LONG ButtonWidth;
    HBRUSH hbr;
    HGDIOBJ hFontOld;
    RECT rc;

    //Height = scheme->Size[SIZE_CAPTION_Y] - 1;
    //VCenter = (rect->bottom - rect->top) / 2;
    //Padding = VCenter - (Height / 2);

    //ButtonWidth = scheme->Size[SIZE_SIZE_X] - 2;

    if (uFlags & DC_GRADIENT)
    {
        GRADIENT_RECT gcap = {0, 1};
        TRIVERTEX vert[2];
        COLORREF Colors[2];

        Colors[0] = scheme->crColor[((uFlags & DC_ACTIVE) ?
            COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION)];
        Colors[1] = scheme->crColor[((uFlags & DC_ACTIVE) ?
            COLOR_GRADIENTACTIVECAPTION : COLOR_GRADIENTINACTIVECAPTION)];

        vert[0].x = rect->left;
        vert[0].y = rect->top;
        vert[0].Red = (WORD)Colors[0]<<8;
        vert[0].Green = (WORD)Colors[0] & 0xFF00;
        vert[0].Blue = (WORD)(Colors[0]>>8) & 0xFF00;
        vert[0].Alpha = 0;

        vert[1].x = rect->right;
        vert[1].y = rect->bottom;
        vert[1].Red = (WORD)Colors[1]<<8;
        vert[1].Green = (WORD)Colors[1] & 0xFF00;
        vert[1].Blue = (WORD)(Colors[1]>>8) & 0xFF00;
        vert[1].Alpha = 0;

        GdiGradientFill(hdc, vert, 2, &gcap, 1, GRADIENT_FILL_RECT_H);
    }
Exemplo n.º 3
0
void VolumeMeterData::DrawVolumeMeter(HDC hDC)
{
    HDC hdcTemp = CreateCompatibleDC(hDC);
    HBITMAP hbmpTemp = CreateCompatibleBitmap(hDC, cx, cy);
    SelectObject(hdcTemp, hbmpTemp);

    RECT clientRect = {0, 0, cx, cy};
    FillRect(hdcTemp, &clientRect, (HBRUSH)COLOR_WINDOW);

    int cxAdjust = cx;
    
    const int padding = 1;

    /* bound volume values */
    float workingVol = max(VOL_MIN, curVolume);
    workingVol = min(VOL_MAX, workingVol);
    float workingMax = max(VOL_MIN, curMax);
    workingMax = min(VOL_MAX, workingMax);

    /* convert dB to logarithmic then to linear scale [0, 1] */
    float rmsScale = (DBtoLog(workingVol) - minLinear) / (maxLinear - minLinear);
    float maxScale = (DBtoLog(workingMax) - minLinear) / (maxLinear - minLinear);

    LONG yStart = 0, yEnd = cy - 5;
    RECT meterRMS = {0, yStart, (LONG)(cx * rmsScale), yEnd};
    RECT meterGray = {0, 0, cx, yEnd};
    
    FillRect(hdcTemp, &meterGray, hLightGray);
    FillRect(hdcTemp, &meterRMS, hGreenDark);

    /* gradient info setup */
    TRIVERTEX        vert[2] ;
    GRADIENT_RECT    gRect;
    vert [0] .x      = (LONG)(cx * rmsScale);
    vert [0] .y      = 0;
    vert [0] .Red    = 0x2000;
    vert [0] .Green  = 0x7d00;
    vert [0] .Blue   = 0x1700;
    vert [0] .Alpha  = 0x0000;
    vert [1] .x      = (LONG)(cx * maxScale);
    vert [1] .y      = yEnd; 
    vert [1] .Red    = 0x3e00;
    vert [1] .Green  = 0xf100;
    vert [1] .Blue   = 0x2b00;
    vert [1] .Alpha  = 0x0000;
    gRect.UpperLeft  = 0;
    gRect.LowerRight = 1;
    GdiGradientFill(hdcTemp,vert,2,&gRect,1,GRADIENT_FILL_RECT_H);

    
    
    /* draw 6dB graduations */
    for(int i = 0; i < 16; i++)
    {
        float scale = graduations[i];
        RECT graduation = {(LONG)(cx * scale), cy - 4, ((LONG)(cx * scale)) + 1, cy};
        FillRect(hdcTemp, &graduation, hGray);
    }
    
    /* draw peak sample indicator */
    float peakScale = (DBtoLog(curPeak) - minLinear) / (maxLinear - minLinear);
    bool maxxed = curPeak >= 0;
    if(maxxed)
        peakScale = 1.0f;
    RECT graduation = {(LONG)(cx * peakScale) - ((maxxed)?1:0), 0, ((LONG)(cx * peakScale)) + 1, cy};
    FillRect(hdcTemp, &graduation, (maxxed)?hRed:hBlack);

    BitBlt(hDC, 0, 0, cx, cy, hdcTemp, 0, 0, SRCCOPY);

    DeleteObject(hdcTemp);
    DeleteObject(hbmpTemp);
}