home *** CD-ROM | disk | FTP | other *** search
- /*
- * callbacks.c
- *
- * notes - by Bob Smith <bob@snuffy.dracut.ma.us>
- */
-
- #include <stdio.h>
- #include <malloc.h>
-
- #include <X11/IntrinsicP.h>
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <X11/Shell.h>
-
- #include <X11/Xaw/Box.h>
- #include <X11/Xaw/Cardinals.h>
- #include <X11/Xaw/Command.h>
- #include <X11/Xaw/Label.h>
- #include <X11/Xaw/Form.h>
- #include <X11/Xaw/List.h>
- #include <X11/Xaw/AsciiText.h>
-
- #include "notes.h"
-
-
- /*
- * external variables
- */
- /* in main.c */
- extern XtAppContext app_con;
- extern Widget toplevel;
- extern Widget **Notes;
- extern char **Titles;
-
-
- /*
- * external functions
- */
- void sensitize_start_button();
-
-
- /*
- * forward declarations
- */
- void show_list(), destroy_list();
-
-
- /*
- * null ()
- * just a stub to redirect some actions to when you don't really
- * want anything to happen -- used by the input dialogs to keep
- * carriage return, newline, and tab from doing anything
- */
- void
- null(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- }
-
-
- /*
- * quit ()
- * self explanatory
- */
- void
- quit(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XtDestroyApplicationContext(app_con);
- exit(0);
- }
-
-
- /*
- * desensitize_all ()
- */
- static void
- desensitize_all(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget w, button;
- int i;
- XWindowAttributes atribs;
-
- w = XtNameToWidget(toplevel, "*Notes");
- if (w) {
- button = XtNameToWidget(w, "*new_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(w, "*dismiss_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(w, "*save_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(w, "*quit_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(w, "*list");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- }
-
- i = 0;
- while (Notes[i]) {
- XGetWindowAttributes(XtDisplay(*Notes[i]),
- XtWindow(*Notes[i]), &atribs);
- if (atribs.map_state != IsUnmapped) {
- button = XtNameToWidget(*Notes[i], "*dismiss_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(*Notes[i], "*title_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(*Notes[i], "*clear_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(*Notes[i], "*delete_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- button = XtNameToWidget(*Notes[i], "*select_button");
- XtVaSetValues(button, XtNsensitive, False, NULL);
- }
- i++;
- }
- }
-
-
- /*
- * sensitize_all ()
- */
- static void
- sensitize_all(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget w, button;
- int i;
- XWindowAttributes atribs;
-
- w = XtNameToWidget(toplevel, "*Notes");
- if (w) {
- button = XtNameToWidget(w, "*new_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(w, "*dismiss_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(w, "*save_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(w, "*quit_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(w, "*list");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- }
-
- i = 0;
- while (Notes[i]) {
- XGetWindowAttributes(XtDisplay(*Notes[i]),
- XtWindow(*Notes[i]), &atribs);
- if (atribs.map_state != IsUnmapped) {
- button = XtNameToWidget(*Notes[i], "*dismiss_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(*Notes[i], "*title_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(*Notes[i], "*clear_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(*Notes[i], "*delete_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- button = XtNameToWidget(*Notes[i], "*select_button");
- XtVaSetValues(button, XtNsensitive, True, NULL);
- }
- i++;
- }
- }
-
-
- /*
- * destroy_widget ()
- * used by a number of the popups to get rid of themselves --
- * the assumption is that the button being pressed is 2 levels
- * deep into the popup we want to destroy - hence the
- * usage of XtGrandParent
- */
- void
- destroy_widget(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XtPopdown(XtGrandParent(widget));
- XtDestroyWidget(XtGrandParent(widget));
- }
-
-
- /*
- * save_callback ()
- * just a callback to get to write_notefile
- */
- static void
- save_callback(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- write_notefile();
- }
-
-
- /*
- * confirm_clear_note ()
- * clear the note widget if confirm is pressed in the dialog box
- */
- static void
- confirm_clear_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XtVaSetValues((Widget) client_data, XtNstring, NULL, NULL);
- }
-
-
- /*
- * clear_note ()
- * put up a dialog asking if you really want to clear the
- * associated note
- */
- static void
- clear_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget note = (Widget) client_data;
- Widget popup, form, prompt;
- Widget confirm_button, filler_box, cancel_button;
- Dimension note_w, popup_w;
- Position x, y;
-
- popup = XtCreatePopupShell("Clear Note",
- transientShellWidgetClass, toplevel,
- NULL, ZERO);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, popup,
- NULL, ZERO);
-
- prompt = XtVaCreateManagedWidget("prompt",
- labelWidgetClass, form,
- XtNlabel, "Clear this note?",
- XtNborderWidth, 0,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
-
- confirm_button = XtVaCreateManagedWidget("confirm_button",
- commandWidgetClass, form,
- XtNlabel, "Confirm",
- XtNwidth, 64,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(confirm_button, confirm_clear_note, note);
- AddCallback(confirm_button, destroy_widget, NULL);
- AddCallback(confirm_button, sensitize_all, NULL);
-
- filler_box = XtVaCreateManagedWidget("filler_box",
- boxWidgetClass, form,
- XtNwidth, 64,
- XtNborderWidth, 0,
- XtNfromHoriz, confirm_button,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- cancel_button = XtVaCreateManagedWidget("cancel_button",
- commandWidgetClass, form,
- XtNlabel, "Cancel",
- XtNwidth, 64,
- XtNfromHoriz, filler_box,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainRight,
- XtNright, XawChainRight,
- NULL);
- AddCallback(cancel_button, destroy_widget, NULL);
- AddCallback(cancel_button, sensitize_all, NULL);
-
- XtRealizeWidget(popup);
-
- XtVaGetValues(XtGrandParent(note), XtNwidth, ¬e_w, NULL);
- XtVaGetValues(popup, XtNwidth, &popup_w, NULL);
- XtTranslateCoords(XtGrandParent(note), (note_w - popup_w)/2, 0, &x, &y);
- XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
-
- XtPopup(popup, XtGrabNone);
- }
-
-
- /*
- * confirm_delete_note ()
- * delete the associated note -- unalloc_note does the real work
- */
- static void
- confirm_delete_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XtPopdown((Widget) client_data);
- XtDestroyWidget((Widget) client_data);
-
- if (widget = XtNameToWidget(toplevel, "*Notes")) {
- XtPopdown(widget);
- XtDestroyWidget(widget);
- }
-
- unalloc_note((Widget) client_data);
-
- if (widget)
- show_list();
-
- }
-
-
- /*
- * delete_note ()
- * put up a dialog asking if you really want to delete the
- * associated note
- */
- static void
- delete_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget note = (Widget) client_data;
- Widget popup, form, prompt;
- Widget confirm_button, filler_box, cancel_button;
- Dimension note_w, popup_w;
- Position x, y;
-
- popup = XtCreatePopupShell("Destroy Note",
- transientShellWidgetClass, toplevel,
- NULL, ZERO);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, popup,
- NULL, ZERO);
-
- prompt = XtVaCreateManagedWidget("prompt",
- labelWidgetClass, form,
- XtNlabel, "Destroy this note?",
- XtNborderWidth, 0,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
-
- confirm_button = XtVaCreateManagedWidget("confirm_button",
- commandWidgetClass, form,
- XtNlabel, "Confirm",
- XtNwidth, 64,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(confirm_button, confirm_delete_note, note);
- AddCallback(confirm_button, destroy_widget, NULL);
- AddCallback(confirm_button, sensitize_all, NULL);
-
- filler_box = XtVaCreateManagedWidget("filler_box",
- boxWidgetClass, form,
- XtNwidth, 64,
- XtNborderWidth, 0,
- XtNfromHoriz, confirm_button,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- cancel_button = XtVaCreateManagedWidget("cancel_button",
- commandWidgetClass, form,
- XtNlabel, "Cancel",
- XtNwidth, 64,
- XtNfromHoriz, filler_box,
- XtNfromVert, prompt,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainRight,
- XtNright, XawChainRight,
- NULL);
- AddCallback(cancel_button, destroy_widget, NULL);
- AddCallback(cancel_button, sensitize_all, NULL);
-
- XtRealizeWidget(popup);
-
- XtVaGetValues(note, XtNwidth, ¬e_w, NULL);
- XtVaGetValues(popup, XtNwidth, &popup_w, NULL);
- XtTranslateCoords(note, (note_w - popup_w)/2, 0, &x, &y);
- XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
-
- XtPopup(popup, XtGrabNone);
- }
-
-
- /*
- * confirm_new_title ()
- * change the title of associated note
- */
- static void
- confirm_new_title(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget w;
- String str;
- int i;
-
- XtVaGetValues(XtNameToWidget(XtGrandParent(widget), "*input"),
- XtNstring, &str, NULL);
-
- if (strlen(str)) {
- i = 0;
- while (Notes[i]) {
- if ((Widget) client_data == *Notes[i]) {
- Titles[i] = (char *) realloc(Titles[i], strlen(str)+1);
- if (!Titles[i])
- die("Realloc in confirm_new_title failed.");
- strcpy(Titles[i], str);
- XtVaSetValues((Widget) client_data, XtNtitle, str, NULL);
- (void) sort_titles(0);
- w = XtNameToWidget(toplevel, "*Notes*list");
- if (w)
- XawListChange(w, Titles, 0, 0, False);
- break;
- }
- i++;
- }
- }
- }
-
-
- /*
- * new_title ()
- * put up a prompt asking for a new title for the
- * associated note
- */
- static void
- new_title(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget popup, form, prompt, input;
- Widget confirm_button, filler_box, cancel_button;
- Dimension client_w, popup_w;
- Position x, y;
- String str;
-
- popup = XtCreatePopupShell("Change Title",
- transientShellWidgetClass, toplevel,
- NULL, ZERO);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, popup,
- NULL, ZERO);
-
- prompt = XtVaCreateManagedWidget("prompt",
- labelWidgetClass, form,
- XtNlabel, "Enter new title",
- XtNborderWidth, 0,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
-
- XtVaGetValues((Widget) client_data, XtNtitle, &str, NULL);
-
- input = XtVaCreateManagedWidget("input",
- asciiTextWidgetClass, form,
- XtNstring, str,
- XtNwidth, 202,
- XtNeditType, XawtextEdit,
- XtNjustify, XtJustifyLeft,
- XtNfromVert, prompt,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- confirm_button = XtVaCreateManagedWidget("confirm_button",
- commandWidgetClass, form,
- XtNlabel, "Confirm",
- XtNwidth, 64,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(confirm_button, confirm_new_title, client_data);
- AddCallback(confirm_button, destroy_widget, NULL);
- AddCallback(confirm_button, sensitize_all, NULL);
-
- /* filler_box's only purpose is to provide spacing... */
- filler_box = XtVaCreateManagedWidget("filler_box",
- boxWidgetClass, form,
- XtNwidth, 64,
- XtNborderWidth, 0,
- XtNfromHoriz, confirm_button,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- cancel_button = XtVaCreateManagedWidget("cancel_button",
- commandWidgetClass, form,
- XtNlabel, "Cancel",
- XtNwidth, 64,
- XtNfromHoriz, filler_box,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainRight,
- XtNright, XawChainRight,
- NULL);
- AddCallback(cancel_button, destroy_widget, NULL);
- AddCallback(cancel_button, sensitize_all, NULL);
-
- XtRealizeWidget(popup);
-
- XtVaGetValues((Widget) client_data, XtNwidth, &client_w, NULL);
- XtVaGetValues(popup, XtNwidth, &popup_w, NULL);
- XtTranslateCoords((Widget) client_data, (client_w - popup_w)/2, 0, &x, &y);
- XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
-
- XtPopup(popup, XtGrabNone);
- }
-
-
- /*
- * confirm_new_note ()
- * create a new note -- alloc_new_note does the bulk
- * of the work
- */
- static void
- confirm_new_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- String str;
- int i;
-
- XtVaGetValues((Widget) client_data, XtNstring, &str, NULL);
-
- if (strlen(str)) {
- i = alloc_new_note(str);
- destroy_list();
- show_list();
- XtPopup(*Notes[i], XtGrabNone);
- }
- }
-
-
- /*
- * new_note ()
- * put up a dialog asking for the title of a new note
- */
- static void
- new_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget popup, form, prompt, input;
- Widget confirm_button, filler_box, cancel_button;
- Dimension top_w, popup_w;
- Position x, y;
-
- popup = XtCreatePopupShell("New Note",
- transientShellWidgetClass, toplevel,
- NULL, ZERO);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, popup,
- NULL, ZERO);
-
- prompt = XtVaCreateManagedWidget("prompt",
- labelWidgetClass, form,
- XtNlabel, "Enter title of new note",
- XtNborderWidth, 0,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
-
- input = XtVaCreateManagedWidget("input",
- asciiTextWidgetClass, form,
- XtNwidth, 202,
- XtNeditType, XawtextEdit,
- XtNjustify, XtJustifyLeft,
- XtNfromVert, prompt,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- confirm_button = XtVaCreateManagedWidget("confirm_button",
- commandWidgetClass, form,
- XtNlabel, "Confirm",
- XtNwidth, 64,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(confirm_button, confirm_new_note, input);
- AddCallback(confirm_button, destroy_widget, NULL);
- AddCallback(confirm_button, sensitize_all, NULL);
-
- /* filler_box's only purpose is to provide spacing... */
- filler_box = XtVaCreateManagedWidget("filler_box",
- boxWidgetClass, form,
- XtNwidth, 64,
- XtNborderWidth, 0,
- XtNfromHoriz, confirm_button,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- cancel_button = XtVaCreateManagedWidget("cancel_button",
- commandWidgetClass, form,
- XtNlabel, "Cancel",
- XtNwidth, 64,
- XtNfromHoriz, filler_box,
- XtNfromVert, input,
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainRight,
- XtNright, XawChainRight,
- NULL);
- AddCallback(cancel_button, destroy_widget, NULL);
- AddCallback(cancel_button, sensitize_all, NULL);
-
- XtRealizeWidget(popup);
-
- XtVaGetValues(toplevel, XtNwidth, &top_w, NULL);
- XtVaGetValues(popup, XtNwidth, &popup_w, NULL);
- XtTranslateCoords(toplevel, (top_w - popup_w)/2, 0, &x, &y);
- XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
-
- XtPopup(popup, XtGrabNone);
- }
-
-
- /*
- * dismiss_show_note ()
- * unmap a note from the display -- note it does not destroy
- * the note widget
- */
- static void
- dismiss_show_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XtPopdown(XtGrandParent(widget));
- XtUnmapWidget(XtGrandParent(widget));
- }
-
-
- /*
- * show_note ()
- * map a note to the display
- */
- static void
- show_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- XawListReturnStruct *item = (XawListReturnStruct*) call_data;
- Widget w;
- XWindowAttributes atribs;
-
- w = *Notes[item->list_index];
- XGetWindowAttributes(XtDisplay(w), XtWindow(w), &atribs);
-
- if (atribs.map_state == IsUnmapped)
- XtPopup(w, XtGrabNone);
- else
- XRaiseWindow(XtDisplay(w), XtWindow(w));
- }
-
-
- /*
- * select_note ()
- */
- static void
- select_note(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget w = (Widget) client_data;
- Display *d;
- String str;
-
- d = XtDisplay(XtGrandParent(widget));
- XtVaGetValues(w, XtNstring, &str, NULL);
- if (strlen(str)) {
- XawTextSetSelection(w, 0, strlen(str));
- XStoreBytes(d, str, strlen(str));
- }
- }
-
-
- /*
- * make_note_widget ()
- * dynamically allocate a widget, create a new note, and
- * return a pointer to the widget -- remember that it's a
- * pointer, not a widget itself
- */
- Widget *
- make_note_widget(title, x, y, w, h, text)
- char *title, *text;
- int x, y, w, h;
- {
- Widget *popup, form, note;
- Widget dismiss_button, title_button, clear_button, delete_button;
- Widget select_button;
-
- popup = (Widget *) malloc(sizeof(Widget));
- if (!popup)
- die("Malloc in make_note_widget failed.");
-
- *popup = XtVaCreatePopupShell(title,
- transientShellWidgetClass, toplevel,
- XtNx, x, XtNy, y, NULL);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, *popup,
- NULL, ZERO);
-
- dismiss_button = XtVaCreateManagedWidget("dismiss_button",
- commandWidgetClass, form,
- XtNlabel, "Dismiss",
- XtNwidth, 64,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(dismiss_button, dismiss_show_note, NULL);
-
- note = XtVaCreateManagedWidget("note",
- asciiTextWidgetClass, form,
- XtNfromVert, dismiss_button,
- XtNstring, text,
- XtNwidth, w,
- XtNheight, h,
- XtNscrollVertical, XawtextScrollAlways,
- XtNeditType, XawtextEdit,
- XtNwrap, XawtextWrapLine,
- XtNtop, XawChainTop,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
-
- title_button = XtVaCreateManagedWidget("title_button",
- commandWidgetClass, form,
- XtNfromHoriz, dismiss_button,
- XtNlabel, "Title",
- XtNwidth, 64,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(title_button, desensitize_all, NULL);
- AddCallback(title_button, new_title, *popup);
-
- clear_button = XtVaCreateManagedWidget("clear_button",
- commandWidgetClass, form,
- XtNfromHoriz, title_button,
- XtNlabel, "Clear",
- XtNwidth, 64,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(clear_button, desensitize_all, NULL);
- AddCallback(clear_button, clear_note, note);
-
- delete_button = XtVaCreateManagedWidget("delete_button",
- commandWidgetClass, form,
- XtNfromHoriz, clear_button,
- XtNlabel, "Destroy",
- XtNwidth, 64,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(delete_button, desensitize_all, NULL);
- AddCallback(delete_button, delete_note, *popup);
-
- select_button = XtVaCreateManagedWidget("select_button",
- commandWidgetClass, form,
- XtNfromHoriz, delete_button,
- XtNlabel, "Select",
- XtNwidth, 64,
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(select_button, select_note, note);
-
- XtRealizeWidget(*popup);
-
- return popup;
- }
-
-
- /*
- * destroy_list ()
- * this destroy_list is called by confirm_new_note
- */
- void
- destroy_list()
- {
- Widget w;
-
- w = XtNameToWidget(toplevel, "*Notes");
- if (w) {
- XtPopdown(w);
- XtDestroyWidget(w);
- }
- }
-
-
- /*
- * show_list ()
- * desensitize the toplevel startup button and put up
- * the list of notes
- */
- void
- show_list(widget, client_data, call_data)
- Widget widget;
- XtPointer client_data, call_data;
- {
- Widget popup, form, list;
- Widget dismiss_button, new_button, save_button, quit_button;
- Dimension top_w, popup_w;
- Position x, y;
-
- popup = XtCreatePopupShell("Notes",
- transientShellWidgetClass, toplevel,
- NULL, ZERO);
-
- form = XtCreateManagedWidget("form",
- formWidgetClass, popup,
- NULL, ZERO);
-
- new_button = XtVaCreateManagedWidget("new_button",
- commandWidgetClass, form,
- XtNwidth, 64,
- XtNlabel, "New",
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainLeft,
- NULL);
- AddCallback(new_button, desensitize_all, NULL);
- AddCallback(new_button, new_note, NULL);
-
- dismiss_button = XtVaCreateManagedWidget("dismiss_button",
- commandWidgetClass, form,
- XtNfromHoriz, new_button,
- XtNwidth, 64,
- XtNlabel, "Dismiss",
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
- AddCallback(dismiss_button, destroy_widget, NULL);
- AddCallback(dismiss_button, sensitize_start_button, NULL);
-
- save_button = XtVaCreateManagedWidget("save_button",
- commandWidgetClass, form,
- XtNfromHoriz, dismiss_button,
- XtNwidth, 64,
- XtNlabel, "Save",
- XtNtop, XawChainTop,
- XtNbottom, XawChainTop,
- XtNleft, XawChainRight,
- XtNright, XawChainRight,
- NULL);
- AddCallback(save_button, save_callback, NULL);
-
- list = XtVaCreateManagedWidget("list",
- listWidgetClass, form,
- XtNfromVert, dismiss_button,
- XtNwidth, 3*64+2*4+2*2,
- XtNlist, Titles,
- XtNtop, XawChainTop,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
- AddCallback(list, show_note, NULL);
-
- quit_button = XtVaCreateManagedWidget("quit_button",
- commandWidgetClass, form,
- XtNfromVert, list,
- XtNwidth, 3*64+2*4+2*2,
- XtNlabel, "Quit",
- XtNtop, XawChainBottom,
- XtNbottom, XawChainBottom,
- XtNleft, XawChainLeft,
- XtNright, XawChainRight,
- NULL);
- AddCallback(quit_button, quit, NULL);
-
- XtRealizeWidget(popup);
-
- XtVaGetValues(toplevel, XtNwidth, &top_w, NULL);
- XtVaGetValues(popup, XtNwidth, &popup_w, NULL);
- XtTranslateCoords(toplevel, (top_w - popup_w)/2, 0, &x, &y);
- XtVaSetValues(popup, XtNx, x, XtNy, y, NULL);
-
- XtPopup(popup, XtGrabNone);
- }
-