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

  1. #include "xsignal.h"
  2.  
  3. void OpenSignal();
  4. void InsertSignal();
  5. void SaveSignal();
  6. void SaveMarkedSignal();
  7.  
  8. /* translations for the button to popup the menu
  9.  * style_popup positions the shell.
  10.  * MenuPopup realizes the shell.
  11.  */
  12. static String pb_Trans =
  13.     "<EnterWindow>:    highlight() \n\
  14.      <LeaveWindow>: unhighlight() \n\
  15.      <Btn1Down>:    style_popup(%s) MenuPopup(%s)";
  16.  
  17. /* translations for the command buttons of the popup menu
  18.  * the command callback is invoked when the button is released with
  19.  * the pointer in the command widget.
  20.  */
  21. static String cb_Trans =
  22.     "<EnterWindow>:    set() \n\
  23.      <LeaveWindow>: unset() \n\
  24.      <Btn1Up>:    notify()";
  25.  
  26. /* translations for the shell of the popup menu.
  27.  * when the button is released the shell catches it and pops itself down.
  28.  */
  29. static String pm_Trans =
  30.     "<LeaveWindow>:    MenuPopdown()";
  31.  
  32. /* new actions added by this program */
  33. static XtActionsRec menu_actions[] = {
  34.     { "style_popup",    style_popup },
  35. };
  36. static char *popup_menu_name = "style_popup";
  37. void
  38. InitStylePopup(pane)
  39. sigbox *pane;
  40. {
  41.     static XtCallbackRec b_callbacks[2];
  42.     Arg args[6];
  43.     Cardinal i = 0;
  44.     char ptrans[250];
  45.     Widget pop_layout;
  46.  
  47.     pane->style = CONTINUOUS;
  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 style_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->style_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->style_popup = XtCreatePopupShell("style_popup",
  63.                 overrideShellWidgetClass, pane->style_button,
  64.                 (ArgList)args,i);
  65.  
  66.     i = 0;
  67.     XtSetArg(args[i], XtNheight, 2*MENUHIGH); i++;
  68.     XtSetArg(args[i], XtNwidth, 70); i++;
  69.     XtSetArg(args[i], XtNvertPane, TRUE); i++;
  70.     pop_layout = XtCreateManagedWidget("layout", menuPaneWidgetClass,
  71.                     pane->style_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, "continuous"); i++;
  84.     b_callbacks[0].callback = StyleCont;
  85.     b_callbacks[0].closure = (caddr_t) pane;
  86.     XtCreateManagedWidget("stylec", commandWidgetClass,
  87.                         pop_layout, (ArgList)args, i);
  88.  
  89.     i = 5;
  90.     XtSetArg(args[4], XtNlabel, "discrete");
  91.     b_callbacks[0].callback = StyleDisc;
  92.     b_callbacks[0].closure = (caddr_t) pane;
  93.     XtCreateManagedWidget("styled", commandWidgetClass,
  94.                         pop_layout, (ArgList)args, i);
  95.  
  96. }
  97.  
  98. void StyleDisc(button,pane,call_data)
  99. Widget button;
  100. sigbox *pane;
  101. caddr_t call_data;
  102. {
  103.     pane->style = DISCRETE;
  104. }
  105.  
  106. void StyleCont(button,pane,call_data)
  107. Widget button;
  108. sigbox *pane;
  109. caddr_t call_data;
  110. {
  111.     pane->style = CONTINUOUS;
  112. }
  113.