/****f* EZ.LCD.Wrapper/CEzLcd::SetText * NAME * HRESULT CEzLcd::SetText -- Set text * INPUTS * handle - handle to the object. * text - text string. * RETURN VALUE * E_FAIL if there was an error. * S_OK if no error. ****** */ HRESULT CEzLcd::SetText(HANDLE handle, LPCTSTR text) { CLCDBase* myObject = GetObject(handle); if (NULL != myObject) { assert(LG_STATIC_TEXT == myObject->GetObjectType() || LG_SCROLLING_TEXT == myObject->GetObjectType()); if (LG_STATIC_TEXT == myObject->GetObjectType()) { CLCDText* staticText = static_cast<CLCDText*>(myObject); assert(NULL != staticText); staticText->SetText(text); return S_OK; } else if (LG_SCROLLING_TEXT == myObject->GetObjectType()) { CLCDStreamingText* streamingText = static_cast<CLCDStreamingText*>(myObject); assert(NULL != streamingText); streamingText->SetText(text); return S_OK; } } return E_FAIL; }
/****f* LCD.SDK/SetText(HANDLE.handle,LPCTSTR.text,BOOL.resetScrollingTextPosition) * NAME * HRESULT SetText(HANDLE handle, * LPCTSTR text, * BOOL resetScrollingTextPosition = FALSE) -- Sets the text in the * control on the page being worked on. * INPUTS * handle - handle to the object. * text - text string. * resetScrollingTextPosition - indicates if position of scrolling * text needs to be reset. * RETURN VALUE * S_OK if succeeded. * E_FAIL otherwise. ****** */ HRESULT CEzLcd::SetText(HANDLE handle, LPCTSTR text, BOOL resetScrollingTextPosition) { CLCDBase* myObject = (CLCDBase*)handle; if (NULL != myObject) { if (!((LG_STATIC_TEXT == myObject->GetObjectType() || LG_SCROLLING_TEXT == myObject->GetObjectType()))) return E_FAIL; if (LG_STATIC_TEXT == myObject->GetObjectType()) { CLCDText* staticText = static_cast<CLCDText*>(myObject); if (NULL == staticText) return E_FAIL; staticText->SetText(text); return S_OK; } else if (LG_SCROLLING_TEXT == myObject->GetObjectType()) { CLCDStreamingText* streamingText = static_cast<CLCDStreamingText*>(myObject); if (NULL == streamingText) return E_FAIL; streamingText->SetText(text); if (resetScrollingTextPosition) { streamingText->ResetUpdate(); } return S_OK; } } return E_FAIL; }
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; } }
void CLCDCollection::ResetUpdate(void) { LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it; LCDUIASSERT(NULL != pObject); pObject->ResetUpdate(); ++it; } }
void CLCDCollection::OnUpdate(DWORD dwTimestamp) { LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it; LCDUIASSERT(NULL != pObject); pObject->OnUpdate(dwTimestamp); ++it; } }
void CLCDCollection::Show(BOOL bShow) { LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it; LCDUIASSERT(NULL != pObject); pObject->Show(bShow); ++it; } CLCDBase::Show(bShow); }
/****f* EZ.LCD.Wrapper/CEzLcd::SetVisible * NAME * HRESULT CEzLcd::SetVisible -- set corresponding object to be * visible or invisible. * INPUTS * handle - handle to the object. * visible - set to FALSE to make object invisible, TRUE to * make it visible (default). * RETURN VALUE * E_FAIL if there was an error. * S_OK if no error. ****** */ HRESULT CEzLcd::SetVisible(HANDLE handle, BOOL visible) { CLCDBase* myObject = GetObject(handle); assert(NULL != myObject); assert(NULL != myObject); if (NULL != myObject && NULL != myObject) { myObject->Show(visible); return S_OK; } return E_FAIL; }
/****f* EZ.LCD.Wrapper/CEzLcd::SetOrigin * NAME * HRESULT CEzLcd::SetOrigin -- Set the origin of an object. The * origin corresponds to the furthest pixel on the * upper left corner of an object. * INPUTS * handle - handle to the object. * x - x-axis part of the origin. * y - y-axis part of the origin. * RETURN VALUE * E_FAIL if there was an error. * S_OK if no error. ****** */ HRESULT CEzLcd::SetOrigin(HANDLE handle, INT x, INT y) { CLCDBase* myObject = GetObject(handle); assert(NULL != myObject); assert(NULL != myObject); if (NULL != myObject && NULL != myObject) { myObject->SetOrigin(x, y); return S_OK; } return E_FAIL; }
void CLCDCollection::OnUpdate(DWORD dwTimestamp) { //iterate through your objects and update them LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it++; LCDUIASSERT(NULL != pObject); pObject->OnUpdate(dwTimestamp); } //and update yourself CLCDBase::OnUpdate(dwTimestamp); }
void CLCDStreamingText::SetOrigin(int nX, int nY) { m_Origin.x = nX; m_Origin.y = nY; LCD_OBJECT_LIST::iterator it = m_Objects.begin(); if (it != m_Objects.end()) { CLCDBase *pObject = *it; POINT ptOldOrigin = pObject->GetOrigin(); pObject->SetOrigin(nX, nY); if ( (ptOldOrigin.x != nX) && (ptOldOrigin.y != nY) ) { ResetUpdate(); } } }
/****f* EZ.LCD.Wrapper/CEzLcd::SetProgressBarSize * NAME * HRESULT CEzLcd::SetProgressBarSize -- Set size of progress bar * INPUTS * handle - handle to the object. * x - x-axis part of the size * y - y-axis part of the size (a good default value is 5). * RETURN VALUE * E_FAIL if there was an error or if handle does not correspond to a * progress bar. * S_OK if no error. ****** */ HRESULT CEzLcd::SetProgressBarSize(HANDLE handle, INT x, INT y) { CLCDBase* myObject = GetObject(handle); assert(NULL != myObject); assert(NULL != myObject); if (NULL != myObject && NULL != myObject) { assert(LG_PROGRESS_BAR == myObject->GetObjectType()); // only allow this function for progress bars if (LG_PROGRESS_BAR == myObject->GetObjectType()) { myObject->SetSize(x, y); return S_OK; } } return E_FAIL; }
/****f* EZ.LCD.Wrapper/CEzLcd::SetProgressBarPosition * NAME * HRESULT CEzLcd::SetProgressBarPosition -- Set position of the * progress bar's cursor * INPUTS * handle - handle to the object. * percentage - percentage of progress (0 to 100). * RETURN VALUE * E_FAIL if there was an error or if handle does not correspond to a * progress bar. * S_OK if no error. ****** */ HRESULT CEzLcd::SetProgressBarPosition(HANDLE handle, FLOAT percentage) { CLCDBase* myObject = GetObject(handle); if (NULL != myObject) { assert(LG_PROGRESS_BAR == myObject->GetObjectType()); // only allow this function for progress bars if (LG_PROGRESS_BAR == myObject->GetObjectType()) { CLCDProgressBar *progressBar = static_cast<CLCDProgressBar*>(myObject); assert(NULL != progressBar); progressBar->SetPos(percentage); return S_OK; } } return E_FAIL; }
HRESULT CEzLcdPage::SetText(HANDLE handle, LPCTSTR text, BOOL resetScrollingTextPosition) { CLCDBase* myObject = GetObject(handle); if (NULL != myObject) { if (!((LG_STATIC_TEXT == myObject->GetObjectType() || LG_SCROLLING_TEXT == myObject->GetObjectType() || LG_RIGHTFOCUS_TEXT == myObject->GetObjectType() ))) return E_FAIL; if (LG_STATIC_TEXT == myObject->GetObjectType()) { CLCDText* staticText = static_cast<CLCDText*>(myObject); if (NULL == staticText) return E_FAIL; staticText->SetText(text); return S_OK; } else if (LG_SCROLLING_TEXT == myObject->GetObjectType()) { CLCDStreamingText* streamingText = static_cast<CLCDStreamingText*>(myObject); if (NULL == streamingText) return E_FAIL; streamingText->SetText(text); if (resetScrollingTextPosition) { streamingText->ResetUpdate(); } return S_OK; } else if (LG_RIGHTFOCUS_TEXT == myObject->GetObjectType()) { CLCDText* rightFocusText = static_cast<CLCDText*>(myObject); if (NULL == rightFocusText) return E_FAIL; rightFocusText->SetText(text); rightFocusText->CalculateExtent(true); // if out of focus, set alignment to right in order to follow what is written if (rightFocusText->GetHExtent().cx>=rightFocusText->GetSize().cx) rightFocusText->SetAlignment(DT_RIGHT); else rightFocusText->SetAlignment(DT_LEFT); return S_OK; } } return E_FAIL; }
void CLCDPage::OnDraw(CLCDGfxBase &rGfx) { if(!IsVisible()) { return; } //Draw the background first if(m_bUseBitmapBackground) { m_Background.OnDraw(rGfx); } else if(m_bUseColorBackground) { HBRUSH hBackBrush = CreateSolidBrush(m_BackgroundColor); HBRUSH hOldBrush = (HBRUSH)SelectObject(rGfx.GetHDC(), hBackBrush); Rectangle(rGfx.GetHDC(), 0, 0, GetWidth(), GetHeight()); SelectObject(rGfx.GetHDC(), hOldBrush); DeleteObject(hBackBrush); } //iterate through your objects and draw them LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it++; LCDUIASSERT(NULL != pObject); if (pObject->IsVisible()) { // create the clip region // Note that pages can now be added to pages (GetOrigin of the page is now factored in) HRGN hRgn = CreateRectRgn(GetOrigin().x + pObject->GetOrigin().x, GetOrigin().y + pObject->GetOrigin().y, GetOrigin().x + pObject->GetOrigin().x + pObject->GetWidth(), GetOrigin().y + 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(), GetOrigin().x + pObject->GetOrigin().x, GetOrigin().y + 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); } } }