Пример #1
0
//Pass the name of the menu and an array of MenuItems, the last of which must be {NULL}
Ihandle* _create_submenu(const char* label, MenuItem* items)
{
	Ihandle* m = IupMenu(NULL);

	int i;

	for(i = 0; items[i].label ; i++)
	{
		if(items[i].label == SEPARATOR)
			IupAppend(m, IupSeparator());
		else
		{
			Ihandle* e = IupItem(items[i].label, NULL);
			IupSetCallback(e, "ACTION", items[i].cb);
			switch(items[i].condition)
			{
			case CONDITION_NONE:
				break;
			case CONDITION_POPULATED:
				IupSetAttribute(e, "ACTIVE", "NO");
				menus_populated[nPopulated++] = e;
				break;
			case CONDITION_SELECTED:
				IupSetAttribute(e, "ACTIVE", "NO");
				menus_selected[nSelected++] = e;
				break;
			}
			IupAppend(m,e);
		}
	}

	return IupSubmenu(label,m);
}
Пример #2
0
void GLCanvasCubeTest(void)
{
  Ihandle *dlg, *canvas, *box;

  IupGLCanvasOpen();

  box = IupVbox(NULL);
  IupSetAttribute(box, "MARGIN", "5x5");

  canvas = IupGLCanvas(NULL);
  IupSetCallback(canvas, "ACTION", action);
  IupSetCallback(canvas, "BUTTON_CB", (Icallback)button_cb);
  IupSetCallback(canvas, "MOTION_CB", (Icallback)motion_cb);
//  IupSetAttribute(canvas, "BUFFER", "DOUBLE");
  IupSetAttribute(canvas, "RASTERSIZE", "300x300");
  IupAppend(box, canvas);

  dlg = IupDialog(IupSetAttributes(IupFrame(box), "TITLE=Test"));
  IupSetAttribute(dlg, "TITLE", "IupGLCanvas Test");
//  IupSetAttribute(dlg, "COMPOSITED", "YES");

  IupMap(dlg);

  IupGLMakeCurrent(canvas);
//  init();
  printf("Vendor: %s\n", glGetString(GL_VENDOR));
  printf("Renderer: %s\n", glGetString(GL_RENDERER));
  printf("Version: %s\n", glGetString(GL_VERSION));
  IupSetAttribute(canvas, "RASTERSIZE", NULL);

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);
}
Пример #3
0
static int iSboxCreateMethod(Ihandle* ih, void** params)
{
  Ihandle* bar;

  ih->data = iupALLOCCTRLDATA();

  ih->data->direction = ISBOX_EAST;
  ih->data->h = -1;
  ih->data->w = -1;

  bar = IupCanvas(NULL);
  bar->flags |= IUP_INTERNAL;
  iupChildTreeAppend(ih, bar);  /* bar will always be the firstchild */

  IupSetAttribute(bar, "BORDER", "YES");
  IupSetAttribute(bar, "EXPAND", "NO");
  IupSetAttribute(bar, "BGCOLOR", "192 192 192");

  /* Setting callbacks */
  IupSetCallback(bar, "BUTTON_CB", (Icallback) iSboxButton_CB);
  IupSetCallback(bar, "FOCUS_CB",  (Icallback) iSboxFocus_CB);
  IupSetCallback(bar, "MOTION_CB", (Icallback) iSboxMotion_CB);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }

  return IUP_NOERROR;
}
Пример #4
0
static int iExpanderCreateMethod(Ihandle* ih, void** params)
{
  Ihandle* bar;

  ih->data = iupALLOCCTRLDATA();

  ih->data->position = IEXPANDER_TOP;
  ih->data->state = IEXPANDER_OPEN;
  ih->data->barSize = -1;

  bar = IupCanvas(NULL);
  iupChildTreeAppend(ih, bar);  /* bar will always be the firstchild */
  bar->flags |= IUP_INTERNAL;

  IupSetAttribute(bar, "CANFOCUS", "NO");
  IupSetAttribute(bar, "BORDER", "NO");
  IupSetAttribute(bar, "EXPAND", "NO");

  /* Setting callbacks */
  IupSetCallback(bar, "BUTTON_CB", (Icallback) iExpanderButton_CB);
  IupSetCallback(bar, "ACTION",    (Icallback) iExpanderAction_CB);
  IupSetCallback(bar, "ACTION",    (Icallback) iExpanderAction_CB);
  IupSetCallback(bar, "ENTERWINDOW_CB", (Icallback)iExpanderEnterWindow_cb);
  IupSetCallback(bar, "LEAVEWINDOW_CB", (Icallback)iExpanderLeaveWindow_cb);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }

  return IUP_NOERROR;
}
Пример #5
0
static void uiSetupModule(Module *module, Ihandle *parent) {
    Ihandle *groupBox, *toggle, *controls, *icon;
    groupBox = IupHbox(
        icon = IupLabel(NULL),
        toggle = IupToggle(module->displayName, NULL),
        IupFill(),
        controls = module->setupUIFunc(),
        NULL
    );
    IupSetAttribute(groupBox, "EXPAND", "HORIZONTAL");
    IupSetAttribute(groupBox, "ALIGNMENT", "ACENTER");
    IupSetAttribute(controls, "ALIGNMENT", "ACENTER");
    IupAppend(parent, groupBox);

    // set controls as attribute to toggle and enable toggle callback
    IupSetCallback(toggle, "ACTION", (Icallback)uiToggleControls);
    IupSetAttribute(toggle, CONTROLS_HANDLE, (char*)controls);
    IupSetAttribute(toggle, SYNCED_VALUE, (char*)module->enabledFlag);
    IupSetAttribute(controls, "ACTIVE", "NO"); // startup as inactive
    IupSetAttribute(controls, "NCGAP", "4"); // startup as inactive

    // set default icon
    IupSetAttribute(icon, "IMAGE", "none_icon");
    IupSetAttribute(icon, "PADDING", "4x");
    module->iconHandle = icon;

    // parameterize toggle
    if (parameterized) {
        setFromParameter(toggle, "VALUE", module->shortName);
    }
}
Пример #6
0
void guiVal_OnInit( void )
{
  guiVal->tbValue  = IupText( NULL );
  guiVal->hlType = IupHList( NULL );
  IupSetStrAttribute( guiVal->hlType,  "1",  "schar" );
  IupSetStrAttribute( guiVal->hlType,  "2",  "uchar" );
  IupSetStrAttribute( guiVal->hlType,  "3",  "short" );
  IupSetStrAttribute( guiVal->hlType,  "4", "ushort" );
  IupSetStrAttribute( guiVal->hlType,  "5",    "int" );
  IupSetStrAttribute( guiVal->hlType,  "6",   "uint" );
  IupSetStrAttribute( guiVal->hlType,  "7",   "long" );
  IupSetStrAttribute( guiVal->hlType,  "8",  "ulong" );
  IupSetStrAttribute( guiVal->hlType,  "9",   "lint" );
  IupSetStrAttribute( guiVal->hlType, "10",  "ulint" );
  IupSetStrAttribute( guiVal->hlType, "11",    "fpn" );
  IupSetStrAttribute( guiVal->hlType, "12",    "dpn" );
  IupSetStrAttribute( guiVal->hlType, "13",    "lpn" );
  guiVal->value.vb   = IupVbox(  guiVal->tbValue, guiVal->hlType, NULL );
  guiVal->value.fset = IupFrame( guiVal->value.vb );
  IupSetAttribute( guiVal->value.fset, IUP_SIZE, "100x30" );
  IupSetAttribute( guiVal->value.fset, IUP_EXPAND, IUP_HORIZONTAL );
  IupAppend( guiVal->main.vb, guiVal->value.fset );
  IupMap( guiVal->value.fset );
  guiVal_OnLang();
}
Пример #7
0
static void ext_iup_append(script_t* script, vector_t* args)
{
	Ihandle* handle = script_get_arg(args, 0)->nat.value;
	Ihandle* new_child = script_get_arg(args, 1)->nat.value;
	
	IupAppend(handle, new_child);
}
Пример #8
0
static void iMatrixEditInitMenu(Ihandle* ih_menu)
{
    char *value;
    int i = 1;
    int v = IupGetInt(ih_menu, "VALUE");

    do
    {
        value = IupGetAttributeId(ih_menu, "", i);
        if (value)
        {
            Ihandle* item = IupItem(value, NULL);

            char* img = IupGetAttributeId(ih_menu, "IMAGE", i);
            if (img)
                IupSetAttribute(item, "IMAGE", img);

            IupSetCallback(item, "ACTION", (Icallback)iMatrixMenuItemAction_CB);

            if (v == i)   /* if v==0 no mark will be shown */
                IupSetAttribute(item, "VALUE", "On");

            IupAppend(ih_menu, item);
        }
        i++;
    } while (value);
}
Пример #9
0
static int iGLCanvasBoxCreateMethod(Ihandle* ih, void** params)
{
  int i;
  char new_name[50];

  for (i = 0; i < CB_NAMES_COUNT; i++)
  {
    /* save the internal callbacks */
    sprintf(new_name, "GLBOX_%s", iglcanvasbox_cb_names[i]);
    IupSetCallback(ih, new_name, iglcanvasbox_cbs[i]);
  }

  IupSetCallback(ih, "SWAPBUFFERS_CB", iGLCanvasBoxSwapBuffers_CB);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams)
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }

  return IUP_NOERROR;
}
Пример #10
0
static Ihandle *boxcreate (Iclass *box_class, void **params)
{
  Ihandle *self = IupCanvas(NULL);
  Ihandle *box = IupHbox(NULL);
  Ihandle *elem;
  
  while ((elem = *((Ihandle **) params)) != NULL)
  {
    IupAppend(box, elem);
    params = ((void **) params) + 1;
  }

  IupAppend(self, box);
  iupSetEnv(self, "__cbox_box", (char *)box);

  return self;
}
Пример #11
0
int item_add_cb(Ihandle* ih)
{
  Ihandle* item = IupItem("New Appended Item", "item_cb");
  printf("ACTION(%s)\n", IupGetAttribute(ih, "TITLE"));
  IupAppend(IupGetParent(ih), item);   /* after the last item */
  IupMap(item);
  return IUP_DEFAULT;
}
Пример #12
0
static int iRadioCreateMethod(Ihandle* ih, void** params)
{
  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }
  return IUP_NOERROR;
}
Пример #13
0
static int iGLFrameCreateMethod(Ihandle* ih, void** params)
{
    if (params)
    {
        Ihandle** iparams = (Ihandle**)params;
        if (*iparams)
            IupAppend(ih, *iparams);
    }

    IupSetCallback(ih, "GL_ACTION", iGLFrameACTION);

    return IUP_NOERROR;
}
Пример #14
0
static int iSplitCreateMethod(Ihandle* ih, void** params)
{
  Ihandle* bar;

  ih->data = iupALLOCCTRLDATA();

  ih->data->orientation = ISPLIT_VERT;
  ih->data->val = -1;
  ih->data->layoutdrag = 1;
  ih->data->autohide = 0;
  ih->data->barsize = 5;
  ih->data->showgrip = 1;
  ih->data->min = 0; 
  ih->data->max = 1000;

  bar = IupCanvas(NULL);
  iupChildTreeAppend(ih, bar);  /* bar will always be the firstchild */
  bar->flags |= IUP_INTERNAL;

  IupSetAttribute(bar, "CANFOCUS", "NO");
  IupSetAttribute(bar, "BORDER", "NO");
  IupSetAttribute(bar, "EXPAND", "NO");
  IupSetAttribute(bar, "CURSOR", "SPLITTER_VERT");

  /* Setting callbacks */
  IupSetCallback(bar, "BUTTON_CB", (Icallback) iSplitButton_CB);
  IupSetCallback(bar, "FOCUS_CB",  (Icallback) iSplitFocus_CB);
  IupSetCallback(bar, "MOTION_CB", (Icallback) iSplitMotion_CB);
  IupSetCallback(bar, "ACTION", (Icallback) iSplitAction_CB);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (iparams[0]) IupAppend(ih, iparams[0]);
    if (iparams[1]) IupAppend(ih, iparams[1]);
  }

  return IUP_NOERROR;
}
Пример #15
0
static int iCboxCreateMethod(Ihandle* ih, void** params)
{
  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams) 
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }

  return IUP_NOERROR;
}
Пример #16
0
static int iSubmenuCreateMethod(Ihandle* ih, void** params)
{
  if (params)
  {
    if (params[0]) iupAttribSetStr(ih, "TITLE", (char*)(params[0]));
    if (params[1]) 
    {
      Ihandle* child = (Ihandle*)(params[1]);
      if (child->iclass->nativetype == IUP_TYPEMENU)
        IupAppend(ih, child);
    }
  }
  return IUP_NOERROR;
}
Пример #17
0
static int iDialogCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }

  iupDlgListAdd(ih);

  return IUP_NOERROR;
}
Пример #18
0
static void create_CircleProgress_animation(void)
{
  Ihandle* animation = IupUser();
  int i;
  char name[30];

  for (i = 0; i < 12; i++)
  {
    sprintf(name, "IUP_CircleProgress%d", i);
    IupAppend(animation, IupGetHandle(name));
  }

  IupSetHandle("IUP_CircleProgressAnimation", animation);
  IupSetAttribute(animation, "FRAMETIME", "83");  /* near 1s for a full turn */
}
Пример #19
0
static int iScrollBoxCreateMethod(Ihandle* ih, void** params)
{
  /* Setting callbacks */
  IupSetCallback(ih, "SCROLL_CB",    (Icallback)iScrollBoxScroll_CB);
  IupSetCallback(ih, "BUTTON_CB",    (Icallback)iScrollBoxButton_CB);
  IupSetCallback(ih, "MOTION_CB",    (Icallback)iScrollBoxMotion_CB);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (iparams[0]) IupAppend(ih, iparams[0]);
  }

  return IUP_NOERROR;
}
Пример #20
0
static int iTabsCreateMethod(Ihandle* ih, void **params)
{
  ih->data = iupALLOCCTRLDATA();

  /* add children */
  if(params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams) 
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }
  return IUP_NOERROR;
}
Пример #21
0
static int iGLScrollBoxCreateMethod(Ihandle* ih, void** params)
{
  IupSetCallback(ih, "GL_ACTION", (Icallback)iGLScrollBoxACTION_CB);
  IupSetCallback(ih, "GL_BUTTON_CB", (Icallback)iGLScrollBoxBUTTON_CB);
  IupSetCallback(ih, "GL_MOTION_CB", (Icallback)iGLScrollBoxMOTION_CB);
  IupSetCallback(ih, "GL_LEAVEWINDOW_CB", (Icallback)iGLScrollBoxLEAVEWINDOW_CB);
  IupSetCallback(ih, "GL_ENTERWINDOW_CB", (Icallback)iGLScrollBoxENTERWINDOW_CB);

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (iparams[0]) IupAppend(ih, iparams[0]);
  }

  return IUP_NOERROR;
}
Пример #22
0
static int cbAddTab(Ihandle* ih)
{
  Ihandle* tabs = (Ihandle*)IupGetAttribute(ih, "APP_TABS");
  Ihandle *vbox;

  vbox = IupFrame(IupVbox(IupLabel("Label XXX"), IupButton("Button XXX", "cbChildButton"), NULL));
  IupSetAttribute(vbox, "TABTITLE", "XXX");
  IupSetAttribute(vbox, "TITLE", "TABS XXX");

  IupAppend(tabs, vbox);
  IupMap(vbox);

  IupRefresh(tabs); /* update children layout */

  return IUP_DEFAULT;
}
Пример #23
0
static int iSpinboxCreateMethod(Ihandle* ih, void** params)
{
  Ihandle *spin = IupSpin();
  spin->flags |= IUP_INTERNAL;
  iupChildTreeAppend(ih, spin);  /* spin will always be the firstchild */

  iupAttribSet(spin, "_IUPSPIN_BOX", (char*)ih);  /* will be used by the callback */

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }

  return IUP_NOERROR;
}
Пример #24
0
static int iZboxCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  ih->data->alignment = IZBOX_ALIGN_NW;

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams)
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }

  return IUP_NOERROR;
}
Пример #25
0
static int iGridBoxCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams) 
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }

  ih->data->num_div = -1; /* default is auto */

  return IUP_NOERROR;
}
Пример #26
0
static int iMenuCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams) 
    {
      Ihandle* child = (Ihandle*)(*iparams);
      if (child->iclass->nativetype == IUP_TYPEMENU)
        IupAppend(ih, child);
      iparams++;
    }
  }

  return IUP_NOERROR;
}
Пример #27
0
static int iDialogCreateMethod(Ihandle* ih, void** params)
{
 ih->data = iupALLOCCTRLDATA();

  ih->data->child_id = 100; /* initial number */
  ih->data->show_state = IUP_HIDE;

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    if (*iparams)
      IupAppend(ih, *iparams);
  }

  iupDlgListAdd(ih);

  return IUP_NOERROR;
}
Пример #28
0
static int iBoxCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams)
    {
      if (iupObjectCheck(*iparams))
        IupAppend(ih, *iparams);
      iparams++;
    }
  }

  IupSetCallback(ih, "UPDATEATTRIBFROMFONT_CB", iBoxUpdateAttribFromFont);

  return IUP_NOERROR;
}
Пример #29
0
static int iGridBoxCreateMethod(Ihandle* ih, void** params)
{
  ih->data = iupALLOCCTRLDATA();

  if (params)
  {
    Ihandle** iparams = (Ihandle**)params;
    while (*iparams) 
    {
      IupAppend(ih, *iparams);
      iparams++;
    }
  }

  ih->data->num_div = -1; /* default is auto */

  IupSetCallback(ih, "UPDATEATTRIBFROMFONT_CB", iGridBoxUpdateAttribFromFont);

  return IUP_NOERROR;
}
Пример #30
0
static int _render_image(Ihandle *ih, char *text, int item, int state)
{
	if(state == 1)
	{
		LinkedList *ll = LL_get(images, item-1);
		if(ll == NULL || ll->contents == NULL)
			return IUP_ERROR;
		imImage* img = ll->contents;

		//Display the scaled image
		char buf[64];
		sprintf(buf,"%dx%d",img->width,img->height);
		IupSetAttribute(preview, "RASTERSIZE", buf);
		IupSetAttributeHandle(preview, "IMAGE", ll->iContents);
		IupRefresh(preview);

		//Recreate the grid where to put all the images
		Ihandle* child;
		while((child = IupGetChild(imgmod, 0)) != NULL)
			IupDestroy(child);
		IupSetInt(imgmod, "NUMDIV", ll->cols);

		//Put the images into the grid
		int i;
		for(i = 0; i < ll->cols * ll->rows; i++)
		{
			Ihandle* tinyimg = IupLabel(NULL);
			IupSetAttributeHandle(tinyimg, "IMAGE", ll->iGrid[i]);
			IupAppend(imgmod, tinyimg);
			IupMap(tinyimg);
		}
		IupRefresh(imgmod);
	}

	main_window_set_menu_state();
	return IUP_DEFAULT;
}