Method setProperty for LABEL:
Code: Select all
//////////////////////////////////////////////////////////////////////////////////
// Label
//////////////////////////////////////////////////////////////////////////////////
function Label( oParent , nRow , nCol , cValue )
{
// Create the label on the fly, set its properties and append to the specified
// parent window
var cId = 'control' + (nControlCount).toString() ; nControlCount++ ;
var control = document.createElement( "span" );
control.className = "label" ;
control.style.top = nRow ;
control.style.left = nCol ;
control.innerHTML = cValue ;
control.id = cId ;
document.getElementById( oParent.getId() ).appendChild( control ) ;
this.getId = function ()
{
return cId;
}
this.setProperty = function ( cPropertyName, PropertyValue )
{
if ( cPropertyName.toLowerCase() == 'row' )
{
document.getElementById(cId).style.top = PropertyValue ;
}
else if ( cPropertyName.toLowerCase() == 'col' )
{
document.getElementById(cId).style.left = PropertyValue ;
}
else if ( cPropertyName.toLowerCase() == 'fontname' )
{
document.getElementById(cId).style.fontFamily = PropertyValue ;
}
else if ( cPropertyName.toLowerCase() == 'fontcolor' )
{
document.getElementById(cId).style.color = PropertyValue ;
}
else if ( cPropertyName.toLowerCase() == 'fontsize' )
{
document.getElementById(cId).style.fontSize = PropertyValue ;
}
else if ( cPropertyName.toLowerCase() == 'bold' )
{
if (PropertyValue)
{
document.getElementById(cId).style.fontWeight = 'bold' ;
}
else
{
document.getElementById(cId).style.fontWeight = 'normal' ;
}
}
else if ( cPropertyName.toLowerCase() == 'italic' )
{
if (PropertyValue)
{
document.getElementById(cId).style.fontStyle = 'italic' ;
}
else
{
document.getElementById(cId).style.fontStyle = 'normal' ;
}
}
else if ( cPropertyName.toLowerCase() == 'underline' )
{
if (PropertyValue)
{
document.getElementById(cId).style.textDecoration = 'underline' ;
}
else
{
document.getElementById(cId).style.textDecoration = 'none' ;
}
}
else if ( cPropertyName.toLowerCase() == 'strikeout' )
{
if (PropertyValue)
{
document.getElementById(cId).style.textDecoration = 'line-through' ;
}
else
{
document.getElementById(cId).style.textDecoration = 'none' ;
}
}
}
}
sample of use:
Code: Select all
oWin = new Form( "Label Demo", 600 , 300 );
oLabelx = new Label( oWin , 100 , 260 , "This is a Label!" );
oLabelx.setProperty("fontcolor","red");
oLabelx.setProperty("fontsize","20");
oLabelx.setProperty("col",100);
Possible properties:
col - column position of a Label
sample: oLabelx.setProperty("col",100);
row - row position of a Label
sample: oLabelx.setProperty("row",240);
fontname - font name of Label
sample: oLabelx.setProperty("fontname","Arial");
fontcolor - font color of Label
sample: oLabelx.setProperty("fontcolor","red");
fontsize - font size of Label
sample: oLabelx.setProperty("fontsize","18");
bold - font bold property
sample: oLabelx.setProperty("bold",true);
italic - font italic property
sample: oLabelx.setProperty("italic",true);
underline - font underline property
sample: oLabelx.setProperty("underline",true);
strikeout - font strikeout property
sample: oLabelx.setProperty("strikeout",true);