home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume2 / xscope / part01 / InitFilePopup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-28  |  3.3 KB  |  111 lines

  1. #include "xsignal.h"
  2.  
  3. void OpenSignal();
  4. void InsertSignal();
  5. void SaveSignal();
  6. void SaveMarkedSignal();
  7. void file_popup();
  8.  
  9. /* translations for the button to popup the menu
  10.  * file_popup positions the shell.
  11.  * MenuPopup realizes the shell.
  12.  */
  13. static String pb_Trans =
  14.     "<EnterWindow>:    highlight() \n\
  15.      <LeaveWindow>: unhighlight() \n\
  16.      <Btn1Down>:    file_popup(%s) MenuPopup(%s)";
  17.  
  18. /* translations for the command buttons of the popup menu
  19.  * the command callback is invoked when the button is released with
  20.  * the pointer in the command widget.
  21.  */
  22. static String cb_Trans =
  23.     "<EnterWindow>:    set() \n\
  24.      <LeaveWindow>: unset() \n\
  25.      <Btn1Up>:    notify()";
  26.  
  27. /* translations for the shell of the popup menu.
  28.  * when the button is released the shell catches it and pops itself down.
  29.  */
  30. static String pm_Trans =
  31.     "<LeaveWindow>:    MenuPopdown()";
  32.  
  33. /* new actions added by this program */
  34. static XtActionsRec menu_actions[] = {
  35.     { "file_popup",    file_popup },
  36. };
  37. static char *popup_menu_name = "file_popup";
  38. void
  39. InitFilePopup(pane)
  40. sigbox *pane;
  41. {
  42.     static XtCallbackRec b_callbacks[2];
  43.     Arg args[6];
  44.     Cardinal i = 0;
  45.     char ptrans[250];
  46.     Widget pop_layout;
  47.  
  48.     XtAddActions((XtActionList)menu_actions, XtNumber(menu_actions));
  49.  
  50.     /* create the translations for the button which pops up the menu */
  51.     /* we pass the name of the popup menu to both file_popup and MenuPopup*/
  52.     (void)sprintf(ptrans, pb_Trans, popup_menu_name, popup_menu_name);
  53.     i = 0;
  54.     XtSetArg(args[i],XtNtranslations, XtParseTranslationTable(ptrans)); i++;
  55.     XtSetValues(pane->file_button, args, i);
  56.  
  57.     /* create the popup menu ... its shell, its layout widget and the menu
  58.      * buttons it holds.
  59.      */
  60.     i = 0;
  61.     XtSetArg(args[i],XtNtranslations,XtParseTranslationTable(pm_Trans));i++;
  62.     pane->file_popup = XtCreatePopupShell("file_popup",
  63.                 overrideShellWidgetClass, pane->file_button,
  64.                 (ArgList)args,i);
  65.  
  66.     i = 0;
  67.     XtSetArg(args[i], XtNheight, 4*MENUHIGH); i++;
  68.     XtSetArg(args[i], XtNwidth, 70); i++;
  69.     XtSetArg(args[i], XtNvertPane, TRUE); i++;
  70.     pop_layout = XtCreateManagedWidget("layout", menuPaneWidgetClass,
  71.                     pane->file_popup, (ArgList)args, i);
  72.  
  73.     i = 0;
  74.     XtSetArg(args[i], XtNwidth, 70); i++;
  75.     XtSetArg(args[i], XtNheight, MENUHIGH); i++;
  76.  
  77.     /* set the translations for the buttons of the menu.
  78.      * Set on window entry. Unset on window leave.
  79.      * Call the callback when button 1 is released.
  80.      */
  81.     XtSetArg(args[i],XtNtranslations,XtParseTranslationTable(cb_Trans));i++;
  82.     XtSetArg(args[i], XtNcallback, b_callbacks); i++;
  83.     XtSetArg(args[i], XtNlabel, "open"); i++;
  84.     b_callbacks[0].callback = OpenSignal;
  85.     b_callbacks[0].closure = (caddr_t) pane;
  86.     XtCreateManagedWidget("new_signal", commandWidgetClass,
  87.                         pop_layout, (ArgList)args, i);
  88.  
  89.     i = 5;
  90.     XtSetArg(args[4], XtNlabel, "insert");
  91.     b_callbacks[0].callback = InsertSignal;
  92.     b_callbacks[0].closure = (caddr_t) pane;
  93.     XtCreateManagedWidget("insert_signal", commandWidgetClass,
  94.                         pop_layout, (ArgList)args, i);
  95.  
  96.     i = 5;
  97.     XtSetArg(args[4], XtNlabel, "save");
  98.     b_callbacks[0].callback = SaveSignal;
  99.     b_callbacks[0].closure = (caddr_t) pane;
  100.     XtCreateManagedWidget("save_signal", commandWidgetClass,
  101.                         pop_layout, (ArgList)args, i);
  102.  
  103.     i = 5;
  104.     XtSetArg(args[4], XtNlabel, "save marked");
  105.     b_callbacks[0].callback = SaveMarkedSignal;
  106.     b_callbacks[0].closure = (caddr_t) pane;
  107.     XtCreateManagedWidget("save_marked", commandWidgetClass,
  108.                         pop_layout, (ArgList)args, i);
  109.  
  110. }
  111.