00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "framework/gui/_motif.h"
00023 #include "framework/gui/_motifcb.h"
00024 #include <stdarg.h>
00025 #include <string.h>
00026
00027 #include "lista.cc"
00028
00029 #ifdef MOTIF_ENABLED
00030 #include <Xm/Xm.h>
00031
00032 #include <Xm/AtomMgr.h>
00033 #include <Xm/BulletinB.h>
00034 #include <Xm/CascadeB.h>
00035 #include <Xm/DialogS.h>
00036 #include <Xm/Form.h>
00037 #include <Xm/Frame.h>
00038 #include <Xm/Label.h>
00039 #include <Xm/MenuShell.h>
00040 #include <Xm/PanedWP.h>
00041 #include <Xm/Protocols.h>
00042 #include <Xm/PushB.h>
00043 #include <Xm/RowColumnP.h>
00044 #include <Xm/Separator.h>
00045 #include <Xm/TextF.h>
00046 #endif
00047
00048
00049
00050
00051
00052 #ifndef MOTIF_ENABLED
00053
00054 JED_GUI_CLASE_NULA(JED_MOTIF_INTERFACE, "JED_MOTIF_INTERFACE",
00055 "MOTIF", "Motif(o lesstiff)", "MOTIF_ENABLED");
00056
00057 #endif
00058
00059 #ifdef MOTIF_ENABLED
00060
00061 #if XmVERSION < 2
00062
00063
00064 #endif
00065
00066
00067
00068
00069
00070 #define VERIFICAR(m) \
00071 if ( !(m) ) { \
00072 fprintf(stderr, \
00073 "<MOTIF> ERROR: No puedo asignar una estructura dinamica!\n"); \
00074 fflush(stdout); \
00075 exit(0); \
00076 }
00077
00078
00079
00080
00081
00087 BOOLEAN SUICIDIO_del_logo = FALSE;
00088
00106 static String RECURSOS_x[] = {
00107 "*GLwDrawingArea.x: 10",
00108 "*GLwDrawingArea.y: 50",
00109 "*GLwDrawingArea.width: 480",
00110 "*GLwDrawingArea.height: 380",
00111 "*GLwDrawingArea.rgba: true",
00112 "*GLwDrawingArea.installColormap: false",
00113 "*GLwDrawingArea.doublebuffer: true",
00114 "*GLwDrawingArea.depthSize: 16",
00115 "*title: AQUYNZA",
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 NULL
00126 };
00127
00128
00129 static JED_MOTIF_INTERFACE *Interface = NULL;
00130 extern VENTANA_GUI_MOTIF LA_ventana;
00131
00132
00133
00134
00135
00136 Widget toplevel;
00137 static Widget main_window, ventanita = NULL;
00138 static XtAppContext app_context;
00139 static Widget form, menubar, gl_draw, area_de_ayuda;
00140
00141
00142
00143
00144
00145 static void motif_quit_callback(Widget, XtPointer, XtPointer);
00146
00147
00148
00149
00150
00151 void
00152 motif_quit_callback(Widget , XtPointer user_data, XtPointer )
00155 {
00156 JED_INTERFACE *Interface = (JED_INTERFACE*)user_data;
00157
00158 Interface->finalizar();
00159 }
00160
00161 void
00162 motif_closelogo_callback(XtPointer ,XtIntervalId * )
00163 {
00164 if ( SUICIDIO_del_logo ) {
00165 if ( EL_Logo ) EL_Logo->elim();
00166 }
00167 else {
00168 XtAppAddTimeOut(app_context, 100 ,
00169 motif_closelogo_callback,
00170 (XtPointer)NULL);
00171 }
00172 }
00173
00174
00175
00176
00177
00178 static void pintar_nulo(int ) { ; }
00179 static int tick_nulo(int ) { return 0; }
00180 static void resize_nulo(int , int , int ) { ; }
00181 static void multiview_nulo(int , int , char * ,
00182 char * , char * )
00183 {
00184 fprintf(stderr, "<MOTIF> - Warning: No se especifico la rutina de "
00185 "administracion de VISTA's\n");
00186 fflush(stderr);
00187 }
00188 static int
00189 ejecutor_nulo(int idc, int contexto)
00190 {
00191 printf("SE DISPARO EL COMANDO %d (%d)!\n", idc, contexto);
00192 fflush(stdout);
00193 return 0;
00194 }
00195
00196
00197
00198
00199
00200 void
00201 motif_paneH_resize(Widget w, XEvent * , String [], unsigned int * )
00202 {
00203 Dimension x_tam, y_tam;
00204 short margen_x, margen_y;
00205 Widget hijo;
00206 Cardinal num_hijos;
00207 WidgetList hijitos;
00208
00209 if ( !Interface ) {
00210 fprintf(stderr, "<MOTIF> ERROR - No tengo interface!\n");
00211 fflush(stderr);
00212 return;
00213 }
00214
00215
00216 XtVaGetValues(w, XmNwidth, &x_tam, XmNheight, &y_tam,
00217 XmNmarginWidth, &margen_x,
00218 XmNmarginHeight, &margen_y,
00219 XmNnumChildren, &num_hijos, NULL);
00220
00221 if ( x_tam > 100 && num_hijos < 1 ) {
00222
00223
00224
00225 hijo = Interface->crear_paneV(w);
00226 XtVaSetValues(hijo, XmNpaneMaximum, 1600, NULL);
00227 }
00228 if ( x_tam <= 100 && num_hijos >= 1 ) {
00229 XtVaGetValues(w, XmNchildren, &hijitos, NULL);
00230 XtDestroyWidget(hijitos[0]);
00231 }
00232
00233
00234 XtVaGetValues(w, XmNnumChildren, &num_hijos, NULL);
00235 if ( num_hijos > 0 ) {
00236 XtVaGetValues(w, XmNchildren, &hijitos, NULL);
00237 XtVaSetValues(hijitos[0], XmNwidth, x_tam - 2 * margen_x,
00238 XmNheight, y_tam - 2 * margen_y, NULL);
00239 XtRealizeWidget(hijitos[0]);
00240 }
00241 }
00242
00243 void
00244 motif_paneV_resize(Widget w, XEvent * , String [], unsigned int * )
00245 {
00246 Dimension x_tam, y_tam;
00247 short margen_x, margen_y;
00248 Widget hijo;
00249 Cardinal num_hijos;
00250 WidgetList hijitos;
00251
00252 if ( !Interface ) {
00253 fprintf(stderr, "<MOTIF> ERROR - No tengo interface!\n");
00254 fflush(stderr);
00255 return;
00256 }
00257
00258
00259 XtVaGetValues(w, XmNwidth, &x_tam, XmNheight, &y_tam,
00260 XmNmarginWidth, &margen_x,
00261 XmNmarginHeight, &margen_y,
00262 XmNnumChildren, &num_hijos, NULL);
00263
00264 if ( y_tam > 100 && num_hijos < 1 ) {
00265 hijo = Interface->crear_area_gl(w);
00266 Interface->iniciar_contexto(
00267 LA_ventana.lista_contextos[LA_ventana.lista_contextos.tam()-1]);
00268 XtVaSetValues(hijo, XmNpaneMaximum, 1600, NULL);
00269
00270 }
00271 if ( y_tam <= 100 && num_hijos >= 1 ) {
00272 XtVaGetValues(w, XmNchildren, &hijitos, NULL);
00273 XtDestroyWidget(hijitos[0]);
00274 }
00275
00276
00277 XtVaGetValues(w, XmNnumChildren, &num_hijos, NULL);
00278 if ( num_hijos > 0 ) {
00279 XtVaGetValues(w, XmNchildren, &hijitos, NULL);
00280 XtVaSetValues(hijitos[0], XmNwidth, x_tam - 2 * margen_x,
00281 XmNheight, y_tam - 2 * margen_y, NULL);
00282 XtRealizeWidget(hijitos[0]);
00283 }
00284 }
00285
00286
00287
00288
00289
00290
00291
00292 JED_MOTIF_INTERFACE::JED_MOTIF_INTERFACE()
00293 {
00294
00295
00296 MOTIFGUI_tick_callback = tick_nulo;
00297 MOTIFGUI_draw_callback = pintar_nulo;
00298 MOTIFGUI_resize_callback = resize_nulo;
00299 MOTIFGUI_multiview_callback = multiview_nulo;
00300 MOTIFGUI_ejecutor = ejecutor_nulo;
00301 Interface = this;
00302 }
00303
00304 JED_MOTIF_INTERFACE::~JED_MOTIF_INTERFACE()
00305 {
00306 ;
00307 }
00308
00309 void JED_MOTIF_INTERFACE::solicitar_repintado(void){;}
00310
00311 void JED_MOTIF_INTERFACE::set_keyboard_callback(
00312 int (*p)(EVENTO_GUI *e, int context_id) )
00313 { MOTIFGUI_keyboard_callback = p; }
00314 void JED_MOTIF_INTERFACE::set_mouse_callback(
00315 int (*p)(EVENTO_GUI *e, int context_id) )
00316 { MOTIFGUI_mouse_callback = p; }
00317 void JED_MOTIF_INTERFACE::set_tick_callback( int (*p)(int context_id) )
00318 { MOTIFGUI_tick_callback = p; }
00319 void JED_MOTIF_INTERFACE::set_draw_callback( void (*p)(int context_id) )
00320 { MOTIFGUI_draw_callback = p; }
00321 void JED_MOTIF_INTERFACE::set_resize_callback(
00322 void (*p)(int x_tam, int y_tam, int context_id))
00323 { MOTIFGUI_resize_callback = p; }
00324 void JED_MOTIF_INTERFACE::set_multiview_callback
00325 ( void (*p)(int operacion, int id_vista, char *detalles,
00326 char *menu, char *botonera) )
00327 { MOTIFGUI_multiview_callback = p; }
00328 void JED_MOTIF_INTERFACE::set_ejecutor( int (*p)(int idc, int context_id) )
00329 { MOTIFGUI_ejecutor = p; }
00330
00331
00332
00333
00334
00335 Widget
00336 JED_MOTIF_INTERFACE::crear_paneH(Widget padre)
00337 {
00338 Widget pane, form1, form2;
00339
00340 pane = XtVaCreateManagedWidget("[PaneH]", xmPanedWindowWidgetClass,
00341 padre, XmNorientation, XmHORIZONTAL, XmNspacing, 8,
00342 XmNsashWidth, 8, XmNsashHeight, 20,
00343 XmNmarginWidth, 0, XmNmarginHeight, 0,
00344 NULL);
00345
00346 form1 = XtVaCreateManagedWidget("[Ph 1/2]",xmBulletinBoardWidgetClass,pane,
00347 XmNmarginWidth, 0, XmNmarginHeight, 0, NULL);
00348 XtOverrideTranslations(form1,
00349 XtParseTranslationTable ("<Configure>: resizeH()") );
00350 form2 = XtVaCreateManagedWidget("[Ph 2/2]",xmBulletinBoardWidgetClass,pane,
00351 XmNmarginWidth, 0, XmNmarginHeight, 0, NULL);
00352 XtOverrideTranslations(form2,
00353 XtParseTranslationTable ("<Configure>: resizeH()") );
00354
00355 return pane;
00356 }
00357
00358 Widget
00359 JED_MOTIF_INTERFACE::crear_paneV(Widget padre)
00360 {
00361 Widget pane, form1, form2;
00362
00363 pane = XtVaCreateManagedWidget("[PaneV]", xmPanedWindowWidgetClass,
00364 padre, XmNorientation, XmVERTICAL, XmNspacing, 8,
00365 XmNsashWidth, 10, XmNsashHeight, 10,
00366 XmNmarginWidth, 0, XmNmarginHeight, 0,
00367 NULL);
00368
00369 form1 = XtVaCreateManagedWidget("[Pv 1/2]",xmBulletinBoardWidgetClass,pane,
00370 XmNmarginWidth, 0, XmNmarginHeight, 0, NULL);
00371 XtOverrideTranslations(form1,
00372 XtParseTranslationTable ("<Configure>: resizeV()") );
00373 form2 = XtVaCreateManagedWidget("[Pv 2/2]",xmBulletinBoardWidgetClass,pane,
00374 XmNmarginWidth, 0, XmNmarginHeight, 0, NULL);
00375 XtOverrideTranslations(form2,
00376 XtParseTranslationTable ("<Configure>: resizeV()") );
00377
00378 return pane;
00379 }
00380
00381
00382
00383 void
00384 JED_MOTIF_INTERFACE::iniciar_contexto(CONTEXTO_GLX *Contexto_glx)
00385 {
00386 char nombre_menu[100] = UNDEFINED_CAD;
00387 char nombre_botonera[100] = UNDEFINED_CAD;
00388
00389 MOTIFGUI_multiview_callback(GUI_CREAR_VISTA, Contexto_glx->id, "default",
00390 nombre_menu, nombre_botonera);
00391
00392 XtAddCallback(Contexto_glx->gl_draw, XmNexposeCallback,
00393 (XtCallbackProc)motif_draw_specific, (XtPointer)Contexto_glx);
00394 XtAddCallback(Contexto_glx->gl_draw, XmNresizeCallback,
00395 (XtCallbackProc)motif_resize, (XtPointer)Contexto_glx);
00396
00397
00398
00399
00400 GUI_BOTONERA *Botonera = resolver_botonera(nombre_botonera);
00401 BOOLEAN con_botonera = FALSE;
00402
00403 if ( strcmp(nombre_botonera, UNDEFINED_CAD) != 0 ) {
00404
00405 if ( Botonera ) con_botonera = TRUE;
00406 }
00407
00408
00409 if ( con_botonera ) {
00410 Widget botonera = Botonera->crear_motif(form);
00411
00412 XtVaSetValues(botonera,
00413 XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0,
00414 XmNrightAttachment, XmATTACH_WIDGET, XmNrightOffset, 0,
00415 XmNrightWidget, Contexto_glx->gl_draw,
00416 XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00417 XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0,
00418 NULL);
00419 XtVaSetValues(Contexto_glx->gl_draw,
00420 XmNleftAttachment, XmATTACH_WIDGET, XmNleftOffset, 0,
00421 XmNleftWidget, botonera,
00422 XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0,
00423 XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00424 XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0,
00425 NULL);
00426 }
00427 else {
00428 XtVaSetValues(Contexto_glx->gl_draw,
00429 XmNleftAttachment, XmATTACH_FORM, XmNleftOffset, 0,
00430 XmNrightAttachment, XmATTACH_FORM, XmNrightOffset, 0,
00431 XmNtopAttachment, XmATTACH_FORM, XmNtopOffset, 0,
00432 XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 0,
00433 NULL);
00434 }
00435
00436
00437 static BOOLEAN ya = FALSE;
00438 if ( !ya ) { arranque_GLX(Contexto_glx->gl_draw); ya = TRUE; }
00439
00440
00441 #ifdef NONONO
00442 if ( strcmp(nombre_menu, UNDEFINED_CAD) != 0 ) {
00443 GUI_MENU *Contexto = resolver_menu(nombre_menu);
00444
00445 Widget popup;
00446 if ( !Contexto ) {
00447 popup = NULL;
00448
00449
00450
00451
00452
00453
00454 }
00455 else {
00456 popup = XmCreatePopupMenu(Contexto_glx->gl_draw, "[PU_MENU]", NULL, 0);
00457 XtVaSetValues(popup, XmNwhichButton, 3, NULL);
00458 Contexto->insertar_motif(popup);
00459 }
00460
00461
00462 if ( popup ) {
00463 XtAddEventHandler(Contexto_glx->gl_draw, ButtonPressMask, False,
00464 motif_button, popup);
00465 }
00466 }
00467 #endif
00468 }
00469
00470
00471 Widget
00472 JED_MOTIF_INTERFACE::crear_area_gl(Widget padre)
00473 {
00474 char translations[500];
00475 Widget frame, form;
00476
00477
00478 sprintf(translations,
00479 "<Btn1Motion>: jed_input() \n"
00480 "<Btn2Motion>: jed_input() \n"
00481 "<Btn3Motion>: jed_input() \n"
00482 "<Btn1Down>: jed_input() \n"
00483 "<Btn2Down>: jed_input() \n"
00484 "<Btn3Down>: jed_input() \n"
00485 "<Btn1Up>: jed_input() \n"
00486 "<Btn2Up>: jed_input() \n"
00487 "<Btn3Up>: jed_input() \n"
00488 "<BtnMotion>: jed_input() \n"
00489 "<MotionNotify>: jed_input() \n"
00490 "<KeyPress>: jed_input() \n"
00491 "<KeyRelease>: jed_input() \n"
00492 "<EnterWindow>: jed_input() \n"
00493 "<LeaveWindow>: jed_input()");
00494
00495 frame = XtVaCreateManagedWidget("[Fr]",xmFrameWidgetClass, padre,
00496 XmNmarginWidth, 0, XmNmarginHeight, 0,
00497 XmNshadowType, XmSHADOW_IN, XmNshadowThickness, 2,
00498 XmNmappedWhenManaged, True, NULL);
00499
00500 form = XtVaCreateManagedWidget("[Fo]", xmFormWidgetClass, frame,
00501 NULL);
00502
00503 #ifdef GL_ENABLED
00504 gl_draw = XtVaCreateManagedWidget("[OpenGL]",
00505 #ifdef DENY_MOTIF_GLW
00506 glwDrawingAreaWidgetClass,
00507 #else
00508 glwMDrawingAreaWidgetClass,
00509 #endif
00510 form, NULL);
00511 #endif
00512 #ifdef GL_ENABLED
00513
00514 gl_draw = NULL;
00515 #endif
00516
00517 XtOverrideTranslations(gl_draw, XtParseTranslationTable(translations));
00518
00519
00520 CONTEXTO_GLX *Contexto_glx;
00521
00522 Contexto_glx =
00523 new CONTEXTO_GLX(LA_ventana.lista_contextos.tam() + 1, gl_draw);
00524
00525 VERIFICAR(Contexto_glx);
00526 LA_ventana.lista_contextos.anx(Contexto_glx);
00527
00528 return frame;
00529 }
00530
00531 Widget
00532 JED_MOTIF_INTERFACE::crear_area_de_ayuda(Widget padre)
00533 {
00534 Widget ayuda;
00535 XmString motif_cad;
00536
00537 ayuda = XtVaCreateManagedWidget("Area_de_ayuda",
00538 xmRowColumnWidgetClass, padre, XmNorientation, XmVERTICAL,
00539 XmNleftAttachment, XmATTACH_FORM,
00540 XmNrightAttachment, XmATTACH_FORM,
00541 XmNbottomAttachment, XmATTACH_FORM,
00542 NULL);
00543 XtVaCreateManagedWidget("-----", xmSeparatorWidgetClass, ayuda, NULL);
00544 motif_cad = XmStringCreateLocalized(
00545 "(c) Copyright Oscar Chavarro 1998 - 2002 - http://www.aquynza.org");
00546 XtVaCreateManagedWidget("AYUDA", xmLabelWidgetClass, ayuda,
00547 XmNlabelString, motif_cad, XmNrecomputeSize, False, NULL);
00548 XmStringFree(motif_cad);
00549
00550 return ayuda;
00551 }
00552
00553 void
00554 JED_MOTIF_INTERFACE::finalizar(void)
00555 {
00556 #if PLATAFORMA != SUN
00557
00558 XtAppSetExitFlag(app_context);
00559 #endif
00560 if ( ventanita ) {
00561 XtUnmapWidget(ventanita);
00562 XtDestroyWidget(ventanita);
00563 }
00564 XtUnmapWidget(toplevel);
00565 XtDestroyWidget(toplevel);
00566 XFlush(XtDisplay(toplevel));
00567 }
00568
00569 void
00570 JED_MOTIF_INTERFACE::desktop_size(int *x_tam, int *y_tam)
00571 {
00572 Display *d = XtDisplay(toplevel);
00573 XWindowAttributes data_raiz;
00574
00575 XGetWindowAttributes(d, RootWindow(d, DefaultScreen(d)), &data_raiz);
00576
00577 (*x_tam) = data_raiz.width;
00578 (*y_tam) = data_raiz.height;
00579 }
00580
00581 void
00582 JED_MOTIF_INTERFACE::init_extra(void)
00592 {
00593
00594 IMAGEN_RGB imagen;
00595 FILE *fd = fopen("./etc/icons/_aquynza.ppm", "rb");
00596 Pixmap icono;
00597
00598 if ( !fd || !imagen.importar_ppm(fd) ) {
00599 fprintf(stderr, "<JED_MOTIF_INTERFACE> - Warning: "
00600 "no encuentro el icono \"%s\".\n", "./etc/icons/_aquynza.ppm");
00601 fflush(stderr);
00602 }
00603 else {
00604 icono = imagen.exportar_pixmap(
00605 XtDisplay(toplevel), XtScreen(toplevel), XtWindow(toplevel));
00606 XtVaSetValues(toplevel, XmNiconPixmap, icono, NULL);
00607 if ( ventanita ) {
00608 XtVaSetValues(ventanita, XmNiconPixmap, icono, NULL);
00609 }
00610 }
00611
00612
00613 int x_tam_fondo, y_tam_fondo;
00614 Dimension x_tam_main, y_tam_main;
00615 Dimension x_pos_main, y_pos_main;
00616 Dimension x_tam_chica, y_tam_chica;
00617
00618 if ( ventanita ) {
00619 XtVaGetValues(ventanita,
00620 XmNwidth, &x_tam_chica, XmNheight, &y_tam_chica,
00621 NULL);
00622 }
00623 else {
00624 x_tam_chica = y_tam_chica = 0;
00625 }
00626
00627 desktop_size(&x_tam_fondo, &y_tam_fondo);
00628
00629 XtMoveWidget(toplevel, x_tam_chica + 10, 15);
00630
00631 XtVaGetValues(toplevel,
00632 XmNx, &x_pos_main, XmNy, &y_pos_main,
00633 XmNwidth, &x_tam_main, XmNheight, &y_tam_main,
00634 NULL);
00635
00636
00637 #ifdef NONONO
00638 int izq, der;
00639 Dimension x_pos_chica = 1, y_pos_chica = y_pos_main;
00640
00641 izq = x_pos_main;
00642 der = x_tam_fondo - (izq + x_tam_main);
00643
00644 if ( izq > der ) {
00645
00646
00647 x_pos_chica = 1;
00648 }
00649 else {
00650
00651 x_pos_chica = x_pos_main + x_tam_main + 5;
00652 }
00653 #endif
00654 y_tam_chica = y_tam_main;
00655
00656 if ( ventanita ) {
00657 XtResizeWidget(ventanita, x_tam_chica, y_tam_chica, 0);
00658 XtMapWidget(ventanita);
00659
00660 XFlush(XtDisplay(ventanita));
00661 }
00662
00663
00664 XtMapWidget(toplevel);
00665 XFlush(XtDisplay(toplevel));
00666
00667
00668
00669
00670
00671 int i;
00672
00673 for ( i = 0; i < LA_ventana.lista_contextos.tam(); i++ ) {
00674 iniciar_contexto(LA_ventana.lista_contextos[i]);
00675 }
00676 }
00677
00678 BOOLEAN
00679 JED_MOTIF_INTERFACE::crear(int * , char *argv[], int x_tam, int y_tam,
00680 char *nombre)
00685 {
00686
00687
00688
00689
00690
00691
00692
00693 _x_tam = x_tam;
00694 _y_tam = y_tam;
00695
00696
00697 XtSetLanguageProc(NULL, NULL, NULL);
00698 XtToolkitInitialize();
00699 app_context = XtCreateApplicationContext();
00700
00701
00702 Display *Display_x;
00703 BOOLEAN poquitos_colores = FALSE;
00704
00705
00706 Display_x = XOpenDisplay(NULL);
00707 if ( !Display_x ) {
00708 XtWarning("<JED_MOTIF_INTERFACE>: No se puede abrir el "
00709 "\"Display X\".");
00710 exit(1);
00711 }
00712
00713 if ( DefaultDepthOfScreen(
00714 ScreenOfDisplay(Display_x, DefaultScreen(Display_x)) ) < 15
00715 ) poquitos_colores = TRUE;
00716 XCloseDisplay(Display_x);
00717
00718
00719 char **REcursitos_X;
00720 int i, tam;
00721
00722
00723 for ( i = 0, tam = 0; RECURSOS_x[i]; i++, tam++ );
00724 REcursitos_X = new char* [tam+1];
00725
00726
00727 for ( i = 0; RECURSOS_x[i]; i++ ) {
00728 if ( strstr(RECURSOS_x[i], "*GLwDrawingArea.rgba:") &&
00729 poquitos_colores ) {
00730 REcursitos_X[i]=new char[strlen("*GLwDrawingArea.rgba: false")+1];
00731 strcpy(REcursitos_X[i], "*GLwDrawingArea.rgba: false");
00732 }
00733 else {
00734 REcursitos_X[i] = new char[strlen(RECURSOS_x[i]) + 1];
00735 strcpy(REcursitos_X[i], RECURSOS_x[i]);
00736 }
00737 }
00738 REcursitos_X[i] = NULL;
00739
00740
00741 XtAppSetFallbackResources(app_context, REcursitos_X);
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 char *argvv[4];
00753 int argcc = 3;
00754 argvv[0] = "aqyunza"; argvv[1] = "-geometry";
00755 argvv[2] = "+100+15"; argvv[3] = NULL;
00756
00757 Display_x =
00758 XtOpenDisplay(app_context,
00759 NULL, "AQUYNZA",
00760 "[AQUYNZA ENGINE]", NULL, 0,
00761 &argcc, argvv);
00762 if ( !Display_x ) {
00763 XtWarning(
00764 "<JED_MOTIF_INTERFACE>: No se puede abrir el \"Display X\".");
00765 exit(1);
00766 }
00767
00768
00769 int argcount = 0;
00770 Arg args[10];
00771
00772 XtSetArg(args[argcount], XmNtitle, nombre); argcount++;
00773 XtSetArg(args[argcount], XmNwidth, _x_tam); argcount++;
00774 XtSetArg(args[argcount], XmNheight, _y_tam); argcount++;
00775 XtSetArg(args[argcount], XmNminWidth, 320); argcount++;
00776 XtSetArg(args[argcount], XmNminHeight, 240); argcount++;
00777 XtSetArg(args[argcount], XmNmappedWhenManaged, True); argcount++;
00778
00779 toplevel =
00780 XtAppCreateShell(argv[0], "AQUYNZA", applicationShellWidgetClass,
00781 Display_x, args, argcount);
00782
00783
00784 Atom quit_id;
00785
00786 XtVaSetValues(toplevel, XmNdeleteResponse, XmDO_NOTHING, NULL);
00787 quit_id = XmInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False);
00788 XmAddWMProtocolCallback(toplevel, quit_id, motif_quit_callback, this);
00789
00790
00791
00792
00793
00794
00795 main_window = XmCreateMainWindow(toplevel, "AQUYNZA_PRO", NULL, 0);
00796
00797
00798 SUICIDIO_del_logo = FALSE;
00799 XtAppAddTimeOut(app_context, 100 ,
00800 motif_closelogo_callback, (XtPointer)NULL);
00801
00802
00803 XtActionsRec nombre_funcional;
00804 nombre_funcional.string = "resizeH";
00805 nombre_funcional.proc = motif_paneH_resize;
00806 XtAppAddActions (app_context, &nombre_funcional, 1);
00807 nombre_funcional.string = "resizeV";
00808 nombre_funcional.proc = motif_paneV_resize;
00809 XtAppAddActions (app_context, &nombre_funcional, 1);
00810 nombre_funcional.string = "jed_input";
00811 nombre_funcional.proc = motif_gl_input;
00812 XtAppAddActions (app_context, &nombre_funcional, 1);
00813
00814
00815 leer_gui("etc/spanish.gui");
00816
00817
00818
00819 char nomenu_cad[200] = "[salir] (sin menu)";
00820 GUI_MENU *Global = resolver_menu("GLOBAL");
00821
00822 if ( lista_menus.tam() > 0 && Global ) {
00823 menubar = Global->crear_motif(main_window, TM_MENUBAR);
00824 }
00825 else {
00826 if ( !Global ) strcpy(nomenu_cad, "[salir] (no esta GLOBAL)");
00827 menubar = XtVaCreateManagedWidget(nomenu_cad,
00828 xmPushButtonWidgetClass, main_window, NULL);
00829 XtAddCallback(menubar,
00830 XmNactivateCallback,(XtCallbackProc)motif_quit_callback, this);
00831 }
00832
00833
00834
00835
00836 if ( lista_botoneras.tam() > 0 ) {
00837 ventanita = XtVaCreateWidget("Ventanita",
00838 xmDialogShellWidgetClass, toplevel, XmNx, 2, XmNy, 14,
00839 XmNmappedWhenManaged, False, NULL);
00840 XtVaSetValues(ventanita,
00841 XmNdeleteResponse, XmDO_NOTHING,
00842 XmNtitle, "Aquynza",
00843 XmNmwmDecorations, 16 | 4 | 2,
00844 NULL);
00845
00846 lista_botoneras[0]->crear_motif(ventanita);
00847 }
00848
00849
00850 form = XtVaCreateManagedWidget("[fo]", xmFormWidgetClass, main_window,
00851 XmNmarginWidth, 2, XmNmarginHeight, 2,
00852
00853 NULL);
00854
00855
00856 Widget frame = crear_paneH(form);
00857 area_de_ayuda = crear_area_de_ayuda(form);
00858
00859 XtVaSetValues(frame,
00860 XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, area_de_ayuda,
00861 XmNleftAttachment, XmATTACH_FORM,
00862 XmNrightAttachment, XmATTACH_FORM,
00863 XmNtopAttachment, XmATTACH_FORM,
00864 NULL);
00865
00866
00867 XmMainWindowSetAreas(main_window, menubar, NULL, NULL, NULL, form);
00868
00869
00870 XtManageChild(main_window);
00871 XtRealizeWidget(toplevel);
00872
00873 return TRUE;
00874 }
00875
00876 void
00877 JED_MOTIF_INTERFACE::ejecutar(void)
00878 {
00879 Dimension x_tam, y_tam;
00880
00881
00882
00883
00884 XtVaGetValues(form, XmNwidth, &x_tam, XmNheight, &y_tam, NULL);
00885 MOTIFGUI_resize_callback((int)x_tam - 2, (int)y_tam - 2, 1);
00886
00887
00888
00889
00890
00891 BOOLEAN primera_vez = TRUE, salir = FALSE;
00892 XEvent e;
00893
00894 do {
00895 XtAppNextEvent(app_context, &e);
00896
00897 if ( primera_vez ) {
00898 primera_vez = FALSE;
00899 init_extra();
00900 }
00901
00902 XtDispatchEvent(&e);
00903 #if PLATAFORMA != SUN
00904
00905 if ( XtAppGetExitFlag(app_context) ) salir = TRUE;
00906 #endif
00907 } while ( !salir );
00908 }
00909
00910 BOOLEAN
00911 JED_MOTIF_INTERFACE::anexar_controles(
00912 #ifndef MOTIF_ENABLED
00913 LISTA <CONTROL_GUI *> * ,
00914 REPOSITORIO_DE_ENTIDADES *
00915 #endif
00916 #ifdef MOTIF_ENABLED
00917 LISTA <CONTROL_GUI *> *Controles, REPOSITORIO_DE_ENTIDADES *Repositorio
00918 #endif
00919 )
00920 {
00921 #ifndef MOTIF_ENABLED
00922 return FALSE;
00923 #endif
00924 #ifdef MOTIF_ENABLED
00925 Widget contenedor;
00926 int margen = 0;
00927
00928
00929 contenedor = XtVaCreateWidget("[VENTANA]", xmDialogShellWidgetClass,
00930 toplevel, XmNx, 0, XmNy, _y_tam + 56,
00931 XmNmarginHeight, margen, XmNmarginWidth, margen,
00932 XmNmappedWhenManaged, False, NULL);
00933 XtVaSetValues(contenedor,
00934 XmNdeleteResponse, XmDO_NOTHING,
00935 XmNtitle, "Controles GUI / MVC",
00936 XmNmwmDecorations, 16 | 4 | 2,
00937 NULL);
00938
00939
00940 int i;
00941 Widget hijo = NULL;
00942
00943 for ( i = 0; i < Controles->tam(); i++ ) {
00944 hijo = (*Controles)[i]->crear_motif(Repositorio, contenedor);
00945 }
00946
00947 if ( !hijo ) {
00948 fprintf(stderr,"<JED_MOTIF_INTERFACE> - ERROR: No hay componentes!\n");
00949 fflush(stderr);
00950 return FALSE;
00951 }
00952
00953
00954 Dimension x_tam_chica = 600, y_tam_chica = 120;
00955
00956 XtVaGetValues(hijo, XmNwidth,&x_tam_chica, XmNheight,&y_tam_chica, NULL);
00957 XtResizeWidget(contenedor, x_tam_chica+2*margen, y_tam_chica+2*margen, 0);
00958
00959
00960 XtMapWidget(contenedor);
00961
00962 return TRUE;
00963 #endif
00964 }
00965
00966 #endif // MOTIF_ENABLED
00967
00968
00969
00970
00971