예제 #1
0
파일: iuplua.c 프로젝트: Airr/iup_mac
static void IupSetIdle(void)
{
  lua_Object obj = lua_getparam(1);
  lua_Object old;
  if (idle_ref != 0)
    old = lua_getref(idle_ref);
  else
    old = LUA_NOOBJECT;
  if (lua_isnil(obj)) 
  {
    lua_unref(idle_ref);
    idle_ref = 0;
    IupSetFunction("IDLE_ACTION", (Icallback) NULL);
  } 
  else 
  {
    if (!lua_isfunction(obj) && !lua_iscfunction(obj))
      lua_error("IupSetIdle: parameter must be a function or a cfunction");
    lua_pushobject(obj);
    idle_ref = lua_ref(1);
    IupSetFunction("IDLE_ACTION", (Icallback) default_idle);
  }

  if (old == LUA_NOOBJECT)
    lua_pushnil();
  else
    lua_pushobject(old);
}
예제 #2
0
파일: gauge.c 프로젝트: defdef/iup
int btn_pause_cb(void)
{
  if(!IupGetFunction("IDLE_ACTION"))
    IupSetFunction("IDLE_ACTION", (Icallback) idle_cb);
  else
    IupSetFunction("IDLE_ACTION", NULL);
  
  return IUP_DEFAULT;
}
예제 #3
0
파일: tray.c 프로젝트: Airr/iup_mac
static int showmenu(Ihandle* ih)
{
  Ihandle* menu = IupMenu(IupItem("Show", "show"), IupItem("Hide", "hide"), IupItem("Exit", "close"), NULL);
  IupSetAttribute(menu, "_DIALOG", (char*)ih);
  IupSetFunction("show", (Icallback) show);
  IupSetFunction("hide", (Icallback) hide);
  IupSetFunction("close", (Icallback) close);
  IupPopup(menu, IUP_MOUSEPOS, IUP_MOUSEPOS);
  IupDestroy(menu);
  return IUP_DEFAULT;
}
예제 #4
0
파일: tree.c 프로젝트: Airr/iup_mac
static int rightclick_cb(Ihandle* ih, int id)
{
  Ihandle *popup_menu;
  char attr[50];

  popup_menu = IupMenu(
    IupItem ("Node Info","nodeinfo"),
    IupItem ("Rename Node","renamenode"),
    IupSeparator(),
    IupItem ("Add Leaf","addleaf"),
    IupItem ("Add Branch","addbranch"),
    IupItem ("Insert Leaf","insertleaf"),
    IupItem ("Insert Branch","insertbranch"),
    IupItem ("Remove Node","removenode"),
    IupItem ("Remove Children","removechild"),
    IupItem ("Toggle State","togglestate"),
    IupSubmenu("Focus", IupMenu(
      IupItem ("ROOT", "selectnode"),
      IupItem ("LAST", "selectnode"),
      IupItem ("PGUP", "selectnode"),
      IupItem ("PGDN", "selectnode"),
      IupItem ("NEXT", "selectnode"),
      IupItem ("PREVIOUS", "selectnode"),
      NULL)),
    IupSubmenu("Mark", IupMenu(
      IupItem ("INVERT", "selectnode"),
      IupItem ("BLOCK", "selectnode"),
      IupItem ("CLEARALL", "selectnode"),
      IupItem ("MARKALL", "selectnode"),
      IupItem ("INVERTALL", "selectnode"),
      NULL)),
    NULL);
    
  IupSetFunction("nodeinfo", (Icallback) nodeinfo);
  IupSetFunction("selectnode", (Icallback) selectnode);
  IupSetFunction("addleaf",    (Icallback) addleaf);
  IupSetFunction("addbranch",  (Icallback) addbranch);
  IupSetFunction("insertleaf",    (Icallback) insertleaf);
  IupSetFunction("insertbranch",  (Icallback) insertbranch);
  IupSetFunction("removenode", (Icallback) removenode);
  IupSetFunction("removechild", (Icallback) removechild);
  IupSetFunction("renamenode", (Icallback) renamenode);
  IupSetFunction("togglestate", (Icallback) togglestate);

//  sprintf(attr, "%d", id);
//  IupSetAttribute(ih, "VALUE", attr);
  IupPopup(popup_menu, IUP_MOUSEPOS, IUP_MOUSEPOS);

  IupDestroy(popup_menu);

  return IUP_DEFAULT;
}
예제 #5
0
파일: iuplua.c 프로젝트: mwoz/Hildim.Source
static int SetIdle(lua_State *L)
{
  if (lua_isnoneornil(L,1))
    IupSetFunction("IDLE_ACTION", NULL);
  else
  {
    luaL_checktype(L, 1, LUA_TFUNCTION);
    lua_pushvalue(L,1);
    lua_setglobal(L, "_IUP_LUA_IDLE_FUNC_");
    IupSetFunction("IDLE_ACTION", (Icallback)idle_cb);
  }
  return 0;
}
예제 #6
0
/* pause button callback */
int pausa_cb(void)
{
  if(IupGetFunction("IDLE_ACTION") == NULL)
  {
    // set idle callback 
    IupSetFunction("IDLE_ACTION", (Icallback) idle_cb);
  }
  else
  {
    // reset idle callback 
    IupSetFunction("IDLE_ACTION", NULL);
  }
  return IUP_DEFAULT ;
}
예제 #7
0
파일: mdi.c 프로젝트: Airr/iup_mac
static void createMenu(void)
{
  Ihandle* winmenu;
  Ihandle* mnu = IupMenu(
  IupSubmenu("MDI",IupMenu(
      IupItem("New", "mdi_new"), 
      NULL)),
  IupSubmenu("Window", winmenu = IupMenu(
      IupItem("Tile Horizontal", "mdi_tilehoriz"), 
      IupItem("Tile Vertical", "mdi_tilevert"), 
      IupItem("Cascade", "mdi_cascade"), 
      IupItem("Icon Arrange", "mdi_icon"), 
      IupItem("Close All", "mdi_closeall"), 
      IupSeparator(),
      IupItem("Next", "mdi_next"), 
      IupItem("Previous", "mdi_previous"), 
      NULL)),
    NULL);
  IupSetHandle("mnu",mnu);
  IupSetHandle("mdiMenu",winmenu);

  IupSetFunction("mdi_new", (Icallback)mdi_new);
  IupSetFunction("mdi_tilehoriz", (Icallback)mdi_tilehoriz);
  IupSetFunction("mdi_tilevert", (Icallback)mdi_tilevert);
  IupSetFunction("mdi_cascade", (Icallback)mdi_cascade);
  IupSetFunction("mdi_icon", (Icallback)mdi_icon);
  IupSetFunction("mdi_next", (Icallback)mdi_next);
  IupSetFunction("mdi_previous", (Icallback)mdi_previous);
  IupSetFunction("mdi_closeall", (Icallback)mdi_closeall);
}
예제 #8
0
파일: idle.c 프로젝트: Airr/iup_mac
static int motion_cb(Ihandle* ih)
{
  printf("MOTION_CB()\n");
  if (idle_count > 30000)
    IupSetFunction ("IDLE_ACTION", NULL);
  return IUP_DEFAULT;
}
예제 #9
0
/* carrega uma nova cena */
int load_cb(void) {
  char* filename = get_file_name();  /* chama o dialogo de abertura de arquivo */
  char buffer[30];

  if (filename==NULL) return 0;

  /* Le a cena especificada */
  scene = sceLoad( filename );
  if( scene == NULL ) return IUP_DEFAULT;

  sceGetCamera( scene, &camera );
  camGetEye( camera, eye );
  camGetScreenWidth( camera, &width );
  camGetScreenHeight( camera, &height );
  yc=0;

  if (image) imgDestroy(image);
  image = imgCreate( width, height );
  IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height);
  sprintf(buffer,"%3dx%3d", width, height);
  IupSetAttribute(canvas,IUP_RASTERSIZE,buffer);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
  start_time  = clock(); 
  return IUP_DEFAULT;
}
예제 #10
0
/* calcula uma linha da imagem a cada camada de idle */
int idle_cb(void)
{
	int x;
	/* Faz uma linha de pixels por vez */
	if (yc<height) {
		IupGLMakeCurrent(canvas);
		glBegin(GL_POINTS);
		for( x = 0; x < width; ++x ) {
			Color pixel;
			Vector ray;				

			ray = camGetRay( camera, x, yc );
			pixel = rayTrace( scene, eye, ray, 0 );

			imageSetPixel( image, x, yc, pixel );
			glColor3f((float)pixel.red,(float)pixel.green,(float)pixel.blue);
			glVertex2i(x,yc);

		}
		glEnd();
		glFlush();
		IupGLSwapBuffers(canvas);  /* change the back buffer with the front buffer */
		yc++;
	}
	else {
		IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL); /* a imagem ja' esta' completa */
		finish_time = clock();
		duration = (double)(finish_time - start_time)/CLOCKS_PER_SEC;
		IupSetfAttribute(label, "TITLE", "tempo=%.3lf s", duration);
	}

	return IUP_DEFAULT;
}
예제 #11
0
파일: text_spin.c 프로젝트: sanikoyes/iup
void TextSpinTest(void)
{
  Ihandle *dlg, *text;

  text = IupText(NULL);
  IupSetAttribute(text, "SIZE", "60x");
//  IupSetAttribute(text, "EXPAND", "HORIZONTAL");

  IupSetAttribute(text, "SPIN", "YES");
  IupSetAttribute(text, "SPINMIN", "5");
  IupSetAttribute(text, "SPINMAX", "50");
  IupSetAttribute(text, "SPININC", "10");
//  IupSetAttribute(text, "SPINWRAP", "YES");
//  IupSetAttribute(text, "SPINALIGN", "LEFT");
  IupSetAttribute(text, "SPINVALUE", "13");
//  IupSetAttribute(text, "SPINAUTO", "NO");
  IupSetAttribute(text, "NAME", "spin");

//  IupSetCallback(text, "SPIN_CB", (Icallback)spin_cb);
//  IupSetCallback(text, "ACTION", (Icallback)action_cb);
//  IupSetCallback(text, "VALUECHANGED_CB", (Icallback)valuechanged_cb);

  dlg = IupDialog(IupVbox(text, IupButton("SPINVALUE", "setspinvalue"), NULL));
  IupSetAttribute(dlg, "GAP", "20");
  IupSetAttribute(dlg, "MARGIN", "20x20");
//  IupSetAttribute(dlg, "BGCOLOR", "173 177 194");  // Motif BGCOLOR for documentation

  IupSetFunction("setspinvalue", (Icallback)setspinvalue);

  IupSetAttribute(dlg, "TITLE", "Text Spin Test");
  IupShow(dlg);
}
예제 #12
0
/* carrega uma nova cena */
int load_cb(void) {
	char* filename = get_file_name();  /* chama o dialogo de abertura de arquivo */
	char buffer[30];

	if (filename==NULL) return 0;

	/* Le a cena especificada */
	scene = sceLoad( filename );
	if( scene == NULL ) return IUP_DEFAULT;

	camera = sceGetCamera( scene );
	eye = camGetEye( camera );
	width = camGetScreenWidth( camera );
	height = camGetScreenHeight( camera );
	yc=0;

	if (image) imgDestroy(image);
	image = imgCreate( width, height );
	IupSetfAttribute(label, "TITLE", "%3dx%3d", width, height);
	sprintf(buffer,"%3dx%3d", width, height);
	IupSetAttribute(canvas,IUP_RASTERSIZE,buffer);
	IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cb);
	start_time  = clock(); 

	IupGLMakeCurrent(canvas);
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT);
	glEnd();
	glFlush();
	IupGLSwapBuffers(canvas);  /* change the back buffer with the front buffer */

	return IUP_DEFAULT;
}
예제 #13
0
파일: tabs.c 프로젝트: Airr/iup_mac
void TabsTest(void)
{
  Ihandle *box, *frm1, *frm2, *dlg, *tabs;

  tabs = CreateTabs(1);
  
  box = IupHbox(tabs, 
                frm1 = IupFrame(IupRadio(IupVbox(IupToggle("TOP", "cbType"), 
                                                 IupToggle("LEFT", "cbType"), 
                                                 IupToggle("BOTTOM", "cbType"), 
                                                 IupToggle("RIGHT", "cbType"), 
                                                 NULL))), 
                frm2 = IupFrame(IupRadio(IupVbox(IupToggle("HORIZONTAL", "cbOrientation"), 
                                                 IupToggle("VERTICAL", "cbOrientation"), 
                                                 NULL))), 
                IupVbox(IupSetAttributes(IupButton("Add Tab", "cbAddTab"), "TIP=\"Button Tip\""),
                        IupButton("Insert Tab", "cbInsertTab"),
                        IupButton("Remove Tab", "cbRemoveTab"),
                        IupToggle("Inactive", "cbInactive"),
                        IupButton("VALUEPOS=0", "cbValuePos"),
                        NULL), 
                NULL);

  IupSetAttribute(frm1, "MARGIN", "5x5");
  IupSetAttribute(frm2, "MARGIN", "5x5");
  IupSetAttribute(frm1, "GAP", "0");
  IupSetAttribute(frm2, "GAP", "0");
  IupSetAttribute(frm1, "TITLE", "Type");
  IupSetAttribute(frm2, "TITLE", "Orientation");

  IupSetAttribute(box, "MARGIN", "10x10");
  IupSetAttribute(box, "GAP", "10");
  dlg = IupDialog(box);

  IupSetAttribute(dlg, "TITLE", "IupTabs Test");
  IupSetAttribute(dlg, "APP_TABS", (char*)tabs);
//  IupSetAttribute(box, "BGCOLOR", "92 92 255");
//  IupSetAttribute(dlg, "BGCOLOR", "92 92 255");
//  IupSetAttribute(dlg, "BACKGROUND", "200 10 80");
//  IupSetAttributeHandle(dlg, "BACKGROUND", load_image_LogoTecgraf());
//  IupSetAttribute(dlg, "FGCOLOR", "10 200 80");
//  IupSetAttribute(dlg, "BGCOLOR", "173 177 194");  // Motif BGCOLOR for documentation
//  IupSetAttribute(dlg,"COMPOSITED","NO");

  IupMap(dlg);
  IupSetAttribute(dlg, "SIZE", NULL);
  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);

  IupSetFunction("cbOrientation", (Icallback)cbOrientation);
  IupSetFunction("cbType", (Icallback)cbType);
  IupSetFunction("cbAddTab", (Icallback)cbAddTab);
  IupSetFunction("cbInsertTab", (Icallback)cbInsertTab);
  IupSetFunction("cbRemoveTab", (Icallback)cbRemoveTab);
  IupSetFunction("cbInactive", (Icallback)cbInactive);
  IupSetFunction("cbChildButton", (Icallback)cbChildButton);
  IupSetFunction("cbValuePos", (Icallback)cbValuePos);
}
예제 #14
0
파일: iuplua.c 프로젝트: mwoz/Hildim.Source
static int SetFunction(lua_State *L)
{
  const char* name = luaL_checkstring(L, 1);

  if (lua_isnil(L, 2))
    IupSetFunction(name, NULL);
  else
  {
    Icallback func;

    if (!lua_iscfunction(L, 2))
      luaL_argerror(L, 2, "must be a C function");

    func = (Icallback)lua_tocfunction(L, 2);
    IupSetFunction(name, func);
  }

  return 0;
}
//Downloads und installs the latest supported nw.js version for the specified application.
int downloaderGui_download(){
	downloaderGui = IupGetHandle("downloaderDlg");
	pb = IupGetHandle("pb");
	status = IupGetHandle("status");
	IupSetCallback(IupGetHandle("cancel"), "ACTION", (Icallback)cancelCb);
	IupSetCallback(downloaderGui, "CLOSE_CB", (Icallback)cancelCb);
	IupSetFunction("IDLE_ACTION", downloadCb);
	IupPopup(downloaderGui, IUP_CENTERPARENT, IUP_CENTERPARENT);
	return globalResult;
}
예제 #16
0
파일: manual.c 프로젝트: svn2github/iup-iup
/* Main program */
int main(int argc, char **argv)
{
  Ihandle *dlg;
  IupOpen(&argc, &argv);       
  IupControlsOpen();
 
  IupSetFunction("removeline", (Icallback)removeline);
  IupSetFunction("addline", (Icallback)addline);
  IupSetFunction("removecol", (Icallback)removecol);
  IupSetFunction("addcol", (Icallback)addcol);
  IupSetFunction("redraw", (Icallback)redraw);

  createmenu();
  
  dlg = IupDialog(
          IupTabs(
            IupSetAttributes(
              IupVbox((create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), 
                NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"),
            IupSetAttributes(
              IupVbox(IupFrame(create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), 
//                NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), 
                NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), 
            NULL)); 
  IupSetAttribute(dlg,IUP_TITLE, "IupMatrix");
  IupSetAttribute(dlg,IUP_MENU, "mymenu");
//  IupSetAttribute(dlg,"BGCOLOR", "255 0 255");

  //IupSetAttribute(dlg,"COMPOSITED", "YES");
  //IupSetAttribute(dlg,"LAYERED", "YES");
  //IupSetAttribute(dlg,"LAYERALPHA", "192");

  IupShowXY(dlg,IUP_CENTER,IUP_CENTER) ;
  IupMainLoop();

  iupmaskMatRemove(IupGetHandle("mat1"), 2, 1) ;
  iupmaskMatRemove(IupGetHandle("mat2"), 2, 1) ;
  IupDestroy(dlg);

  IupControlsClose();
  IupClose();  
  return 0;
}
예제 #17
0
파일: iupglview.c 프로젝트: LuaDist/im
void mainMenuCreate(void) 
{
  Ihandle* file_menu = IupMenu(
     IupItem( "Open...", "app_open_cb"),
     IupSeparator(),
     IupItem( "Exit", "app_exit_cb"),
     NULL
  );

  Ihandle* menu = IupMenu(
     IupSubmenu("File", file_menu),
     NULL
  );

  /* this will be used by the dialog */
  IupSetHandle("app_menu", menu);

  IupSetFunction("app_open_cb", (Icallback)app_open_cb);
  IupSetFunction("app_exit_cb", (Icallback)app_exit_cb);
}
예제 #18
0
void MatrixCbsTest(void)
{
  Ihandle *dlg, *bt;

  IupMatrixExOpen();
 
  IupSetFunction("removeline", (Icallback)removeline);
  IupSetFunction("addline", (Icallback)addline);
  IupSetFunction("removecol", (Icallback)removecol);
  IupSetFunction("addcol", (Icallback)addcol);
  IupSetFunction("redraw", (Icallback)redraw);

  createmenu();

  bt = IupButton("Button", NULL);
  IupSetCallback(bt, "ACTION", bt_cb);
  IupSetAttribute(bt, "CANFOCUS", "NO");

  dlg = IupDialog(
//          IupZbox(
          IupTabs(
            IupSetAttributes(
              IupVbox((create_mat(1)), bt, IupText(""), IupLabel("Label Text"), IupFrame(IupVal("HORIZONTAL")), 
                NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"),
            IupSetAttributes(
              IupVbox(IupFrame(create_mat(2)), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), 
//                NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), 
//                NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), 
                NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), 
            NULL)); 
  IupSetAttribute(dlg,"TITLE", "IupMatrix");
  IupSetAttribute(dlg,"MENU", "mymenu");
  IupSetAttributeHandle(dlg,"DEFAULTENTER", bt);
//  IupSetAttribute(dlg,"BGCOLOR", "255 0 255");

  //IupSetAttribute(dlg,"COMPOSITED", "YES");
  //IupSetAttribute(dlg,"OPACITY", "192");

  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);
}
예제 #19
0
int main(int argc, char **argv)
{
  Ihandle *dg, *A, *B;

  IupOpen(&argc, &argv);
  IupControlsOpen();

  IupSetFunction("showcb", (Icallback) show_cb);
  IupSetFunction("buttoncb", (Icallback) button_cb);
  IupSetFunction("getfocus_cb", (Icallback) getfocus_cb);
  IupSetFunction("mm", (Icallback) mm);
  
  A = IupButton("Open Popup", "buttoncb");
  B = IupButton("Dummy", "");
  IupSetAttribute(A, IUP_TIP, "TIP DO PRIMEIRO ELEMENTO");
  dg = IupDialog(IupVbox(A, B, NULL));
  IupPopup(dg, IUP_CENTER, IUP_CENTER);

  IupMainLoop();
  IupClose();
  return 1;
}
예제 #20
0
static int iExpanderTimer_cb(Ihandle* timer)
{
  Ihandle* ih = (Ihandle*)iupAttribGet(timer, "_IUP_EXPANDER");
  Ihandle *child = ih->firstchild->brother;

  /* run timer just once each time */
  IupSetAttribute(timer, "RUN", "No");

  /* just show child on top,
     that's why child must be a native container when using autoshow. */
  ih->data->state = IEXPANDER_OPEN_FLOAT;
  iExpanderOpenCloseChild(ih, 0);
  IupRefreshChildren(ih);
  IupSetAttribute(child, "ZORDER", "TOP"); 

  /* now monitor mouse move */
  IupSetGlobal("INPUTCALLBACKS", "Yes");
  IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", IupGetFunction("GLOBALMOTION_CB"));
  IupSetGlobal("_IUP_EXPANDER_GLOBAL", (char*)ih);
  IupSetFunction("GLOBALMOTION_CB", (Icallback)iExpanderGlobalMotion_cb);
  return IUP_DEFAULT;
}
예제 #21
0
파일: opengl3D.c 프로젝트: LuaDist/iup
Ihandle* initDialog(void)
{
  Ihandle* dialog;   /* dialog containing the canvas */

  canvas = IupGLCanvas("repaint_cb"); /* create _canvas and define its repaint callback */
  IupSetFunction("repaint_cb", (Icallback) repaint_cb);  

  IupSetAttribute(canvas,IUP_RASTERSIZE,"640x480");   /* define the size in pixels */
  IupSetAttribute(canvas,IUP_BUFFER,IUP_DOUBLE);      /* define that this OpenGL _canvas has double buffer (front and back) */


   /* bind callback actions with callback functions */
   IupSetCallback(canvas, "RESIZE_CB",(Icallback) resize_cb); 

  /* create the dialog and set its attributes */
  dialog = IupDialog(canvas);
  IupSetAttribute(dialog, "TITLE", "IUP_3D_OpenGL");

  IupSetCallback(dialog, "CLOSE_CB", (Icallback) exit_cb);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) idle_cd);

  return dialog;
}
예제 #22
0
파일: idle.c 프로젝트: Airr/iup_mac
void IdleTest(void)
{
  Ihandle* dlg, *canvas;

  canvas = IupCanvas(NULL);
  IupSetCallback(canvas, "MOTION_CB", motion_cb);
 
  dlg = IupDialog(canvas);
  IupSetAttribute(dlg, "TITLE", "Idle Test");
  IupSetAttribute(dlg, "RASTERSIZE", "500x500");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);

  IupSetFunction ("IDLE_ACTION", (Icallback)idle);
}
예제 #23
0
파일: iupglview.c 프로젝트: LuaDist/im
void mainDialogCreate(void)
{
  Ihandle *dialog, *box, *canvas;

  /* initialize interface */

  /* canvas for the image */

  canvas = IupGLCanvas("app_repaint_cb");
  IupSetAttribute(canvas, "BORDER", "NO");
  IupSetAttribute(canvas, "BUFFER", "DOUBLE");   /* use double buffer */
  IupSetAttribute(canvas, "RESIZE_CB", "app_resize_cb");   /* configure the resize callback */

  IupSetFunction("app_resize_cb", (Icallback)app_resize_cb);
  IupSetFunction("app_repaint_cb", (Icallback)app_repaint_cb);

  /* this is the most external box that puts together
     the toolbar, the two canvas and the status bar */
  box = IupSetAttributes(IupHbox(
            canvas, 
            NULL), "MARGIN=10x10");

  /* create the dialog and set its attributes */

  mainMenuCreate();

  dialog = IupDialog(box);
  IupSetAttribute(dialog, "MENU", "app_menu");     /* configure the menu */
  IupSetAttribute(dialog, "CLOSE_CB", "app_exit_cb");
  IupSetAttribute(dialog, "TITLE", "IUPGLView");
  IupSetAttribute(dialog, "RASTERSIZE", "680x380"); /* initial size */
  IupSetAttribute(dialog, "SHRINK", "YES");
  IupSetHandle("app_dialog", dialog);

  IupShowXY(dialog, IUP_CENTER, IUP_CENTER);
}
예제 #24
0
static int iExpanderGlobalMotion_cb(int x, int y)
{
  int child_x, child_y;
  Ihandle* ih = (Ihandle*)IupGetGlobal("_IUP_EXPANDER_GLOBAL");
  Ihandle *child = ih->firstchild->brother;

  if (ih->data->state != IEXPANDER_OPEN_FLOAT)
  {
    IupSetGlobal("_IUP_EXPANDER_GLOBAL", NULL);
    IupSetFunction("GLOBALMOTION_CB", IupGetFunction("_IUP_OLD_GLOBALMOTION_CB"));
    IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", NULL);
    IupSetGlobal("INPUTCALLBACKS", "No");
    return IUP_DEFAULT;
  }

  child_x = 0, child_y = 0;
  iupdrvClientToScreen(ih->firstchild, &child_x, &child_y);
  if (x > child_x && x < child_x+ih->firstchild->currentwidth &&
      y > child_y && y < child_y+ih->firstchild->currentheight)
    return IUP_DEFAULT;  /* ignore if inside the bar */

  child_x = 0, child_y = 0;
  iupdrvClientToScreen(child, &child_x, &child_y);
  if (x < child_x || x > child_x+child->currentwidth ||
      y < child_y || y > child_y+child->currentheight)
  {
    ih->data->state = IEXPANDER_CLOSE;
    iExpanderOpenCloseChild(ih, 0);
    IupSetGlobal("_IUP_EXPANDER_GLOBAL", NULL);
    IupSetFunction("GLOBALMOTION_CB", IupGetFunction("_IUP_OLD_GLOBALMOTION_CB"));
    IupSetFunction("_IUP_OLD_GLOBALMOTION_CB", NULL);
    IupSetGlobal("INPUTCALLBACKS", "No");
  }

  return IUP_DEFAULT;
}
예제 #25
0
int main(int argc, char **argv)
{
  Ihandle *dlg;
  IupOpen(&argc, &argv);       
  IupMatrixOpen();

  matrixHandle = create_mat();
  IupSetAttribute(matrixHandle, IUP_CLICK_CB, "CLICK_ACTION");
  IupSetFunction("CLICK_ACTION", (Icallback)matrixClickCallback);

  dlg = IupDialog(matrixHandle);

  IupShowXY (dlg,IUP_CENTER,IUP_CENTER) ;
  IupMainLoop () ;
  IupClose () ;  
  return 0 ;
}
예제 #26
0
/* calcula uma linha da imagem a cada camada de idle */
int idle_cb(void)
{
	int x;
	double ray[VECTOR];
	float pixel[COLOR];

  /* Faz uma linha de pixels por vez */
  if (yc < height) {

    IupGLMakeCurrent(canvas);
    glBegin(GL_POINTS);
    {
      for (x = 0; x < width; ++x) {

        camGetRay(camera, x, yc, ray);
        rayTrace(scene, eye, ray, 0, pixel);

        imageSetPixel(image, x, yc, pixel);
        glColor3f((float) pixel[RED], (float) pixel[GREEN], (float) pixel[BLUE]);
        glVertex2i(x, yc);

      }
    }
    glEnd();

    glFlush();

    IupGLSwapBuffers(canvas);
    
    yc++;
  } else {

		IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL); /* a imagem ja' esta' completa */
		finish_time = clock();
		duration = (double)(finish_time - start_time)/CLOCKS_PER_SEC;
		IupSetfAttribute(label, "TITLE", "tempo=%.3lf s", duration);

		glFlush();
	}


	return IUP_DEFAULT;
}
예제 #27
0
파일: iup_recplay.c 프로젝트: Archs/iup-aio
int IupRecordInput(const char* filename, int mode)
{
  if (irec_file)
    fclose(irec_file);

  if (filename)
  {
    irec_file = fopen(filename, "wb");
    if (!irec_file)
      return IUP_ERROR;
    irec_mode = mode;
  }
  else
    irec_file = NULL;

  if (irec_file)
  {
    char* mode_str[3] = {"BIN", "TXT", "SYS"};
    iRecWriteStr(irec_file, "IUPINPUT", IUP_RECTEXT);  /* add space after, even for non text mode */
    iRecWriteStr(irec_file, mode_str[irec_mode], IUP_RECBINARY); /* no space after */
    iRecWriteByte(irec_file, '\n', IUP_RECBINARY);  /* no space after */
    irec_lastclock = iRecClock();

    IupSetGlobal("INPUTCALLBACKS", "Yes");
    IupSetFunction("GLOBALWHEEL_CB", (Icallback)iRecInputWheelCB);
    IupSetFunction("GLOBALBUTTON_CB", (Icallback)iRecInputButtonCB);
    IupSetFunction("GLOBALMOTION_CB", (Icallback)iRecInputMotionCB);
    IupSetFunction("GLOBALKEYPRESS_CB", (Icallback)iRecInputKeyPressCB);
  }
  else
  {
    IupSetGlobal("INPUTCALLBACKS", "No");
    IupSetFunction("GLOBALWHEEL_CB", NULL);
    IupSetFunction("GLOBALBUTTON_CB", NULL);
    IupSetFunction("GLOBALMOTION_CB", NULL);
    IupSetFunction("GLOBALKEYPRESS_CB", NULL);
  }

  return IUP_NOERROR;
}
예제 #28
0
int main(int argc, char **argv)
{
  Ihandle* dlg, *iupcanvas;	

  IupOpen(&argc, &argv);

//  iupcanvas = IupCanvas(NULL);
  iupcanvas = IupText(NULL);
  IupSetAttribute(iupcanvas,IUP_KEYPRESS_CB,"keypress_cb"); 
  IupSetFunction("keypress_cb", (Icallback) keypress_cb);
  
  dlg = IupDialog(iupcanvas);
  IupSetAttribute(dlg, "TITLE", "IupCanvas");
//  IupSetAttribute(dlg, "K_ANY", "k_any");
//  IupSetFunction("k_any", (Icallback) k_any);

  IupShowXY(dlg,100,100);
  
  IupMainLoop();
  IupDestroy(dlg);
  IupClose();
  return 0;
}
예제 #29
0
/* main program */
int main(int argc, char **argv)
{
  char *error=NULL;
  
  /* IUP initialization */
  IupOpen(&argc, &argv);       
  IupControlsOpen () ;

  /* loads LED */
  if(error = IupLoad("iupgauge.led"))
  {
    IupMessage("LED error", error);
    return 1 ;
  }

  dlg = IupGetHandle("dialog_name");
  gauge = IupGetHandle("gauge_name");

  /* sets callbacks */
  IupSetFunction( "acao_pausa", (Icallback) pausa_cb );
  IupSetFunction( "acao_inicio", (Icallback) inicio_cb );
  IupSetFunction( "acao_acelera", (Icallback) acelera_cb );
  IupSetFunction( "acao_freia", (Icallback) freia_cb );
  IupSetFunction( "acao_exibe", (Icallback) exibe_cb );
  IupSetFunction( "IDLE_ACTION", (Icallback) idle_cb);
  
  /* shows dialog */
  IupShowXY(dlg,IUP_CENTER,IUP_CENTER);

  /* main loop */
  IupMainLoop();

  IupDestroy(dlg);

  /* ends IUP */
  IupControlsClose() ;
  IupClose();

  return 0 ;
}
예제 #30
0
int init(void)
{
  Ihandle *dialog, *statusbar,  *box;

  Ihandle *toolbar, *load, *save;

  /* creates the toolbar and its buttons */
  load = IupButton("Load", "load_cb");
  IupSetAttribute(load,"TIP","Carrega uma imagem.");
  //IupSetAttribute(load,"IMAGE","icon_lib_open");
  IupSetFunction("load_cb", (Icallback)load_cb);

  save = IupButton("Save", "save_cb");
  IupSetAttribute(save,"TIP","Salva no formato GIF.");
  //IupSetAttribute(save,"IMAGE","icon_lib_save");
  

  toolbar = IupHbox(
       load, 
       save,
	   IupFill(),
     NULL);

  IupSetAttribute(toolbar, "ALIGNMENT", "ACENTER");
 

  /* cria um canvas */
  canvas = IupGLCanvas("repaint_cb"); 
  IupSetAttribute(canvas,IUP_RASTERSIZE,"400x400");
  IupSetAttribute(canvas, "RESIZE_CB", "resize_cb");

  /* associa o evento de repaint a funccao repaint_cb */
  IupSetFunction("repaint_cb", (Icallback) repaint_cb);
  IupSetFunction("save_cb", (Icallback)save_cb);
  IupSetFunction("resize_cb", (Icallback) resize_cb);
  IupSetFunction (IUP_IDLE_ACTION, (Icallback) NULL);

  /* the status bar is just a label to put some usefull information in run time */
  label = IupLabel("status");
  IupSetAttribute(label, "EXPAND", "HORIZONTAL");
  IupSetAttribute(label, "FONT", "COURIER_NORMAL_10");
  statusbar = IupSetAttributes(IupHbox(
	  IupFrame(IupHbox(label, NULL)), 
                NULL), "MARGIN=5x5");

  /* this is the most external box that puts together
     the toolbar, the two canvas and the status bar */
  box = IupVbox(
          toolbar,
          canvas, 
          statusbar, 
          NULL);

  /* create the dialog and set its attributes */
  dialog = IupDialog(box);
  IupSetAttribute(dialog, "CLOSE_CB", "app_exit_cb");
  IupSetAttribute(dialog, "TITLE", "CG2004: Trab. 2");


  IupShowXY(dialog, IUP_CENTER, IUP_CENTER);

  return 1;
}