/****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;
}
Пример #2
0
/****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;
}
Пример #3
0
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;
}
Пример #4
0
/****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;
}
Пример #5
0
/****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;
}