Post.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuPost - Maps a given menu to the display and activates
  7. * the menu for user selection. The user is allowed to
  8. * specify the mouse button event mask that will be used
  9. * to identify a selection request. When a selection
  10. * request is received (i.e., when the specified mouse
  11. * event occurs) the data returned will be either the
  12. * data associated with the particular selection active
  13. * at the time of the selection request or NULL if no
  14. * selection was active. A menu selection is shown to
  15. * be active by placing a highlight box around the
  16. * selection as the mouse cursor enters its active
  17. * region. Inactive selections will not be highlighted.
  18. * As the mouse cursor moved from one menu pane
  19. * to another menu pane the pane being entered is raised
  20. * and activated and the pane being left is deactivated.
  21. * If an error occurs NULL will be returned with the
  22. * p_num set to POST_ERROR, s_num set to
  23. * NO_SELECTION and _XMErrorCode set to an
  24. * appropriate value.
  25. * Every time the routine returns successfully the
  26. * p_num and s_num indices will be set to indicate
  27. * the currently active pane and/or selection. If the
  28. * mouse was not in a selection window at the time
  29. * s_num will be set to NO_SELECTION.
  30. *
  31. * Author: Tony Della Fera, DEC
  32. * August, 1984
  33. *
  34. */
  35. #include "XMenuInt.h"
  36. char *
  37. XMenuPost(display, menu, p_num, s_num, x_pos, y_pos, event_mask)
  38. register Display *display; /* Previously opened display. */
  39. register XMenu *menu; /* Menu to post. */
  40. register int *p_num; /* Pane number selected. */
  41. register int *s_num; /* Selection number selected. */
  42. register int x_pos; /* X coordinate of menu position. */
  43. register int y_pos; /* Y coordinate of menu position. */
  44. int event_mask; /* Mouse button event mask. */
  45. {
  46. register int stat; /* Routine call return status. */
  47. char *data; /* Return data. */
  48. /*
  49. * Set up initial pane and selection assumptions.
  50. */
  51. /*
  52. * Make the procedure call.
  53. */
  54. stat = XMenuActivate(
  55. display,
  56. menu,
  57. p_num, s_num,
  58. x_pos, y_pos,
  59. event_mask,
  60. &data, 0);
  61. /*
  62. * Check the return value and return accordingly.
  63. */
  64. switch (stat) {
  65. case XM_FAILURE:
  66. *p_num = POST_ERROR;
  67. *s_num = NO_SELECTION;
  68. return(NULL);
  69. case XM_NO_SELECT:
  70. case XM_IA_SELECT:
  71. *s_num = NO_SELECTION;
  72. return(NULL);
  73. case XM_SUCCESS:
  74. default:
  75. return(data);
  76. }
  77. }
  78. /* arch-tag: 7b6104e5-fa32-4342-aa17-05296a30dd70
  79. (do not change this comment) */