Ejemplo n.º 1
0
/**
 *PrintGraphic
 *  打印图形.
 *Params:
 *  pGraphic[in] - 需要打印的图片.
 *  X0[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y0[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  X1[in] - 相对打印区域右下角(X坐标), 单位: mm, 缺省: 0
 *  Y1[in] - 相对打印区域右下角(Y坐标), 单位: mm, 缺省: 0
 *  bStretch[in] - 是否进行缩放打印
 */
void __fastcall CPrinter::PrintGraphic(TGraphic* pGraphic, Extended X0, Extended Y0, Extended X1, Extended Y1,
                                       bool bStretch)
{
    if ((PPRN == NULL) || (pGraphic == NULL))
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px0 = Ceil(Ceil((X0 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py0 = Ceil(Ceil((Y0 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    int px1 = Ceil(Ceil((X1 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py1 = Ceil(Ceil((Y1 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px0 = px0 + 2 * AvgCharWidth();
    py0 = py0 - GetOffSetY();
    px1 = px1 + 2 * AvgCharWidth();
    py1 = py1 - GetOffSetY();
    if (bStretch)
    {
        PPRN->Canvas->StretchDraw(TRect(px0, py0, px1, py1), pGraphic);
    }
    else
    {
        PPRN->Canvas->Draw(px0, py0, pGraphic);
    }
}
Ejemplo n.º 2
0
/**
 *PrintRectangle
 *  打印边框.
 *Params:
 *  X0[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y0[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  X1[in] - 相对打印区域右下角(X坐标), 单位: mm
 *  Y1[in] - 相对打印区域右下角(Y坐标), 单位: mm
 *  bBold[in] - 是否画粗线
 *  LineColor[in] - 边框颜色, 缺省: clBlack(黑色)
 */
void __fastcall CPrinter::PrintRectangle(Extended X0, Extended Y0, Extended X1, Extended Y1, bool bBold,
                                         TColor LineColor)
{
    if (PPRN == NULL)
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px0 = Ceil(Ceil((X0 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py0 = Ceil(Ceil((Y0 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    int px1 = Ceil(Ceil((X1 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py1 = Ceil(Ceil((Y1 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px0 = px0 + 2 * AvgCharWidth();
    py0 = py0 - GetOffSetY();
    px1 = px1 + 2 * AvgCharWidth();
    py1 = py1 - GetOffSetY();
    PPRN->Canvas->Pen->Width = bBold ? 2 : 1;
    PPRN->Canvas->Pen->Color = LineColor;
    PPRN->Refresh();
    PPRN->Canvas->Rectangle(px0, py0, px1, py1);
}
Ejemplo n.º 3
0
void cSkinDisplayMenu::SetTabs(int Tab1, int Tab2, int Tab3, int Tab4, int Tab5)
{
    tabs[0] = 0;
    tabs[1] = Tab1 ? tabs[0] + Tab1 : 0;
    tabs[2] = Tab2 ? tabs[1] + Tab2 : 0;
    tabs[3] = Tab3 ? tabs[2] + Tab3 : 0;
    tabs[4] = Tab4 ? tabs[3] + Tab4 : 0;
    tabs[5] = Tab5 ? tabs[4] + Tab5 : 0;
    for (int i = 1; i < MaxTabs; i++)
        tabs[i] *= AvgCharWidth();
}
Ejemplo n.º 4
0
void cSkinCursesDisplayMenu::SetItem(const char *Text, int Index, bool Current, bool Selectable)
{
  int y = 2 + Index;
  int ColorFg, ColorBg;
  if (Current) {
     ColorFg = clrBlack;
     ColorBg = clrCyan;
     }
  else {
     ColorFg = Selectable ? clrWhite : clrCyan;
     ColorBg = clrBackground;
     }
  for (int i = 0; i < MaxTabs; i++) {
      const char *s = GetTabbedText(Text, i);
      if (s) {
         int xt = Tab(i) / AvgCharWidth();// Tab() is in "pixel" - see also skins.c!!!
         osd->DrawText(xt, y, s, ColorFg, ColorBg, &Font, ScOsdWidth - 2 - xt);
         }
      if (!Tab(i + 1))
         break;
      }
  SetEditableWidth(ScOsdWidth - 2 - Tab(1) / AvgCharWidth()); // Tab() is in "pixel" - see also skins.c!!!
}
Ejemplo n.º 5
0
/**
 *PrintText
 *  打印文本.
 *Params:
 *  sText[in] - 需要打印的文本
 *  X[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  FontSize[in] - 字体大小, 缺省:10
 *  FontColor[in] - 字体颜色, 缺省:clBlack(黑色)
 */
void __fastcall CPrinter::PrintText(AnsiString sText, Extended X, Extended Y, int FontSize, TColor FontColor)
{
    if (PPRN == NULL)
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px = Ceil(Ceil((X + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py = Ceil(Ceil((Y + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px = px + 2 * AvgCharWidth();
    py = py - GetOffSetY();                 //绝对坐标, 不用换算成相对于Y轴坐标
    PPRN->Canvas->Font->Name = "宋体";
    PPRN->Canvas->Font->Size = FontSize;
    PPRN->Canvas->Font->Color = FontColor;
    PPRN->Refresh();
    PPRN->Canvas->TextOut(px, py, sText);
}