From e446629b5944baaca18971448f607c4e920c280f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Teuli=C3=A8re?= Date: Sun, 3 Apr 2005 12:56:25 +0000 Subject: [PATCH] * skins2: Text control now accepts lefttop and rightbottom attributes, like most other controls. The text is not really resized though (only cropped when needed). The change in the DTD is backwards-compatible. --- modules/gui/skins2/parser/builder.cpp | 11 +++++++---- modules/gui/skins2/parser/builder_data.def | 2 +- modules/gui/skins2/parser/builder_data.hpp | 6 ++++-- modules/gui/skins2/parser/skin_parser.cpp | 3 +++ share/skins2/skin.dtd | 4 +++- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index bc4996a830..ba1331af8a 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -453,10 +453,13 @@ void Builder::addText( const BuilderData::Text &rData ) int height = pFont->getSize(); - pLayout->addControl( pText, Position( rData.m_xPos, rData.m_yPos, - rData.m_xPos + rData.m_width, - rData.m_yPos + height, *pLayout ), - rData.m_layer ); + // Compute the position of the control + const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom, + rData.m_xPos, rData.m_yPos, + rData.m_width, height, + *pLayout ); + + pLayout->addControl( pText, pos, rData.m_layer ); m_pTheme->m_controls[rData.m_id] = CtrlGenericPtr( pText ); } diff --git a/modules/gui/skins2/parser/builder_data.def b/modules/gui/skins2/parser/builder_data.def index 4d37660b7a..f14075b18d 100644 --- a/modules/gui/skins2/parser/builder_data.def +++ b/modules/gui/skins2/parser/builder_data.def @@ -8,7 +8,7 @@ Anchor xPos:int yPos:int range:int priority:int points:string layoutId:string Button id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string upId:string downId:string overId:string actionId:string tooltip:string help:string layer:int windowId:string layoutId:string Checkbox id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string up1Id:string down1Id:string over1Id:string up2Id:string down2Id:string over2Id:string state:string action1:string action2:string tooltip1:string tooltip2:string help:string layer:int windowId:string layoutId:string Image id:string xPos:int yPos:int leftTop:string rightBottom:string visible:string bmpId:string actionId:string help:string layer:int windowId:string layoutId:string -Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int color:uint32_t help:string layer:int windowId:string layoutId:string +Text id:string xPos:int yPos:int visible:string fontId:string text:string width:int leftTop:string rightBottom:string color:uint32_t help:string layer:int windowId:string layoutId:string RadialSlider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string sequence:string nbImages:int minAngle:float maxAngle:float value:string tooltip:string help:string layer:int windowId:string layoutId:string Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string upId:string downId:string overId:string points:string thickness:int value:string tooltip:string help:string layer:int windowId:string layoutId:string List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string diff --git a/modules/gui/skins2/parser/builder_data.hpp b/modules/gui/skins2/parser/builder_data.hpp index 5a204eccc7..9f3022a31a 100644 --- a/modules/gui/skins2/parser/builder_data.hpp +++ b/modules/gui/skins2/parser/builder_data.hpp @@ -223,8 +223,8 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_leftTop( leftTop ), m_rightBottom( /// Type definition struct Text { - Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, uint32_t color, const string & help, int layer, const string & windowId, const string & layoutId ): -m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_color( color ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} + Text( const string & id, int xPos, int yPos, const string & visible, const string & fontId, const string & text, int width, const string & leftTop, const string & rightBottom, uint32_t color, const string & help, int layer, const string & windowId, const string & layoutId ): +m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( fontId ), m_text( text ), m_width( width ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_color( color ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {} const string m_id; int m_xPos; @@ -233,6 +233,8 @@ m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_visible( visible ), m_fontId( font const string m_fontId; const string m_text; int m_width; + const string m_leftTop; + const string m_rightBottom; uint32_t m_color; const string m_help; int m_layer; diff --git a/modules/gui/skins2/parser/skin_parser.cpp b/modules/gui/skins2/parser/skin_parser.cpp index 4e6a4cba10..7f5a7e8c1c 100644 --- a/modules/gui/skins2/parser/skin_parser.cpp +++ b/modules/gui/skins2/parser/skin_parser.cpp @@ -310,12 +310,15 @@ void SkinParser::handleBeginElement( const string &rName, AttrList_t &attr ) CheckDefault( "text", "" ); CheckDefault( "color", "#000000" ); CheckDefault( "width", "0" ); + CheckDefault( "lefttop", "lefttop" ); + CheckDefault( "rightbottom", "lefttop" ); CheckDefault( "help", "" ); const BuilderData::Text textData( uniqueId( attr["id"] ), atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset, attr["visible"], attr["font"], attr["text"], atoi( attr["width"] ), + attr["lefttop"], attr["rightbottom"], convertColor( attr["color"] ), attr["help"], m_curLayer, m_curWindowId, m_curLayoutId ); m_curLayer++; diff --git a/share/skins2/skin.dtd b/share/skins2/skin.dtd index 8d28d626fe..3c8bbf4c94 100644 --- a/share/skins2/skin.dtd +++ b/share/skins2/skin.dtd @@ -162,10 +162,12 @@ visible CDATA "true" x CDATA "0" y CDATA "0" + width CDATA "0" + lefttop CDATA "lefttop" + rightbottom CDATA "lefttop" text CDATA "" font CDATA #REQUIRED color CDATA "#000000" - width CDATA "0" help CDATA "" > -- 2.39.5