home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / btnlib / buttons.h < prev    next >
C/C++ Source or Header  |  1991-08-03  |  7KB  |  182 lines

  1. #ifndef lint
  2. static char SccsBtnhId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /*
  6.  * Module:    buttons.h
  7.  * Project:    PROS -- ROSAT RSDC
  8.  * Purpose:    Define structures for SAO button toolkit
  9.  * Typedefs:    ButtonLabel, ButtonLook, ButtonFeel, ButtonSpec
  10.  * Typedefs:    BoxGeometry, BoxParent, BorderPatterns
  11.  * Typedefs:    ButtonRecord, ButtonBox
  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        21 March 1989
  19.  *        {n} <who> -- <does what> -- <when>
  20.  */
  21.  
  22. #define SUBMENU_LIMIT 5
  23. #define OPTION_LIMIT 6
  24. #define DATA_LIMIT 4    /* option and data limit should be both even or odd */
  25.  
  26. #define OFF_OUT 0
  27. #define OFF_IN 1
  28. #define ON_OUT 2
  29. #define ON_IN 3
  30.  
  31. /* BUTTON FUNCTION CODES */
  32. #define BTNNoOp    0x00  /* makes no report, does not highlight */
  33. #define BTNFlash   0x01  /* reports selection event, flashed when pressed */
  34. #define BTNOneShot 0x02  /* reports selection event, lighted while pressed */
  35. #define BTNToggle  0x03  /* alternates on and off with selection events */
  36. #define BTNWhile   0x04  /* reports selection and release events */
  37. #define BTNCoWhile 0x05  /* same as While, unlights others while pressed */
  38. #define BTNMode    0x06  /* ganged radio button, can have submenus */
  39. #define BTNCoMode  0x07  /* same as Mode, gangs with others in same menu */
  40.  
  41.  
  42. /* Detail of mouse button pressed event to distinguish among possible modes */
  43. /* detail = (xbutton.button << 16) | (xbutton.state & 0xffff); */
  44. #define BTNDetail(a,b) (((a) << 16) | ((b) & 0xffff))
  45.  
  46.  
  47. typedef struct _ButtonLabel {
  48.   unsigned char *label;    /* byte bitmap of label pattern */ 
  49.   unsigned char *mask;    /* byte bitmap mask to stencil label */
  50.   int width, height;    /* dimensions in pixels of label and mask */
  51.   float x_ratio;    /* placement as fraction of button width */
  52.   float y_ratio;    /* placement as fraction of button height */
  53.   int x_offset;        /* offset from label center for positioning */
  54.   int y_offset;        /* offset from label center for positioning */
  55.   int bytes_per_line;    /* number of chars in bitmap line (allows padding) */
  56.   int x_clip;        /* 0=even, <0 clip from left, >0 clip from right */
  57.   int y_clip;        /* 0=even, <0 clip from top, >0 clip from bottom */
  58.   int *breaks;        /* array of clip offsets for one axis */
  59. } ButtonLabel;
  60.  
  61. /* BUTTON INFORMATION PASSED TO BUTTON CREATION ROUTINE */
  62. typedef struct _ButtonLook {
  63.   ButtonLabel *off_out_1;    /* label and params for off & unoccupied */
  64.   ButtonLabel *off_out_2;    /* 2nd label allows 2 parts placed as sized */
  65.   ButtonLabel *on_out_1;    /* label and params for on & unoccupied */
  66.   ButtonLabel *on_out_2;    /* 2nd label allows 2 parts placed as sized */
  67.   ButtonLabel *off_in_1;    /* label and params for off & occupied */
  68.   ButtonLabel *off_in_2;    /* 2nd label allows 2 parts placed as sized */
  69.   ButtonLabel *on_in_1;        /* label and params for on & occupied */
  70.   ButtonLabel *on_in_2;        /* 2nd label allows 2 parts placed as sized */
  71. } ButtonLook;
  72.  
  73. typedef struct _ButtonFeel {
  74.   char *title;            /* name of button for reference */
  75.   int nfunctions;        /* number of response options given */
  76.   /* functional type (for each mouse button response) */
  77.   int function[OPTION_LIMIT];    /* function identifiers */
  78.   /* test to identify and/or verify response */
  79.   /* (((xbutton.button<<16)|(xbutton.state&0xffff))&mask)==reference */
  80.   int mask[OPTION_LIMIT];    /* function masks */
  81.   int reference[OPTION_LIMIT];    /* function references */
  82.   /* user supplied data to be returned when selected */
  83.   int data[DATA_LIMIT];        /* data returned when selected */
  84. } ButtonFeel;
  85.  
  86. typedef struct _ButtonSpec {
  87.   ButtonLook *look;
  88.   ButtonFeel *feel;
  89. } ButtonSpec;
  90.  
  91. typedef struct _BoxGeometry {
  92.   int panel_index;        /* index of parent panel window */
  93.   int btn_cnt;            /* number of defined button */
  94.   int box_cols, box_rows;    /* geometric arrangement of box */
  95.   double parent_cols, parent_rows;    /* geometric arrangement of panel */
  96.   double box_col_x, box_row_y;    /* panel index of first box button */
  97.   int off_inverse, on_inverse;    /* flag for state to use inverse video */
  98. } BoxGeometry;
  99.  
  100. typedef struct _BoxParent {
  101.   Window wndwID;
  102.   Display *display;
  103.   int x, y;
  104.   int width, height;
  105.   int xwdth, yhght;
  106. } BoxParent;
  107.  
  108. typedef struct _BorderPatterns {
  109.   unsigned char *off_out; /* bitmaps of 32x32 button borders */
  110.   unsigned char *off_in;  /* To create border patterns of buttons */
  111.   unsigned char *on_out;
  112.   unsigned char *on_in;
  113. } BorderPatterns;
  114.  
  115. typedef struct _ButtonRecord {
  116.   Display *display;        /* X server connection */
  117.   Window wndwID;        /* window handle */
  118.   GC gc;            /* graphics context for XPutImage() */
  119.   unsigned int width;        /* dimensions of button */
  120.   unsigned int height;
  121.   XImage *image[4];        /* bitmaps to draw for each phase */
  122.   ButtonLook *look;        /* appearance specifications */
  123.   ButtonFeel *feel;        /* interaction specifications */
  124.   int selected;            /* status booleans */
  125.   int highlight;
  126.   int occupied;
  127.   int submenu_count[OPTION_LIMIT];    /* number of button's submenu boxes */
  128.   int *submenu[OPTION_LIMIT][SUBMENU_LIMIT];    /* list of submenu boxes */
  129. #ifdef ALLIANT
  130.     int id[4];
  131. #endif
  132. } ButtonRecord;
  133.  
  134. typedef struct _ButtonBox {
  135.   Display *display;        /* X server connection */
  136.   Window wndwID;        /* window ID of box enclosing window */
  137.   Window parentID;        /* ID of window of which wndwID is subwindow */
  138.   int parent_width, parent_height;    /* references for resize check */
  139.   Visual *visual;        /* X11 Visual to create bitmap XImages */
  140.   unsigned long background;    /* window background pixel value */
  141.   BoxGeometry *geometry;    /* button arrangement and count info */  
  142.   int btn_cnt;            /* number of actual buttons */
  143.   ButtonRecord *buttons;    /* array of button records */
  144.   BorderPatterns *borders;    /* corner patterns to make button border */
  145.   int mode_btn;            /* currently active "mode" button */
  146.   int mode_btn_func;        /* response function of active mode */
  147.   int co_mode_btn;        /* currently active "comode" button */
  148.   int co_mode_func;        /* response function of active comode */
  149.   int down_btn;            /* button currently being selected */
  150.   int down_btn_func;        /* response function of selected button */
  151.   int down_mouse_btn;        /* mouse button used to make selection */
  152.   int window_count;        /* number of windows which might get events */
  153.   Window *window_list;        /* list of their ID's */
  154.   struct _ButtonBox *parentmenu;    /* parent if this is a submenu */
  155.   int submenu_count;        /* number of active mode submenus */
  156.   int cosubmenu_count;        /* number of active comode submenus */
  157.   int co_menu_count;        /* number of co-equal menus */
  158.   struct _ButtonBox *submenu[SUBMENU_LIMIT];    /* list of active submenus */
  159.   struct _ButtonBox *cosubmenu[SUBMENU_LIMIT];    /* list of active cosubmenus */
  160.   struct _ButtonBox *co_menu[SUBMENU_LIMIT];    /* list of co-equal menus */
  161. } *ButtonBox;
  162.  
  163.  
  164. /* Define application callable subroutines */
  165. ButtonBox MakeButtonBox();
  166. void AttachSubmenu();
  167. void JoinMenu();
  168. void MountButtonMenu();
  169. void ResizeButtons();
  170. void ResizeBox();
  171. void SetTAEButtonLook();
  172. int ButtonEvent();
  173. int ButtonControl();
  174. int PushButton();
  175. int TouchButton();
  176. int ReleaseButton();
  177. int SetToggleButton();
  178. int ButtonNumber();
  179. int ButtonStatus();
  180. int EnableButton();
  181. int DisableButton();
  182.