home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume15 / xmail / part08 / windows.c next >
C/C++ Source or Header  |  1991-10-29  |  23KB  |  737 lines

  1. /*
  2.  * xmail - X window system interface to the mail program
  3.  *
  4.  * Copyright 1989 The University of Texas at Austin
  5.  *
  6.  * Author:    Po Cheung
  7.  * Date:    March 10, 1989
  8.  *
  9.  * Permission to use, copy, modify, and distribute this software and
  10.  * its documentation for any purpose and without fee is hereby granted,
  11.  * provided that the above copyright notice appear in all copies and that
  12.  * both that copyright notice and this permission notice appear in
  13.  * supporting documentation.  The University of Texas at Austin makes no 
  14.  * representations about the suitability of this software for any purpose.  
  15.  * It is provided "as is" without express or implied warranty.
  16.  *
  17.  * Copyright 1990,1991 by National Semiconductor Corporation
  18.  *
  19.  * Permission to use, copy, modify, and distribute this software and its
  20.  * documentation for any purpose is hereby granted without fee, provided that
  21.  * the above copyright notice appear in all copies and that both that
  22.  * copyright notice and this permission notice appear in supporting
  23.  * documentation, and that the name of National Semiconductor Corporation not
  24.  * be used in advertising or publicity pertaining to distribution of the
  25.  * software without specific, written prior permission.
  26.  *
  27.  * NATIONAL SEMICONDUCTOR CORPORATION MAKES NO REPRESENTATIONS ABOUT THE
  28.  * SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS"
  29.  * WITHOUT EXPRESS OR IMPLIED WARRANTY.  NATIONAL SEMICONDUCTOR CORPORATION
  30.  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  31.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO
  32.  * EVENT SHALL NATIONAL SEMICONDUCTOR CORPORATION BE LIABLE FOR ANY SPECIAL,
  33.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  34.  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  35.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  36.  * PERFORMANCE OF THIS SOFTWARE.
  37.  *
  38.  * The following software modules were created and are Copyrighted by National
  39.  * Semiconductor Corporation:
  40.  *
  41.  * 1. AddHelpText:
  42.  * 2. AddInfoHandler:
  43.  * 3. AddMenuWindow:
  44.  * 4. AddSetMenu:
  45.  * 5. CreateFolderButton: and
  46.  * 6. CreateInputWindow.
  47.  *
  48.  * Author:  Michael C. Wagnitz - National Semiconductor Corporation
  49.  *
  50.  */
  51.  
  52.  
  53. #include "global.h"
  54. #include "MailwatchP.h"
  55. #include "patchlevel.h"
  56. #include "national.bm"
  57.  
  58. #ifdef XPM
  59. #define    mail_width    64
  60. #define    mail_height    64
  61. #else
  62. #include "icon.mail"
  63. #endif
  64.  
  65. /*
  66. ** @(#)AddHelpText() - add help text to string resources for help widget
  67. */
  68. void
  69. AddHelpText(parent, help_text)
  70. Widget parent;
  71. String    help_text;
  72. {
  73.  Arg        args[2];
  74.  String        name;
  75.  
  76.  static String    p_Trans = "#override \
  77.             !Shift<Btn2Down>: ShowHelp()\n\
  78.                 <Btn2Up>: MenuPopdown(help)";
  79.  
  80.  XtOverrideTranslations(parent, XtParseTranslationTable(p_Trans));
  81.  
  82.  HelpList.name[HelpList.indx] = name = parent->core.name;
  83.  
  84.  XtSetArg(args[0], XtNstring, (XtArgVal) help_text);
  85.  XtSetArg(args[1], XtNlength, (XtArgVal) strlen(help_text));
  86.  
  87.  HelpList.text[HelpList.indx] = XtCreateWidget(name, asciiSrcObjectClass,
  88.                            XtNameToWidget(toplevel, "topBox.help.helpWindow"),
  89.                            args, 2);
  90.  HelpList.indx += 1;
  91. } /* AddHelpText */
  92.  
  93.  
  94. void
  95. AddInfoHandler(widget, message)
  96. Widget widget;
  97. char *message;
  98. {
  99.  if (XMail.Show_Info)
  100.     XtAddEventHandler(widget,
  101.           (EventMask) (EnterWindowMask|LeaveWindowMask),
  102.           False,
  103.           info_handler,
  104.           (caddr_t) message);
  105. }
  106.  
  107.  
  108. /* 
  109. ** @(#)AddMenuWindow() - create menu popup for the specified widget
  110. */
  111. void
  112. AddMenuWindow(parent, action, list, info_text)
  113. Widget        parent;
  114. String        action;
  115. menuList_p    *list;
  116. String        *info_text;
  117. {
  118.  Arg         args[6];
  119.  Widget        menu, layout, previous, next;
  120.  int        j, k, n, indx;
  121.  char        tag[BUFSIZ], trans[BUFSIZ], *c;        
  122.  
  123.  static String p_Trans =
  124.     "<Btn3Down>:    SetPopup(%s) MenuPopup(%s)";
  125.  
  126.  static String b_Trans =
  127.     "<EnterWindow>:    highlight() set() \n\
  128.      <LeaveWindow>: unset()  unhighlight()\n\
  129.      <Btn3Up>:    notify() reset()";
  130.  
  131.  static String m_Trans =
  132.     "<Btn3Up>:    MenuPopdown(%s)";
  133.  
  134.  static String L_Trans[] = { NULL,
  135.     "! Shift      <Btn1Down>: %s(%s)",
  136.     "!       Ctrl <Btn1Down>: %s(%s)",
  137.     "! Shift Ctrl <Btn1Down>: %s(%s)",
  138.     NULL };
  139.  
  140.  static String Labels[] = { NULL,
  141.     " [Shift]",
  142.     "        [Ctrl]",
  143.     " [Shift][Ctrl]",
  144.     NULL };
  145.  
  146.  
  147.  if (list[0]) {
  148.     (void) sprintf(tag, "%s_menu", parent->core.name);
  149.     (void) sprintf(trans, p_Trans, tag, tag);
  150.     XtOverrideTranslations(parent, XtParseTranslationTable(trans));
  151.  
  152.     (void) sprintf(trans, m_Trans, tag);
  153.     XtSetArg(args[0], XtNtranslations, XtParseTranslationTable(trans));
  154.     menu = XtCreatePopupShell(tag, overrideShellWidgetClass, parent, args, 1);
  155.  
  156.     XtSetArg(args[0], XtNdefaultDistance, (XtArgVal) 1);
  157.     layout = XtCreateManagedWidget("menu", formWidgetClass, menu, args, 1);
  158. /*
  159. ** Find widest label for this menu
  160. */
  161.     for (j = k = n = indx = 0; list[indx] != NULL; indx++)
  162.         if ((k = strlen(list[indx]->label)) > j) {
  163.            j = k;
  164.            n = indx;
  165.           }
  166.     k = XTextWidth(XMail.buttonFont, list[n]->label, j) + 12;
  167.  
  168.     if (--indx > 0)    /* add length for accelerator keys menu notes */
  169.        k += XTextWidth(XMail.buttonFont, Labels[indx], strlen(Labels[indx]));
  170. /*
  171. ** create the menu buttons
  172. */
  173.     previous = NULL;
  174.     XtSetArg(args[0], XtNwidth, k);
  175.     XtSetArg(args[1], XtNfont, XMail.buttonFont);
  176.     XtSetArg(args[2], XtNjustify, XtJustifyLeft);
  177.     XtSetArg(args[3], XtNtranslations, XtParseTranslationTable(b_Trans));
  178.     for (indx = 0; list[indx] != NULL; indx++) {
  179.         (void) strcpy(tag, list[indx]->label);    /* set window name by label */
  180.         if ((c = strchr(tag, ' '))) *c = '\0';    /* first word only */
  181.         (void) sprintf(trans, "%-*.*s", j, j, list[indx]->label);
  182.         if (Labels[indx])            /* add accel. note if needed */
  183.            (void) strcat(trans, Labels[indx]);
  184.  
  185.         XtSetArg(args[4], XtNlabel, trans);
  186.         XtSetArg(args[5], XtNfromVert, previous);
  187.         next = XtCreateManagedWidget(tag, commandWidgetClass, layout, args, 6);
  188.  
  189.         if (info_text)
  190.            AddInfoHandler(next, info_text[indx]);
  191.  
  192.         XtAddCallback(next, XtNcallback, list[indx]->func, list[indx]->data);
  193.         previous = next;
  194.  
  195.     if (L_Trans[indx]) {
  196.        (void) sprintf(trans, L_Trans[indx], action, list[indx]->data);
  197.            XtOverrideTranslations(parent, XtParseTranslationTable(trans));
  198.           }
  199.        }
  200. /*
  201. ** Dummy out any remaining combinations of accelerators to do nothing
  202. */
  203.     for (; L_Trans[indx] != NULL; indx++) {
  204.     (void) sprintf(trans, L_Trans[indx], "DoNothing", "");
  205.         XtOverrideTranslations(parent, XtParseTranslationTable(trans));
  206.        }
  207.    }
  208. } /* AddMenuWindow */
  209.  
  210.  
  211. /*
  212. ** @(#)AddButton() - add a button to the command window
  213. **                   include help and an auxilary commands popup menu
  214. */
  215. void
  216. AddButton(parent, name, action, command, list, info_text, help_text)
  217. Widget        parent;            /* widget which holds this button */
  218. String        name;            /* Label for button (and children) */
  219. String        action;            /* name of the XtActionProc to call */
  220. String        command;        /* passed as param(s) to ActionProc */
  221. menuList_p    *list;            /* aux. menu buttons list w/ cbacks */
  222. String        *info_text;        /* pointer to button specific info */
  223. String        help_text;        /* pointer to button specific help */
  224. {
  225.  Arg        args[5];
  226.  Widget        button;
  227.  char        trans[BUFSIZ];
  228. /*
  229. ** Insert name of XtActionProc (and parameter(s)) in the translation list
  230. */
  231.  (void) sprintf(trans, "#override <Btn1Down>: %s(%s)", action, command);
  232.  
  233.  XtSetArg(args[0], XtNwidth, XMail.buttonWidth);
  234.  XtSetArg(args[1], XtNheight, XMail.buttonHeight);
  235.  XtSetArg(args[2], XtNresize, False);
  236.  XtSetArg(args[3], XtNfont, XMail.buttonFont);
  237.  XtSetArg(args[4], XtNtranslations, XtParseTranslationTable(trans));
  238.  button = XtCreateManagedWidget(name, commandWidgetClass, parent, args, 5);
  239.  
  240.  if (info_text)
  241.     AddInfoHandler(button, info_text[0]);
  242.  
  243.  if (help_text)
  244.     AddHelpText(button, help_text);
  245.  
  246.  if (list)
  247.     AddMenuWindow(button, action, list, info_text);
  248. } /* AddButton */
  249.  
  250.  
  251. /* 
  252. ** @(#)AddSetMenu() - add hook to create menu for toggling mail options
  253. */
  254. void
  255. AddSetMenu(w)
  256. Widget        w;
  257. {
  258.  Widget        parent = XtNameToWidget(w, "preserve");
  259.  static String p_Trans = "#override \
  260.     <Btn3Down>: SetMenu() MenuPopup(set_menu)";
  261.  
  262.  XtOverrideTranslations(parent, XtParseTranslationTable(p_Trans));
  263. } /* AddSetMenu */
  264.  
  265.  
  266. void
  267. CreateButtons(parent)
  268. Widget parent;
  269. {
  270.  menuList_p    *list;
  271.  menuList    b1, b2, b3, b4;
  272.  
  273.  
  274.  list = (menuList **) XtMalloc(5 * sizeof(menuList *));
  275.  
  276.  b1.label = "read";        b1.func = (XtCallbackProc) DoWith;  b1.data = "p";
  277.  b2.label = "next";        b2.func = (XtCallbackProc) DoIt;    b2.data = "n";
  278.  b3.label = "previous";    b3.func = (XtCallbackProc) DoIt;    b3.data = "-";
  279.  b4.label = "full header"; b4.func = (XtCallbackProc) DoWith;  b4.data = "P";
  280.  list[0] = &b1; list[1] = &b2; list[2] = &b3; list[3] = &b4; list[4] = NULL;
  281.  AddButton(parent, "read", "DoSelected", "p", list, Read_Info, Read_Help);
  282.  
  283.  b1.label = "save";    b1.func = (XtCallbackProc) Save;    b1.data = "s";
  284.  b2.label = "Save to author"; b2.func = (XtCallbackProc) Save;    b2.data = "S";
  285.  b3.label = "write";    b3.func = (XtCallbackProc) Save;    b3.data = "w";
  286.  list[0] = &b1; list[1] = &b2; list[2] = &b3; list[3] = NULL;
  287.  AddButton(parent, "save", "DoSave", "s", list, Save_Info, Save_Help);
  288.  
  289.  CreateFolderButton(parent);
  290.  
  291.  b1.label = "copy";    b1.func = (XtCallbackProc) Save;    b1.data = "c";
  292.  b2.label = "Copy to author"; b2.func = (XtCallbackProc) Save;    b2.data = "C";
  293.  list[0] = &b1; list[1] = &b2; list[2] = NULL;
  294.  AddButton(parent, "copy", "DoSave", "c", list, Copy_Info, Copy_Help);
  295.  
  296.  AddButton(parent, "preserve", "DoSelected", "preserve", (menuList_p *)NULL, Hold_Info, Hold_Help);
  297.  
  298.  b1.label = "delete";    b1.func = (XtCallbackProc) DoWith;    b1.data = "d";
  299.  b2.label = "undelete";    b2.func = (XtCallbackProc) DoWith;    b2.data = "u";
  300.  list[0] = &b1; list[1] = &b2; list[2] = NULL;
  301.  AddButton(parent, "delete", "DoSelected", "d", list, Delete_Info, Delete_Help);
  302.  
  303.  b1.label = "Newmail"; b1.func = (XtCallbackProc) DoIt; b1.data = "file %";
  304.  b2.label = "inc (no commit)"; b2.func = (XtCallbackProc) DoIt; b2.data = "inc";
  305.  b3.label = "Drop Folders"; b3.func = (XtCallbackProc) DropIt; b3.data = "drop";
  306.  list[0] = &b1; list[1] = &b2; list[2] = &b3; list[3] = NULL;
  307.  AddButton(parent, "Newmail", "DoCmd", "file %", list, NewMail_Info, NewMail_Help);
  308.  
  309.  b1.label = "quit";    b1.func = (XtCallbackProc) DoQuit;    b1.data = "q";
  310.  b2.label = "exit";    b2.func = (XtCallbackProc) DoQuit;    b2.data = "x";
  311.  list[0] = &b1; list[1] = &b2; list[2] = NULL;
  312.  AddButton(parent, "quit", "Quit", "q", list, Quit_Info, Quit_Help);
  313.  
  314.  b1.label = "print"; b1.func = (XtCallbackProc) DoPrint; b1.data = "";
  315.  list[0] = &b1; list[1] = NULL;
  316.  AddButton(parent, "Print", "PrintMsg", "", list, Print_Info, Print_Help);
  317.  
  318.  b1.label="send a message";    b1.func = (XtCallbackProc) Reply; b1.data = "s";
  319.  b2.label="forward message";   b2.func = (XtCallbackProc) Reply; b2.data = "S";
  320.  list[0] = &b1; list[1] = &b2; list[2] = NULL;
  321.  AddButton(parent, "Send", "DoReply", "s", list, Send_Info, Send_Help);
  322.  
  323.  b1.label="reply";             b1.func = (XtCallbackProc) Reply; b1.data = "r";
  324.  b2.label="reply included";    b2.func = (XtCallbackProc) Reply; b2.data = "R";
  325.  b3.label="replyall";          b3.func = (XtCallbackProc) Reply; b3.data = "a";
  326.  b4.label="replyall included"; b4.func = (XtCallbackProc) Reply; b4.data = "A";
  327.  list[0] = &b1; list[1] = &b2; list[2] = &b3;
  328.  list[3] = &b4; list[4] = NULL;
  329.  AddButton(parent, "reply", "DoReply", "r", list, Reply_Info, Reply_Help);
  330.  
  331.  XtFree((menuList *) list);
  332.  
  333.  CreateFileWindow(parent);
  334.  
  335.  AddSetMenu(parent);        /* add a menu for toggling mail options */
  336.  
  337. } /* CreateButtons */
  338.  
  339.  
  340. /*
  341. ** @(#)CreateCommandPanel() - add buttons, and set up the file menu.
  342. */
  343. void
  344. CreateCommandPanel(parent)
  345. Widget parent;
  346. {
  347.  Arg        args[8];
  348.  Widget        cw;
  349.  
  350.  static String w_Trans = "\
  351.     <Btn1Down>:    DoNothing()\n\
  352.     <Btn2Down>:    DoNothing()\n\
  353.     <Btn3Down>:    DoNothing()";
  354.  
  355.  XtSetArg(args[0], XtNhSpace, XMail.commandHSpace);
  356.  XtSetArg(args[1], XtNvSpace, XMail.commandVSpace);
  357.  XtSetArg(args[2], XtNallowResize, (XtArgVal) False);
  358.  XtSetArg(args[3], XtNmax, XMail.commandHeight);
  359.  XtSetArg(args[4], XtNmin, XMail.commandHeight);
  360.  XtSetArg(args[5], XtNfont, XMail.buttonFont);
  361.  XtSetArg(args[6], XtNtranslations, XtParseTranslationTable(w_Trans));
  362.  XtSetArg(args[7], XtNshowGrip, (XtArgVal) False);
  363.  
  364.  cw = XtCreateManagedWidget("commandPanel", boxWidgetClass, parent, args, 8);
  365.  
  366.  CreateButtons(cw);
  367. } /* CreateCommandPanel */
  368.  
  369.  
  370. /*
  371. ** @(#)CreateFileWindow() - for user entry of file and folder names
  372. ** Includes a special set of action routines for the keys to do
  373. ** Delete/Backspace, Ctrl-U, Ctrl-W, and insert-selection().
  374. */
  375. void
  376. CreateFileWindow(parent)
  377. Widget parent;
  378. {
  379.  Arg        args[9];
  380.  Widget        w;
  381.  
  382.  static String    trans = "#override \n\
  383.   Ctrl <Key>a:        beginning-of-file() \n\
  384.   Ctrl <Key>b:        backward-character() \n\
  385.   Ctrl <Key>d:        CheckInsert() delete-next-character() \n\
  386.   Ctrl <Key>e:        end-of-file() \n\
  387.   Ctrl <Key>f:        forward-character() \n\
  388.   Ctrl <Key>h:        DeleteChar() \n\
  389.   Ctrl <Key>j:        DoNothing() \n\
  390.   Ctrl <Key>m:        DoNothing() \n\
  391.   Ctrl <Key>u:        DeleteLine() \n\
  392.   Ctrl <Key>w:        DeleteWord() \n\
  393.   Meta <Key>b:        backward-word() \n\
  394.   Meta <Key>d:        CheckInsert() delete-next-word() \n\
  395.   Meta <Key>f:        forward-word() \n\
  396.        <Key>Delete:    DeleteChar() \n\
  397.        <Key>BackSpace:    DeleteChar() \n\
  398.        <Key>Linefeed:    DoNothing() \n\
  399.        <Key>Return:    DoNothing() \n\
  400.        <Key>Right:    forward-character() \n\
  401.        <Key>Left:    backward-character() \n\
  402.        <Key>:        CheckInsert() insert-char()\n\
  403.        <Btn1Down>:    select-start() \n\
  404.        <Btn2Down>:    CheckInsert() insert-selection(PRIMARY, CUT_BUFFER0)";
  405.  
  406.  
  407.  XtSetArg(args[0], XtNwidth, XMail.fileBoxWidth);
  408.  XtSetArg(args[1], XtNheight, XMail.buttonHeight);
  409.  XtSetArg(args[2], XtNborderWidth, 1);
  410.  XtSetArg(args[3], XtNfont, XMail.buttonFont);
  411.  XtSetArg(args[4], XtNeditType, XawtextEdit);
  412.  XtSetArg(args[5], XtNstring, (XtArgVal) "");
  413.  XtSetArg(args[6], XtNtranslations, XtParseTranslationTable(trans));
  414.  
  415.  w = XtCreateManagedWidget("fileWindow", asciiTextWidgetClass, parent, args, 7);
  416.  
  417.  writeTo(w, "File: ", REPLACE);        /* insert label and position cursor */
  418.  
  419.  AddInfoHandler(w, "Specify the name of a mail folder");
  420.  
  421.  AddHelpText(w, File_Help);
  422. } /* CreateFileWindow */
  423.  
  424.  
  425. /*
  426. ** @(#)CreateFolderButton() - attach special Btn3 hook to list folders
  427. */
  428. void
  429. CreateFolderButton(parent)
  430. Widget    parent;
  431. {
  432.  Arg        args[5];
  433.  Widget        button;
  434.  
  435.  static String    trans = "#override \n\
  436.             <Btn1Down>: Folder() \n\
  437.             <Btn3Down>: SetFolders()";
  438.  
  439.  XtSetArg(args[0], XtNwidth, XMail.buttonWidth);
  440.  XtSetArg(args[1], XtNheight, XMail.buttonHeight);
  441.  XtSetArg(args[2], XtNresize, False);
  442.  XtSetArg(args[3], XtNfont, XMail.buttonFont);
  443.  XtSetArg(args[4], XtNtranslations, XtParseTranslationTable(trans));
  444.  button = XtCreateManagedWidget("Folder", commandWidgetClass, parent, args, 5);
  445.  
  446.  AddInfoHandler(button, Folder_Info[0]);
  447.  
  448.  AddHelpText(button, Folder_Help);
  449.  
  450.  XtRegisterGrabAction(SetFolders, True, ButtonPressMask | ButtonReleaseMask,
  451.                        GrabModeAsync, GrabModeAsync);
  452. } /* CreateFolderButton */
  453.  
  454.  
  455. /* 
  456. ** @(#)CreateHelpWindow() - create popup window for the help text
  457. */
  458. void
  459. CreateHelpWindow(parent)
  460. Widget parent;
  461. {
  462.  Arg    args[4];
  463.  Widget    w;
  464.  static String    trans = "#override \n\
  465.   Ctrl <Key>J:        MenuPopdown(help) \n\
  466.   <Key>Linefeed:    MenuPopdown(help)";
  467.  
  468.  XtSetArg(args[0], XtNborderWidth, 3);
  469.  w = XtCreatePopupShell("help", overrideShellWidgetClass, parent, args, 1);
  470.  
  471.  XtSetArg(args[0], XtNwidth, XMail.helpWidth);
  472.  XtSetArg(args[1], XtNheight, XMail.helpHeight);
  473.  XtSetArg(args[2], XtNfont, XMail.helpFont);
  474.  XtSetArg(args[3], XtNtranslations, XtParseTranslationTable(trans));
  475.  
  476.  XtCreateManagedWidget("helpWindow", asciiTextWidgetClass, w, args, 4);
  477. } /* CreateHelpWindow */
  478.  
  479.  
  480. /* 
  481. ** Index window is a AsciiTextWidget, with special key assignments
  482. */
  483. void
  484. CreateIndexWindow(parent)
  485. Widget parent;
  486. {
  487.  Arg    args[7];
  488.  Widget    w;
  489.  
  490.  XtSetArg(args[0], XtNheight, XMail.indexHeight);
  491.  XtSetArg(args[1], XtNfont, XMail.textFont);
  492.  XtSetArg(args[2], XtNdisplayCaret, (XtArgVal) False);
  493.  XtSetArg(args[3], XtNeditType, XawtextEdit);
  494.  XtSetArg(args[4], XtNscrollVertical, XawtextScrollAlways);
  495.  XtSetArg(args[5], XtNwrap, XawtextWrapNever);
  496.  XtSetArg(args[6], XtNstring, "");
  497.  
  498.  w = XtCreateManagedWidget("indexWindow", asciiTextWidgetClass,parent,args,7);
  499.  
  500.  AddHelpText(w, Index_Help);
  501. } /* CreateIndexWindow */
  502.  
  503.  
  504. /*
  505. ** @(#)CreateStatusWindow() - place for messages from mail
  506. */
  507. void
  508. CreateStatusWindow(parent)
  509. Widget parent;
  510. {
  511.  Arg        args[10];
  512.  Widget        w;
  513.  
  514.  static String w_Trans = "\
  515.     <Btn1Down>:    DoNothing()\n\
  516.     <Btn3Down>:    DoNothing()";
  517.  
  518.  XtSetArg(args[0], XtNallowResize, False);
  519.  XtSetArg(args[1], XtNmin, XMail.buttonHeight);
  520.  XtSetArg(args[2], XtNmax, XMail.buttonHeight);
  521.  XtSetArg(args[3], XtNshowGrip, False);
  522.  
  523.  XtSetArg(args[4], XtNwidth, XMail.shellWidth);
  524.  XtSetArg(args[5], XtNfont, XMail.textFont);
  525.  XtSetArg(args[6], XtNjustify, XtJustifyCenter);
  526.  XtSetArg(args[7], XtNlabel, "Establishing connections");
  527.  XtSetArg(args[8], XtNresize, False);
  528.  XtSetArg(args[9], XtNtranslations, XtParseTranslationTable(w_Trans));
  529.  
  530.  w = XtCreateManagedWidget("statusWindow", labelWidgetClass, parent, args, 10);
  531.  
  532.  AddHelpText(w, Status_Help);
  533. } /* CreateStatusWindow */
  534.  
  535.  
  536. /*
  537. ** @(#)CreateSubWindows() - create all the xmail subwindows.
  538. */
  539. void
  540. CreateSubWindows(parent)
  541. Widget parent;
  542. {
  543.  Arg        args[4];
  544.  Widget        icon, mb, topbox;
  545.  int        n, x, y;
  546.  
  547.  
  548.  XtSetArg(args[0], XtNinput,      True);
  549.  XtSetArg(args[1], XtNwidth,      XMail.shellWidth);
  550.  XtSetArg(args[2], XtNgripIndent, 0);
  551.  XtSetArg(args[3], XtNskipAdjust, True);
  552.  
  553.  topbox = XtCreateManagedWidget("topBox", panedWidgetClass, parent, args, 4);
  554.  
  555.  CreateHelpWindow(topbox);
  556.  CreateTitleBar(topbox);
  557.  CreateIndexWindow(topbox);
  558.  CreateStatusWindow(topbox);
  559.  CreateCommandPanel(topbox);
  560.  CreateTextWindow(topbox);
  561. /*
  562. ** Create an icon window for the mailwatchWidget
  563. */
  564.  XtSetArg(args[0], XtNwidth, (XtArgVal) mail_width);
  565.  XtSetArg(args[1], XtNheight, (XtArgVal) mail_height);
  566.  n = 2;
  567.  if (XMail.iconGeometry) {
  568.     ParseIconGeometry(XMail.iconGeometry, &x, &y);
  569.     XtSetArg(args[n], XtNx, (XtArgVal) x);        n++;
  570.     XtSetArg(args[n], XtNy, (XtArgVal) y);        n++;
  571.    }
  572.  icon = XtCreateWidget("icon", applicationShellWidgetClass, toplevel, args, n);
  573.  mb = XtCreateManagedWidget("mailbox", mailwatchWidgetClass, icon, NULL, 0);
  574.  XtAddCallback(mb, XtNcallback, SetNewmail, NULL);
  575. } /* CreateSubWindows */ 
  576.  
  577.  
  578. /* 
  579. ** @(#)CreateTextWindow() - AsciiTextWidget window, without special keys
  580. */
  581. void
  582. CreateTextWindow(parent)
  583. Widget parent;
  584. {
  585.  Arg         args[11];
  586.  Widget        form, tw;
  587.  
  588.  
  589.  XtSetArg(args[0], XtNmin, XMail.textHeight / 3);
  590.  XtSetArg(args[1], XtNheight, XMail.textHeight);
  591.  XtSetArg(args[2], XtNwidth, XMail.shellWidth);
  592.  form = XtCreateManagedWidget("textWindow", formWidgetClass, parent, args, 3);
  593.  
  594.  XtSetArg(args[0], XtNleft, XtChainRight);
  595.  XtSetArg(args[1], XtNright, XtChainRight);
  596.  XtSetArg(args[2], XtNtop, XtChainTop);
  597.  XtSetArg(args[3], XtNbottom, XtChainTop);
  598.  XtSetArg(args[4], XtNvertDistance, 0);
  599.  XtSetArg(args[5], XtNhorizDistance, XMail.shellWidth - 48);
  600.  XtSetArg(args[6], XtNborderWidth, 0);
  601.  XtSetArg(args[7], XtNheight, 48);
  602.  XtSetArg(args[8], XtNwidth, 48);
  603.  XtSetArg(args[9], XtNinternalWidth, 0);
  604.  XtCreateWidget("face", labelWidgetClass, form, args, 10);
  605.  
  606.  XtSetArg(args[0], XtNleft, XtChainLeft);
  607.  XtSetArg(args[1], XtNright, XtChainRight);
  608.  XtSetArg(args[2], XtNtop, XtChainTop);
  609.  XtSetArg(args[3], XtNbottom, XtChainBottom);
  610.  /* see above... */
  611.  XtSetArg(args[5], XtNhorizDistance, 0);
  612.  /* see above... */
  613.  XtSetArg(args[7], XtNheight, XMail.textHeight);
  614.  XtSetArg(args[8], XtNfont, XMail.textFont);
  615.  XtSetArg(args[9], XtNstring, "");
  616.  XtSetArg(args[10], XtNscrollVertical, XawtextScrollAlways);
  617.  tw = XtCreateManagedWidget("text", asciiTextWidgetClass, form, args, 11);
  618.  
  619.  AddHelpText(tw, Text_Help);
  620.  
  621.  HelpList.name[HelpList.indx] = XtNewString("text2");
  622.  
  623.  XtSetArg(args[0], XtNstring, (XtArgVal) Text2_Help);
  624.  XtSetArg(args[1], XtNlength, (XtArgVal) strlen(Text2_Help));
  625.  HelpList.text[HelpList.indx] = XtCreateWidget("text2", asciiSrcObjectClass,
  626.                         XtNameToWidget(toplevel, "topBox.help.helpWindow"),
  627.                         args, 2);
  628.  HelpList.indx += 1;
  629. } /* CreateTextWindow */
  630.  
  631.  
  632. /*
  633. ** @(#)CreateTitleBar() - creates the title bar displayed at top of shell
  634. **              Include Nat. Semi. Corp. logo in top left corner.
  635. */
  636. void
  637. CreateTitleBar(parent)
  638. Widget parent;
  639. {
  640.  Arg        args[8];
  641.  Pixmap        logo;
  642.  Widget        form, lg, tb;
  643.  char        buf[20];
  644.  
  645.  static String w_Trans = "\
  646.     <Btn1Down>:    DoNothing()\n\
  647.     <Btn2Down>:    DoNothing()\n\
  648.     <Btn3Down>:    DoNothing()";
  649.  
  650.  static String l_Trans = "\
  651.     <Btn1Down>:    Iconify()\n\
  652.     <Btn2Down>:    Iconify()\n\
  653.     <Btn3Down>:    Iconify()";
  654.  
  655.  XtSetArg(args[0], XtNdefaultDistance, 1);
  656.  XtSetArg(args[1], XtNallowResize, (XtArgVal) False);
  657.  XtSetArg(args[2], XtNmax, (XtArgVal) XMail.buttonHeight);
  658.  XtSetArg(args[3], XtNmin, (XtArgVal) XMail.buttonHeight);
  659.  XtSetArg(args[4], XtNshowGrip, (XtArgVal) False);
  660.  
  661.  form = XtCreateManagedWidget("titleBar", formWidgetClass, parent, args, 5);
  662.  
  663.  logo = XCreateBitmapFromData(XtDisplay(toplevel), XtScreen(toplevel)->root,
  664.                         national_bits, national_width, national_height);
  665.  
  666.  XtSetArg(args[0], XtNborderWidth, 0);
  667.  XtSetArg(args[1], XtNheight, (XtArgVal) XMail.buttonHeight);
  668.  XtSetArg(args[2], XtNwidth, national_width);
  669.  XtSetArg(args[3], XtNinternalWidth, 0);
  670.  XtSetArg(args[4], XtNbitmap, (XtArgVal) logo);
  671.  XtSetArg(args[5], XtNtranslations, XtParseTranslationTable(l_Trans));
  672.  lg = XtCreateManagedWidget("logo", commandWidgetClass, form, args, 6);
  673.  
  674.  (void) sprintf(buf, "%s%d", TITLE, PATCHLEVEL);
  675.  
  676.  XtSetArg(args[2], XtNwidth, XMail.shellWidth - national_width - 2);
  677.  XtSetArg(args[3], XtNlabel, (XtArgVal) buf);
  678.  XtSetArg(args[4], XtNfont, XMail.textFont);
  679.  XtSetArg(args[5], XtNjustify, (XtArgVal) XtJustifyLeft);
  680.  XtSetArg(args[6], XtNfromHoriz, lg);
  681.  XtSetArg(args[7], XtNtranslations, XtParseTranslationTable(w_Trans));
  682.  tb = XtCreateManagedWidget("title", labelWidgetClass, form, args, 8);
  683.  
  684.  AddHelpText(tb, Title_Help);
  685. } /* CreateTitleBar */
  686.  
  687.  
  688. /*
  689. ** @(#)CreateInputWindow() - for specifying recipient, subject, and Cc list
  690. ** Has its own set of translations for editing.
  691. ** Special actions for Delete/Backspace, Ctrl-U, and Ctrl-W.
  692. */
  693. Widget
  694. CreateInputWindow(parent, name)
  695. Widget    parent;
  696. String    name;
  697. {
  698.  Arg    args[7];
  699.  int    n;
  700.  Widget    w;
  701.  
  702.  n  = XMail.shellWidth - 26;    /* - (20 + 2 * (internal_width+def_dist)) */
  703.  n -= figureWidth(XMail.buttonFont)*9-10; /* less label width+fudge factor */
  704.  
  705.  XtSetArg(args[0], XtNinput, True);
  706.  XtSetArg(args[1], XtNwidth, n);
  707.  XtSetArg(args[2], XtNheight, XMail.buttonHeight + XMail.borderWidth);
  708.  XtSetArg(args[3], XtNborderWidth, 1);
  709.  XtSetArg(args[4], XtNfont, XMail.buttonFont);
  710.  XtSetArg(args[5], XtNstring, "");
  711.  XtSetArg(args[6], XtNeditType, XawtextEdit);
  712.  
  713.  w = XtCreateManagedWidget(name, asciiTextWidgetClass, parent, args, 7);
  714.  
  715.  return( w );
  716. } /* CreateInputWindow */
  717.  
  718. /* 
  719. ** @(#)ParseIconGeometry() - Parse the icon geometry
  720. */
  721. void
  722. ParseIconGeometry(str, x, y)
  723. char    *str;
  724. int    *x, *y;
  725. {
  726.  int        res;
  727.  unsigned int    w, h;
  728.  
  729.  *x = 0;
  730.  *y = 0;
  731.  res = XParseGeometry(str, x, y, &w, &h);
  732.  if ((res & (XNegative|XValue)) == (XNegative|XValue))
  733.     *x = RootWidth + *x - mail_width;
  734.  if ((res & (YNegative|YValue)) == (YNegative|YValue))
  735.     *y = RootHeight + *y - mail_height;
  736. } /* ParseIconGeometry */
  737.