Exemplo n.º 1
0
int ImageList_ReplaceIcon(HIMAGELIST list, int offset, HICON image)
{
  if (!image || !list) return -1;
  WDL_PtrList<HGDIOBJ__> *l=(WDL_PtrList<HGDIOBJ__> *)list;

  HGDIOBJ__ *imgsrc = (HGDIOBJ__*)image;
  if (!HGDIOBJ_VALID(imgsrc,TYPE_BITMAP)) return -1;

  HGDIOBJ__* icon=GDP_OBJECT_NEW();
  icon->type=TYPE_BITMAP;
  icon->wid=1;
  // todo: copy underlying image

  image = (HICON) icon;

  if (offset<0||offset>=l->GetSize()) 
  {
    l->Add(image);
    offset=l->GetSize()-1;
  }
  else
  {
    HICON old=l->Get(offset);
    l->Set(offset,image);
    if (old) DeleteObject(old);
  }
  return offset;
}
Exemplo n.º 2
0
HBRUSH  CreateSolidBrushAlpha(int col, float alpha)
{
  HGDIOBJ__ *brush=GDP_OBJECT_NEW();
  brush->type=TYPE_BRUSH;
//  brush->color=CreateColor(col,alpha);
  brush->wid=0; 
  return brush;
}
Exemplo n.º 3
0
HPEN CreatePenAlpha(int attr, int wid, int col, float alpha)
{
  HGDIOBJ__ *pen=GDP_OBJECT_NEW();
  pen->type=TYPE_PEN;
  pen->wid=wid<0?0:wid;
//  pen->color=CreateColor(col,alpha);
  return pen;
}
Exemplo n.º 4
0
HBRUSH  CreateSolidBrushAlpha(int col, float alpha)
{
  HGDIOBJ__ *brush=GDP_OBJECT_NEW();
  brush->type=TYPE_BRUSH;
  brush->color=LICE_RGBA_FROMNATIVE(col);
  brush->alpha = alpha;
  brush->wid=0; 
  return brush;
}
Exemplo n.º 5
0
HPEN CreatePenAlpha(int attr, int wid, int col, float alpha)
{
  HGDIOBJ__ *pen=GDP_OBJECT_NEW();
  pen->type=TYPE_PEN;
  pen->wid=wid<0?0:wid;
  pen->alpha = alpha;
  pen->color=LICE_RGBA_FROMNATIVE(col);
  return pen;
}
Exemplo n.º 6
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=GDP_OBJECT_NEW();
  font->type=TYPE_FONT;
  float fontwid=lfHeight;
  
  
  if (!fontwid) fontwid=lfWidth;
  if (fontwid<0)fontwid=-fontwid;
  
  if (fontwid < 2 || fontwid > 8192) fontwid=10;
 
  return font;
}
Exemplo n.º 7
0
int ImageList_Add(HIMAGELIST list, HBITMAP image, HBITMAP mask)
{
  if (!image || !list) return -1;
  WDL_PtrList<HGDIOBJ__> *l=(WDL_PtrList<HGDIOBJ__> *)list;
  
  HGDIOBJ__ *imgsrc = (HGDIOBJ__*)image;
  if (!HGDIOBJ_VALID(imgsrc,TYPE_BITMAP)) return -1;
  
  HGDIOBJ__* icon=GDP_OBJECT_NEW();
  icon->type=TYPE_BITMAP;
  icon->wid=1;
  // todo: copy underlying image

  image = (HICON) icon;
  
  l->Add(image);
  return l->GetSize();
}
Exemplo n.º 8
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;
}