Post.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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(register Display *display, register XMenu *menu, register int *p_num, register int *s_num, register int x_pos, register int y_pos, int event_mask)
  38. /* Previously opened display. */
  39. /* Menu to post. */
  40. /* Pane number selected. */
  41. /* Selection number selected. */
  42. /* X coordinate of menu position. */
  43. /* Y coordinate of menu position. */
  44. /* 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. }