root/oldXMenu/Destroy.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. XMenuDestroy

     1 /* Copyright    Massachusetts Institute of Technology    1985   */
     2 
     3 /*
     4 
     5 Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
     6 
     7 Permission to use, copy, modify, and distribute this
     8 software and its documentation for any purpose and without
     9 fee is hereby granted, provided that the above copyright
    10 notice appear in all copies and that both that copyright
    11 notice and this permission notice appear in supporting
    12 documentation, and that the name of M.I.T. not be used in
    13 advertising or publicity pertaining to distribution of the
    14 software without specific, written prior permission.
    15 M.I.T. makes no representations about the suitability of
    16 this software for any purpose.  It is provided "as is"
    17 without express or implied warranty.
    18 
    19 */
    20 
    21 
    22 
    23 
    24 /*
    25  * XMenu:       MIT Project Athena, X Window system menu package
    26  *
    27  *      XMenuDestroy - Free all resources associated with and XMenu.
    28  *
    29  *      Author:         Tony Della Fera, DEC
    30  *                      August, 1985
    31  *
    32  */
    33 
    34 #include "XMenuInt.h"
    35 
    36 void
    37 XMenuDestroy(Display *display, register XMenu *menu)
    38 
    39                                 /* Menu object to destroy. */
    40 {
    41     register XMPane *p_ptr;     /* Pointer to the current pane. */
    42     register XMPane *p_next;    /* Pointer to the next pane. */
    43     register XMSelect *s_ptr;   /* Pointer to the current selection. */
    44     register XMSelect *s_next;  /* Pointer to the next selection. */
    45 
    46     /*
    47      * Destroy the selection and pane X windows and free
    48      * their corresponding XMWindows.
    49      */
    50     for (
    51         p_ptr = menu->p_list->next;
    52         p_ptr != menu->p_list;
    53         p_ptr = p_next
    54     ) {
    55         for (
    56             s_ptr = p_ptr->s_list->next;
    57             s_ptr != p_ptr->s_list;
    58             s_ptr = s_next
    59         ) {
    60             s_next = s_ptr->next;
    61             free(s_ptr);
    62         }
    63         if (p_ptr->window) {
    64             XDestroySubwindows(display, p_ptr->window);
    65             XDestroyWindow(display, p_ptr->window);
    66         }
    67         p_next = p_ptr->next;
    68         free(p_ptr);
    69     }
    70 
    71     /*
    72      * Destroy the association table.
    73      */
    74     XDestroyAssocTable(menu->assoc_tab);
    75 
    76     /*
    77      * Free the mouse cursor.
    78      */
    79     XFreeCursor(display, menu->mouse_cursor);
    80 
    81     /*
    82      * Free the fonts.
    83      */
    84     XFreeFont(display, menu->p_fnt_info);
    85     XFreeFont(display, menu->s_fnt_info);
    86 
    87     /*
    88      * Free the pixmaps.
    89      */
    90 /*    XFreePixmap(display, menu->p_bdr_pixmap);
    91     XFreePixmap(display, menu->s_bdr_pixmap);
    92     XFreePixmap(display, menu->p_frg_pixmap);
    93     XFreePixmap(display, menu->s_frg_pixmap);
    94     XFreePixmap(display, menu->bkgnd_pixmap); */
    95     XFreePixmap(display, menu->inact_pixmap);
    96 
    97     /*
    98      * Free the color cells.
    99      */
   100     if ((menu->p_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_bdr_color != WhitePixel(display, DefaultScreen(display))))
   101         XFreeColors(
   102                     display,
   103                     DefaultColormap(display, DefaultScreen(display)),
   104                     &menu->p_bdr_color,
   105                     1, 0);
   106     if ((menu->s_bdr_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_bdr_color != WhitePixel(display, DefaultScreen(display))))
   107         XFreeColors(
   108                     display,
   109                     DefaultColormap(display, DefaultScreen(display)),
   110                     &menu->s_bdr_color,
   111                     1, 0);
   112     if ((menu->p_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->p_frg_color != WhitePixel(display, DefaultScreen(display))))
   113         XFreeColors(
   114                     display,
   115                     DefaultColormap(display, DefaultScreen(display)),
   116                     &menu->p_frg_color,
   117                     1, 0);
   118     if ((menu->s_frg_color != BlackPixel(display, DefaultScreen(display))) && (menu->s_frg_color != WhitePixel(display, DefaultScreen(display))))
   119         XFreeColors(
   120                     display,
   121                     DefaultColormap(display, DefaultScreen(display)),
   122                     &menu->s_frg_color,
   123                     1, 0);
   124     if ((menu->bkgnd_color != BlackPixel(display, DefaultScreen(display))) && (menu->bkgnd_color != WhitePixel(display, DefaultScreen(display))))
   125         XFreeColors(
   126                     display,
   127                     DefaultColormap(display, DefaultScreen(display)),
   128                     &menu->bkgnd_color,
   129                     1, 0);
   130 
   131     /*
   132      * Free the XMenu.
   133      */
   134     free(menu);
   135 }

/* [<][>][^][v][top][bottom][index][help] */