Destroy.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuDestroy - Free all resources associated with and XMenu.
  7. *
  8. * Author: Tony Della Fera, DEC
  9. * August, 1985
  10. *
  11. */
  12. #include "XMenuInt.h"
  13. void
  14. XMenuDestroy(Display *display, register XMenu *menu)
  15. /* Menu object to destroy. */
  16. {
  17. register XMPane *p_ptr; /* Pointer to the current pane. */
  18. register XMPane *p_next; /* Pointer to the next pane. */
  19. register XMSelect *s_ptr; /* Pointer to the current selection. */
  20. register XMSelect *s_next; /* Pointer to the next selection. */
  21. /*
  22. * Destroy the selection and pane X windows and free
  23. * their corresponding XMWindows.
  24. */
  25. for (
  26. p_ptr = menu->p_list->next;
  27. p_ptr != menu->p_list;
  28. p_ptr = p_next
  29. ) {
  30. for (
  31. s_ptr = p_ptr->s_list->next;
  32. s_ptr != p_ptr->s_list;
  33. s_ptr = s_next
  34. ) {
  35. s_next = s_ptr->next;
  36. free(s_ptr);
  37. }
  38. if (p_ptr->window) {
  39. XDestroySubwindows(display, p_ptr->window);
  40. XDestroyWindow(display, p_ptr->window);
  41. }
  42. p_next = p_ptr->next;
  43. free(p_ptr);
  44. }
  45. /*
  46. * Destroy the association table.
  47. */
  48. XDestroyAssocTable(menu->assoc_tab);
  49. /*
  50. * Free the mouse cursor.
  51. */
  52. XFreeCursor(display, menu->mouse_cursor);
  53. /*
  54. * Free the fonts.
  55. */
  56. XFreeFont(display, menu->p_fnt_info);
  57. XFreeFont(display, menu->s_fnt_info);
  58. /*
  59. * Free the pixmaps.
  60. */
  61. /* XFreePixmap(display, menu->p_bdr_pixmap);
  62. XFreePixmap(display, menu->s_bdr_pixmap);
  63. XFreePixmap(display, menu->p_frg_pixmap);
  64. XFreePixmap(display, menu->s_frg_pixmap);
  65. XFreePixmap(display, menu->bkgnd_pixmap); */
  66. XFreePixmap(display, menu->inact_pixmap);
  67. /*
  68. * Free the color cells.
  69. */
  70. if ((menu->p_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_bdr_color != WhitePixel(display, DefaultScreen(display))))
  71. XFreeColors(
  72. display,
  73. DefaultColormap(display, DefaultScreen(display)),
  74. &menu->p_bdr_color,
  75. 1, 0);
  76. if ((menu->s_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_bdr_color != WhitePixel(display, DefaultScreen(display))))
  77. XFreeColors(
  78. display,
  79. DefaultColormap(display, DefaultScreen(display)),
  80. &menu->s_bdr_color,
  81. 1, 0);
  82. if ((menu->p_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_frg_color != WhitePixel(display, DefaultScreen(display))))
  83. XFreeColors(
  84. display,
  85. DefaultColormap(display, DefaultScreen(display)),
  86. &menu->p_frg_color,
  87. 1, 0);
  88. if ((menu->s_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_frg_color != WhitePixel(display, DefaultScreen(display))))
  89. XFreeColors(
  90. display,
  91. DefaultColormap(display, DefaultScreen(display)),
  92. &menu->s_frg_color,
  93. 1, 0);
  94. if ((menu->bkgnd_color != BlackPixel(display, DefaultScreen(display))) && (menu->bkgnd_color != WhitePixel(display, DefaultScreen(display))))
  95. XFreeColors(
  96. display,
  97. DefaultColormap(display, DefaultScreen(display)),
  98. &menu->bkgnd_color,
  99. 1, 0);
  100. /*
  101. * Free the XMenu.
  102. */
  103. free(menu);
  104. }