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) + 5);
143 sprintf(path2, "XFILESEARCHPATH=%s:%s/%%N", path1, DATADIR);
146 sprintf(path2, "%s:%s/%N", path1, DATADIR);
147 setenv("XFILESEARCHPATH", path2, 1);
153 toplevel = XtVaAppInitialize(&app_con, "XZwrite", app_options,
154 #if XtSpecificationRelease > 4
155 num_options, argc, argv,
157 num_options, (Cardinal *) argc, argv,
159 fallback_resources, NULL);
161 XtVaGetApplicationResources(toplevel, (XtPointer) &defs, app_resources,
162 num_resources, NULL);
164 XtAppAddActions(app_con, actionTable, XtNumber(actionTable));
166 /* Create the icon */
167 icon = XVCMW("icon", commandWidgetClass, toplevel, NULL);
169 /* Create the menu */
170 menuWindow = XtVaCreatePopupShell("menuWindow", transientShellWidgetClass,
172 menuForm = XVCMW("menuForm", formWidgetClass, menuWindow, NULL);
173 menuClose = XVCMW("menuClose", commandWidgetClass, menuForm, NULL);
174 signature = XVCMW("signature", commandWidgetClass, menuForm, NULL);
175 clearOnSend = XVCMW("clearOnSend", toggleWidgetClass, menuForm, NULL);
176 closeOnSend = XVCMW("closeOnSend", toggleWidgetClass, menuForm, NULL);
177 pings = XVCMW("pings", toggleWidgetClass, menuForm, NULL);
178 verbose = XVCMW("verbose", toggleWidgetClass, menuForm, NULL);
179 authentic = XVCMW("authentic", toggleWidgetClass, menuForm, NULL);
180 yankDest = XVCMW("yankDest", toggleWidgetClass, menuForm, NULL);
181 addGlobals = XVCMW("addGlobals", toggleWidgetClass, menuForm, NULL);
182 classInst = XVCMW("classInst", toggleWidgetClass, menuForm, NULL);
183 exitProgram = XVCMW("exitProgram", commandWidgetClass, menuForm, NULL);
185 /* Create the editor/destination list */
186 sendWindow = XtVaCreatePopupShell("sendWindow", transientShellWidgetClass,
188 sendForm = XVCMW("sendForm", formWidgetClass, sendWindow, NULL);
189 sendClose = XVCMW("sendClose", commandWidgetClass, sendForm, NULL);
191 editPane = XVCMW("editPane", panedWidgetClass, sendForm, NULL);
192 editTitle = XVCMW("editTitle", labelWidgetClass, editPane, NULL);
193 editForm = XVCMW("editForm", formWidgetClass, editPane, NULL);
194 editSend = XVCMW("editSend", commandWidgetClass, editForm, NULL);
195 editClear = XVCMW("editClear", commandWidgetClass, editForm, NULL);
196 editPrev = XVCMW("editPrev", commandWidgetClass, editForm, NULL);
197 editNext = XVCMW("editNext", commandWidgetClass, editForm, NULL);
198 editor = XVCMW("editor", asciiTextWidgetClass, editPane, NULL);
200 destForm = XVCMW("destForm", formWidgetClass, sendForm, NULL);
201 destScroll = XVCMW("destScroll", viewportWidgetClass, destForm, NULL);
202 destList = XVCMW("destList", listWidgetClass, destScroll, NULL);
204 XtSetKeyboardFocus(sendForm, editor);
205 getString = InitGetString(toplevel, "getStringWindow");
207 XtAppAddInput(app_con, ZGetFD(), (XtPointer)XtInputReadMask, zeph_dispatch, NULL);
209 if (defs.track_logins) {
210 XtAppAddWorkProc(app_con, (XtWorkProc)login_scan_work, NULL);
214 set_sendclose_width();
215 XtRealizeWidget(toplevel);
218 /* Action Procedures */
221 static void Quit(w, e, p, n)
227 XtDestroyApplicationContext(app_con);
228 ZCancelSubscriptions(NULL, 0);
233 static void OpenSend(w, e, p, n)
239 XtPopup(sendWindow, XtGrabNone);
243 static void CloseSend(w, e, p, n)
249 XtPopdown(sendWindow);
253 static void SendMessage(w, e, p, n)
263 static void ClearEditor(w, e, p, n)
273 static void YankStore(w, e, p, n)
283 static void YankPrev(w, e, p, n)
293 static void YankNext(w, e, p, n)
303 static void AlignParagraph(w, e, p, n)
312 static void SelectDest(w, e, p, n)
322 static void DeleteDest(w, e, p, n)
332 static void HighlightDest(w, e, p, n)
341 static void CreateDest(w, e, p, n)
351 static void OpenMenu(w, e, p, n)
357 XtPopup(menuWindow, XtGrabNone);
361 static void ToggleOption(w, e, p, n)
371 static void Signature(w, e, p, n)
381 static void CloseMenu(w, e, p, n)
387 XtPopdown(menuWindow);
390 static void set_editor_width ()
392 int w, c; char m = 'm';
393 XFontStruct *fs = (XFontStruct *) NULL;
396 /* get the font structure. */
397 XtVaGetValues(editor, XtNfont, &fs, NULL);
398 if (c < 1 || fs == (XFontStruct *) NULL) return;
400 /* set the editor width */
401 w = c * XTextWidth(fs, &m, 1);
402 XtVaSetValues(editor, XtNwidth, (Dimension)w, NULL);
404 /* set the destList to have 3/8ths the width of the editor */
405 /* an other idea would be to make it have 3/8ths as many characters,
406 which makes a difference when the editor and destList are in
408 however, I prefer this way. */
409 XtVaSetValues(destForm, XtNwidth, (Dimension)(w*3/8), NULL);
412 static void set_sendclose_width ()
414 /* make the Close Window button the width of the form */
416 XtRealizeWidget (sendWindow);
417 XtVaGetValues(sendForm, XtNwidth, &wi, NULL);
418 XtUnrealizeWidget (sendWindow);
419 XtVaSetValues(sendClose, XtNwidth, wi, NULL);