Esempio n. 1
0
void CLCDProgressBar::OnDraw(CLCDGfx &rGfx)
{   
    rGfx.ClearScreen();

    // draw the border
    RECT r = { 0, 0, GetWidth(), GetHeight() };
    
    FrameRect(rGfx.GetHDC(), &r, m_hBrush);

    // draw the progress
    switch(m_eStyle)
    {
    case STYLE_CURSOR:
        {
            int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                   (float)1, (float)(GetWidth() - m_nCursorWidth-1),
                                   m_fPos);
            r.left = nCursorPos;
            r.right = r.left + m_nCursorWidth;
            FillRect(rGfx.GetHDC(), &r, m_hBrush);
        }
        break;
    case STYLE_FILLED:
        {
            int nBarWidth = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                  0.0f, (float)GetWidth(),
                                  m_fPos);
            r.right = nBarWidth;
            FillRect(rGfx.GetHDC(), &r, m_hBrush);
        }
        break;
    default:
        break;
    }
}
Esempio n. 2
0
void CLCDMyProgressBar::OnDraw(CLCDGfxBase& rGfx)
{
    // draw the border
    RECT r = { 0, 0, GetWidth(), GetHeight() };

    FrameRect(rGfx.GetHDC(), &r, m_hBrush);

    // draw the progress
    switch (m_eMyStyle) {
        case STYLE_CURSOR: {
            int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                         (float)1, (float)(GetWidth() - m_nCursorWidth - 1),
                                         m_fPos);
            r.left = nCursorPos;
            r.right = r.left + m_nCursorWidth;
            FillRect(rGfx.GetHDC(), &r, m_hBrush);
        }
        break;
        case STYLE_FILLED_H:
        case STYLE_FILLED_V: {
            int nBar = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                   0.0f, (m_eMyStyle == STYLE_FILLED_H ? (float)GetWidth() : (float)GetHeight()) - 4,
                                   m_fPos);
            r.left   = r.left + 2;
            r.bottom = r.bottom - 2;
            if (m_eMyStyle == STYLE_FILLED_H) {
                r.right = nBar + 2;
                r.top   = r.top + 2;
            } else {
                r.right = r.right - 2;
                r.top   = r.bottom - nBar;
            }

            FillRect(rGfx.GetHDC(), &r, m_hBrush);
        }
        break;
        case STYLE_DASHED_CURSOR: {
            int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                         (float)1, (float)(GetWidth() - m_nCursorWidth - 1),
                                         m_fPos);
            r.left = nCursorPos;
            r.right = r.left + m_nCursorWidth;
            FillRect(rGfx.GetHDC(), &r, m_hBrush);
            HPEN hOldPen = (HPEN)::SelectObject(rGfx.GetHDC(), m_hPen);

            ::MoveToEx(rGfx.GetHDC(), 0, (r.bottom - r.top) / 2, NULL);
            ::LineTo(rGfx.GetHDC(), nCursorPos, (r.bottom - r.top) / 2);
            ::SelectObject(rGfx.GetHDC(), hOldPen);
        }
        break;
        default:
            break;
    }
}
Esempio n. 3
0
int CLCDProgressBar::Scale(int nFromMin, int nFromMax,
                           int nToMin, int nToMax, __int64 nFromValue)
{
    return (int)Scalef(
        (float)nFromMin,
        (float)nFromMax,
        (float)nToMin,
        (float)nToMax,
        nFromValue
        );
}
Esempio n. 4
0
void CLCDSkinnedProgressBar::OnDraw(CLCDGfxBase &rGfx)
{
    RECT rBoundary = { 0, 0, GetWidth(), GetHeight() };

    HDC hdcMem = CreateCompatibleDC(rGfx.GetHDC());
    HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, m_hBackground);

    //Draw the background
    //BitBlt the background onto the screen
    BLENDFUNCTION opblender = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
    AlphaBlend(rGfx.GetHDC(), 0, 0, GetWidth(), GetHeight(), hdcMem, 0, 0, GetWidth(), GetHeight(), opblender);

    SelectObject(hdcMem, hbmOld);
    DeleteDC(hdcMem);

    //Drawing the cursor
    switch(m_eStyle)
    {
    case STYLE_FILLED:
        {
            

            HDC hdcMemCursor = CreateCompatibleDC(rGfx.GetHDC());

            if(m_bUse3P)
            {
                RECT r = rBoundary;
                r.left = 0;
                r.right = GetWidth() - m_3PCursorRightWidth - m_3PCursorLeftWidth;
                int nBarWidth = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                    (float)r.left, (float)r.right,
                    m_fPos);

                int midstart, midwidth;
                midstart = m_3PCursorLeftWidth;
                midwidth = nBarWidth;

                //Left
                hbmOld = (HBITMAP)SelectObject(hdcMemCursor, m_h3PCursorLeft);

                AlphaBlend(rGfx.GetHDC(), 0, 0, m_3PCursorLeftWidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorLeftWidth, m_3PCursorLeftHeight, opblender);

                //Mid
                SelectObject(hdcMemCursor, m_h3PCursorMid);

                AlphaBlend(rGfx.GetHDC(), midstart, 0, midwidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorMidWidth, m_3PCursorMidHeight, opblender);

                //Right
                SelectObject(hdcMemCursor, m_h3PCursorRight);

                AlphaBlend(rGfx.GetHDC(), midstart+midwidth, 0, m_3PCursorRightWidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorRightWidth, m_3PCursorRightHeight, opblender);

                // restore previous bitmap
                SelectObject(hdcMemCursor, hbmOld);
                
            }
            else
            {     
                RECT r = rBoundary;
                int nBarWidth = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                    (float)rBoundary.left, (float)(rBoundary.right),
                    m_fPos);
                r.right = nBarWidth ? nBarWidth : r.left;

                HBITMAP hbmOldCursor = (HBITMAP)SelectObject(hdcMemCursor, m_hFiller);

                BitBlt(rGfx.GetHDC(), 0, 0, nBarWidth, GetHeight(), hdcMemCursor, 0, 0, SRCCOPY);

                SelectObject(hdcMemCursor, hbmOldCursor);
            }

            DeleteDC(hdcMemCursor);

            break;
        }
        //These two cases will be the same
    case STYLE_CURSOR:
    case STYLE_DASHED_CURSOR:
        {
            HDC hdcMemCursor = CreateCompatibleDC(rGfx.GetHDC());

            if(m_bUse3P)
            {
                RECT r = rBoundary;
                int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                    (float)rBoundary.left, (float)(rBoundary.right - m_nCursorWidth),
                    m_fPos);
                r.left = nCursorPos;
                r.right = nCursorPos + m_nCursorWidth;

                int midstart, midwidth;
                midstart = r.left+m_3PCursorLeftWidth;
                midwidth = m_3PCursorMidWidth;
                
                //Left
                hbmOld = (HBITMAP)SelectObject(hdcMemCursor, m_h3PCursorLeft);

                AlphaBlend(rGfx.GetHDC(), r.left, 0, m_3PCursorLeftWidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorLeftWidth, m_3PCursorLeftHeight, opblender);

                //Mid
                SelectObject(hdcMemCursor, m_h3PCursorMid);

                AlphaBlend(rGfx.GetHDC(), midstart, 0, midwidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorMidWidth, m_3PCursorMidHeight, opblender);

                //Right                
                SelectObject(hdcMemCursor, m_h3PCursorRight);

                AlphaBlend(rGfx.GetHDC(), midstart+midwidth, 0, m_3PCursorRightWidth, GetHeight(), 
                    hdcMemCursor, 0, 0, m_3PCursorRightWidth, m_3PCursorRightHeight, opblender);

                // restore old bitmap
                SelectObject(hdcMemCursor, hbmOld);
            }
            else
            {
                RECT r = rBoundary;
                int nCursorPos = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                    (float)rBoundary.left, (float)(rBoundary.right - m_nCursorWidth),
                    m_fPos);
                r.left = nCursorPos;
                r.right = nCursorPos + m_nCursorWidth;
                
                HBITMAP hbmOldCursor = (HBITMAP)SelectObject(hdcMemCursor, m_hCursor);

                BitBlt(rGfx.GetHDC(), r.left, 0, m_nCursorWidth, GetHeight(), hdcMemCursor, 0, 0, SRCCOPY);

                SelectObject(hdcMemCursor, hbmOldCursor);
            }

            DeleteDC(hdcMemCursor);

            break;
        }
    default:
        break;
    }

    if( NULL != m_hHighlight )
    {
        HDC hdcMemHighlight = CreateCompatibleDC(rGfx.GetHDC());
        HBITMAP hbmOldHighlight = (HBITMAP)SelectObject(hdcMemHighlight, m_hHighlight);

        AlphaBlend(rGfx.GetHDC(), 0, 0, GetWidth(), GetHeight(), hdcMemHighlight, 0, 0, m_HighlightWidth, m_HighlightHeight, opblender);

        SelectObject(hdcMemHighlight, hbmOldHighlight);
        DeleteDC(hdcMemHighlight);
    }
}