Recomp.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuRecompute - Recompute XMenu object dependencies.
  7. *
  8. * Author: Tony Della Fera, DEC
  9. * September, 1985
  10. *
  11. */
  12. #include "XMenuInt.h"
  13. int
  14. XMenuRecompute(display, menu)
  15. Display *display;
  16. register XMenu *menu; /* Menu object to be recomputed. */
  17. {
  18. register XMPane *p_ptr; /* Pane pointer. */
  19. register XMSelect *s_ptr; /* Selection pointer. */
  20. register int p_num; /* Pane serial number. */
  21. register int s_num; /* Selection serial number. */
  22. /*
  23. * If there are no panes in the menu then return failure
  24. * because the menu is not initialized.
  25. */
  26. if (menu->p_count == 0) {
  27. _XMErrorCode = XME_NOT_INIT;
  28. return(XM_FAILURE);
  29. }
  30. /*
  31. * Recompute menu wide global values: pane window size,
  32. * selection size and maximum selection count.
  33. */
  34. _XMRecomputeGlobals(display, menu);
  35. /*
  36. * For each pane in the menu...
  37. */
  38. p_num = 0;
  39. for (
  40. p_ptr = menu->p_list->next;
  41. p_ptr != menu->p_list;
  42. p_ptr = p_ptr->next
  43. ){
  44. /*
  45. * Recompute pane dependencies.
  46. */
  47. if (_XMRecomputePane(display, menu, p_ptr, p_num) == _FAILURE) {
  48. return(XM_FAILURE);
  49. }
  50. p_num++;
  51. /*
  52. * For each selection in the pane...
  53. */
  54. s_num = 0;
  55. for (
  56. s_ptr = p_ptr->s_list->next;
  57. s_ptr != p_ptr->s_list;
  58. s_ptr = s_ptr->next
  59. ) {
  60. /*
  61. * Recompute selection dependencies.
  62. */
  63. if (_XMRecomputeSelection(display, menu, s_ptr, s_num) == _FAILURE) {
  64. return(XM_FAILURE);
  65. }
  66. s_num++;
  67. }
  68. }
  69. /*
  70. * Recompute menu size.
  71. */
  72. if (menu->menu_style == CENTER) {
  73. menu->width = menu->p_width + (menu->p_bdr_width << 1);
  74. }
  75. else {
  76. menu->width = menu->p_width + (menu->p_bdr_width << 1) +
  77. ((menu->p_count - 1) * menu->p_x_off);
  78. }
  79. menu->height = menu->p_height + (menu->p_bdr_width << 1) +
  80. ((menu->p_count - 1) * menu->p_y_off);
  81. /*
  82. * Reset the recompute flag.
  83. */
  84. menu->recompute = 0;
  85. /*
  86. * Return successfully.
  87. */
  88. _XMErrorCode = XME_NO_ERROR;
  89. return(XM_SUCCESS);
  90. }
  91. /* arch-tag: 1fe99b82-3873-4aab-b2b3-f277c93e00d9
  92. (do not change this comment) */