Ejemplo n.º 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);
}
Ejemplo n.º 2
0
void G2DTestSystemDriver::SetupFrame ()
{
  if (state_sptr == 0)
  {
    EventOutlet->Broadcast (csevQuit (object_reg));
    return;
  }

  appState curstate = state [state_sptr - 1];
  switch (curstate)
  {
    case stInit:
    case stStartup:
    case stContextInfo:
    case stWindowFixed:
    case stWindowResize:
    case stCustomCursor:
    case stCustomIcon:
    case stAlphaTest:
    case stTestUnicode1:
    case stTestUnicode2:
    case stTestFreetype:
    case stTestLineDraw:
    case stTestLinePerf:
    case stTestTextDraw:
    case stTestTextDraw2:
    case stPixelClipTest:
    case stLineClipTest:
    case stBoxClipTest:
    case stFontClipTest:
    case stBlitTest:
    {
      if (!myG3D->BeginDraw (CSDRAW_2DGRAPHICS))
        break;

      myG2D->Clear (black);
      LeaveState ();
      switch (curstate)
      {
        case stInit:
	  fontLarge = GetFont (CSFONT_LARGE);
	  fontItalic = GetFont (CSFONT_ITALIC);
	  fontCourier = GetFont (CSFONT_COURIER);
	  fontSmall = GetFont (CSFONT_SMALL);
	  {
	    csRef<iVFS> vfs = csQueryRegistry<iVFS> (object_reg);
	    csRef<iImageIO> iio = 
	      csQueryRegistry<iImageIO> (object_reg);
	    if (vfs.IsValid () && iio.IsValid ())
	    {
	      csRef<iFile> testFile = vfs->Open ("/lib/g2dtest/up.png", 
		VFS_FILE_READ);
	      if (testFile.IsValid ())
	      {
		csRef<iDataBuffer> fileData = testFile->GetAllData ();
		blitTestImage = iio->Load (fileData, CS_IMGFMT_TRUECOLOR 
		  | CS_IMGFMT_ALPHA);
	      }
	      testFile = vfs->Open ("/lib/std/cslogo2.png", VFS_FILE_READ);
	      if (testFile.IsValid ())
	      {
		csRef<iDataBuffer> fileData = testFile->GetAllData ();
		alphaBlitImage = iio->Load (fileData, CS_IMGFMT_TRUECOLOR |
		  CS_IMGFMT_ALPHA);
	      }
	    }
	  }
	  EnterState (stStartup);
	  break;
        case stStartup:
          DrawStartupScreen ();
	  EnterState (stContextInfo);
          EnterState (stPause, 5000);
          break;
        case stContextInfo:
          DrawContextInfoScreen ();
          EnterState (stWindowFixed);
          EnterState (stWaitKey);
          break;
        case stWindowFixed:
          DrawWindowScreen ();
          EnterState (stWindowResize);
          EnterState (stWaitKey);
          break;
        case stWindowResize:
          DrawWindowResizeScreen ();
          EnterState (stCustomCursor);
          EnterState (stWaitKey);
          break;
	case stCustomCursor:
          DrawCustomCursorScreen ();
	  SetCustomCursor ();
	  if (lastkey9)
            EnterState (stCustomIcon);
	  else
            EnterState (stCustomCursor);
          break;
	case stCustomIcon:
          SetNormalCursor ();
	  SetCustomIcon ();
          DrawCustomIconScreen ();
	  EnterState (stAlphaTest);
          EnterState (stWaitKey);
          break;
	case stAlphaTest:
          DrawAlphaTestScreen ();
          EnterState (stTestUnicode1);
          EnterState (stWaitKey);
          break;
	case stTestUnicode1:
	  DrawUnicodeTest1 ();
          EnterState (stTestUnicode2);
          EnterState (stWaitKey);
          break;
	case stTestUnicode2:
	  DrawUnicodeTest2 ();
          EnterState (stTestFreetype);
          EnterState (stWaitKey);
          break;
	case stTestFreetype:
	  DrawFreetypeTest ();
          EnterState (stTestLineDraw);
          EnterState (stWaitKey);
          break;
        case stTestLineDraw:
          DrawLineTest ();
          EnterState (stTestLinePerf);
          EnterState (stWaitKey);
          break;
        case stTestLinePerf:
          DrawLinePerf ();
          if (lastkey2)
            EnterState (stTestTextDraw);
          else
            EnterState (stTestLinePerf);
          break;
        case stTestTextDraw:
          DrawTextTest ();
          if (lastkey3)
            EnterState (stTestTextDraw2);
          else
            EnterState (stTestTextDraw);
          break;
        case stTestTextDraw2:
          DrawTextTest2 ();
          if (lastkey4)
            EnterState (stPixelClipTest);
          else
            EnterState (stTestTextDraw2);
          break;
        case stPixelClipTest:
          PixelClipTest ();
          if (lastkey5)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stLineClipTest);
          }
          else
            EnterState (stPixelClipTest);
          break;
        case stLineClipTest:
          LineClipTest ();
          if (lastkey6)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
            EnterState (stBoxClipTest);
          }
          else
            EnterState (stLineClipTest);
          break;
        case stBoxClipTest:
          BoxClipTest ();
          if (lastkey7)
          {
            myG2D->SetClipRect(0,0,myG2D->GetWidth(), myG2D->GetHeight());
	    EnterState (stFontClipTest);
          }
          else
            EnterState (stBoxClipTest);
          break;
        case stFontClipTest:
          FontClipTest ();
          if (lastkey8)
	    EnterState (stBlitTest);
          else
            EnterState (stFontClipTest);
          break;
	case stBlitTest:
	  BlitTest ();
          EnterState (stWaitKey);
          break;
        default:
          break;
      }
      break;
    }
    case stPause:
      if (int (csGetTicks () - timer) > 0)
        LeaveState ();
      else
        csSleep (1);
      break;
    case stWaitKey:
      if (lastkey)
      {
        LeaveState ();
        SwitchBB = false;
      }
      else
      {
        if (SwitchBB)
        {
          myG2D->Print (0);
          csSleep (200);
        }
        else
          csSleep (1);
      }
      break;
  }
}
Ejemplo n.º 3
0
void csTinyDocWrapper::Clear ()
{
  tinydoc->Clear();
}