Exemple #1
0
void G2DTestSystemDriver::ResizeContext ()
{
  if (!myG2D->BeginDraw ())
    return;

  myG2D->Clear (black);
  DrawWindowResizeScreen ();

  csString text;
  text.Format ("Canvas [%d x %d]", myG2D->GetWidth (), myG2D->GetHeight ());
  SetFont (fontLarge);
  int fw, fh;
  font->GetDimensions (text, fw, fh);
  int x = myG2D->GetWidth () - fw;
  myG2D->Write (font, x, 0, red, -1, text);

  myG2D->FinishDraw ();
  myG2D->Print (0);
}
Exemple #2
0
void G2DTestSystemDriver::FontClipTest()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  int sx = w/10, sy = h / 2 + 60, sw = sx * 2, sh = h / 6 - 60;
  int sx1 = sx * 1, sx2 = sx * 4, sx3 = sx * 7;
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);
  
  SetFont (fontItalic);
  WriteCentered (0,-16*8, white, -1, "FONT CLIP TEST");

  SetFont (fontLarge);
  WriteCentered (0,-16*7, black, dsteel, "This will test if font clipping is being done properly");
  WriteCentered (0,-16*6, black, dsteel, "You should see three thin green rectangles below");

  WriteCentered (0,-16*4, black, dsteel, "Again all the black should be contained inside the first");
  WriteCentered (0,-16*3, black, dsteel, "green rectangle. The red rectangle should not be visible.");
  
  WriteCentered (0,-16*1, black, dsteel, "The second and third green rectangles shouldn't be crossed as well,");
  WriteCentered (0, 16*0, black, dsteel, "the text should only overdraw the red rectangle. Additionally,");
  WriteCentered (0, 16*1, black, dsteel, "all the text should look the same (well, except for the parts cut off.)");

  SetFont (fontCourier);

  const char* testText = "CrystalSpace";
  int fW, fH;

  font->GetDimensions (testText, fW, fH);

  int fX = -fW /2, fY = -fH / 2;

  DrawClipRect(sx2, sy, sw, sh);
  myG2D->SetClipRect(sx2 + 1, sy + 1, sx2 + sw, sy + sh);

  myG2D->Write (font, sx2 + fX,          sy + fY,          black, -1, testText);
  myG2D->Write (font, sx2 + sw / 2 + fX, sy + fY,          black, -1, testText);
  myG2D->Write (font, sx2 + sw + fX,     sy + fY,          black, -1, testText);

  myG2D->Write (font, sx2 + fX,          sy + sh / 2 + fY, black, -1, testText);
  myG2D->Write (font, sx2 + sw / 2 + fX, sy + sh / 2 + fY, black, -1, testText);
  myG2D->Write (font, sx2 + sw + fX,     sy + sh / 2 + fY, black, -1, testText);

  myG2D->Write (font, sx2 + fX,          sy + sh + fY,     black, -1, testText);
  myG2D->Write (font, sx2 + sw / 2 + fX, sy + sh + fY,     black, -1, testText);
  myG2D->Write (font, sx2 + sw + fX,     sy + sh + fY,     black, -1, testText);

  myG2D->SetClipRect(0,0,w,h);
  DrawClipRect(sx3, sy, sw, sh);
  myG2D->SetClipRect(sx3 + 1, sy + 1, sx3 + sw, sy + sh);

  myG2D->Write (font, sx3 + fX,          sy + fY,          black, blue, testText);
  myG2D->Write (font, sx3 + sw / 2 + fX, sy + fY,          black, blue, testText);
  myG2D->Write (font, sx3 + sw + fX,     sy + fY,          black, blue, testText);

  myG2D->Write (font, sx3 + fX,          sy + sh / 2 + fY, black, blue, testText);
  myG2D->Write (font, sx3 + sw / 2 + fX, sy + sh / 2 + fY, black, blue, testText);
  myG2D->Write (font, sx3 + sw + fX,     sy + sh / 2 + fY, black, blue, testText);

  myG2D->Write (font, sx3 + fX,          sy + sh + fY,     black, blue, testText);
  myG2D->Write (font, sx3 + sw / 2 + fX, sy + sh + fY,     black, blue, testText);
  myG2D->Write (font, sx3 + sw + fX,     sy + sh + fY,     black, blue, testText);

  myG2D->SetClipRect(0,0,w,h);
  DrawClipRect(sx1, sy, sw, sh);
  myG2D->SetClipRect(sx1 + 1, sy + 1, sx1 + sw, sy + sh);

  // Test random text drawing
  csRandomGen rng (csGetTicks ());
  csTicks start_time = csGetTicks (), delta_time;

  // widen the range where we try to draw
  sx -= fW;
  sy -= fH;
  sw += fW * 2;
  sh += fH * 2;

  do
  {
    int i;
    for (i = 0; i < 1000; i++)
    {
      int x = int(sx + rng.Get () * sw);
      int y = int(sy + rng.Get () * sh);
      myG2D->Write (font, x, y, black, blue, testText);
    }
    delta_time = csGetTicks () - start_time;
  } while (delta_time < 100);
}
Exemple #3
0
const char* csTinyDocWrapper::Write (iString* str)
{
  return tinydoc->Write (str);
}
Exemple #4
0
const char* csTinyDocWrapper::Write (iVFS* vfs, const char* filename)
{
  return tinydoc->Write (vfs, filename);
}
Exemple #5
0
const char* csTinyDocWrapper::Write (iFile* file)
{
  return tinydoc->Write (file);
}