void FoompButton::draw (HDC buf)
{
	//Create drawing tools
	HPEN hDefPen = CreatePen(PS_SOLID, 1, getStyles().OuterStyle.TextColor);
	HPEN hPressedPen = CreatePen(PS_SOLID, 1, getStyles().ButtonStyle.TextColor);
	HPEN hShadowPen = CreatePen(PS_SOLID, 1, GetShadowColor(getStyles().OuterStyle));
	HPEN hPressedShadowPen = CreatePen(PS_SOLID, 1, GetShadowColor(getStyles().ButtonStyle));
	//Save current object
	HGDIOBJ prev = SelectObject(buf,hDefPen);

	if (pressed)
		MakeStyleGradient(buf, &hitrect, &getStyles().ButtonStyle, false);

	if (getSettings().FooShadowsEnabled)
	{
		SelectObject(buf,pressed ? hPressedShadowPen : hShadowPen);
		drawShape(buf,x+1,y+1);
	}
	SelectObject(buf,pressed ? hPressedPen : hDefPen);
	drawShape(buf,x,y);


	//Revert old object
	SelectObject(buf, prev);
	//Destroy drawing tools
	DeleteObject(hDefPen);
	DeleteObject(hPressedPen);
	DeleteObject(hShadowPen);
	DeleteObject(hPressedShadowPen);
}
Example #2
0
void UIStaticText::Draw(const UIGeometricData &geometricData)
{
	textBlock->SetRectSize(size);
	textBlock->SetPosition(geometricData.position);
	textBlock->SetPivotPoint(geometricData.pivotPoint);
	PrepareSprite();
	textBlock->PreDraw();

    UIControl::Draw(geometricData);

    if(!FLOAT_EQUAL(shadowBg->GetDrawColor().a, 0.0f) && (!FLOAT_EQUAL(shadowOffset.dx, 0.0f) || !FLOAT_EQUAL(shadowOffset.dy, 0.0f)))
    {
		textBlock->Draw(GetShadowColor(), &shadowOffset);
        UIGeometricData shadowGeomData;
        shadowGeomData.position = shadowOffset;
        shadowGeomData.size = GetSize();
        shadowGeomData.AddToGeometricData(geometricData);

        shadowBg->SetAlign(textBg->GetAlign());
        shadowBg->SetPerPixelAccuracyType(background->GetPerPixelAccuracyType());
        shadowBg->Draw(shadowGeomData);
    }

    textBlock->Draw(GetTextColor());
    textBg->SetPerPixelAccuracyType(background->GetPerPixelAccuracyType());
    textBg->Draw(geometricData);
}
Example #3
0
void MAS::HyperText::Draw(Bitmap &canvas) {
    // get the button state
    int state = Disabled() ? 2 : ((Selected() || (Flags() & D_PRESSED)) ? 1 : (HasFocus() ? 3 : 0));

    // get the button colors and font
    Color fg = GetFontColor(state);
    Color bg = GetShadowColor(state);
    Font f = GetFont(state);
    Color textMode = GetTextMode();

    canvas.Clear(textMode);

    switch (state) {
    case 0:
    case 2:
        f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0);
        canvas.Hline(1, h()-3, w()-2, fg);
        break;

    case 1:
        f.GUITextoutEx(canvas, text, 2, 2, fg, bg, textMode, 0);
        canvas.DrawDottedRect(1, 1, w()-1, h()-1, skin->c_font);
        canvas.Hline(1, h()-2, w()-2, fg);
        break;

    case 3:
        f.GUITextoutEx(canvas, text, 1, 1, fg, bg, textMode, 0);
        canvas.DrawDottedRect(0, 0, w()-2, h()-2, skin->c_font);
        canvas.Hline(1, h()-3, w()-2, fg);
        break;
    };
}
Example #4
0
Pixel GetShadow(Pixel background)
{
  XColor *colorp;

  colorp = GetShadowColor(background);
  XAllocColor (Pdpy, Pcmap, colorp);
  return colorp->pixel;
}
Example #5
0
Pixel GetShadow(Pixel background)
{
	XColor *colorp;

	colorp = GetShadowColor(background);
	PictureAllocColor(Pdpy, Pcmap, colorp, True);
	if (colorp->pixel == background)
	{
		colorp->pixel = PictureGetNextColor(colorp->pixel, 1);
	}
	return colorp->pixel;
}
YamlNode * UITextField::SaveToYamlNode(UIYamlLoader * loader)
{
    YamlNode *node = UIControl::SaveToYamlNode(loader);

    //Temp variable
    VariantType *nodeValue = new VariantType();

    //Control Type
	SetPreferredNodeType(node, "UITextField");

    //Text
    nodeValue->SetWideString(this->GetText());
    node->Set("text", nodeValue);

    //Font
    //Get font name and put it here
    nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont()));
    node->Set("font", nodeValue);
	
	//TextColor
	Color textColor = GetTextColor();
	nodeValue->SetVector4(Vector4(textColor.r, textColor.g, textColor.b, textColor.a));
	node->Set("textcolor", nodeValue);

	// ShadowColor
	Color shadowColor = GetShadowColor();
	nodeValue->SetVector4(Vector4(shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a));
	node->Set("shadowcolor", nodeValue);

	// ShadowOffset
	nodeValue->SetVector2(GetShadowOffset());
	node->Set("shadowoffset", nodeValue);

	// Text align
	node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign()));

	// Draw Type must be overwritten fot UITextField.
	UIControlBackground::eDrawType drawType =  this->GetBackground()->GetDrawType();
	node->Set("drawType", loader->GetDrawTypeNodeValue(drawType));

    SafeDelete(nodeValue);
    
    return node;
}
Example #7
0
YamlNode * UIStaticText::SaveToYamlNode(UIYamlLoader * loader)
{
    YamlNode *node = UIControl::SaveToYamlNode(loader);

    UIStaticText *baseControl = new UIStaticText();

    //Temp variable
    VariantType *nodeValue = new VariantType();

    //Font
    //Get font name and put it here
    nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont()));
    node->Set("font", nodeValue);

    //TextColor
    const Color &textColor = GetTextColor();
    if (baseControl->GetTextColor() != textColor)
    {
        nodeValue->SetColor(textColor);
        node->Set("textcolor", nodeValue);
    }

    // Text Color Inherit Type.
    int32 colorInheritType = (int32)GetTextBackground()->GetColorInheritType();
    if (baseControl->GetTextBackground()->GetColorInheritType() != colorInheritType)
    {
        node->Set("textcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType));
    }

    // ShadowColor
    const Color &shadowColor = GetShadowColor();
    if (baseControl->GetShadowColor() != shadowColor)
    {
        nodeValue->SetColor(shadowColor);
        node->Set("shadowcolor", nodeValue);
    }

    // Shadow Color Inherit Type.
    colorInheritType = (int32)GetShadowBackground()->GetColorInheritType();
    if (baseControl->GetShadowBackground()->GetColorInheritType() != colorInheritType)
    {
        node->Set("shadowcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType));
    }

    // ShadowOffset
    const Vector2 &shadowOffset = GetShadowOffset();
    if (baseControl->GetShadowOffset() != shadowOffset)
    {
        nodeValue->SetVector2(shadowOffset);
        node->Set("shadowoffset", nodeValue);
    }

    //Text
    const WideString &text = GetText();
    if (baseControl->GetText() != text)
    {
        node->Set("text", text);
    }
    //Multiline
    if (baseControl->textBlock->GetMultiline() != this->textBlock->GetMultiline())
    {
        node->Set("multiline", this->textBlock->GetMultiline());
    }
    //multilineBySymbol
    if (baseControl->textBlock->GetMultilineBySymbol() != this->textBlock->GetMultilineBySymbol())
    {
        node->Set("multilineBySymbol", this->textBlock->GetMultilineBySymbol());
    }
    //fitting - Array of strings
    if (baseControl->textBlock->GetFittingOption() != this->textBlock->GetFittingOption())
    {
        node->SetNodeToMap("fitting", loader->GetFittingOptionNodeValue(textBlock->GetFittingOption()));
    }

    // Text Align
    if (baseControl->GetTextAlign() != this->GetTextAlign())
    {
        node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign()));
    }

    // Draw type. Must be overriden for UITextControls.
    if (baseControl->GetBackground()->GetDrawType() != this->GetBackground()->GetDrawType())
    {
        node->Set("drawType", loader->GetDrawTypeNodeValue(this->GetBackground()->GetDrawType()));
    }

    SafeDelete(nodeValue);
    SafeRelease(baseControl);

    return node;
}