main(int ac, char **av) { EZ_Widget *frame, *tmp, *btn; int i; EZ_Initialize(ac,av,0); MY_BG_ATOM = EZ_GetAtom("MY_BG_ATOM"); frame = EZ_CreateFrame(NULL, "Drag sources"); tmp = EZ_CreateFrame(frame, NULL); EZ_ConfigureWidget(tmp, EZ_ORIENTATION, EZ_VERTICAL, EZ_FILL_MODE, EZ_FILL_BOTH, 0); for(i = 0; i < 8; i++) { btn = EZ_CreateButton(tmp, colors[i], -1); EZ_ConfigureWidget(btn, EZ_EXPAND, True, EZ_BACKGROUND, colors[i], 0); EZ_WidgetAddDnDDataEncoder(btn, MY_BG_ATOM, 0, encodeBG, NULL, NULL, NULL); } EZ_DisplayWidget(frame); EZ_EventMainLoop(); }
main(int argc, char **argv) { EZ_Widget *menu, *button, *tmp; EZ_Initialize(argc, argv, 0); button = EZ_CreateButton(NULL,"An Optional Button", -1); /* a button */ menu = EZ_CreatePopupMenu(NULL); EZ_ConfigureWidget(button, EZ_EVENT_HANDLER, buttonEventHandler, EZ_CLIENT_PTR_DATA, menu, 0); EZ_ConfigureWidget(menu, EZ_CALLBACK, menuCallBack, EZ_CLIENT_PTR_DATA, button, 0); { char **ptr = colors; int i = 0; while(*ptr) { tmp = EZ_CreateMenuNormalButton(menu, *ptr, -1, i++); ptr++; } } EZ_DisplayWidget(button); EZ_EventMainLoop(); }
/*---------------------- Open_Info_Widget() ------------------------*/ int Open_Info_Widget() { char tmp_name[128], tmp_cmd[256]; /* check to make sure we have a minc file loaded */ if (file_format!=MINC_FORMAT) { EZW_Error("Error: This is not a minc file!"); return(-1); } /* create a temp filename */ tmpnam(tmp_name); /* issue shell command to create a mincheader dump file */ sprintf(tmp_cmd,"mincheader %s > %s \n",fname, tmp_name); if (Verbose) fprintf(stderr,"issue shell command: %s \n", tmp_cmd); system (tmp_cmd); /* set window name to the current filename (minus leading dirs) */ EZ_ConfigureWidget(Info_Widget,EZ_LABEL_STRING,basfname,0); /* load the mincheader dump info into a text widget and siplay the result */ EZ_ActivateWidget(Info_Widget); EZ_TextLoadFile(Mincheader_Widget,tmp_name); EZ_DisplayWidget(Info_Widget); XStoreName(theDisp, EZ_GetWidgetWindow(Info_Widget), "xdisp: Minc Header\0"); /* clean up the tmp file */ sprintf(tmp_cmd,"rm %s &\n",tmp_name); if (Verbose) fprintf(stderr,"issue shell command: %s\n",tmp_cmd); system (tmp_cmd); }
/* * setup an animated label/icon. */ void setupAnimation(EZ_Widget *widget, EZ_LabelPixmap **pixmaps, int npixmaps) { if(widget) { int i; EZ_LabelPixmap **pmps; EZ_UnknownDataType d; pmps = (EZ_LabelPixmap **)EZ_Malloc((npixmaps+1) * sizeof(EZ_LabelPixmap *)); for(i = 0; i < npixmaps; i++) pmps[i] = pixmaps[i]; EZ_ConfigureWidget(widget, EZ_LABEL_PIXMAP, pmps[0], NULL); d.i = 0; EZ_SetWidgetUnknownData(widget,IDX,d); /* pixmap index */ d.l = ANIMATION_MAGIC; EZ_SetWidgetUnknownData(widget,MAGIC,d); /* magic */ d.p = (void *)pmps; EZ_SetWidgetUnknownData(widget,PXMPS,d); /* pointer to pixmaps */ d.i = npixmaps; EZ_SetWidgetUnknownData(widget,NPXMPS,d); /* number of pixmaps */ d.p = NULL; EZ_SetWidgetUnknownData(widget,TIMER,d); /* timer */ EZ_AddWidgetCallBack(widget, EZ_DESTROY_CALLBACK, animationWidgetDestroyCallback, NULL, 0); } }
void wcallback(EZ_Widget *w, void *d) { if(EZ_GetWidgetIntData(w) == 0) { EZ_ConfigureWidget(w, EZ_FONT_NAME, "-Adobe-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*", NULL); EZ_SetWidgetIntData(w, 1); } else { EZ_ConfigureWidget(w, EZ_FONT_NAME, "-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*", NULL); EZ_SetWidgetIntData(w, 0); } EZ_UpdateDisplayItem(d); }
/*------------------ Initialize_Info_Widget() ----------------------*/ void Initialize_Info_Widget() { EZ_Widget *tmp_w1, *tmp_w2; /* create and configure the information display widget */ Info_Widget = EZ_CreateFrame(NULL, fname); EZ_ConfigureWidget(Info_Widget, EZ_PADX, 0, EZ_PADY, 0, EZ_STACKING, EZ_VERTICAL, EZ_WIDTH, 650, EZ_HEIGHT, 500, EZ_FILL_MODE, EZ_FILL_BOTH, 0); tmp_w1 = EZ_CreateFrame(Info_Widget, NULL); EZ_ConfigureWidget(tmp_w1, EZ_PADX, 8, EZ_PADY, 0, EZ_EXPAND, True, EZ_HEIGHT, 0, EZ_STACKING, EZ_HORIZONTAL_LEFT, 0); Info_Close_Button = EZ_CreateButton(tmp_w1,"Close",-1); /* create a widget for the actual mincheader text */ tmp_w2 = EZ_CreateFrame(Info_Widget, NULL); EZ_ConfigureWidget(tmp_w2, EZ_FILL_MODE, EZ_FILL_BOTH, 0); Mincheader_Widget = EZ_CreateTextWidget(tmp_w2,0,1,1); /* add the callback for shutdown of the info widget */ EZ_AddWidgetCallBack(Info_Close_Button, EZ_CALLBACK, Close_Info_Widget, NULL,0); /* set WM hints for user placement */ EZ_SetWMHintsAndSizeHints(File_Save_Widget, 0); }
main(int ac, char **av) { int i; EZ_Widget *ezclock; EZ_Timer *timer; EZ_Initialize(ac,av,0); ezclock= EZ_CreateWidget(EZ_WIDGET_LCD, NULL, EZ_LCD_NDIGITS, 5, EZ_LCD_FONT_SIZE, 30, 0); for(i = 1; i < ac; ) { if(!strcmp(av[i], "-bg")) { if(i+1 < ac) EZ_ConfigureWidget(ezclock, EZ_LCD_BACKGROUND, av[(++i)], 0);} if(!strcmp(av[i], "-fg")) { if(i+1 < ac) EZ_ConfigureWidget(ezclock, EZ_LCD_FOREGROUND, av[(++i)], 0); } i++; } EZ_DisplayWidget(ezclock); timer = EZ_CreateTimer(0, 200000, -1, timer_callback, ezclock, 0); EZ_EventMainLoop(); }
void msgHandler(EZ_Message *msg, void *data) { EZ_Widget *label = (EZ_Widget *)data; if(msg->messageLength > 0) { Pixmap pixmap, shape; int w, h; if(sscanf(msg->message, "%d %d %lx %lx", &w, &h, &pixmap, &shape) == 4 && w > 0) { EZ_Pixmap *ptr = EZ_CreateLabelPixmapFromXPixmap(pixmap, shape, 0, 0, w,h, 1); if(ptr) EZ_ConfigureWidget((EZ_Widget *)data, EZ_LABEL_PIXMAP, ptr, 0); /* delete this handler */ EZ_DeleteMessageHandler(msg->messageType, msg->messageId, data, (EZ_MessageHandler) msgHandler); } } }
void menuCallBack(EZ_Widget *widget) { if(widget) { int i = EZ_GetWidgetReturnedData(widget); if( i >= 0 && i <= 6) /* to make sure */ { EZ_Widget *tmp = (EZ_Widget *)EZ_GetWidgetPtrData(widget); if(tmp) { char str[64]; sprintf(str,"A %s Button", colors[i]); EZ_ConfigureWidget(tmp, EZ_LABEL_STRING, str, EZ_FOREGROUND, colors[i],0); } } } }
/* Animation is done by a repeating timer */ static void animationTimerCallback(EZ_Timer *timer, void *data) { EZ_Widget *widget = (EZ_Widget *)data; if(widget && isAnimationWidget(widget)) { EZ_UnknownDataType d; int idx, npxmps, ti, cancel = 0; EZ_Timer *ctimer; EZ_LabelPixmap **pixmaps; ti = EZ_GetTimerIntData(timer); /* number of cycles remaining */ EZ_GetWidgetUnknownData(widget, NPXMPS, &d); /* total number of pmps */ npxmps = d.i; EZ_GetWidgetUnknownData(widget, PXMPS, &d); /* ptr to pmps */ pixmaps = (EZ_LabelPixmap **)d.p; EZ_GetWidgetUnknownData(widget, IDX, &d); /* current pmp index */ idx = d.i; if(idx < 0 || idx >= npxmps) { ti--; idx = 0;} /* done one cycle */ /* if startAnimation is called before 'timer' finishes, */ /* cancel timer. */ EZ_GetWidgetUnknownData(widget, TIMER, &d); /* the current timer */ ctimer = (EZ_Timer *)d.p; if(timer != ctimer || ti <= 0) { idx = 0; cancel = 1;} if(EZ_WidgetIsViewable(widget)) EZ_ConfigureWidget(widget, EZ_LABEL_PIXMAP, pixmaps[idx], NULL); idx++; d.i = idx; EZ_SetWidgetUnknownData(widget, IDX, d); /* increment idx */ if(cancel) EZ_CancelTimer(timer); else EZ_SetTimerIntData(timer, ti); } }
static void timeoutCb(void *label, void *data) { char str[256]; sprintf(str, "message handler for msgId \n \t '%d'\n expired", (int)data); EZ_ConfigureWidget(label, EZ_LABEL_STRING, str, EZ_LABEL_PIXMAP, NULL, 0); }
main(int ac, char **av) { EZ_Item *item; EZ_Widget *tree, *btn; EZ_TreeNode *root, *node1, *node2, *node11, *tmp; EZ_TextProperty *p1, *p2, *p3; EZ_Initialize(ac, av, 0); tree = EZ_CreateWidget(EZ_WIDGET_LIST_TREE, NULL, EZ_WIDTH_HINT, 400, EZ_HEIGHT_HINT, 400, EZ_IPADY, 2, EZ_ROW_BG, 1, "white", "bisque", EZ_SELECTION_BACKGROUND, "green3", 0); EZ_ConfigureWidget(tree, EZ_CALLBACK, callback, tree, NULL); p1 = EZ_GetTextProperty(EZ_PIXMAP_FILE, "question.xpm", EZ_FOREGROUND, "red", EZ_FONT_NAME, "-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*", 0); p2 = EZ_GetTextProperty(EZ_PIXMAP_FILE, "folder.xpm", EZ_FOREGROUND, "blue", 0); p3 = EZ_GetTextProperty(EZ_PIXMAP_FILE, "file.xpm", EZ_FOREGROUND, "yellow", 0); /* the root node */ item = EZ_CreateLabelItem("root", p1); Root = root = EZ_CreateTreeNode(NULL, item); /* children */ item = EZ_CreateLabelItem("child 1", p2); node1 = EZ_CreateTreeNode(root, item); item = EZ_CreateLabelItem("child 2", p2); node2 = EZ_CreateTreeNode(root, item); /* grand children */ item = EZ_CreateLabelItem("grandchild 11", p3); node11 = EZ_CreateTreeNode(node1, item); item = EZ_CreateLabelItem("grandchild 12", p3); tmp = EZ_CreateTreeNode(node1, item); item = EZ_CreateLabelItem("grandchild 21", p3); tmp = EZ_CreateTreeNode(node2, item); /* grand grand children */ item = EZ_CreateLabelItem("gg child 111", p2); tmp = EZ_CreateTreeNode(node11, item); btn = EZ_CreateButton(NULL, "A Widget", 0); /* EZ_AddWidgetCallBack(btn, EZ_CALLBACK, resettree, root, 0);*/ item = EZ_CreateWidgetItem(btn); EZ_AddWidgetCallBack(btn, EZ_CALLBACK, wcallback, item, 0); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("child of widget item", p2); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("test node 1", p2); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("test node 2", p2); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("test node 3", p2); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("test node 4", p2); node11 = EZ_CreateTreeNode(node11, item); item = EZ_CreateLabelItem("test node 5", p2); tmp = node11 = EZ_CreateTreeNode(node11, item); { unsigned long gcmask; XGCValues gcvalues; unsigned long red, green, blue, yellow, cyan, magenta; GC gc; gcvalues.foreground = red; gc = EZ_GetGC( GCForeground, &gcvalues); item = EZ_CreateItem(EZ_FIG_ITEM, NULL); /*EZ_FigItemAddRectangle(item, gc, 0,0,90, 80);*/ gcvalues.foreground = green; gc = EZ_GetGC( GCForeground, &gcvalues); EZ_FigItemAddFilledArc(item, gc, 0, 0, 50, 50, 0, 300*64); /* item = EZ_CreateLabelItem("test node 6", p2);*/ node11 = EZ_CreateTreeNode(node11, item); } EZ_SetListTreeWidgetTree(tree, root); EZ_ListTreeWidgetSelectNode(tree, tmp, NULL); EZ_TreeSetCharacter(root, EZ_BRANCHED_LIST_TREE, 20, 2, 2); EZ_DisplayWidget(tree); EZ_EventMainLoop(); }
static int initgui(void) { int i; EZ_Widget *tmp; topw=EZ_CreateFrame(0,0); EZ_ConfigureWidget(topw,EZ_PADY,0,EZ_ORIENTATION,EZ_VERTICAL_TOP,EZ_SIDE,EZ_LEFT,0); upframew=EZ_CreateFrame(topw,0); EZ_ConfigureWidget(topw,EZ_IPADX,6,0); bbsnamew=EZ_CreateLabel(upframew,maincfg.CFG_BOARDNAME); EZ_ConfigureWidget(bbsnamew,EZ_BORDER_TYPE,EZ_BORDER_RIDGE,EZ_BORDER_WIDTH,1,EZ_WIDTH,500,0); sizecw=EZ_CreateCheckButton(upframew,"Show buttons",0,1,0,1); nodelistw=EZ_CreateListBox(topw,0,1); EZ_ConfigureWidget(nodelistw,EZ_HEIGHT,5+16*nlines,EZ_WIDTH,640,EZ_FONT_NAME,"-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1",0); EZ_SetWidgetCallBack(nodelistw,listsel,0); botw=EZ_CreateFrame(topw,0); EZ_ConfigureWidget(botw,EZ_SIDE,EZ_LEFT,0); cmd1w=EZ_CreateFrame(botw,0); EZ_ConfigureWidget(cmd1w,EZ_ORIENTATION,EZ_HORIZONTAL,EZ_SIDE,EZ_LEFT,EZ_PADY,1,0); cmd1lw=EZ_CreateFrame(cmd1w,0); openvieww=EZ_CreateButton(cmd1lw,"Open view",0); EZ_ConfigureWidget(openvieww,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,0,EZ_Y,0,0); EZ_SetWidgetCallBack(openvieww,openview,0); closevieww=EZ_CreateButton(cmd1lw,"Close view",0); EZ_ConfigureWidget(closevieww,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,81,EZ_Y,0,0); EZ_SetWidgetCallBack(closevieww,closeview,0); chatw=EZ_CreateButton(cmd1lw,"Chat",0); EZ_ConfigureWidget(chatw,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,0,EZ_Y,26,0); EZ_SetWidgetCallBack(chatw,chat,0); kickw=EZ_CreateButton(cmd1lw,"Kick user",0); EZ_ConfigureWidget(kickw,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,81,EZ_Y,26,0); EZ_SetWidgetCallBack(kickw,kick,0); editw=EZ_CreateButton(cmd1lw,"Edit user",0); EZ_ConfigureWidget(editw,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,0,EZ_Y,52,0); EZ_SetWidgetCallBack(editw,edit,0); quitw=EZ_CreateButton(cmd1lw,"Quit",0); EZ_ConfigureWidget(quitw,EZ_WIDTH,80,EZ_HEIGHT,25,EZ_X,81,EZ_Y,52,0); EZ_SetWidgetCallBack(quitw,quit,0); for (i=0; i < 4 ; i++) { radiow[i]=EZ_CreateRadioButton(cmd1lw,viewnames[i],-1,0,i); EZ_ConfigureWidget(radiow[i],EZ_X,170+i*120,EZ_Y,1,0); EZ_SetWidgetCallBack(radiow[i],radiocall,0); } EZ_SetRadioButtonGroupVariableValue(tmp,0); infow=EZ_CreateListBox(cmd1lw,0,1); EZ_ConfigureWidget(infow,EZ_Y,30,EZ_X,170,EZ_WIDTH,440,EZ_HEIGHT,5+16*isize,EZ_FONT_NAME,"-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1",0); buildnodew(0); EZ_SetListBoxItems(infow,lulines,ilines); EZ_DisplayWidget(topw); EZ_CreateTimer(1,0,-1,mytimer,0,0); }
main(int argc, char **argv) { EZ_Widget *frame, *canvas; /* * Initialize EZWGL, don't forget to * initialize the graphics library also. */ EZ_Initialize(argc, argv, 1); /* notice the 1 */ /* * canvases do not resize propertly as toplevel * widgets (bug!) It is recommended to put it * under a frame at least for now. */ frame = EZ_CreateFrame(NULL, NULL); EZ_ConfigureWidget(frame, EZ_FILL_MODE, EZ_FILL_BOTH,0); canvas = EZ_Create3DCanvas(frame); /* * the min size for 3DCanvas is too small * so we HINT it with a bigger size. */ EZ_ConfigureWidget(canvas, EZ_ORIENTATION, EZ_VERTICAL_BOTTOM, EZ_WIDTH_HINT, 320, EZ_HEIGHT_HINT, 320, EZ_EVENT_HANDLE, eventHandler, NULL, 0); /* * now display the canvas. One must first display * a 3DCanvas before calling any GL functions !!! */ EZ_DisplayWidget(canvas); /* now setup global GL attributes */ EZ_RGBMode(); /* we are using RGB mode */ EZ_AutoSelectBackBuffer(); /* select a back buffer */ EZ_DrawBuffer(EZ_BACK);/* always draw into the back buf */ EZ_ShadeModel(EZ_SMOOTH); /* turn on smooth shading */ EZ_Enable(EZ_DEPTH_TEST); /* turn on zbuffer */ EZ_Enable(EZ_CULL_FACE); /* turn on backface cull */ EZ_Enable(EZ_LIGHTING); /* turn on lighting */ EZ_Enable(EZ_LIGHT0); /* turn on 3 lights */ EZ_Enable(EZ_LIGHT1); EZ_Enable(EZ_LIGHT2); EZ_Enable(EZ_COLOR_MATERIAL); /* enable color material */ EZ_MatrixMode(EZ_PROJECTION); /* set up a proj matrix */ EZ_LoadIdentity(); /* clear the top mtx 2 id */ EZ_Perspective(60.0, 1.0, 1.0, 100.0); EZ_MatrixMode(EZ_MODELVIEW); EZ_LoadIdentity(); EZ_LookAt(0.0,0.0,60.0, 0.0,0.0,0.0, 0.0,1.0,0.0); EZ_GetMatrix(ViewMatrix); EZ_GenerateRotationMatrix(RotationMatrix, 90.0, 1.0,0.0,0.0); /* now we have to set up the three lights */ { static EZ_LightSrc *Light1, *Light2, *Light3; static float light1[] = { EZ_POSITION_F, 1.0,0.0,2.0, 1.0, EZ_DIFFUSE_F, 1.0,1.0,1.0,1.0, EZ_NULL_F, }; static float light2[] = { EZ_POSITION_F, 0.0,5.0,10.0,1.0, EZ_SPECULAR_F, 1.0,1.0,1.0,1.0, EZ_SPOT_DIRECTION_F, 0.0,0.0,-1.0,0.0, EZ_SPOT_CUTOFF_F, 30.0, EZ_SPOT_EXPONENT_F, 10.0, EZ_NULL_F, }; static float light3[] = { EZ_POSITION_F, 4.0,0.0,8.0, 1.0, EZ_DIFFUSE_F, 1.0,1.0,0.0,1.0, EZ_SPECULAR_F, 1.0,1.0,0.0,1.0, EZ_NULL_F, }; Light1 = EZ_DefineLight(light1); Light2 = EZ_DefineLight(light2); Light3 = EZ_DefineLight(light3); EZ_BindLight(0, Light1); EZ_BindLight(1, Light2); EZ_BindLight(2, Light3); } /* set up some material properties */ { static float specular[] = {1.0,1.0,1.0,1.0}; static float shininess[] = {4.0}; EZ_Materialfv(EZ_FRONT,EZ_SPECULAR,specular); EZ_Materialfv(EZ_FRONT,EZ_SHININESS,shininess); } /* * We don't draw anything here, let the * event handler handle the drawing */ while(1) { EZ_ServiceEvents(); draw(canvas); } }