home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XGAMES / SPIDER.TAR / spider / xv_ui.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-28  |  21.2 KB  |  814 lines

  1. /*
  2.  *      Spider
  3.  *
  4.  *      (c) Copyright 1989, Donald R. Woods and Sun Microsystems, Inc.
  5.  *      (c) Copyright 1990, David Lemke and Network Computing Devices Inc.
  6.  *      (c) Copyright 1990, Heather Rose and Sun Microsystems, Inc.
  7.  *
  8.  *      See copyright.h for the terms of the copyright.
  9.  *
  10.  *      @(#)xv_ui.c    2.2    90/04/27
  11.  *
  12.  */
  13.  
  14. /*
  15.  * XView Toolkit interface to Spider
  16.  */
  17.  
  18. #include <stdio.h>
  19. #include <xview/xview.h>
  20. #include <xview/canvas.h>
  21. #include <xview/icon_load.h>
  22. #include <xview/panel.h>
  23. #include <xview/svrimage.h>
  24. #include <xview/text.h>
  25. #include <xview/defaults.h>
  26. #include <xview/notice.h>
  27. #include <xview/font.h>
  28. #include "xv_ui.h"
  29. #include "spider.bm"
  30.  
  31. int defaultHelpDir = FALSE;
  32. extern Bool squish;
  33.  
  34. /*
  35.  * Create object `BackUpMenu' in the specified instance.
  36.  *
  37.  * TODO:  Change from menu gen proc style to menu notify style with pins.
  38.  */
  39. Xv_opaque
  40. spider_BackUpMenu_create(ip, owner)
  41.     caddr_t        *ip;
  42.     Xv_opaque    owner;
  43. {
  44.     extern Menu_item    undo_onemove_handler();
  45.     extern Menu_item    undo_startover_handler();
  46.     extern Menu_item    undo_replay_handler();
  47.     Xv_opaque    obj;
  48.     
  49.     obj = xv_create(owner, MENU_COMMAND_MENU,
  50.         XV_KEY_DATA, INSTANCE, ip,
  51.         MENU_ITEM,
  52.             XV_KEY_DATA, INSTANCE, ip,
  53.             MENU_STRING, "One Move",
  54.             MENU_GEN_PROC, undo_onemove_handler,
  55.             0,
  56.         MENU_ITEM,
  57.             XV_KEY_DATA, INSTANCE, ip,
  58.             MENU_STRING, "Start Over",
  59.             MENU_GEN_PROC, undo_startover_handler,
  60.             0,
  61.         MENU_ITEM,
  62.             XV_KEY_DATA, INSTANCE, ip,
  63.             MENU_STRING, "Replay",
  64.             MENU_GEN_PROC, undo_replay_handler,
  65.             0,
  66.         0);
  67.     return obj;
  68. }
  69.  
  70. /*
  71.  * Create object `HelpMenu' in the specified instance.
  72.  *
  73.  * TODO:  Change from menu gen proc style to menu notify style with pins.
  74.  */
  75. Xv_opaque
  76. spider_HelpMenu_create(ip, owner)
  77.     caddr_t        *ip;
  78.     Xv_opaque    owner;
  79. {
  80.     extern Menu_item    help_handler();
  81.     Xv_opaque    obj;
  82.     
  83.     obj = xv_create(owner, MENU_COMMAND_MENU,
  84.         XV_KEY_DATA, INSTANCE, ip,
  85.         MENU_ITEM,
  86.             XV_KEY_DATA, INSTANCE, ip,
  87.             XV_KEY_DATA, HELPKEY, HELP_INTRO,
  88.             MENU_STRING, "Intro...",
  89.             MENU_GEN_PROC, help_handler,
  90.             0,
  91.         MENU_ITEM,
  92.             XV_KEY_DATA, INSTANCE, ip,
  93.             XV_KEY_DATA, HELPKEY, HELP_RULES,
  94.             MENU_STRING, "Rules...",
  95.             MENU_GEN_PROC, help_handler,
  96.             0,
  97.         MENU_ITEM,
  98.             XV_KEY_DATA, INSTANCE, ip,
  99.             XV_KEY_DATA, HELPKEY, HELP_CNTRLS,
  100.             MENU_STRING, "Controls...",
  101.             MENU_GEN_PROC, help_handler,
  102.             0,
  103.         MENU_ITEM,
  104.             XV_KEY_DATA, INSTANCE, ip,
  105.             XV_KEY_DATA, HELPKEY, HELP_EXS,
  106.             MENU_STRING, "Examples...",
  107.             MENU_GEN_PROC, help_handler,
  108.             0,
  109.         MENU_ITEM,
  110.             XV_KEY_DATA, INSTANCE, ip,
  111.             XV_KEY_DATA, HELPKEY, HELP_MISC,
  112.             MENU_STRING, "Extras...",
  113.             MENU_GEN_PROC, help_handler,
  114.             0,
  115.         MENU_ITEM,
  116.                         XV_KEY_DATA, INSTANCE, ip,
  117.                         XV_KEY_DATA, HELPKEY, HELP_SUM,
  118.                         MENU_STRING, "Summary...",
  119.                         MENU_GEN_PROC, help_handler,
  120.                         0,
  121.         0);
  122.     return obj;
  123. }
  124.  
  125. /*
  126.  * Create object `FileMenu' in the specified instance.
  127.  *
  128.  * TODO:  Change from menu gen proc style to menu notify style with pins.
  129.  */
  130. Xv_opaque
  131. spider_FileMenu_create(ip, owner)
  132.     caddr_t        *ip;
  133.     Xv_opaque    owner;
  134. {
  135.     extern Menu_item    file_save_handler();
  136.     extern Menu_item    file_resume_handler();
  137.     extern Menu_item    file_resumefromselection_handler();
  138.     extern Menu_item    file_properties_handler();
  139.     Xv_opaque    obj;
  140.     
  141.     obj = xv_create(owner, MENU_COMMAND_MENU,
  142.         XV_KEY_DATA, INSTANCE, ip,
  143.         MENU_ITEM,
  144.             XV_KEY_DATA, INSTANCE, ip,
  145.             MENU_STRING, "Save in File",
  146.             MENU_GEN_PROC, file_save_handler,
  147.             0,
  148.         MENU_ITEM,
  149.             XV_KEY_DATA, INSTANCE, ip,
  150.             MENU_STRING, "Resume from File",
  151.             MENU_GEN_PROC, file_resume_handler,
  152.             0,
  153.         MENU_ITEM,
  154.             XV_KEY_DATA, INSTANCE, ip,
  155.             MENU_STRING, "Resume from Selection",
  156.             MENU_GEN_PROC, file_resumefromselection_handler,
  157.             0,
  158.         MENU_ITEM,
  159.                         XV_KEY_DATA, INSTANCE, ip,
  160.                         MENU_STRING, "Properties...",
  161.                         MENU_GEN_PROC, file_properties_handler,
  162.             0,
  163.         0);
  164.     return obj;
  165. }
  166.  
  167. /*
  168.  * Initialize an instance of object `window1'.
  169.  */
  170. spider_window1_objects *
  171. spider_window1_objects_initialize(ip, owner)
  172.     spider_window1_objects    *ip;
  173.     Xv_opaque    owner;
  174. {
  175.     extern void newgame_handler(), expand_handler(), locate_handler();
  176.     extern void score_handler();
  177.     extern int helpfiles_exist();
  178.  
  179.     if (!ip &&
  180.         !(ip = (spider_window1_objects *)
  181.           calloc(1, sizeof (spider_window1_objects))))
  182.         return (spider_window1_objects *) NULL;
  183.     ip->defaults = spider_defaults_objects_initialize(ip, ip->window1);
  184.     ip->window1 = spider_window1_window1_create(ip, owner);
  185.     ip->controls1 = spider_window1_controls1_create(ip, ip->window1);
  186.     ip->button1 = spider_button_create(ip, ip->controls1, 
  187.         "New Game", newgame_handler);
  188.     xv_set(ip->button1, XV_HELP_DATA, "spider:NewGame", 0);
  189.     ip->button2 = spider_button_menu_create(ip, ip->controls1,
  190.         "Back Up", spider_BackUpMenu_create(ip, NULL));
  191.     xv_set(ip->button2, XV_HELP_DATA, "spider:BackUp", 0);
  192.     ip->button3 = spider_button_create(ip, ip->controls1,
  193.         "Expand", expand_handler);
  194.     xv_set(ip->button3, XV_HELP_DATA, "spider:Expand", 0);
  195.     ip->button4 = spider_button_create(ip, ip->controls1,
  196.         "Locate", locate_handler);
  197.     xv_set(ip->button4, XV_HELP_DATA, "spider:Locate", 0);
  198.     ip->button5 = spider_button_create(ip, ip->controls1,
  199.         "Score", score_handler);
  200.     xv_set(ip->button5, XV_HELP_DATA, "spider:Score", 0);
  201.     ip->button6 = spider_button_menu_create(ip, ip->controls1,
  202.         "Help", spider_HelpMenu_create(ip, NULL));
  203.     if (!helpfiles_exist(ip->defaults->helpDir)) {
  204.         xv_set(ip->button6, PANEL_INACTIVE, TRUE, 0);
  205.     }
  206.     xv_set(ip->button6, XV_HELP_DATA, "spider:Help", 0);
  207.     ip->button7 = spider_button_menu_create(ip, ip->controls1,
  208.         "File", spider_FileMenu_create(ip, NULL));
  209.     xv_set(ip->button7, XV_HELP_DATA, "spider:File", 0);
  210.     ip->textfield1 = spider_textfield_create(ip, ip->controls1, "Name:");
  211.     xv_set(ip->textfield1, XV_HELP_DATA, "spider:Name.textfield", 0);
  212.     window_fit_height(ip->controls1);
  213.     ip->canvas1 = spider_window1_canvas1_create(ip, ip->window1);
  214.     ip->subwindow1 = (spider_subwindow1_objects *)NULL;
  215.     ip->subwindow2 = (spider_subwindow2_objects *)NULL;
  216.     return ip;
  217. }
  218.  
  219. /*
  220.  * Create object `window1' in the specified instance.
  221.  */
  222. Xv_opaque
  223. spider_window1_window1_create(ip, owner)
  224.     spider_window1_objects *ip;
  225.     Xv_opaque    owner;
  226. {
  227.     Xv_opaque    obj;
  228.     Icon        icon;
  229.     Server_image    icon_image;
  230.     
  231.     obj = xv_create(owner, FRAME,
  232.         XV_KEY_DATA, INSTANCE, ip,
  233.         XV_WIDTH, TABLE_WIDTH + 20,
  234.         XV_HEIGHT, TABLE_HEIGHT + 20,
  235.         XV_LABEL, ip->defaults->instanceName,
  236.         FRAME_SHOW_FOOTER, TRUE,
  237.         0);
  238.  
  239.     icon_image = (Server_image)xv_create(XV_NULL, SERVER_IMAGE,
  240.         XV_WIDTH,        spider_width,
  241.         XV_HEIGHT,        spider_height,
  242.         SERVER_IMAGE_X_BITS,    spider_bits,
  243.         NULL);
  244.  
  245.     icon = (Icon)xv_create(obj, ICON,
  246.         ICON_IMAGE,    icon_image,
  247.         NULL);
  248.  
  249.     xv_set(obj, FRAME_ICON, icon, NULL);
  250.  
  251.     return obj;
  252. }
  253.  
  254. /*
  255.  * Create object `controls1' in the specified instance.
  256.  */
  257. Xv_opaque
  258. spider_window1_controls1_create(ip, owner)
  259.     caddr_t        *ip;
  260.     Xv_opaque    owner;
  261. {
  262.     Xv_opaque    obj;
  263.     
  264.     obj = xv_create(owner, PANEL,
  265.         XV_KEY_DATA, INSTANCE, ip,
  266.         XV_X, 0,
  267.         XV_Y, 0,
  268.         XV_WIDTH, WIN_EXTEND_TO_EDGE,
  269.         OPENWIN_SHOW_BORDERS, FALSE,
  270.         0);
  271.     return obj;
  272. }
  273.  
  274. /*
  275.  * Create a button.
  276.  */
  277. Xv_opaque
  278. spider_button_create(ip, owner, label, proc)
  279.     caddr_t        *ip;
  280.     Xv_opaque       owner;
  281.     char        *label;
  282.     void        *proc;
  283. {
  284.     Xv_opaque       obj;
  285.     
  286.     obj = xv_create(owner, PANEL_BUTTON,
  287.                 XV_KEY_DATA, INSTANCE, ip,
  288.                 PANEL_LABEL_STRING, label,
  289.         PANEL_NOTIFY_PROC, proc,
  290.                 0);
  291.         return obj;
  292. }
  293.  
  294. /*
  295.  * Create a button with a menu.
  296.  */
  297. Xv_opaque
  298. spider_button_menu_create(ip, owner, label, menu)
  299.     caddr_t         *ip;
  300.         Xv_opaque       owner;
  301.         char            *label;
  302.     Xv_opaque    menu;
  303. {
  304.     Xv_opaque       obj;
  305.         
  306.         obj = xv_create(owner, PANEL_BUTTON,
  307.                 XV_KEY_DATA, INSTANCE, ip,
  308.                 PANEL_LABEL_STRING, label,
  309.                 PANEL_ITEM_MENU, menu,
  310.                 0);
  311.         return obj;
  312. }
  313.  
  314. /*
  315.  * Create a textfield.
  316.  */
  317. Xv_opaque
  318. spider_textfield_create(ip, owner, label)
  319.     spider_window1_objects    *ip;
  320.     Xv_opaque    owner;
  321.     char        *label;
  322. {
  323.     Xv_opaque    obj;
  324.     
  325.     obj = xv_create(owner, PANEL_TEXT,
  326.         XV_KEY_DATA, INSTANCE, ip,
  327.         PANEL_LABEL_STRING, label,
  328.         PANEL_LAYOUT, PANEL_HORIZONTAL,
  329.         PANEL_VALUE_DISPLAY_LENGTH, ip->defaults->textField,
  330.         PANEL_VALUE_STORED_LENGTH, 256,
  331.         PANEL_READ_ONLY, FALSE,
  332.         0);
  333.     return obj;
  334. }
  335.  
  336. /*
  337.  * Create object `canvas1' in the specified instance.
  338.  */
  339. Xv_opaque
  340. spider_window1_canvas1_create(ip, owner)
  341.     caddr_t        *ip;
  342.     Xv_opaque    owner;
  343. {
  344.     extern Notify_value    handle_card_event();
  345.     extern void        spider_resize_proc();
  346.     Xv_opaque    obj;
  347.     
  348.     obj = xv_create(owner, CANVAS,
  349.         XV_KEY_DATA, INSTANCE, ip,
  350.         XV_X, 0,
  351.         XV_WIDTH, WIN_EXTEND_TO_EDGE,
  352.         XV_HEIGHT, WIN_EXTEND_TO_EDGE,
  353.         CANVAS_X_PAINT_WINDOW, TRUE,
  354.         CANVAS_RETAINED, TRUE,
  355.         CANVAS_RESIZE_PROC, spider_resize_proc,
  356.         0);
  357.     xv_set(xv_get(obj, CANVAS_PIXWIN), WIN_CONSUME_EVENTS,
  358.         WIN_ASCII_EVENTS,
  359.         WIN_MOUSE_BUTTONS,
  360.         LOC_DRAG,
  361.         0, 0);
  362.     notify_interpose_event_func(xv_get(obj, CANVAS_PIXWIN),
  363.         handle_card_event, NOTIFY_SAFE);
  364.     return obj;
  365. }
  366.  
  367. /*
  368.  * define the help window strings, subwindow1
  369.  */
  370. #define    HELP_STR_CATS        "Categories:"
  371. #define HELP_STR_INTRO        "Introduction"
  372. #define HELP_STR_RULES        "Rules"
  373. #define HELP_STR_CNTRLS        "Controls"
  374. #define HELP_STR_EXS        "Examples"
  375. #define HELP_STR_MISC        "Extras"
  376. #define HELP_STR_SUM        "Summary"
  377. #define HELP_STR_DISMISS    "Dismiss"
  378.  
  379. /*
  380.  * Initialize an instance of object `subwindow1'.
  381.  */
  382. spider_subwindow1_objects *
  383. spider_subwindow1_objects_initialize(ip, owner)
  384.     spider_window1_objects    *ip;
  385.     Xv_opaque    owner;
  386. {
  387.     spider_subwindow1_objects *obj = ip->subwindow1;
  388.     extern void subhelp_handler(), help_done_handler();
  389.  
  390.     if (obj != (spider_subwindow1_objects *)NULL ){
  391.         return obj;
  392.     } else if ( !(obj = (spider_subwindow1_objects *)
  393.         calloc(1, sizeof (spider_subwindow1_objects)))) {
  394.         return (spider_subwindow1_objects *) NULL;
  395.     }
  396.     obj->window2 = spider_popup_create(ip, owner);
  397.     obj->controls2 = xv_get(obj->window2, FRAME_CMD_PANEL);
  398.     obj->categoryChoice = xv_create(obj->controls2, PANEL_CHOICE,
  399.         XV_KEY_DATA, INSTANCE, ip,
  400.         PANEL_CHOOSE_ONE, TRUE,
  401.         PANEL_LABEL_STRING, HELP_STR_CATS,
  402.         PANEL_CHOICE_STRINGS,
  403.             HELP_STR_INTRO, 
  404.             HELP_STR_RULES,
  405.             HELP_STR_CNTRLS,
  406.             HELP_STR_EXS,
  407.             HELP_STR_MISC,
  408.             HELP_STR_SUM,
  409.             NULL,
  410.         PANEL_VALUE, 0,
  411.         PANEL_NOTIFY_PROC, subhelp_handler,
  412.         NULL);
  413.     obj->dismissButton = spider_button_create(ip, obj->controls2,
  414.         HELP_STR_DISMISS, help_done_handler);
  415.     xv_set(obj->dismissButton, 
  416.         XV_X, (int)xv_get(obj->dismissButton, XV_X) + 
  417.             ((int)xv_get(obj->dismissButton, XV_WIDTH) / 2),
  418.         0);
  419.     window_fit_height(obj->controls2);
  420.     obj->textsw1 = spider_subwindow1_textsw1_create(ip, obj->window2);
  421.  
  422.     return obj;
  423. }
  424.  
  425. /*
  426.  * Create a popup window.
  427.  */
  428. Xv_opaque
  429. spider_popup_create(ip, owner)
  430.     caddr_t        *ip;
  431.     Xv_opaque    owner;
  432. {
  433.     Xv_opaque    obj;
  434.     
  435.     obj = xv_create(owner, FRAME_CMD,
  436.         XV_KEY_DATA, INSTANCE, ip,
  437.         FRAME_SHOW_LABEL, TRUE,
  438.         FRAME_CMD_PUSHPIN_IN, TRUE,
  439.         0);
  440.     return obj;
  441. }
  442.  
  443. /*
  444.  * Create object `textsw1' in the specified instance.
  445.  */
  446. Xv_opaque
  447. spider_subwindow1_textsw1_create(ip, owner)
  448.     caddr_t        *ip;
  449.     Xv_opaque    owner;
  450. {
  451.     Xv_opaque    obj;
  452.     
  453.     obj = xv_create(owner, TEXTSW,
  454.         XV_KEY_DATA, INSTANCE, ip,
  455.         0);
  456.  
  457.     return obj;
  458. }
  459.  
  460. /*
  461.  * Initialize an instance of object `defaults'.
  462.  */
  463. spider_defaults_objects *
  464. spider_defaults_objects_initialize(ip, owner)
  465.     spider_window1_objects  *ip;
  466.         Xv_opaque       owner;
  467. {
  468.     spider_defaults_objects *obj=ip->defaults;
  469.     char buf1[256];
  470.     char *s;
  471.     extern int usebell;
  472. #ifdef ROUND_CARDS
  473.     extern int round_cards;
  474. #endif
  475.     extern int deltamod;
  476.     extern char *helpDir;
  477.     extern char *instanceName;
  478.     extern char *resourceFile;
  479.     extern int squish;
  480.  
  481.     if (obj != (spider_defaults_objects *)NULL ){
  482.                 return obj;
  483.         } else if ( !(obj = (spider_defaults_objects *)
  484.         calloc(1, sizeof (spider_defaults_objects)))) {
  485.         return (spider_defaults_objects *) NULL;
  486.     }
  487.     defaults_load_db(resourceFile);
  488.         
  489.     obj->instanceName = instanceName;
  490.     sprintf(buf1,"%s.%s", obj->instanceName, "bell");
  491.     obj->bell = usebell =
  492.         (int) defaults_get_boolean(buf1, "Bell", TRUE);
  493.     sprintf(buf1,"%s.%s", obj->instanceName, "replayTime");
  494.     obj->replayTime = 
  495.         defaults_get_integer(buf1, "ReplayTime", 200);
  496.     sprintf(buf1,"%s.%s", obj->instanceName, "confirm");
  497.     obj->confirm =
  498.         (int) defaults_get_boolean(buf1, "Confirm", TRUE);
  499. #ifdef  ROUND_CARDS
  500.     sprintf(buf1,"%s.%s", obj->instanceName, "roundCards");
  501.     obj->roundCards = round_cards = 
  502.         defaults_get_boolean(buf1, "RoundCards", TRUE);
  503. #endif
  504.     sprintf(buf1,"%s.%s", obj->instanceName, "squish");
  505.     obj->squish = squish =
  506.         defaults_get_boolean(buf1, "Squish", TRUE);
  507.     sprintf(buf1,"%s.%s", obj->instanceName, "deltaMod");
  508.     obj->deltaMod = deltamod = 
  509.         defaults_get_integer(buf1, "DeltaMod", 1);
  510.  
  511.     sprintf(buf1,"%s.%s", obj->instanceName, "textField");
  512.         obj->textField = defaults_get_integer_check(buf1, "TextField",32,8,45);
  513.  
  514.     sprintf(buf1,"%s.%s", obj->instanceName, "helpDir");
  515.     s = (char *)defaults_get_string(buf1, "HelpDir", (char *)NULL);
  516.     if (s == (char *)NULL) {
  517.         s = helpDir;
  518.     }
  519.     /*
  520.      * Do some checking around for help files if not already found
  521.      */
  522.     if (!helpfiles_exist(s)) {
  523.         char *helphome;
  524.         extern char *getenv();
  525.  
  526.         if (((helphome = getenv("OPENWINHOME")) ||
  527.              (helphome = getenv("XVIEWHOME"))) &&
  528.              (helphome != (char *)NULL)) {
  529.             sprintf(buf1,"%s/lib/help/spider",helphome);
  530.             if (helpfiles_exist(buf1)) {
  531.                 s = buf1;
  532.             } 
  533.         } 
  534.     }
  535.     obj->helpDir = malloc(strlen(s) + 1);
  536.     sprintf(obj->helpDir, "%s", s);
  537.     free(helpDir);
  538.     helpDir = obj->helpDir;
  539.                 
  540.     return(obj);
  541. }
  542.  
  543. void
  544. set_props_label(win, name)
  545.     Xv_opaque win;
  546.     char    *name;
  547. {
  548.     char    *buf;
  549.  
  550.     buf = malloc(strlen(name) + 16);
  551.     sprintf(buf, "%s Properties", name);
  552.     xv_set(win, XV_LABEL, buf, 0);
  553. }
  554.  
  555. /*
  556.  * strings used in the properties panel, subwindow2.
  557.  */
  558. #define    PROPS_BELL        "Use audible bell to notify:"
  559. #define PROPS_REPLAY        "Replay Time (in microseconds):"
  560. #define PROPS_ROUND        "Use rounded edges on cards:"
  561. #define PROPS_NOTICE        "Use notice to verify deletion of data:"
  562. #define PROPS_STACK        "Stack contiguous cards of the same suit:"
  563. #define PROPS_DELTA        "Spacing of cards relative to board size:"
  564. #define PROPS_VISIBLE        "Characters visible in text fields:"
  565. #define PROPS_HELPDIR        "Help Directory:"
  566. #define PROPS_APPLY        "Apply"
  567. #define PROPS_SAVE        "Apply & Save"
  568. #define PROPS_RESET        "Reset"
  569. #define PROPS_DISMISS        "Dismiss"
  570.  
  571. /*
  572.  * Initialize an instance of object `subwindow2'.
  573.  */
  574. spider_subwindow2_objects *
  575. spider_subwindow2_objects_initialize(ip, owner)
  576.     spider_window1_objects    *ip;
  577.     Xv_opaque    owner;
  578. {
  579.     char *buf;
  580.  
  581.     spider_subwindow2_objects *obj = ip->subwindow2;
  582.     int row=1, width, bwidth, space, basex, mplw, w[10], i;
  583.     Panel_item pitem;
  584.     extern void     props_done_handler(), props_apply_handler(), 
  585.         props_apply_save_handler(), props_reset_handler();
  586.  
  587.     if (obj != (spider_subwindow2_objects *)NULL ){
  588.         return obj;
  589.     } else if ( !(obj = (spider_subwindow2_objects *)
  590.         calloc(1, sizeof (spider_subwindow2_objects)))) {
  591.         return (spider_subwindow2_objects *) NULL;
  592.     }
  593.     obj->window3 = spider_popup_create(ip, owner);
  594.     set_props_label(obj->window3, ip->defaults->instanceName);
  595.     obj->controls3 = xv_get(obj->window3, FRAME_CMD_PANEL);
  596.     xv_set(obj->controls3, XV_HELP_DATA, "spider:props.panel", 0);
  597.     obj->choice1 = spider_boolean_choice_create(ip, obj->controls3, 
  598.         PROPS_BELL);
  599.     xv_set(obj->choice1,
  600.         XV_X, xv_cols(obj->controls3, 1),
  601.         XV_Y, xv_rows(obj->controls3, row++),
  602.         PANEL_VALUE, ip->defaults->bell,
  603.         XV_HELP_DATA, "spider:bell",
  604.         0);
  605.     obj->numtext1 = spider_subwindow2_numtext1_create(ip, obj->controls3, 
  606.         row++);
  607.     xv_set(obj->numtext1, 
  608.         XV_HELP_DATA, "spider:replayTime", 
  609.         0);
  610. #ifdef ROUND_CARDS
  611.     obj->choice2 = spider_boolean_choice_create(ip, obj->controls3,
  612.         PROPS_ROUND);
  613.     xv_set(obj->choice2, 
  614.                 XV_X, xv_cols(obj->controls3, 1), 
  615.                 XV_Y, xv_rows(obj->controls3, row++), 
  616.                 PANEL_VALUE, ip->defaults->roundCards,
  617.         XV_HELP_DATA, "spider:roundCards",
  618.                 0);
  619. #endif
  620.     obj->choice3 = spider_boolean_choice_create(ip, obj->controls3,
  621.                 PROPS_NOTICE);
  622.         xv_set(obj->choice3,
  623.                 XV_X, xv_cols(obj->controls3, 1),
  624.                 XV_Y, xv_rows(obj->controls3, row++),
  625.                 PANEL_VALUE, ip->defaults->confirm,
  626.         XV_HELP_DATA, "spider:confirm",
  627.                 0);
  628.     obj->choice4 = spider_boolean_choice_create(ip, obj->controls3,
  629.         PROPS_STACK);
  630.     xv_set(obj->choice4, 
  631.                 XV_X, xv_cols(obj->controls3, 1), 
  632.                 XV_Y, xv_rows(obj->controls3, row++), 
  633.                 PANEL_VALUE, ip->defaults->squish,
  634.         XV_HELP_DATA, "spider:squish",
  635.                 0);
  636.     obj->slider1 = spider_slider_create(ip, obj->controls3, 
  637.         PROPS_DELTA, 0, 30, 15);
  638.     xv_set(obj->slider1, 
  639.                 XV_X, xv_cols(obj->controls3, 1), 
  640.                 XV_Y, xv_rows(obj->controls3, row++), 
  641.                 PANEL_VALUE, ip->defaults->deltaMod, 
  642.         XV_HELP_DATA, "spider:deltaMod",
  643.                 0);
  644.     obj->slider2 = spider_slider_create(ip, obj->controls3, 
  645.         PROPS_VISIBLE, 8, 45, 20);
  646.     xv_set(obj->slider2,
  647.         XV_X, xv_cols(obj->controls3, 1),
  648.                 XV_Y, xv_rows(obj->controls3, row++),
  649.                 PANEL_VALUE, ip->defaults->textField,
  650.         XV_HELP_DATA, "spider:textField",
  651.                 0);
  652.     obj->textfield2 = spider_textfield_create(ip, obj->controls3, 
  653.         PROPS_HELPDIR);
  654.     xv_set(obj->textfield2,
  655.         XV_X, xv_cols(obj->controls3, 1),
  656.         XV_Y, xv_rows(obj->controls3, row++),
  657.         PANEL_VALUE, ip->defaults->helpDir,
  658.         XV_HELP_DATA, "spider:helpDir",
  659.         0);
  660.     /* 
  661.      * right justify the panel labels along the ":" 
  662.      */
  663.     mplw = 0; i = 0;
  664.     PANEL_EACH_ITEM(obj->controls3, pitem)
  665.         mplw = ( mplw > (w[i]=(int)xv_get(pitem, PANEL_LABEL_WIDTH))) ?
  666.             mplw : w[i];
  667.         i++;
  668.     PANEL_END_EACH
  669.     mplw = mplw + xv_cols(obj->controls3, 1);
  670.     i = 0;
  671.     PANEL_EACH_ITEM(obj->controls3, pitem)
  672.         xv_set(pitem, PANEL_LABEL_X, mplw - w[i], NULL);
  673.         i++;
  674.     PANEL_END_EACH
  675.     /*
  676.      * fit the panel to width of items and then create bottom buttons
  677.      */
  678.     window_fit_width(obj->controls3);
  679.     width = xv_get(obj->controls3, XV_WIDTH);
  680.     obj->button15 = spider_button_create(ip, obj->controls3,
  681.         PROPS_APPLY, props_apply_handler);
  682.     obj->button18 = spider_button_create(ip, obj->controls3,
  683.         PROPS_SAVE, props_apply_save_handler);
  684.     obj->button16 = spider_button_create(ip, obj->controls3,
  685.         PROPS_RESET, props_reset_handler);
  686.     obj->button17 = spider_button_create(ip, obj->controls3,
  687.         PROPS_DISMISS, props_done_handler);
  688.     bwidth = ((int)xv_get(obj->button15, XV_WIDTH) + 
  689.         (int)xv_get(obj->button18, XV_WIDTH) + 
  690.         (int)xv_get(obj->button16, XV_WIDTH) + 
  691.         (int)xv_get(obj->button17, XV_WIDTH))/4;
  692.     space = 2*(int)xv_get(xv_get(obj->controls3,WIN_FONT),FONT_CHAR_WIDTH);
  693.     basex = (width - (4*bwidth + 3*space)) / 2;
  694.     xv_set(obj->button15,
  695.         XV_Y, xv_rows(obj->controls3, ++row),
  696.         XV_X, basex,
  697.         XV_HELP_DATA, "spider:props.apply",
  698.         0);
  699.     basex = basex + (int)xv_get(obj->button15, XV_WIDTH) + space;
  700.     xv_set(obj->button18,
  701.         XV_Y, xv_rows(obj->controls3, row),
  702.         XV_X, basex, 
  703.         XV_HELP_DATA, "spider:props.apply_save",
  704.         0);
  705.     basex = basex + (int)xv_get(obj->button18, XV_WIDTH) + space;
  706.     xv_set(obj->button16,
  707.         XV_Y, xv_rows(obj->controls3, row),
  708.         XV_X, basex,
  709.                 XV_HELP_DATA, "spider:props.reset", 
  710.         0);
  711.     basex = basex + (int)xv_get(obj->button16, XV_WIDTH) + space;
  712.     xv_set(obj->button17,
  713.         XV_Y, xv_rows(obj->controls3, row),
  714.         XV_X, basex,
  715.                 XV_HELP_DATA, "spider:props.dismiss", 
  716.         0);
  717.     window_fit_height(obj->controls3);
  718.     window_fit(obj->window3);
  719.  
  720.     return obj;
  721. }
  722.  
  723. /*
  724.  * Create boolean choice.
  725.  */
  726. Xv_opaque
  727. spider_boolean_choice_create(ip, owner, label)
  728.         spider_window1_objects    *ip;
  729.         Xv_opaque           owner;
  730.     char            *label;
  731. {
  732.         Xv_opaque       obj;
  733.     
  734.     obj = xv_create(owner, PANEL_CHOICE,
  735.         XV_KEY_DATA, INSTANCE, ip,
  736.         PANEL_LAYOUT, PANEL_HORIZONTAL,
  737.         PANEL_LABEL_STRING, label,
  738.         PANEL_CHOICE_STRINGS,    "False", "True", 0,
  739.         0);
  740.     return(obj);
  741. }
  742.  
  743. /*
  744.  * Create object `numtext1' in the specified instance. 
  745.  */ 
  746. Xv_opaque 
  747. spider_subwindow2_numtext1_create(ip, owner, row) 
  748.         spider_window1_objects    *ip;
  749.         Xv_opaque           owner;
  750.     int            row;
  751.         Xv_opaque       obj;
  752.     
  753.     obj = xv_create(owner, PANEL_NUMERIC_TEXT, 
  754.                 XV_KEY_DATA, INSTANCE, ip, 
  755.         XV_X, xv_cols(owner, 1),
  756.         XV_Y, xv_rows(owner, row),    
  757.                 PANEL_LAYOUT, PANEL_HORIZONTAL,
  758.         PANEL_LABEL_STRING, PROPS_REPLAY,
  759.         PANEL_MIN_VALUE, 20,
  760.         PANEL_MAX_VALUE, 20000,
  761.         PANEL_VALUE_DISPLAY_LENGTH, 6,
  762.         PANEL_VALUE_STORED_LENGTH, 10,
  763.         PANEL_VALUE, ip->defaults->replayTime,
  764.         0);
  765.  
  766.     return(obj);
  767. }    
  768.  
  769. /*
  770.  * Create a slider object in the specified instance. 
  771.  */ 
  772. Xv_opaque 
  773. spider_slider_create(ip, owner, label, min, max, cols) 
  774.         spider_window1_objects    *ip;
  775.         Xv_opaque           owner;
  776.     char            *label;
  777.     int            min, max, cols;
  778.         Xv_opaque       obj;
  779.     
  780.     obj = xv_create(owner, PANEL_SLIDER, 
  781.                 XV_KEY_DATA, INSTANCE, ip, 
  782.                 PANEL_LAYOUT, PANEL_HORIZONTAL,
  783.         PANEL_LABEL_STRING, label,
  784.         PANEL_MIN_VALUE, min,
  785.         PANEL_MAX_VALUE, max,
  786.         PANEL_SLIDER_WIDTH, xv_col(owner, cols),
  787.         PANEL_SHOW_RANGE, TRUE,
  788.         0);
  789.  
  790.     return(obj);
  791. }    
  792.  
  793. int
  794. do_notice(message)
  795.         char *message;
  796. {
  797.         int result;
  798.     extern spider_window1_objects *spider_window1;
  799.  
  800.         result = notice_prompt(spider_window1->controls1, NULL,
  801.                 NOTICE_MESSAGE_STRINGS, message, 0,
  802.                 NOTICE_BUTTON_YES, "Yes",
  803.                 NOTICE_BUTTON_NO, "No",
  804.                 0);
  805.         if (result == NOTICE_YES) {
  806.                 return(TRUE);
  807.         } else {
  808.                 return(FALSE);
  809.         }
  810. }
  811.  
  812.