home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / menuinit.c < prev    next >
C/C++ Source or Header  |  1990-04-21  |  5KB  |  144 lines

  1. #ifndef lint
  2. static char SccsId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /* Module:    menuinit.c (Menu Initialize)
  6.  * Purpose:    Create and resize menu button panels
  7.  * Subroutine:  control_buttonbox()        returns: int *
  8.  * Subroutine:    init_buttonmenus()        returns: void
  9.  * Subroutine:    mount_buttonmenus()        returns: void
  10.  * Subroutine:    resize_buttonmenu()        returns: void
  11.  * Subroutine:    init_buttonbox_settings()    returns: void
  12.  * Copyright:    1989 Smithsonian Astrophysical Observatory
  13.  *        You may do anything you like with this file except remove
  14.  *        this copyright.  The Smithsonian Astrophysical Observatory
  15.  *        makes no representations about the suitability of this
  16.  *        software for any purpose.  It is provided "as is" without
  17.  *        express or implied warranty.
  18.  * Modified:    {0} Michael VanHilst    initial version         4 July 1989
  19.  *        {n} <who> -- <does what> -- <when>
  20.  */
  21.  
  22. #include <stdio.h>        /* define NULL */
  23. #include <X11/Xlib.h>        /* X window stuff */
  24. #include <X11/Xutil.h>        /* X window manager stuff */
  25. #include "btnlib/buttons.h"
  26. #include "hfiles/window.h"
  27.  
  28. BoxParent parent[4];
  29. ButtonBox box;
  30.  
  31. /*
  32.  * Subroutine:    control_buttonbox
  33.  * Purpose:    boxcontrol from a remote file
  34.  * Returns:    Pointer to data of just activated button, else NULL pointer
  35.  * Pre-state:    Most recent event from XNextEvent() in event
  36.  * Post-state:    Mouse button event of selection, or a client event
  37.  * Called by:    main event loop
  38.  * Uses:    ButtonControl() in buttonlib/libbtn.a (EventCtrl.c)
  39.  * Note:    ButtonControl returns -1 on non-X event from UNIX select
  40.  */
  41. int *control_buttonbox ( event )
  42.      XEvent *event;    /* i/o: event yet to be fielded or just fielded */
  43. {
  44.   int *response;
  45.   if( ButtonControl(box, event, &response) == 1 )
  46.     return( response );
  47.   else
  48.     return( NULL );
  49. }
  50.  
  51. /*
  52.  * Subroutine:    init_buttonmenu
  53.  * Purpose:    Create the main button menu and fit it to its windows
  54.  * Note:    Uses preprocessed code in panel subdirectory
  55.  */
  56. void init_buttonmenu ( btnbox, gc, visual, foreground, background )
  57.      struct windowRec *btnbox;
  58.      GC gc;            /* i: optional, else 0 */
  59.      Visual *visual;        /* i: optional, else 0 */
  60.      unsigned long foreground;
  61.      unsigned long background;    /* i: optional, else 0 */
  62. {
  63.   ButtonBox CreateMenu();    /* i: precompiled in panel/MakeMenu.c */
  64.  
  65.   parent[0].display = btnbox->display;
  66.   parent[0].wndwID = btnbox->ID;
  67.   parent[0].x = btnbox->xzero;
  68.   parent[0].y = btnbox->yzero;
  69.   parent[0].width = btnbox->width;
  70.   parent[0].height = btnbox->height;
  71.   parent[0].xwdth = btnbox->xwidth;
  72.   parent[0].yhght = (parent[0].height / 2) + 2;
  73.  
  74.   parent[1].display = btnbox->display;
  75.   parent[1].wndwID = btnbox->ID;
  76.   parent[1].x = parent[0].x;
  77.   parent[1].y = parent[0].y + parent[0].yhght;
  78.   parent[1].width = btnbox->width;
  79.   parent[1].height = btnbox->height;
  80.   parent[1].xwdth = btnbox->xwidth;
  81.   parent[1].yhght = btnbox->yheight - parent[0].yhght;
  82.  
  83.   parent[2].display = btnbox->display;
  84.   parent[2].wndwID = btnbox->ID;
  85.   parent[2].x = parent[1].x;
  86.   parent[2].y = parent[1].y;
  87.   parent[2].width = btnbox->width;
  88.   parent[2].height = btnbox->height;
  89.   parent[2].xwdth = (7 * btnbox->xwidth) / 8;
  90.   parent[2].yhght = parent[1].yhght;
  91.  
  92.   parent[3].display = btnbox->display;
  93.   parent[3].wndwID = btnbox->ID;
  94.   parent[3].x = parent[1].x + (parent[1].xwdth + 6) / 7;
  95.   parent[3].y = parent[1].y;
  96.   parent[3].width = btnbox->width;
  97.   parent[3].height = btnbox->height;
  98.   parent[3].xwdth = parent[1].xwdth - (parent[3].x - parent[1].x);
  99.   parent[3].yhght = parent[1].yhght;
  100.  
  101.   box = CreateMenu (parent, gc, visual, background);
  102. }
  103.  
  104. /*
  105.  * Subroutine:    mount_buttonmenu
  106.  * Purpose:    Put the menu up on the screen
  107.  */
  108. void mount_buttonmenu ( )
  109. {
  110.   MountButtonMenu (box);
  111. }
  112.  
  113. /*
  114.  * Subroutine:    adjust_buttonmenu
  115.  * Purpose:    Adjust all buttons in the buttonmenu
  116.  * Note:    Uses precompiled call in panel/MakeMenu.c
  117.  */
  118. void adjust_buttonmenu ( btnbox )
  119.      struct windowRec *btnbox;
  120. {
  121.   int flags[4];
  122.   void ResizeMenu();
  123.  
  124.   parent[0].width = btnbox->width;
  125.   parent[0].height = btnbox->height;
  126.   parent[0].xwdth = btnbox->xwidth;
  127.   flags[0] = 1;
  128.   parent[1].width = btnbox->width;
  129.   parent[1].height = btnbox->height;
  130.   parent[1].xwdth = btnbox->xwidth;
  131.   flags[1] = 1;
  132.   parent[2].width = btnbox->width;
  133.   parent[2].height = btnbox->height;
  134.   parent[2].xwdth = (7 * btnbox->xwidth) / 8;
  135.   flags[2] = 1;
  136.   parent[3].x = parent[1].x + (parent[1].xwdth + 6) / 7;
  137.   parent[3].width = btnbox->width;
  138.   parent[3].height = btnbox->height;
  139.   parent[3].xwdth = parent[1].xwdth - (parent[3].x - parent[1].x);
  140.   flags[3] = 1;
  141.  
  142.   ResizeMenu (parent, flags);
  143. }
  144.