Set the text alignment mode.

syntaxSyntax:
DlxText.SetAlignment(alignment, mode)

Parameters

Parameter Description
alignment Specifies the horizontal and vertical alignment of the text with respect to the insertion point. Enter a combination of the following values:
Vertical
DlxApp.TEXTALIGN_TOP
DlxApp.TEXTALIGN_MIDDLE
DlxApp.TEXTALIGN_BASE
DlxApp.TEXTALIGN_BOTTOM
Horizontal
DlxApp.TEXTALIGN_LEFT
DlxApp.TEXTALIGN_CENTER
DlxApp.TEXTALIGN_RIGHT
DlxApp.TEXTALIGN_COMMA
DlxApp.TEXTALIGN_JUSTIFY
Vertical & Horizontal
DlxApp.TEXTALIGN_TOPLEFT
DlxApp.TEXTALIGN_TOPCENTER
DlxApp.TEXTALIGN_TOPRIGHT
DlxApp.TEXTALIGN_TOPJUSTIFY
DlxApp.TEXTALIGN_MIDDLELEFT
DlxApp.TEXTALIGN_MIDDLECENTER
DlxApp.TEXTALIGN_MIDDLERIGHT
DlxApp.TEXTALIGN_MIDDLEJUSTIFY
DlxApp.TEXTALIGN_BASELEFT
DlxApp.TEXTALIGN_BASECENTER
DlxApp.TEXTALIGN_BASERIGHT
DlxApp.TEXTALIGN_BASEJUSTIFY
DlxApp.TEXTALIGN_BOTTOMLEFT
DlxApp.TEXTALIGN_BOTTOMCENTER
DlxApp.TEXTALIGN_BOTTOMRIGHT
DlxApp.TEXTALIGN_BOTTOMJUSTIFY
mode Specify which alignment. Enter one of the following values:
DlxApp.ALIGNMODE_ALL
DlxApp.ALIGNMODE_VERTICAL
DlxApp.ALIGNMODE_HORIZONTAL

Return Value

If the operation ends correctly it returns true otherwise it returns false.

Example

  Copy codeCopy code
var prj = DlxApp.GetJob().GetProject("Example Sch");
if (!prj.IsValid())
  prj = DlxApp.GetJob().NewProject("Example Sch");
var doc = prj.GetDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
if (!doc.IsValid())
{
  doc = prj.NewDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
  doc.SetPageFormat("A4", false);
}
if (doc.IsValid() && doc.Activate())
{
  var page = doc.GetActivePage();
  if (page.IsValid())
  {
    var layer = page.GetLayerFromType(DlxApp.LAYERTYPE_DRAWING);
    if (layer.IsValid())
    {
      var obj = layer.DrawText(new DlxPoint(100,100), "Hello, World.\nHello, World.\n");

      var dlg = new DlxDialog(400, 110, "Alignment");
      if (dlg.IsValid())
      {
        dlg.AddStaticText(10, 33, 70, "Horizontal: ");
        var ctrl_cbl = dlg.AddComboBox(90, 30, 300);
        ctrl_cbl.AddString("Left", DlxApp.TEXTALIGN_LEFT, obj.GetAlignment(DlxApp.ALIGNMODE_HORIZONTAL)==DlxApp.TEXTALIGN_LEFT);
        ctrl_cbl.AddString("Center", DlxApp.TEXTALIGN_CENTER, obj.GetAlignment(DlxApp.ALIGNMODE_HORIZONTAL)==DlxApp.TEXTALIGN_CENTER);
        ctrl_cbl.AddString("Right", DlxApp.TEXTALIGN_RIGHT, obj.GetAlignment(DlxApp.ALIGNMODE_HORIZONTAL)==DlxApp.TEXTALIGN_RIGHT);
        dlg.AddOkButton(280, 70, 50, 25);
        dlg.AddCancelButton(340, 70, 50, 25);
        if (dlg.DoModal())
        {
          obj.SetAlignment(ctrl_cbl.GetNumber(), DlxApp.ALIGNMODE_HORIZONTAL);
        }
      }
    }
  }
}

See also