Ejemplo n.º 1
0
int iupTextSetAddFormatTagHandleAttrib(Ihandle* ih, const char* value)
{
  Ihandle* formattag = (Ihandle*)value;
  if (!iupObjectCheck(formattag))
    return 0;

  if (ih->handle)
  {
    /* must update VALUE before updating the format */
    iTextUpdateValueAttrib(ih);

    iupdrvTextAddFormatTag(ih, formattag);
    IupDestroy(formattag);
  }
  else
  {
    Ihandle** tag_array;
    int i;

    if (!ih->data->formattags)
      ih->data->formattags = iupArrayCreate(10, sizeof(Ihandle*));

    i = iupArrayCount(ih->data->formattags);
    tag_array = (Ihandle**)iupArrayInc(ih->data->formattags);
    tag_array[i] = formattag;
  }
  return 0;
}
Ejemplo n.º 2
0
int iupTextSetAddFormatTagHandleAttrib(Ihandle* ih, const char* value)
{
  Ihandle* formattag = (Ihandle*)value;
  if (!iupObjectCheck(formattag))
    return 0;

  if (ih->handle)
  {
    char* bulk;

    /* must update VALUE before updating the format */
    iTextUpdateValueAttrib(ih);

    bulk = iupAttribGet(formattag, "BULK");
    if (bulk && iupStrBoolean(bulk))
    {
      Ihandle* child;
      void* state = iupdrvTextAddFormatTagStartBulk(ih);

      char* cleanout = iupAttribGet(formattag, "CLEANOUT");
      if (cleanout && iupStrBoolean(cleanout))
        IupSetAttribute(ih, "REMOVEFORMATTING", "ALL");

      for (child = formattag->firstchild; child; child = child->brother)
        iupdrvTextAddFormatTag(ih, child, 1);

      iupdrvTextAddFormatTagStopBulk(ih, state);
    }
    else
      iupdrvTextAddFormatTag(ih, formattag, 0);

    IupDestroy(formattag);
  }
  else
  {
    Ihandle** tag_array;
    int i;

    if (!ih->data->formattags)
      ih->data->formattags = iupArrayCreate(10, sizeof(Ihandle*));

    i = iupArrayCount(ih->data->formattags);
    tag_array = (Ihandle**)iupArrayInc(ih->data->formattags);
    tag_array[i] = formattag;
  }
  return 0;
}
Ejemplo n.º 3
0
static void gtkFileDlgGetMultipleFiles(Ihandle* ih, GSList* list)
{
  int len, cur_len, dir_len = -1;
  char *filename, *all_names;
  Iarray* names_array = iupArrayCreate(1024, 1);  /* just set an initial size, but count is 0 */

  while (list)
  {
    filename = (char*)list->data;
    len = strlen(filename);

    if (dir_len == -1)
    {
      dir_len = len;

      while (dir_len && (filename[dir_len] != '/' && filename[dir_len] != '\\'))
        dir_len--;

      cur_len = iupArrayCount(names_array);
      all_names = iupArrayAdd(names_array, dir_len+1);
      memcpy(all_names+cur_len, filename, dir_len);
      all_names[cur_len+dir_len] = '0';
      iupAttribStoreStr(ih, "DIRECTORY", all_names);
      all_names[cur_len+dir_len] = '|';

      dir_len++; /* skip separator */
    }
    len -= dir_len; /* remove directory */

    cur_len = iupArrayCount(names_array);
    all_names = iupArrayAdd(names_array, len+1);
    memcpy(all_names+cur_len, filename+dir_len, len);
    all_names[cur_len+len] = '|';

    g_free(filename);
    list = list->next;
  }

  cur_len = iupArrayCount(names_array);
  all_names = iupArrayInc(names_array);
  all_names[cur_len+1] = 0;

  iupAttribStoreStr(ih, "VALUE", iupgtkStrConvertFromFilename(all_names));

  iupArrayDestroy(names_array);
}
Ejemplo n.º 4
0
static int motFileDlgGetMultipleFiles(Ihandle* ih, const char* dir, Widget wList)
{
  int *pos, sel_count, dir_len;
  int i, len, cur_len;
  char *filename, *all_names;
  Iarray* names_array;
  XmString* items;

  if (!XmListGetSelectedPos(wList, &pos, &sel_count))
    return 0;

  names_array = iupArrayCreate(1024, 1);  /* just set an initial size, but count is 0 */
  XtVaGetValues(wList, XmNitems, &items, NULL);

  cur_len = strlen(dir);

  all_names = iupArrayAdd(names_array, cur_len+1);
  memcpy(all_names, dir, cur_len);
  all_names[cur_len] = '|';
  dir_len = cur_len;
  cur_len++; /* skip separator */

  for (i = 0; i<sel_count; i++)
  {
    filename = iupmotConvertString(items[pos[i]-1]);  /* XmListGetSelectedPos starts at 1 */
    len = strlen(filename)-dir_len;

    cur_len = iupArrayCount(names_array);
    all_names = iupArrayAdd(names_array, len+1);
    memcpy(all_names+cur_len, filename+dir_len, len);
    all_names[cur_len+len] = '|';
  }

  XtFree((char*)pos);

  cur_len = iupArrayCount(names_array);
  all_names = iupArrayInc(names_array);
  all_names[cur_len+1] = 0;

  iupAttribStoreStr(ih, "VALUE", all_names);

  iupArrayDestroy(names_array);
  return 1;
}
Ejemplo n.º 5
0
static int iNormalizerCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();
  ih->data->ih_array = iupArrayCreate(10, sizeof(Ihandle*));

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    Ihandle** ih_list;
    int i = 0;
    while (*iparams) 
    {
      ih_list = (Ihandle**)iupArrayInc(ih->data->ih_array);
      ih_list[i] = *iparams;
      i++;
      iparams++;
    }
  }

  return IUP_NOERROR;
}
Ejemplo n.º 6
0
static int iMatrixExSetCopyDataAttrib(Ihandle *ih, const char* value)
{
  if (!value)
    iupAttribSet(ih, "COPYDATA", NULL);
  else
  {
    ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
    Iarray* data =  iupArrayCreate(100, sizeof(char));

    iMatrixExCopyData(matex_data, data, value);

    if (iupArrayCount(data)!=0)
    {
      iMatrixExArrayAddChar(data, '\0');

      iupAttribSetStr(ih, "COPYDATA", (char*)iupArrayGetData(data));
    }

    iupArrayDestroy(data);
  }
  return 0;
}
Ejemplo n.º 7
0
static int iMatrixExSetCopyAttrib(Ihandle *ih, const char* value)
{
  ImatExData* matex_data = (ImatExData*)iupAttribGet(ih, "_IUP_MATEX_DATA");
  Iarray* data =  iupArrayCreate(100, sizeof(char));

  iMatrixExCopyData(matex_data, data, value);

  if (iupArrayCount(data)!=0)
  {
    Ihandle* clipboard;

    iMatrixExArrayAddChar(data, '\0');

    clipboard = IupClipboard();
    IupSetAttribute(clipboard, "TEXT", NULL);  /* clear all data from clipboard */
    IupSetAttribute(clipboard, "TEXT", (char*)iupArrayGetData(data));
    IupDestroy(clipboard);
  }

  iupArrayDestroy(data);
  return 0;
}
Ejemplo n.º 8
0
void iupdrvFontInit(void)
{
  win_fonts = iupArrayCreate(50, sizeof(IwinFont));
}
Ejemplo n.º 9
0
static void iMatrixExUndoStackInit(ImatExData* matex_data)
{
  if (!matex_data->undo_stack) 
    matex_data->undo_stack = iupArrayCreate(40, sizeof(IundoData));
}
Ejemplo n.º 10
0
static int winTabsGetImageIndex(Ihandle* ih, const char* name)
{
  HIMAGELIST image_list;
  int count, i, bpp, ret;
  Iarray* bmp_array;
  HBITMAP *bmp_array_data, hMask=NULL;
  HBITMAP bmp = iupImageGetImage(name, ih, 0);
  if (!bmp)
    return -1;

  /* the array is used to avoi adding the same bitmap twice */
  bmp_array = (Iarray*)iupAttribGet(ih, "_IUPWIN_BMPARRAY");
  if (!bmp_array)
  {
    /* create the array if does not exist */
    bmp_array = iupArrayCreate(50, sizeof(HBITMAP));
    iupAttribSetStr(ih, "_IUPWIN_BMPARRAY", (char*)bmp_array);
  }

  bmp_array_data = iupArrayGetData(bmp_array);

  image_list = (HIMAGELIST)SendMessage(ih->handle, TCM_GETIMAGELIST, 0, 0);
  if (!image_list)
  {
    int width, height;
    UINT flags = ILC_COLOR32|ILC_MASK;

    /* must use this info, since image can be a driver image loaded from resources */
    iupdrvImageGetInfo(bmp, &width, &height, &bpp);

    /* create the image list if does not exist */
    image_list = ImageList_Create(width, height, flags, 0, 50);
    SendMessage(ih->handle, TCM_SETIMAGELIST, 0, (LPARAM)image_list);
  }
  else
    iupdrvImageGetInfo(bmp, NULL, NULL, &bpp);

  /* check if that bitmap is already added to the list,
     but we can not compare with the actual bitmap at the list since it is a copy */
  count = ImageList_GetImageCount(image_list);
  for (i=0; i<count; i++)
  {
    if (bmp_array_data[i] == bmp)
      return i;
  }

  if (bpp == 8)
  {
    Ihandle* image = IupGetHandle(name);
    if (image)
    {
      iupAttribSetStr(image, "_IUPIMG_NO_INVERT", "1");
      hMask = iupdrvImageCreateMask(image);
      iupAttribSetStr(image, "_IUPIMG_NO_INVERT", NULL);
    }
  }

  bmp_array_data = iupArrayInc(bmp_array);
  bmp_array_data[i] = bmp;
  ret = ImageList_Add(image_list, bmp, hMask);  /* the bmp is duplicated at the list */
  DeleteObject(hMask);
  return ret;
}
Ejemplo n.º 11
0
void iupdrvFontInit(void)
{
  gtk_fonts = iupArrayCreate(50, sizeof(IgtkFont));
  gtk_fonts_context = gdk_pango_context_get();
  pango_context_set_language(gtk_fonts_context, gtk_get_default_language());
}
Ejemplo n.º 12
0
void iupdrvFontInit(void)
{
  mot_fonts = iupArrayCreate(50, sizeof(ImotFont));
}