Exemple #1
0
  Font::Font(const ezString& fontName, int size, const HDC deviceContext)
  {
	  HFONT font;
	  HFONT oldfont;

	  m_DisplayList = glGenLists(96);		

	  font = CreateFontA(	size,
						  0,		
						  0,						
						  0,		
						  FW_REGULAR,	
						  FALSE,					
						  FALSE,	
						  FALSE,
						  ANSI_CHARSET,				
						  OUT_TT_PRECIS,				
						  CLIP_DEFAULT_PRECIS,		
						  ANTIALIASED_QUALITY,		
						  FF_DONTCARE|DEFAULT_PITCH,	
						  fontName.GetData());	

	  oldfont = (HFONT)SelectObject(deviceContext, font);      
	  wglUseFontBitmaps(deviceContext, 32, 96, m_DisplayList);
	  SelectObject(deviceContext, oldfont);		
	  DeleteObject(font);	
  }
Exemple #2
0
void ezQtEditorApp::GuiCreateOrOpenDocument(bool bCreate)
{
  const ezString sAllFilters = BuildDocumentTypeFileFilter(bCreate);

  if (sAllFilters.IsEmpty())
  {
    ezQtUiServices::MessageBoxInformation("No file types are currently known. Load plugins to add file types.");
    return;
  }

  static QString sSelectedExt;
  const QString sDir = QString::fromUtf8(m_sLastDocumentFolder.GetData());

  ezString sFile;

  if (bCreate)
    sFile = QFileDialog::getSaveFileName(QApplication::activeWindow(), QLatin1String("Create Document"), sDir,
                                         QString::fromUtf8(sAllFilters.GetData()), &sSelectedExt, QFileDialog::Option::DontResolveSymlinks)
                .toUtf8()
                .data();
  else
    sFile = QFileDialog::getOpenFileName(QApplication::activeWindow(), QLatin1String("Open Document"), sDir,
                                         QString::fromUtf8(sAllFilters.GetData()), &sSelectedExt, QFileDialog::Option::DontResolveSymlinks)
                .toUtf8()
                .data();

  if (sFile.IsEmpty())
    return;

  m_sLastDocumentFolder = ezPathUtils::GetFileDirectory(sFile);

  const ezDocumentTypeDescriptor* pTypeDesc = nullptr;
  if (ezDocumentManager::FindDocumentTypeFromPath(sFile, bCreate, pTypeDesc).Succeeded())
  {
    sSelectedExt = pTypeDesc->m_sDocumentTypeName;
  }

  if (bCreate)
    CreateDocument(sFile, ezDocumentFlags::AddToRecentFilesList | ezDocumentFlags::RequestWindow);
  else
    OpenDocument(sFile, ezDocumentFlags::AddToRecentFilesList | ezDocumentFlags::RequestWindow);
}
Exemple #3
0
  void Font::DrawString(const ezString& sText, const ezVec2& screenPosition, const ezColor& color)
  {
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	  glUseProgram(0);
	  glColor4fv(&color.r);

	  float screenPosX = screenPosition.x * 2.0f - 1.0f;
	  float screenPosY = 1.0f - screenPosition.y * 2.0f;
	 // screenPosY -= 20.0f / RenderDevice::Get().GetBackBufferHeight(); // padding due to window frame - the direct3d implementatoin is aware of it
	  glRasterPos2f(screenPosX, screenPosY);

	  glPushAttrib(GL_LIST_BIT);					
	  glListBase(m_DisplayList - 32);
	  glCallLists(static_cast<GLsizei>(sText.GetElementCount()), GL_UNSIGNED_BYTE, sText.GetData());
	  glPopAttrib();

    glDisable(GL_BLEND);
  }
Exemple #4
0
const ezTokenizer* ezTokenizedFileCache::Tokenize(const ezString& sFileName, const ezDynamicArray<ezUInt8>& FileContent, const ezTimestamp& FileTimeStamp, ezLogInterface* pLog)
{
  EZ_LOCK(m_Mutex);

  auto& data = m_Cache[sFileName];

  data.m_Timestamp = FileTimeStamp;
  ezTokenizer* pTokenizer = &data.m_Tokens;
  pTokenizer->Tokenize(FileContent, pLog);

  ezDeque<ezToken>& Tokens = pTokenizer->GetTokens();

  ezHashedString sFile;
  sFile.Assign(sFileName.GetData());

  ezInt32 iLineOffset = 0;

  for (ezUInt32 i = 0; i + 1 < Tokens.GetCount(); ++i)
  {
    const ezUInt32 uiCurLine = Tokens[i].m_uiLine;

    Tokens[i].m_File = sFile;
    Tokens[i].m_uiLine += iLineOffset;

    if (Tokens[i].m_iType == ezTokenType::NonIdentifier &&
        ezString(Tokens[i].m_DataView) == "#")
    {
      ezUInt32 uiNext = i + 1;

      SkipWhitespace(Tokens, uiNext);

      if (uiNext < Tokens.GetCount() && 
          Tokens[uiNext].m_iType == ezTokenType::Identifier &&
          ezString(Tokens[uiNext].m_DataView) == "line")
      {
        ++uiNext;
        SkipWhitespace(Tokens, uiNext);

        if (uiNext < Tokens.GetCount() && 
            Tokens[uiNext].m_iType == ezTokenType::Identifier)
        {
          ezInt32 iNextLine = 0;

          const ezString sNumber = Tokens[uiNext].m_DataView;
          if (ezConversionUtils::StringToInt(sNumber.GetData(), iNextLine).Succeeded())
          {
            iLineOffset = (iNextLine - uiCurLine) - 1;

            ++uiNext;
            SkipWhitespace(Tokens, uiNext);

            if (uiNext < Tokens.GetCount())
            {
              if (Tokens[uiNext].m_iType == ezTokenType::String1)
              {
                ezStringBuilder sFileName = Tokens[uiNext].m_DataView;
                sFileName.Shrink(1, 1); // remove surrounding "

                sFile.Assign(sFileName.GetData());
              }
            }
          }
        }
      }
    }
  }

  return pTokenizer;
}