00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include "framework/gui/logo.h"
00025
00026 static BOOLEAN SINGLETON_test = FALSE;
00027
00028 LOGO *EL_Logo = NULL;
00029
00030
00031
00032
00033
00034 #ifdef MOTIF_ENABLED
00035 #define LOGO_MODO_MOTIF
00036 #endif
00037 #ifndef MOTIF_ENABLED
00038 #define LOGO_MODO_X11
00039 #endif
00040
00041 #ifdef X_ENABLED
00042
00043 XImage *IMAGEN_x = NULL;
00044
00045 #define TITULO_LOGO "AQUYNZA! - starting up..."
00046
00047 #ifdef LOGO_MODO_X11
00048 #include <X11/X.h>
00049 #include <X11/Xlib.h>
00050
00051 Display *THE_Display1;
00052 Window THE_window;
00053 #endif
00054
00055 #ifdef LOGO_MODO_MOTIF
00056 #include <Xm/Xm.h>
00057 #include <Xm/DrawingA.h>
00058 #include <Xm/MainW.h>
00059
00060 XtAppContext interface;
00061 Display *THE_Display;
00062 Widget frame, draw;
00063 #endif
00064
00065 #ifdef LOGO_MODO_X11
00066 void
00067 pintar_logo_X(IMAGEN_RGB *Imagen, GC gc)
00068 {
00069
00070 fprintf(stderr, "logo.cc: OJO! Hay codigo castrado!\n"); fflush(stderr);
00071
00074
00078 }
00079 #endif
00080
00081 #ifdef LOGO_MODO_MOTIF
00082 void
00083 pintar_logo_motif(Widget w,
00084 XtPointer data, XmDrawingAreaCallbackStruct * )
00085 {
00086 IMAGEN_RGB *Imagen = (IMAGEN_RGB *)data;
00087
00088
00089
00090 if ( !IMAGEN_x ) IMAGEN_x = Imagen->exportar_ximage(XtDisplay(w));
00091 else Imagen->copiar_ximage(XtDisplay(w), IMAGEN_x);
00092
00093 GC gc;
00094 XtVaGetValues(w, XmNuserData, &gc, NULL);
00095
00096 XPutImage(XtDisplay(w), XtWindow(w), gc, IMAGEN_x,
00097 0, 0, 0, 0, Imagen->xtam(), Imagen->ytam());
00098 XFlush(THE_Display);
00099 }
00100
00101 #endif
00102
00103 #endif // X_ENABLED
00104
00105
00106
00107
00108
00109 LOGO::LOGO(char *archivo)
00131 {
00132
00133
00134
00135 if ( SINGLETON_test ) return;
00136 SINGLETON_test = TRUE;
00137
00138 EL_Logo = this;
00139
00140
00141 FILE *fd = fopen(archivo, "rb");
00142
00143 if ( !fd ) {
00144 fprintf(stderr, "<LOGO> - ERROR abriendo el archivo \"%s\".\n",
00145 archivo);
00146 fflush(stderr);
00147 return;
00148 }
00149
00150 Imagen = new IMAGEN_RGB();
00151
00152 if ( !Imagen || !((IMAGEN_RGB*)Imagen)->importar_ppm(fd) ) {
00153 fprintf(stderr, "<LOGO> - ERROR: Creando imagen!\n"); fflush(stderr);
00154 return;
00155 }
00156 fclose(fd);
00157
00158
00159
00160 #ifdef X_ENABLED
00161 #ifdef LOGO_MODO_X11
00162
00163 THE_Display1 = XOpenDisplay(NULL);
00164 XWindowAttributes data_raiz;
00165 int x_pos = 100, y_pos = 200;
00166
00167 if ( !THE_Display1 ) {
00168 fprintf(stderr,
00169 "<LOGO> - Error: no puedo abrir una conexion con el servidor X!\n");
00170 fflush(stderr);
00171 return;
00172 }
00173
00174 Screen *Zona1 = ScreenOfDisplay(THE_Display1, DefaultScreen(THE_Display1));
00175
00176 XGetWindowAttributes(THE_Display1,
00177 RootWindow(THE_Display1, DefaultScreen(THE_Display1)),
00178 &data_raiz);
00179
00180 x_pos = (data_raiz.width - Imagen->xtam())/2;
00181 y_pos = (data_raiz.height - Imagen->ytam())/2;
00182
00183
00184 XSetWindowAttributes swa;
00185 XWindowChanges swa2;
00186 XSizeHints swa3;
00187 char truco[20];
00188
00189 sprintf(truco, "+%d+%d", x_pos, y_pos);
00190
00191 char *argv[4];
00192 int argc = 3;
00193 argv[0] = TITULO_LOGO; argv[1] = "-geometry";
00194 argv[2] = new char[strlen(truco)+1]; argv[3] = NULL;
00195 strcpy(argv[2], truco);
00196
00197 swa.border_pixel = 0;
00198 swa.cursor = None;
00199 swa.event_mask = ExposureMask | ButtonPressMask | StructureNotifyMask;
00200 THE_window = XCreateWindow(THE_Display1,
00201 RootWindow(THE_Display1, DefaultScreen(THE_Display1)),
00202 x_pos, y_pos, Imagen->xtam(), Imagen->ytam(),
00203 0 , DefaultDepthOfScreen(Zona1),
00204 InputOutput, CopyFromParent,
00205 CWBorderPixel | CWCursor | CWEventMask, &swa);
00206 XSetStandardProperties(THE_Display1, THE_window,
00207 "BIENVENIDO A AQUYNZA!", "?!", None, argv, argc, NULL);
00208
00209 swa3.min_width = swa3.max_width = Imagen->xtam();
00210 swa3.min_height = swa3.max_height = Imagen->ytam();
00211 XSetWMSizeHints(THE_Display1, THE_window, &swa3, PMinSize | PMaxSize);
00212
00213 XMapWindow(THE_Display1, THE_window);
00214 swa2.x = x_pos;
00215 swa2.y = y_pos;
00216 swa2.stack_mode = TopIf;
00217 XConfigureWindow(THE_Display1, THE_window,
00218 CWX | CWY | CWStackMode, &swa2);
00219 XRaiseWindow(THE_Display1, THE_window);
00220 XFlush(THE_Display1);
00221
00222
00223 GC gc;
00224 XGCValues gcv;
00225
00226 gcv.foreground = BlackPixelOfScreen(Zona1);
00227 gc = XCreateGC(THE_Display1, RootWindowOfScreen(Zona1),
00228 GCForeground, &gcv);
00229
00230 pintar_logo_X(Imagen, gc);
00231 #endif // LOGO_MODO_X11
00232
00233 #ifdef LOGO_MODO_MOTIF
00234
00235 int x_pos = 100, y_pos = 200;
00236 XWindowAttributes data_raiz;
00237 char truco[20];
00238 char *argv[4];
00239 int argc = 3;
00240
00241
00242 THE_Display = XOpenDisplay(NULL);
00243 if ( !THE_Display ) {
00244 fprintf(stderr,
00245 "<LOGO> - Error: no puedo abrir una conexion con el servidor X!\n");
00246 fflush(stderr);
00247 return;
00248 }
00249 XGetWindowAttributes(THE_Display,
00250 RootWindow(THE_Display, DefaultScreen(THE_Display)), &data_raiz);
00251 XCloseDisplay(THE_Display);
00252 x_pos = (data_raiz.width - Imagen->xtam())/2;
00253 y_pos = (data_raiz.height - Imagen->ytam())/2;
00254
00255 sprintf(truco, "+%d+%d", x_pos, y_pos);
00256
00257 argv[0] = "aqyunza"; argv[1] = "-geometry";
00258 argv[2] = new char[strlen(truco)+1]; argv[3] = NULL;
00259 strcpy(argv[2], truco);
00260
00261
00262
00263
00264 frame = XtVaAppInitialize(&interface, "Bienvenido a AQUYNZA!",
00265 NULL, 0, &argc, argv, NULL,
00266 XmNwidth, Imagen->xtam(), XmNheight, Imagen->ytam(),
00267 XmNminWidth, Imagen->xtam(), XmNminHeight, Imagen->ytam(),
00268 XmNmaxWidth, Imagen->xtam(), XmNmaxHeight, Imagen->ytam(), NULL);
00269 #ifdef NONONO
00270 XtToolkitInitialize();
00271 interface = XtCreateApplicationContext();
00272
00273
00274 THE_Display =
00275 XtOpenDisplay(interface,
00276 NULL, "Bienvenido a AQUYNZA!",
00277 "[LOGO]", NULL, 0,
00278 &argc, argv);
00279 if ( !THE_Display ) {
00280 XtWarning(
00281 "<JED_MOTIF_INTERFACE>: No se puede abrir el \"Display X\".");
00282 exit(1);
00283 }
00284
00285
00286 int argcount = 0;
00287 Arg args[10];
00288 XtSetArg(args[argcount], XmNwidth, Imagen->xtam()); argcount++;
00289 XtSetArg(args[argcount], XmNheight, Imagen->ytam()); argcount++;
00290
00291
00292
00293
00294
00295 frame = XtVaAppCreateShell(argv[0], "[LOGO]", transientShellWidgetClass,
00296 THE_Display, XmNwidth, Imagen->xtam(),
00297 XmNheight, Imagen->ytam(), NULL);
00298 #endif
00299
00300
00301 draw = XtVaCreateManagedWidget("[Image]",
00302 xmDrawingAreaWidgetClass, frame, NULL);
00303 XtAddCallback(draw, XmNexposeCallback,
00304 (XtCallbackProc)pintar_logo_motif, Imagen);
00305
00306 THE_Display = XtDisplay(draw);
00307
00308
00309 GC gc;
00310 XGCValues gcv;
00311 Screen *Zona = XtScreen(draw);
00312
00313 gcv.foreground = BlackPixelOfScreen(Zona);
00314 gc = XCreateGC(THE_Display, RootWindowOfScreen(Zona),
00315 GCForeground, &gcv);
00316
00317 XtVaSetValues(draw, XmNuserData, gc, NULL);
00318
00319 XtRealizeWidget(frame);
00320
00321
00322 IMAGEN_RGB imagen;
00323 fd = fopen("./etc/icons/_aquynza.ppm", "rb");
00324 Pixmap icono;
00325
00326 if ( !fd || !imagen.importar_ppm(fd) ) {
00327 fprintf(stderr, "<JED_MOTIF_INTERFACE> - Warning: "
00328 "no encuentro el icono \"%s\".\n", "./etc/icons/_aquynza.ppm");
00329 fflush(stderr);
00330 }
00331 else {
00332 icono = imagen.exportar_pixmap(
00333 XtDisplay(frame), XtScreen(frame), XtWindow(frame));
00334 XtVaSetValues(frame, XmNiconPixmap, icono, NULL);
00335 }
00336
00337 XtVaSetValues(frame, XmNtitle, TITULO_LOGO, NULL);
00338
00339 XtMapWidget(draw);
00340
00341 pintar_logo_motif(draw, Imagen, NULL);
00342 #endif // LOGO_MODO_MOTIF
00343
00344 #endif // X_ENABLED
00345
00346
00347
00348 }
00349
00350 LOGO::~LOGO()
00351 {
00352 elim();
00353 }
00354
00355 void
00356 LOGO::elim(void)
00357 {
00358 #ifdef X_ENABLED
00359 if ( Imagen ) {
00360 #ifdef LOGO_MODO_X11
00361 XUnmapWindow(THE_Display1, THE_window);
00362 XCloseDisplay(THE_Display1);
00363 XFlush(THE_Display1);
00364 #endif
00365
00366 #ifdef LOGO_MODO_MOTIF
00367 XtUnmapWidget(frame);
00368 XFlush(THE_Display);
00369 XtUnrealizeWidget(frame);
00370 #endif
00371 }
00372 #endif
00373
00374 if ( Imagen ) delete Imagen;
00375 Imagen = NULL;
00376 }
00377
00378
00379
00380
00381