void CLCDAnimatedBitmap::OnDraw(CLCDGfx &rGfx)
{
    if(m_dwTotalSubpics > 0)
    {
        int xoffs = m_dwCurrSubpic * m_dwSubpicWidth;

        DWORD increment = m_dwElapsedTime / m_dwRate;
        if(increment > 0)
        {
            m_dwCurrSubpic += increment;
            m_dwCurrSubpic %= m_dwTotalSubpics;
            m_dwElapsedTime %= m_dwRate;
			m_dwLastUpdate = m_dwLastTickCount;
        }
        
        // stolen from: CLCDBitmap::OnDraw(rGfx);
        if(m_hBitmap)
        {
            HDC hCompatibleDC = CreateCompatibleDC(rGfx.GetHDC());
            HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, m_hBitmap);
            
            // get
            BitBlt(rGfx.GetHDC(), 0, 0, m_Size.cx, m_Size.cy, hCompatibleDC, xoffs, 0, m_dwROP);
            
            // restores
            SelectObject(hCompatibleDC, hOldBitmap);
            DeleteDC(hCompatibleDC);
        }
    }
}
Exemplo n.º 2
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;
    }
}
Exemplo n.º 3
0
void CLCDIcon::OnDraw(CLCDGfx &rGfx)
{
    int nOldBkMode = SetBkMode(rGfx.GetHDC(), TRANSPARENT);

    if (m_hIcon)
    {
        DrawIconEx(rGfx.GetHDC(), 0, 0, m_hIcon,
                   m_nIconWidth, m_nIconHeight, 0, NULL, DI_NORMAL);
    }

    // restores
    SetBkMode(rGfx.GetHDC(), nOldBkMode);
}
Exemplo n.º 4
0
void CLCDBitmap::OnDraw(CLCDGfx &rGfx)
{
    if(m_hBitmap)
    {
        HDC hCompatibleDC = CreateCompatibleDC(rGfx.GetHDC());
        HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC, m_hBitmap);
        
        BitBlt(rGfx.GetHDC(), 0, 0, m_Size.cx, m_Size.cy, hCompatibleDC, m_ptLogical.x, m_ptLogical.y, m_dwROP);
        
        // restores
        SelectObject(hCompatibleDC, hOldBitmap);
        DeleteDC(hCompatibleDC);
    }
}
Exemplo n.º 5
0
void CLCDText::DrawText(CLCDGfx &rGfx)
{
    // draw the text
    RECT rBoundary = { 0, 0,0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 
    DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rBoundary, m_nTextFormat, &m_dtp);
    
//    LCDUITRACE(_T("Drawing %s at (%d,%d)-(%d-%d) lmargin=%d, rmargin=%d\n"),
//         m_sText.c_str(), m_Origin.x, m_Origin.y, GetWidth(), GetHeight(),
//         m_dtp.iLeftMargin, m_dtp.iRightMargin);

    if (m_bInverted)
    {
        InvertRect(rGfx.GetHDC(), &rBoundary);
    }
}
Exemplo n.º 6
0
void CLCDText::DrawText(CLCDGfx &rGfx)
{
    // draw the text
    RECT rBoundary = { 0, 0,0 + GetLogicalSize().cx, 0 + GetLogicalSize().cy }; 
    DrawTextEx(rGfx.GetHDC(), m_szText, m_nTextLength, &rBoundary, m_nTextFormat, &m_dtp);
    
//    Printf(_T("Drawing %s at (%d,%d)-(%d-%d) lmargin=%d, rmargin=%d\n"),
//         m_szText, m_Origin.x, m_Origin.y, GetWidth(), GetHeight(),
//         m_dtp.iLeftMargin, m_dtp.iRightMargin);

    if (m_bInverted)
    {
        InvertRect(rGfx.GetHDC(), &rBoundary);
    }
}
Exemplo n.º 7
0
void CLCDCollection::OnDraw(CLCDGfx &rGfx)
{
    LCD_OBJECT_LIST::iterator it = m_Objects.begin();
    while(it != m_Objects.end())
    {
        CLCDBase *pObject = *it;
        LCDUIASSERT(NULL != pObject);

        if (!pObject->IsVisible())
        {
            ++it;
            continue;
        }

        // create the clip region
        HRGN hRgn = CreateRectRgn(pObject->GetOrigin().x, pObject->GetOrigin().y,
                                  pObject->GetOrigin().x + pObject->GetWidth(),
                                  pObject->GetOrigin().y + pObject->GetHeight());
        
        // ensure that controls only draw within their specified region
        SelectClipRgn(rGfx.GetHDC(), hRgn);

        // free the region (a copy is used in the call above)
        DeleteObject(hRgn);

        // offset the control at its origin so controls use (0,0)
        POINT ptPrevViewportOrg = { 0, 0 };
        SetViewportOrgEx(rGfx.GetHDC(),
                         pObject->GetOrigin().x,
                         pObject->GetOrigin().y,
                         &ptPrevViewportOrg);

        // allow controls to supply additional translation
        // this allows controls to move freely within the confined viewport
        OffsetViewportOrgEx(rGfx.GetHDC(),
                            pObject->GetLogicalOrigin().x,
                            pObject->GetLogicalOrigin().y,
                            NULL);

        pObject->OnDraw(rGfx);

        // set the clipping region to nothing
        SelectClipRgn(rGfx.GetHDC(), NULL);

        // restore the viewport origin
        SetViewportOrgEx(rGfx.GetHDC(),
            ptPrevViewportOrg.x,
            ptPrevViewportOrg.y,
            NULL);

        // restore the viewport origin offset
        OffsetViewportOrgEx(rGfx.GetHDC(), 0, 0, NULL);

        ++it;
    }
}
Exemplo n.º 8
0
void CLCDProgressBar::OnDraw(CLCDGfx &rGfx)
{  
	HPEN	hOldPen;

	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_Pos);
		r.left = nCursorPos;
		r.right = r.left + m_nCursorWidth;
		FillRect(rGfx.GetHDC(), &r, m_hBrush);
	}
		break;
	case STYLE_FILLED_V:
	case STYLE_FILLED_H:
	{
		int nBar = (int)Scalef((float)m_Range.nMin, (float)m_Range.nMax,
                                  0.0f, (m_eStyle == STYLE_FILLED_H ? (float)GetWidth() : (float)GetHeight())-4,
                                  m_Pos);
		r.left   = r.left+2;
		r.bottom = r.bottom-2;
		if (m_eStyle == 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_Pos);
		r.left = nCursorPos;
		r.right = r.left + m_nCursorWidth;
		FillRect(rGfx.GetHDC(), &r, m_hBrush);
		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;
	}
}
Exemplo n.º 9
0
void CLCDText::OnDraw(CLCDGfx &rGfx)
{

    if (GetBackgroundMode() == OPAQUE)
    {
        // clear the clipped area
        RECT rcClp = { 0, 0, m_Size.cx, m_Size.cy };
        FillRect(rGfx.GetHDC(), &rcClp, (HBRUSH) GetStockObject(BLACK_BRUSH));
    
        // clear the logical area
        RECT rcLog = { 0, 0, m_sizeLogical.cx, m_sizeLogical.cy };
        FillRect(rGfx.GetHDC(), &rcLog, (HBRUSH) GetStockObject(BLACK_BRUSH));
    }
    
    if (m_nTextLength)
    {

        // map mode text, with transparency
        int nOldMapMode = SetMapMode(rGfx.GetHDC(), MM_TEXT);
        int nOldBkMode = SetBkMode(rGfx.GetHDC(), GetBackgroundMode()); 

        // select current font
        HFONT hOldFont = (HFONT)SelectObject(rGfx.GetHDC(), m_hFont);   

        // select color
        COLORREF crOldTextColor = SetTextColor(rGfx.GetHDC(), m_crColor);
        
        if (m_bRecalcExtent)
        {
            int nTextFormat;

            RECT rExtent;
            // calculate vertical extent with word wrap
            nTextFormat = (m_nTextFormat | DT_WORDBREAK | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rExtent, nTextFormat, &m_dtp);
            m_sizeVExtent.cx = rExtent.right;
            m_sizeVExtent.cy = rExtent.bottom;

            // calculate horizontal extent w/o word wrap
            nTextFormat = (m_nTextFormat | DT_CALCRECT);
            rExtent.left = rExtent.top = 0;
            rExtent.right = GetWidth();
            rExtent.bottom = GetHeight();
            DrawTextEx(rGfx.GetHDC(), (LPTSTR)m_sText.c_str(), static_cast<int>(m_nTextLength), &rExtent, nTextFormat, &m_dtp);
            m_sizeHExtent.cx = rExtent.right;
            m_sizeHExtent.cy = rExtent.bottom;

            m_bRecalcExtent = FALSE;
        }

        if (IsVisible())
        {
            DrawText(rGfx);
        }

        // restores
        SetMapMode(rGfx.GetHDC(), nOldMapMode);
        SetTextColor(rGfx.GetHDC(), crOldTextColor);
        SetBkMode(rGfx.GetHDC(), nOldBkMode);
        SelectObject(rGfx.GetHDC(), hOldFont);
    }
}