Exemple #1
0
void CStringEdit::SetText(LPCSTR lpszText)
{
	CString strText = lpszText;		// copy input text to local space
	ValidateText(strText);			// validate and adjust string if necessary

	if((m_bMode == FALSE) && (m_bAlert == FALSE)) // in edit mode
	{
		SetWindowText(strText);		// place into the control
		OnUpdate();
	}
}
Exemple #2
0
BOOL CStringEdit::OnUpdate() 
{
	//	Local Variables
	CString strText;
	CString strSave;
	int nSelBeg;
	int nSelEnd;

	if(m_bAlert)				// in alert mode ?
	{
		GetWindowText(strText);		// get current text
		if(strText != m_strAlert)	// force alert back if changed
		{
			SetWindowText(m_strAlert);	// force back to alert always
		}
		return(TRUE);		// exit here and prevent parent from 
	}						// seeing a reflected UPDATE message
	else
	{
		if(m_bMode)					// in status mode?
		{
			GetWindowText(strText);		// get current text
			if(strText != m_strStatus)	// force status back if changed
			{
				SetWindowText(m_strStatus);	// force back to status always
			}
			return(TRUE);		// exit here and prevent parent from 
		}						// seeing a reflected UPDATE message
	}

	//	Copy the contents of the edit control to a string
	GetWindowText(strText);
	strSave = strText;			// keep a copy of the text

	// Get the current selection position
	GetSel(nSelBeg,nSelEnd);

	// validate the window text now
	if(ValidateText(strText) == FALSE)
	{
		//	Alert the operator of the error
		MessageBeep(0xFFFFFFFF);
	}

	if(strSave != strText)			// string was changed by validate
	{
		SetWindowText(strText);

		// reset the selector position
		SetSel(nSelBeg,nSelEnd);
	}
	return(FALSE);					// let parent get an UPDATE message too
}
Exemple #3
0
void CStringEdit::SetIllegal(LPCSTR lpszIllegal)
{
	m_strIllegal = lpszIllegal;		// save illegal string into member string

	// if new illegal string does not validate text the clear last valid 
	if(ValidateText(m_strLastValid) == FALSE)
	{
		m_strLastValid.Empty();
	}

	if((m_bMode == FALSE) && (m_bAlert == FALSE))	// in edit mode
	{
		OnUpdate();
	}
}
Exemple #4
0
void UITextBox::GenerateTexture()
{
    ValidateText();

    SDL_Surface* textSurface = TTF_RenderUTF8_Solid( m_font, m_label.c_str(), m_textColor );
    m_sprite.SetTexture ( SDL_CreateTextureFromSurface( kuko::Application::GetRenderer(), textSurface ) );
    SDL_FreeSurface( textSurface );

    m_sprite.position = m_position;

    // Set w/h to fit the ratio
    int fullWidth, fullHeight;
    SDL_QueryTexture( m_sprite.texture, NULL, NULL, &fullWidth, &fullHeight );

    float fontRatio = float(fullWidth) / float(fullHeight);

    m_sprite.position.w = m_sprite.position.h * fontRatio;
    m_sprite.position.x += 2;
}