Exemplo n.º 1
0
void GrooveDialog::RefreshGrooveList()
{
    SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_RESETCONTENT, 0, 0);
    SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_ADDSTRING, 0, (LPARAM)__LOCALIZE("** User Groove **","sws_DLG_157"));
    WDL_DirScan dirScan;
    WDL_String searchStr(currentDir.c_str());
/* dirScan doesn't support wildcards on OSX do filtering later */
#ifdef _WIN32
    searchStr.Append( PATH_SEP "*.rgt", MAX_PATH);
    int iFind = dirScan.First(searchStr.Get(), true);
#else
    int iFind = dirScan.First(searchStr.Get());
#endif

    if (iFind == 0) {
        do {
            std::string fileName = dirScan.GetCurrentFN();
/* dirScan doesn't support wildcards on OSX so do basic filtering here */
#ifndef _WIN32
            std::string::size_type index = fileName.find_last_of(".");
            if(index == std::string::npos)
                continue;
            if(fileName.substr(index) != ".rgt")
                continue;
#endif
            std::string fileHead = fileName.substr(0, fileName.size() - 4);
            SendDlgItemMessage(m_hwnd, IDC_GROOVELIST, LB_ADDSTRING, 0, (LPARAM)fileHead.c_str());
        } while(!dirScan.Next());
    }
}
Exemplo n.º 2
0
int SearchDirectory(vector<string> &refvecFiles, const char* cDir, const char* cExt, bool bSubdirs)
{
	WDL_DirScan ds;
	int iRet = ds.First(cDir);
	int found = 0;
	g_bAbortScan = false;
	if (!iRet)
	{
		do
		{
			if (strcmp(ds.GetCurrentFN(), ".") == 0 || strcmp(ds.GetCurrentFN(), "..") == 0)
				continue;
			WDL_String foundFile;
			ds.GetCurrentFullFN(&foundFile);
			lstrcpyn(g_CurrentScanFile, foundFile.Get(), 1024);
			if (bSubdirs && ds.GetCurrentIsDirectory())
			{
				found += SearchDirectory(refvecFiles, foundFile.Get(), cExt, true);
			}
			else
			{
				char* cFoundExt  = strrchr(foundFile.Get(), '.');
				if (cFoundExt)
				{
					cFoundExt++;
					if ((!cExt && IsMediaExtension(cFoundExt, false)) || (cExt && _stricmp(cFoundExt, cExt) == 0))
					{
						refvecFiles.push_back(foundFile.Get());
						found++;
					}
				}
			}
		}
		while(!ds.Next() && !g_bAbortScan);
	}
	return found;
}
Exemplo n.º 3
0
HFONT CreateFont(int lfHeight, int lfWidth, int lfEscapement, int lfOrientation, int lfWeight, char lfItalic, 
  char lfUnderline, char lfStrikeOut, char lfCharSet, char lfOutPrecision, char lfClipPrecision, 
         char lfQuality, char lfPitchAndFamily, const char *lfFaceName)
{
  HGDIOBJ__ *font=NULL;
#ifdef SWELL_FREETYPE
  FT_Face face=NULL;
  if (!s_freetype_failed && !s_freetype) s_freetype_failed = !!FT_Init_FreeType(&s_freetype);
  if (s_freetype)
  {
    if (!lfFaceName || !*lfFaceName) lfFaceName = "Arial";

    int fn_len = strlen(lfFaceName);

    const char *leadpath = "/usr/share/fonts/truetype/msttcorefonts"; // todo: scan subdirs?
    char tmp[1024];
    char bestmatch[512];
    bestmatch[0]=0;
    int x;
    for (x=0;x < s_registered_fonts.GetSize(); x ++)
    {
      const char *fn = s_registered_fonts.Get(x);
      if (fn)
      {
        const char *fnpart = WDL_get_filepart(fn);
        if (!strnicmp(fnpart,lfFaceName,strlen(lfFaceName)))
        {
          FT_New_Face(s_freetype,fn,0,&face);
          if (face) break;
        }
      }
    }

    if (!face)
    {
      snprintf(tmp,sizeof(tmp),"%s/%s.ttf",leadpath,lfFaceName);
      FT_New_Face(s_freetype,tmp,0,&face);
    }
    if (!face)
    {
      WDL_DirScan ds;
      if (!ds.First(leadpath)) do
      { 
        if (!strnicmp(ds.GetCurrentFN(),lfFaceName,fn_len))
        {
          if (!stricmp(ds.GetCurrentFN()+fn_len,".ttf"))
          {
            snprintf(tmp,sizeof(tmp),"%s/%s",leadpath,ds.GetCurrentFN());
            FT_New_Face(s_freetype,tmp,0,&face);
          }
          else 
          {
            // todo look for italic/bold/etc too
            int sl = strlen(ds.GetCurrentFN());
            if (sl > 4 && !stricmp(ds.GetCurrentFN() + sl - 4, ".ttf")  && (!bestmatch[0] || sl < strlen(bestmatch)))
            {
              lstrcpyn_safe(bestmatch,ds.GetCurrentFN(),sizeof(bestmatch));
            }
          }
        }
      } while (!face && !ds.Next());
      if (!face && bestmatch[0])
      {
        snprintf(tmp,sizeof(tmp),"%s/%s",leadpath,bestmatch);
        FT_New_Face(s_freetype,tmp,0,&face);
      }
    }
    if (!face) FT_New_Face(s_freetype,"/usr/share/fonts/truetype/freefont/FreeSans.ttf",0,&face);
    if (!face) FT_New_Face(s_freetype,"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",0,&face);
  }
  
  if (face)
  {
    font = GDP_OBJECT_NEW();
    font->type=TYPE_FONT;
    font->fontface = face;
    font->alpha = 1.0f;
    ////unsure here
    if (lfWidth<0) lfWidth=-lfWidth;
    if (lfHeight<0) lfHeight=-lfHeight;
    FT_Set_Char_Size(face,lfWidth*64, lfHeight*64,0,0); // 72dpi
//    FT_Set_Pixel_Sizes(face,0,lfHeight);
  }
#else
  font->type=TYPE_FONT;
#endif
 
  return font;
}