centrer mon texte dans le rectangle
bonjour,
je voudrais afficher du texte de couleur sur un fond. les couleurs seront choisie par les utilisateurs.
Le texte s'affiche et change de couleur, mais la couleur de fond ne s'affiche pas!!!
j'aurai besoin d'aide svp
voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/******************************************************************************
* Textback Class
******************************************************************************/
Textback.prototype = new DynamicComponent();
Textback.parent = DynamicComponent.prototype;
Textback.prototype.constructor = Textback;
/******************************************************************************
* Constructor
******************************************************************************/
function Textback()
{
}
/******************************************************************************
* Initialize object
* svgId -> Id of SVG node
* objectName -> global variable name of the object
******************************************************************************/
Textback.prototype.init = function(svgId, objectName)
{
Textback.parent.init.call(this, svgId, objectName, false);
this.m_SizeFont = GetVisioPropAsInt(this.m_SvgNode, "FontSize");
removeAllChildExceptNodeName(this.m_SvgNode, "text");
this.m_txtParentElem = getChildNodeFromName(this.m_SvgNode, "text");
removeAllChild(this.m_txtParentElem);
this.m_txtElem = createTextNode(this.m_txtParentElem, "");
}
/******************************************************************************
* Callback for refresh event
******************************************************************************/
Textback.prototype.OnRefresh = function()
{
// Get the value
var value = this.m_arrayValueDefinition[0].getValue();
var coltext = colortext;
var red = Math.round((coltext & 0x000000FF) >> 0);
var green = Math.round((coltext & 0x0000FF00) >> 8);
var blue = Math.round((coltext & 0x00FF0000) >> 16);
var fill = "fill:rgb("+ red +","+ green+","+blue+")";
var size = "font-size:"+this.m_SizeFont;
var fontType = "font-family:Arial Unicode MS"
this.m_txtParentElem.setAttribute("style", fill+";"+size+";"+fontType);
var colback = colorback;
var red = Math.round((colback & 0x000000FF) >> 0);
var green = Math.round((colback & 0x0000FF00) >> 8);
var blue = Math.round((colback & 0x00FF0000) >> 16);
var back = "back:rgb("+ red +","+ green+","+blue+")";
this.m_txtParentElem.style.background="back";
// Change text value to reflect the read value
var st = value;
this.m_txtElem.nodeValue = st;
} |
le PB vien de cette ligne de code :
this.m_txtParentElem.style.background="back";
mais comment la modifier???
merci d'avance pour votre aide
centrer le texte dans le rectangle
bonjour
maitenance que les couleur fonctionnent, et que le texte s'affiche correctement, je voudrai centrer mon texte dans le rectangle.
par contre la je n'est aucune idée sur la question.
quelqu'un pour me suggerer une fonction?
merci