Example #1
0
static int iScintillaSetFontAttrib(Ihandle* ih, const char* value)
{
  if (!ih->handle)
    return iupdrvSetFontAttrib(ih, value);
  else
  {
    int i, size = 0,
       is_bold = 0,
      is_italic = 0,
      is_underline = 0,
      is_strikeout = 0;
    char typeface[1024];

    if (!iupdrvSetFontAttrib(ih, value))
      return 0;

    if (!iupGetFontInfo(value, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
      return 0;

    for (i = 0; i < 256; i++)
    {
      IupScintillaSendMessage(ih, SCI_STYLESETFONT, i, (sptr_t)typeface);
      IupScintillaSendMessage(ih, SCI_STYLESETSIZE, i, size);
      IupScintillaSendMessage(ih, SCI_STYLESETBOLD, i, is_bold);
      IupScintillaSendMessage(ih, SCI_STYLESETITALIC, i, is_italic);
      IupScintillaSendMessage(ih, SCI_STYLESETUNDERLINE, i, is_underline);
    }

    return 1;
  }
}
Example #2
0
char* iupGetFontStyleAttrib(Ihandle* ih)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char *str;
  char* standardfont; 
  
  standardfont = iupGetFontAttrib(ih);

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return NULL;

  str = iupStrGetMemory(200);
  sprintf(str, "%s%s%s%s", is_bold?"Bold ":"", is_italic?"Italic ":"", is_underline?"Underline ":"", is_strikeout?"Strikeout ":"");
  return str;
}
Example #3
0
char* iupGetDefaultFontSizeGlobalAttrib(void)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char *str;
  char* standardfont; 
  
  standardfont = IupGetGlobal("DEFAULTFONT");

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return NULL;

  str = iupStrGetMemory(50);
  sprintf(str, "%d", size);
  return str;
}
Example #4
0
char* iupGetFontSizeAttrib(Ihandle* ih)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char *str;
  char* standardfont; 
  
  standardfont = iupGetFontAttrib(ih);

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return NULL;

  str = iupStrGetMemory(50);
  sprintf(str, "%d", size);
  return str;
}
Example #5
0
int iupSetFontStyleAttrib(Ihandle* ih, const char* value)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char new_standardfont[1024];
  char* standardfont; 

  if (!value)
    return 0;
  
  standardfont = iupGetFontAttrib(ih);

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return 0;

  sprintf(new_standardfont, "%s, %s %d", typeface, value, size);
  IupStoreAttribute(ih, "STANDARDFONT", new_standardfont);

  return 0;
}
Example #6
0
void iupSetDefaultFontSizeGlobalAttrib(const char* value)
{
  int size = 0;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  char typeface[1024];
  char new_standardfont[1024];
  char* standardfont; 

  if (!value)
    return;
  
  standardfont = IupGetGlobal("DEFAULTFONT");

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return;

  sprintf(new_standardfont, "%s, %s%s%s%s%s", typeface, is_bold?"Bold ":"", is_italic?"Italic ":"", is_underline?"Underline ":"", is_strikeout?"Strikeout ":"", value);
  IupStoreGlobal("DEFAULTFONT", new_standardfont);

  return;
}
Example #7
0
static IwinFont* winFindFont(const char *standardfont)
{
  HFONT hFont;
  int height_pixels;  /* negative value */
  char typeface[50] = "";
  int size = 8;
  int is_bold = 0,
    is_italic = 0, 
    is_underline = 0,
    is_strikeout = 0;
  int res = iupwinGetScreenRes();
  int i, count = iupArrayCount(win_fonts);
  const char* mapped_name;

  /* Check if the standardfont already exists in cache */
  IwinFont* fonts = (IwinFont*)iupArrayGetData(win_fonts);
  for (i = 0; i < count; i++)
  {
    if (iupStrEqualNoCase(standardfont, fonts[i].standardfont))
      return &fonts[i];
  }

  if (!iupGetFontInfo(standardfont, typeface, &size, &is_bold, &is_italic, &is_underline, &is_strikeout))
    return NULL;

  /* Map standard names to native names */
  mapped_name = iupFontGetWinName(typeface);
  if (mapped_name)
    strcpy(typeface, mapped_name);

  /* get in pixels */
  if (size < 0)  
    height_pixels = size;    /* already in pixels */
  else
    height_pixels = -iupWIN_PT2PIXEL(size, res);

  if (height_pixels == 0)
    return NULL;

  hFont = CreateFont(height_pixels, 0,0,0,
                    (is_bold) ? FW_BOLD : FW_NORMAL,
                    is_italic, is_underline, is_strikeout,
                    DEFAULT_CHARSET,OUT_TT_PRECIS,
                    CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
                    FF_DONTCARE|DEFAULT_PITCH,
                    iupwinStrToSystem(typeface));

  if (!hFont)
    return NULL;

  /* create room in the array */
  fonts = (IwinFont*)iupArrayInc(win_fonts);

  strcpy(fonts[i].standardfont, standardfont);
  fonts[i].hFont = hFont;

  {
    HDC hdc = GetDC(NULL);
    HFONT oldfont = (HFONT)SelectObject(hdc, hFont);

    TEXTMETRIC tm;
    GetTextMetrics(hdc, &tm);
    /* NOTICE that this is different from CD.
       In IUP we need "average" width,
       in CD is "maximum" width. */
    fonts[i].charwidth = tm.tmAveCharWidth; 
    fonts[i].charheight = tm.tmHeight;

    SelectObject(hdc, oldfont);
    ReleaseDC(NULL, hdc);
  }

  return &fonts[i];
}