#define _MAIN_ #include "mdp.h" static char SCSIident[] = "@(#) mdp 1.0, (c) J.A. Magallon, 09/05/94"; extern double sx,sy; extern int fixedw,fixedh; char file_name[256]; /* Nombre y clase del recurso nuevo */ #define XmNtextFont "textFont" #define XmCTextFont "TextFont" /* Recursos de la aplicacion */ typedef struct { XFontStruct *font; XFontStruct *tfont; } app_data, *app_data_ptr; /* Recursos por defecto */ static XtResource resources[] = { { XmNfont, XmCFont, XmRFontStruct, sizeof (XFontStruct *), XtOffset (app_data_ptr, font), XmRString, "Fixed" }, { XmNtextFont, XmCTextFont, XmRFontStruct, sizeof (XFontStruct *), XtOffset(app_data_ptr,tfont), XmRString, "Fixed" } }; #if defined(__STDC__) || defined(__stdc__) void main ( int argc, char *argv[] ) #else void main (argc,argv) int argc; char *argv[]; #endif { extern char *optarg; extern int optind,opterr; Arg al[10]; Cardinal ac; int i,opcion; app_data data; Widget work; /* Inicializacion */ XtToolkitInitialize(); theContext = XtCreateApplicationContext(); theDisp = XtOpenDisplay(theContext,NULL,argv[0],"XMclient", NULL,0,&argc,argv); charset = (XmStringCharSet)XmSTRING_DEFAULT_CHARSET; theScreen = DefaultScreen(theDisp); theCmap = DefaultColormap(theDisp, theScreen); theGC = DefaultGC(theDisp,theScreen); theVisual = DefaultVisual(theDisp,theScreen); theDepth = DefaultDepth(theDisp,theScreen); ac = 0; XtSetArg(al[ac],XmNallowShellResize, True); ac++; app_shell = XtAppCreateShell(argv[optind],NULL, applicationShellWidgetClass,theDisp,al,ac); /* Lectura de recursos */ XtGetApplicationResources (app_shell,&data,resources, XtNumber(resources),NULL,0); fontlist = XmFontListCreate(data.font,charset); tfontlist = XmFontListCreate(data.tfont,charset); theFont = *(data.font); theTFont = *(data.tfont); /* Ventana principal */ ac = 0; XtSetArg(al[ac],XmNshadowThickness,3); ac++; XtSetArg(al[ac],XmNshowSeparator,True); ac++; XtSetArg(al[ac],XmNscrollingPolicy,XmAUTOMATIC); ac++; main_window = XmCreateMainWindow(app_shell,"main",al,ac); XtManageChild(main_window); /* Barra de menu */ menu_bar = create_menu(main_window); create_dialogs(menu_bar); ac = 0; XtSetArg(al[ac], XmNshadowThickness, 2); ac++; work = XmCreateForm(main_window,"work",al,ac); XtManageChild(work); XmMainWindowSetAreas(main_window,menu_bar,NULL,NULL,NULL,work); XmSetMenuCursor(theDisp,XCreateFontCursor(theDisp,58)); XtRealizeWidget(app_shell); mode = OPTIMAL; usedcolors = USEDCOLS; sx = sy = 1; fixedw = fixedh = 0; while ( (opcion=getopt(argc,argv,"amc:s:w:h:x:y:")) != EOF ) { switch(opcion) { case 'a': mode = M_ALPHA; break; case 'm': mode = GRAYSCALE; break; case 'c': usedcolors = 256-atoi(optarg); if (usedcolors < 0) usedcolors=0; break; case 'x': sx = atof(optarg); if (sx < 0) sx=1; break; case 'y': sy = atof(optarg); if (sy < 0) sy=1; break; case 'w': fixedw = atoi(optarg); if (fixedw < 0) fixedw=0; break; case 'h': fixedh = atoi(optarg); if (fixedh < 0) fixedh=0; break; case 's': sx = atof(optarg); if (sx < 0) sx=1; sy = sx; break; default: fprintf(stderr,"Uso: %s [a|m][c N][s S][x Sx][y Sy][w Rx][h Ry] [file]\n", argv[0]); exit(1); break; } } pixmap = load_pixmap(argv[optind],work); set_colors(pict,work); XtAppMainLoop(theContext); }