コード例 #1
0
ファイル: text_field.cpp プロジェクト: sainteos/project-spero
std::shared_ptr<TextField> TextField::create(std::shared_ptr<Skin> skin, std::shared_ptr<WrappableText> default_text, std::shared_ptr<WrappableText> typed_text, glm::vec4 background_color, float padding, float screen_width, float screen_height, float x_pos, float y_pos, float width, float height, const unsigned int layer) {
    auto vertex_data = VertexData();
    vertex_data.addVec(VertexData::DATA_TYPE::GEOMETRY, generateRect(screen_width, screen_height, 0, 0, width, height));
    vertex_data.addVec(VertexData::DATA_TYPE::TEX_COORDS, basisTexCoords());

    default_text->setSize(width - (2.0 * padding), height - (2.0 * padding));
    typed_text->setSize(width - (2.0 * padding), height - (2.0 * padding));
    typed_text->setText("");

    auto field = std::make_shared<TextField>(default_text, typed_text, vertex_data, skin, layer);
    field->setColor(background_color);
    field->setAnchorPoint(glm::vec2(x_pos, y_pos));
    field->setWidth(width);
    field->setHeight(height);
    field->setTextPadding(padding);

    return field;
}
コード例 #2
0
ファイル: wucCombo.cpp プロジェクト: madsen-git/NTools
void comboUC::setAttribute(PCWSTR pstrName, PCWSTR pstrValue)
{
	PWSTR pstr = NULL;
	if( _tcscmp(pstrName, L"textpadding") == 0 ) {
		RECT rcTextPadding = { 0 };
		rcTextPadding.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcTextPadding.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcTextPadding.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcTextPadding.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);    
		setTextPadding(rcTextPadding);
	}
	else if( _tcscmp(pstrName, L"normalimage") == 0 )
	{
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setNormalImage(rcCell);
		//setNormalImage(pstrValue);
	}
	else if( _tcscmp(pstrName, L"hotimage") == 0 )
	{
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setHotImage(rcCell);
		//setHotImage(pstrValue);
	}
	else if( _tcscmp(pstrName, L"pushedimage") == 0 )
	{
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setPushedImage(rcCell);
		//SetPushedImage(pstrValue);
	}
	else if( _tcscmp(pstrName, L"focusedimage") == 0 )
	{
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setFocusedImage(rcCell);
		//SetFocusedImage(pstrValue);
	}
	else if( _tcscmp(pstrName, L"disabledimage") == 0 )
	{
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setDisabledImage(rcCell);
		//SetDisabledImage(pstrValue);
	}
	else if( _tcscmp(pstrName, L"dropbox") == 0 ) setDropBoxAttributeList(pstrValue);
	// 列表单元格属性
	else if( _tcscmp(pstrName, L"itemfont") == 0 ) setItemFont(_ttoi(pstrValue));
	else if( _tcscmp(pstrName, L"itemlinecolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemLineColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemshowhtml") == 0 ) setItemShowHtml(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"alternatebk") == 0 ) setAlternateBk(_tcscmp(pstrValue, L"true") == 0);
	else if( _tcscmp(pstrName, L"itemalign") == 0 ) {
		if( _tcsstr(pstrValue, L"left") != NULL ) {
			m_listInfo.uTextStyle &= ~(DT_CENTER | DT_RIGHT);
			m_listInfo.uTextStyle |= DT_LEFT;
		}
		if( _tcsstr(pstrValue, L"center") != NULL ) {
			m_listInfo.uTextStyle &= ~(DT_LEFT | DT_RIGHT);
			m_listInfo.uTextStyle |= DT_CENTER;
		}
		if( _tcsstr(pstrValue, L"right") != NULL ) {
			m_listInfo.uTextStyle &= ~(DT_LEFT | DT_CENTER);
			m_listInfo.uTextStyle |= DT_RIGHT;
		}
	}
	else if( _tcscmp(pstrName, L"itemendellipsis") == 0 ) {
		if( _tcscmp(pstrValue, L"true") == 0 ) m_listInfo.uTextStyle |= DT_END_ELLIPSIS;
		else m_listInfo.uTextStyle &= ~DT_END_ELLIPSIS;
	}
	else if( _tcscmp(pstrName, L"itemtextpadding") == 0 ) {
		RECT rcPadding = { 0 };
		rcPadding.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcPadding.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcPadding.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);    
		setItemTextPadding(rcPadding);
	}
	else if( _tcscmp(pstrName, L"itemtextcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemTextColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itembkcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemselectedtextcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemSelectedTextColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemselectedbkcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemSelectedBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemhottextcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemHotTextColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemhotbkcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemHotBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemcuttextcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemCutTextColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemcutbkcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemCutBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemdisabledtextcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemDisabledTextColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemdisabledbkcolor") == 0 ) {
		if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue);
		DWORD clrColor = _tcstoul(pstrValue, &pstr, 16);
		setItemDisabledBkColor(clrColor);
	}
	else if( _tcscmp(pstrName, L"itemimage") == 0 ) setItemImage(pstrValue);
	else if( _tcscmp(pstrName, L"itemnormalimage") == 0 ) {
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setItemNormalImage(rcCell);
	}
	else if( _tcscmp(pstrName, L"itemselectedimage") == 0 ) {
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setItemSelectedImage(rcCell);
	}
	else if( _tcscmp(pstrName, L"itemcutedimage") == 0 ) {
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setItemCutedImage(rcCell);
	}
	else if( _tcscmp(pstrName, L"itemhotimage") == 0 ) {
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setItemHotImage(rcCell);
	}
	else if( _tcscmp(pstrName, L"itemdisabledimage") == 0 ) {
		RECT rcCell = { 0 };
		rcCell.left = _tcstol(pstrValue, &pstr, 10);  assert(pstr);    
		rcCell.top = _tcstol(pstr + 1, &pstr, 10);    assert(pstr);    
		rcCell.right = _tcstol(pstr + 1, &pstr, 10);  assert(pstr);    
		rcCell.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr);
		setItemDisabledImage(rcCell);
	}
	else containerUC::setAttribute(pstrName, pstrValue);
}