2 * The xzwrite interface structure. All top level widgets except toplevel
5 * toplevel - the top level shell
6 * icon - the top level "Z" icon
8 * sendWindow - the popup shell for the editor/destlist
9 * sendForm - the form holding the edit tree and dest tree
10 * sendClose - button to close sendWindow
12 * editPane - the pane holding editor widgets
13 * editTitle - the label holding the zephyr triple
14 * editForm - the box holding editor command buttons
15 * editSend - button to send message
16 * editClear - button to clear editor
17 * editPrev - button to yank previous
18 * editNext - button to yank next
19 * editor - the text editor
21 * destForm - the form holding the destinations list/button
22 * destScroll - the scrollbar holding the list
23 * destList - the destination list
25 * menuWindow - the popup shell for the menu
26 * menuForm - the form holding the menu list/button
27 * menuClose - the Close Window button for the dest list
28 * signature - button to change signature
39 * getStringWindow - the popup shell for dialog boxes (GetString.c)
40 * getStringForm - the form containing the dialog widgets
41 * getStringTitle - the title label width
42 * getStringEdit - the text editor
43 * getStringAccept - the accept button
44 * getStringCancel - the cancel button
48 #include "GetString.h"
50 #include <X11/Intrinsic.h>
51 #include <X11/StringDefs.h>
52 #include <X11/Shell.h>
53 #include <X11/Xaw/Label.h>
54 #include <X11/Xaw/Command.h>
55 #include <X11/Xaw/Paned.h>
56 #include <X11/Xaw/List.h>
57 #include <X11/Xaw/Box.h>
58 #include <X11/Xaw/Form.h>
59 #include <X11/Xaw/AsciiText.h>
60 #include <X11/Xaw/Toggle.h>
61 #include <X11/Xaw/Viewport.h>
63 #include <zephyr/zephyr.h> /* for ZGetFD() */
65 #define XVCMW XtVaCreateManagedWidget
67 /* Action Procedure declarations */
68 static void Quit(), SendMessage(), OpenSend(), CloseSend(),
69 ClearEditor(), YankPrev(), YankNext(), YankStore(), AlignParagraph(),
70 DeleteDest(), HighlightDest(), SelectDest(), OpenMenu(),
71 ToggleOption(), Signature(), CloseMenu(), CreateDest();
73 static void set_editor_width(), set_sendclose_width();
75 static XtActionsRec actionTable[] = {
76 /* sendWindow actions */
77 {"OpenSend", (XtActionProc) OpenSend},
78 {"CloseSend", (XtActionProc) CloseSend},
81 {"Quit", (XtActionProc) Quit},
82 {"SendMessage", (XtActionProc) SendMessage},
83 {"ClearEditor", (XtActionProc) ClearEditor},
84 {"YankStore", (XtActionProc) YankStore},
85 {"YankPrev", (XtActionProc) YankPrev},
86 {"YankNext", (XtActionProc) YankNext},
87 {"AlignParagraph", (XtActionProc) AlignParagraph},
89 /* Destination list actions */
90 {"SelectDest", (XtActionProc) SelectDest},
91 {"DeleteDest", (XtActionProc) DeleteDest},
92 {"CreateDest", (XtActionProc) CreateDest},
93 {"HighlightDest", (XtActionProc) HighlightDest},
96 {"OpenMenu", (XtActionProc) OpenMenu},
97 {"ToggleOption", (XtActionProc) ToggleOption},
98 {"Signature", (XtActionProc) Signature},
99 {"CloseMenu", (XtActionProc) CloseMenu},
102 extern unsigned int num_options, num_resources;
103 extern String fallback_resources[];
104 extern XrmOptionDescRec app_options[];
105 extern XtResource app_resources[];
107 XtAppContext app_con;
111 Widget toplevel, icon, getString;
112 Widget sendWindow, sendForm, sendClose;
113 Widget destForm, destScroll, destList;
114 Widget editPane, editTitle, editForm, editSend, editClear,
115 editPrev, editNext, editor;
116 Widget menuWindow, menuForm, menuClose, signature,
117 clearOnSend, closeOnSend, pings, verbose, authentic,
118 yankDest, addGlobals, classInst, commandMask, exitProgram;
122 XtAppMainLoop(app_con);
125 void build_interface(argc, argv)
129 /* Set XFILESEARCHPATH to find xzwrite's resource file */
130 /* XXX This is gross XXX */
134 path1 = (char *) getenv("XFILESEARCHPATH");
135 if (! path1) path1 = "";
136 path2 = (char *) malloc(strlen(path1) +
138 strlen("XFILESEARCHPATH=") +
140 strlen(DATADIR) + 12);
143 sprintf(path2, "XFILESEARCHPATH=%s:%s/zephyr/%%N", path1,
147 sprintf(path2, "%s:%s/zephyr/%%N", path1, DATADIR);
148 setenv("XFILESEARCHPATH", path2, 1);
154 toplevel = XtVaAppInitialize(&app_con, "XZwrite", app_options,
155 #if XtSpecificationRelease > 4
156 num_options, argc, argv,
158 num_options, (Cardinal *) argc, argv,
160 fallback_resources, NULL);
162 XtVaGetApplicationResources(toplevel, (XtPointer) &defs, app_resources,
163 num_resources, NULL);
165 XtAppAddActions(app_con, actionTable, XtNumber(actionTable));
167 /* Create the icon */
168 icon = XVCMW("icon", commandWidgetClass, toplevel, NULL);
170 /* Create the menu */
171 menuWindow = XtVaCreatePopupShell("menuWindow", transientShellWidgetClass,
173 menuForm = XVCMW("menuForm", formWidgetClass, menuWindow, NULL);
174 menuClose = XVCMW("menuClose", commandWidgetClass, menuForm, NULL);
175 signature = XVCMW("signature", commandWidgetClass, menuForm, NULL);
176 clearOnSend = XVCMW("clearOnSend", toggleWidgetClass, menuForm, NULL);
177 closeOnSend = XVCMW("closeOnSend", toggleWidgetClass, menuForm, NULL);
178 pings = XVCMW("pings", toggleWidgetClass, menuForm, NULL);
179 verbose = XVCMW("verbose", toggleWidgetClass, menuForm, NULL);
180 authentic = XVCMW("authentic", toggleWidgetClass, menuForm, NULL);
181 yankDest = XVCMW("yankDest", toggleWidgetClass, menuForm, NULL);
182 addGlobals = XVCMW("addGlobals", toggleWidgetClass, menuForm, NULL);
183 classInst = XVCMW("classInst", toggleWidgetClass, menuForm, NULL);
184 exitProgram = XVCMW("exitProgram", commandWidgetClass, menuForm, NULL);
186 /* Create the editor/destination list */
187 sendWindow = XtVaCreatePopupShell("sendWindow", transientShellWidgetClass,
189 sendForm = XVCMW("sendForm", formWidgetClass, sendWindow, NULL);
190 sendClose = XVCMW("sendClose", commandWidgetClass, sendForm, NULL);
192 editPane = XVCMW("editPane", panedWidgetClass, sendForm, NULL);
193 editTitle = XVCMW("editTitle", labelWidgetClass, editPane, NULL);
194 editForm = XVCMW("editForm", formWidgetClass, editPane, NULL);
195 editSend = XVCMW("editSend", commandWidgetClass, editForm, NULL);
196 editClear = XVCMW("editClear", commandWidgetClass, editForm, NULL);
197 editPrev = XVCMW("editPrev", commandWidgetClass, editForm, NULL);
198 editNext = XVCMW("editNext", commandWidgetClass, editForm, NULL);
199 editor = XVCMW("editor", asciiTextWidgetClass, editPane, NULL);
201 destForm = XVCMW("destForm", formWidgetClass, sendForm, NULL);
202 destScroll = XVCMW("destScroll", viewportWidgetClass, destForm, NULL);
203 destList = XVCMW("destList", listWidgetClass, destScroll, NULL);
205 XtSetKeyboardFocus(sendForm, editor);
206 getString = InitGetString(toplevel, "getStringWindow");
208 XtAppAddInput(app_con, ZGetFD(), (XtPointer)XtInputReadMask, zeph_dispatch, NULL);
210 if (defs.track_logins) {
211 XtAppAddWorkProc(app_con, (XtWorkProc)login_scan_work, NULL);
215 set_sendclose_width();
216 XtRealizeWidget(toplevel);
219 /* Action Procedures */
222 static void Quit(w, e, p, n)
228 XtDestroyApplicationContext(app_con);
229 ZCancelSubscriptions(0);
234 static void OpenSend(w, e, p, n)
240 XtPopup(sendWindow, XtGrabNone);
244 static void CloseSend(w, e, p, n)
250 XtPopdown(sendWindow);
254 static void SendMessage(w, e, p, n)
264 static void ClearEditor(w, e, p, n)
274 static void YankStore(w, e, p, n)
284 static void YankPrev(w, e, p, n)
294 static void YankNext(w, e, p, n)
304 static void AlignParagraph(w, e, p, n)
313 static void SelectDest(w, e, p, n)
323 static void DeleteDest(w, e, p, n)
333 static void HighlightDest(w, e, p, n)
342 static void CreateDest(w, e, p, n)
352 static void OpenMenu(w, e, p, n)
358 XtPopup(menuWindow, XtGrabNone);
362 static void ToggleOption(w, e, p, n)
372 static void Signature(w, e, p, n)
382 static void CloseMenu(w, e, p, n)
388 XtPopdown(menuWindow);
391 static void set_editor_width ()
393 int w, c; char m = 'm';
394 XFontStruct *fs = (XFontStruct *) NULL;
397 /* get the font structure. */
398 XtVaGetValues(editor, XtNfont, &fs, NULL);
399 if (c < 1 || fs == (XFontStruct *) NULL) return;
401 /* set the editor width */
402 w = c * XTextWidth(fs, &m, 1);
403 XtVaSetValues(editor, XtNwidth, (Dimension)w, NULL);
405 /* set the destList to have 3/8ths the width of the editor */
406 /* an other idea would be to make it have 3/8ths as many characters,
407 which makes a difference when the editor and destList are in
409 however, I prefer this way. */
410 XtVaSetValues(destForm, XtNwidth, (Dimension)(w*3/8), NULL);
413 static void set_sendclose_width ()
415 /* make the Close Window button the width of the form */
417 XtRealizeWidget (sendWindow);
418 XtVaGetValues(sendForm, XtNwidth, &wi, NULL);
419 XtUnrealizeWidget (sendWindow);
420 XtVaSetValues(sendClose, XtNwidth, wi, NULL);