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