コード例 #1
0
void TFuncSpecView::Print_CreateWidths(TFuncSpecView::XPosVector& xpos, uint& divider, TDC& dc) const
{
  xpos.erase(xpos.begin(), xpos.end());

  uint x=0;
  string text;
  char pch[64];
  ostrstream os(pch, 64);
  XPosInfo xinfo;

  // Calculate for inputs
  unsigned long inputs=swdoc->GetSystem()->GetInputs();
  while (inputs--) {
    xinfo.x=x;
    // create input symbol
    os.seekp(0);
    os << 'x' << inputs << " " << ends;
    xinfo.s=pch;

    xpos.push_back(xinfo);

    // move x position
    x += dc.GetTextExtent(pch, strlen(pch)).cx;
  }

  // Calculate for divider
  divider=x;
  x += (divider - xpos.back().x);

  // Calculate for outputs
  swmin::FunctionSet::iterator i=swdoc->GetSystem()->GetFuncsConst()->begin(),
                        e=swdoc->GetSystem()->GetFuncsConst()->end();
  while (i!=e) {
    xinfo.x=x;
    // create output symbol
    os.seekp(0);
    os << (*i).id << " " << ends;
    xinfo.s=pch;

    xpos.push_back(xinfo);

    // move x position
    x += dc.GetTextExtent(pch, strlen(pch)).cx;

    i++;
  }

  xinfo.x=x;
  xinfo.s="";
  xpos.push_back(xinfo);  // save ending x-position
}
コード例 #2
0
ファイル: font.cpp プロジェクト: Darkman-M59/Meridian59_115
//
/// Returns the extent of a given string using this particular font in a
/// particular DC.
//
TSize
TFont::GetTextExtent(TDC& dc, const tstring& text) const
{
  dc.SelectObject(*this);
  TSize size = dc.GetTextExtent(text, static_cast<int>(text.length())); // TODO: Widen parameter type to avoid this narrowing cast.
  dc.RestoreFont();
  return size;
}