Пример #1
0
static void iMatrixUndoListUpdate(ImatExData* matex_data, Ihandle* ih_list)
{
  int pos, item;
  char* undostr = IupGetLanguageString("IUP_UNDONAME");
  char* redostr = IupGetLanguageString("IUP_REDONAME");
  int undo_stack_count = iupArrayCount(matex_data->undo_stack);
  IundoData* undo_stack_data = (IundoData*)iupArrayGetData(matex_data->undo_stack);

  item = 1;

  for (pos=0; pos<matex_data->undo_stack_pos; pos++)
  {
    IupSetfAttributeId(ih_list, "", item, "%s: %s", undostr, undo_stack_data[pos].name);
    item++;
  }

  IupSetStrAttributeId(ih_list, "", item, "_@IUP_CURRENTSTATE");
  item++;

  for (pos=matex_data->undo_stack_pos; pos<undo_stack_count; pos++)
  {
    IupSetfAttributeId(ih_list, "", item, "%s: %s", redostr, undo_stack_data[pos].name);
    item++;
  }

  IupSetAttributeId(ih_list, "", item, NULL);  /* stack+current+null */
}
Пример #2
0
static void motFontDlgInitSizeList(Ihandle* ih, const char* fontface, int size)
{
  int i, j = 1, selected=-1, count = 0, sz, prev_sz = -1;
  char pattern[1024];
  Ihandle* list3 = IupGetDialogChild(ih, "LIST3");
  int size_list[32767];
  char**font_list_str;

  sprintf(pattern,"-*-%s-medium-r-*-*-*-*-*-*-*-*-*-*", fontface);
  font_list_str = XListFonts(iupmot_display, pattern, 32767, &count);
  if (!font_list_str)
    return;

  for (i=0; i<count; i++)
    size_list[i] = motGetFontSize(font_list_str[i]);

  qsort(size_list, count, sizeof(int), motFontDlgCompareSize);

  for (i=0; i<count; i++)
  {
    sz = size_list[i];
    if (sz && sz != prev_sz)  /* avoid duplicates, and zero */
    {
      if (sz == size)
        selected = j;
      IupSetfAttributeId(list3, "", j, "%d", sz);
      prev_sz = sz;
      j++;
    }
  }
  IupSetAttributeId(list3, "", j, NULL);

  if (selected != -1)
  {
    IupSetfAttribute(list3, "VALUE", "%d", selected);
    IupSetfAttribute(list3, "TOPITEM", "%d", selected);
  }

  XFreeFontNames(font_list_str);
}