root/oldXMenu/XMenu.h

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

INCLUDED FROM


     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  *      XMenu.h -       Include file for the MIT Project Athena
    28  *                      XMenu X window system menu package.
    29  *
    30  *      Author:         Tony Della Fera, DEC
    31  *                      August, 1984
    32  */
    33 
    34 #ifndef _XMenu_h_
    35 #define _XMenu_h_
    36 
    37 #include <stdlib.h>
    38 #include <X11/Xutil.h>
    39 #include "X10.h"
    40 
    41 #define FAILURE                 -1
    42 #define SUCCESS                 1
    43 #define POST_ERROR              -1
    44 #define NO_SELECTION            -1
    45 
    46 #define XM_FAILURE              -1
    47 #define XM_SUCCESS              1
    48 #define XM_NO_SELECT            2
    49 #define XM_IA_SELECT            3
    50 
    51 #define XME_CODE_COUNT          17
    52 
    53 #define XME_NO_ERROR            0
    54 #define XME_NOT_INIT            1
    55 #define XME_ARG_BOUNDS          2
    56 #define XME_P_NOT_FOUND         3
    57 #define XME_S_NOT_FOUND         4
    58 #define XME_STYLE_PARAM         5
    59 #define XME_GRAB_MOUSE          6
    60 #define XME_INTERP_LOC          7
    61 #define XME_CALLOC              8
    62 #define XME_CREATE_ASSOC        9
    63 #define XME_STORE_BITMAP        10
    64 #define XME_MAKE_TILES          11
    65 #define XME_MAKE_PIXMAP         12
    66 #define XME_CREATE_CURSOR       13
    67 #define XME_OPEN_FONT           14
    68 #define XME_CREATE_WINDOW       15
    69 #define XME_CREATE_TRANSP       16
    70 
    71 /*
    72  * XMenu error code and error list definitions.
    73  */
    74 extern int _XMErrorCode;
    75 extern char const *const _XMErrorList[];
    76 
    77 /*
    78  * Define the XMWindow datatypes.
    79  *
    80  * An XMWindow is either an XMPane or an XMSelect.
    81  *
    82  * XMWindow is wrapper used to identify the constant window
    83  * information that makes up XMPane and XMSelect objects.
    84  *
    85  * An XMPane is a menu pane made up of one or more XMSelect and a label.
    86  *
    87  * An XMSelect is a menu selection object with a label and a data pointer.
    88  */
    89 typedef enum _xmwintype {PANE, SELECTION, PL_HEADER, SL_HEADER, SEPARATOR} XMWType;
    90 
    91 typedef struct _xmwindow {
    92     struct _xmwindow *next;     /* Next obj pointer (for emacs_insque). */
    93     struct _xmwindow *prev;     /* Prev obj pointer (for emacs_insque). */
    94     XMWType type;               /* Type of window. */
    95     Window window;              /* X Window Id. */
    96     int window_x;               /* Window upper left X coordinate. */
    97     int window_y;               /* Window upper left y coordinate. */
    98     int window_w;               /* Window width. */
    99     int window_h;               /* Window height. */
   100     int active;                 /* Window active? */
   101     int activated;              /* Window activated? */
   102     int pad_l1;                 /* ---- */
   103     char *pad_l2;               /* ---- */
   104     int pad_l3;                 /* ---- */
   105     int pad_l4;                 /* ---- */
   106     int pad_l5;                 /* ---- */
   107     int pad_l6;                 /* ---- */
   108     int pad_l7;                 /* ---- */
   109     int pad_l8;                 /* ---- */
   110     struct _xmwindow *pad_l9;   /* ---- */
   111     char *pad_l10;              /* ---- */
   112     struct _xmwindow *pad_l11;  /* ---- */
   113 } XMWindow;
   114 
   115 typedef struct _xmpane {
   116     struct _xmpane *next;       /* Next obj pointer (for emacs_insque). */
   117     struct _xmpane *prev;       /* Prev obj pointer (for emacs_insque). */
   118     XMWType type;               /* Type of window. */
   119     Window window;              /* X Window Id. */
   120     int window_x;               /* Window upper left X coordinate. */
   121     int window_y;               /* Window upper left y coordinate. */
   122     int window_w;               /* Window width. */
   123     int window_h;               /* Window height. */
   124     int active;                 /* Window active? */
   125     int activated;              /* Window activated? */
   126     int serial;                 /* -- Pane serial number. */
   127     char const *label;          /* -- Pane label. */
   128     int label_width;            /* -- Pane label width in pixels. */
   129     int label_length;           /* -- Pane label length in chars. */
   130     int label_x;                /* -- Pane label X offset. */
   131     int label_uy;               /* -- Pane label upper Y offset. */
   132     int label_ly;               /* -- Pane label lower Y offset. */
   133     int s_count;                /* -- Selections in this pane. */
   134     struct _xmselect *s_list;   /* -- Selection  window list. */
   135     char *pad_l10;              /* ---- */
   136     struct _xmwindow *pad_l11;  /* ---- */
   137 } XMPane;
   138 
   139 typedef struct _xmselect {
   140     struct _xmselect *next;     /* Next obj pointer (for emacs_insque). */
   141     struct _xmselect *prev;     /* Prev obj pointer (for emacs_insque). */
   142     XMWType type;               /* Type of window. */
   143     Window window;              /* X Window Id. */
   144     Window parent;              /* X Window id of parent window. */
   145     int window_x;               /* Window upper left X coordinate. */
   146     int window_y;               /* Window upper left y coordinate. */
   147     int window_w;               /* Window width. */
   148     int window_h;               /* Window height. */
   149     int active;                 /* Window active? */
   150     int activated;              /* Window activated? */
   151     int serial;                 /* -- Selection serial number. */
   152     char *label;                /* -- Selection label. */
   153     int label_width;            /* -- Selection label width in pixels. */
   154     int label_length;           /* -- Selection label length in chars. */
   155     int label_x;                /* -- Selection label X offset. */
   156     int label_y;                /* -- Selection label Y offset. */
   157     int pad_l7;                 /* ---- */
   158     int pad_l8;                 /* ---- */
   159     struct _xmwindow *pad_l9;   /* ---- */
   160     char *data;                 /* -- Selection data pointer. */
   161     struct _xmpane *parent_p;   /* -- Selection parent pane structure. */
   162     char const *help_string;    /* Help string or null.  */
   163 } XMSelect;
   164 
   165 
   166 /*
   167  * Define the XMStyle datatype.
   168  *
   169  * Menu presentation style information.
   170  *
   171  */
   172 typedef enum _xmstyle {
   173     LEFT,                       /* Left oriented object. */
   174     RIGHT,                      /* Right oriented object. */
   175     CENTER                      /* Center oriented object. */
   176 } XMStyle;
   177 
   178 
   179 /*
   180  * Define the XMMode datatype.
   181  *
   182  * Menu presentation mode information.
   183  *
   184  */
   185 typedef enum _xmmode {
   186     BOX,                        /* BOXed graphic rendition. */
   187     INVERT                      /* INVERTed graphic rendition. */
   188 } XMMode;
   189 
   190 
   191 /*
   192  * Define the XMenu datatype.
   193  *
   194  * All dimensions are in pixels unless otherwise noted.
   195  */
   196 typedef struct _xmenu {
   197     /* -------------------- Menu data -------------------- */
   198     XMStyle menu_style;         /* Menu display style. */
   199     XMMode menu_mode;           /* Menu display mode. */
   200     int freeze;                 /* Freeze server mode? */
   201     int aeq;                    /* Asynchronous Event Queuing mode? */
   202     int recompute;              /* Recompute menu dependencies? */
   203     Window parent;              /* Menu's parent window. */
   204     int width;                  /* Overall menu width. */
   205     int height;                 /* Overall menu height. */
   206     int x_pos;                  /* Overall menu origin. */
   207     int y_pos;                  /* Overall menu origin. */
   208     Cursor mouse_cursor;        /* Mouse cursor raster. */
   209     XAssocTable *assoc_tab;     /* XMWindow association table. */
   210     XMPane *p_list;             /* List of XMPanes. */
   211     /* -------------------- Pane window data -------------------- */
   212     XMStyle p_style;            /* Pane display style. */
   213     int p_events;               /* Pane window X events. */
   214     XFontStruct *p_fnt_info;    /* Flag font info structure. */
   215     GC pane_GC;                 /* Pane graphics context. */
   216     int p_fnt_pad;              /* Fixed flag font padding in pixels. */
   217     double p_spread;            /* Pane spread in flag height fractions. */
   218     int p_bdr_width;            /* Pane border width. */
   219     int flag_height;            /* Flag height. */
   220     int p_width;                /* Menu pane width. */
   221     int p_height;               /* Menu pane height. */
   222     int p_x_off;                /* Pane window X offset. */
   223     int p_y_off;                /* Pane window Y offset. */
   224     int p_count;                /* Number of panes per menu. */
   225     /* -------------------- Selection window data -------------------- */
   226     XMStyle s_style;            /* Selection display style. */
   227     int s_events;               /* Selection window X events. */
   228     XFontStruct *s_fnt_info;    /* Body font info structure. */
   229     int s_fnt_pad;              /* Fixed body font padding in pixels. */
   230     double s_spread;            /* Select spread in line height fractions. */
   231     int s_bdr_width;            /* Select border width. */
   232     int s_width;                /* Selection window width. */
   233     int s_height;               /* Selection window height. */
   234     int s_x_off;                /* Selection window X offset. */
   235     int s_y_off;                /* Selection window Y offset. */
   236     int s_count;                /* Maximum number of selections per pane. */
   237     GC normal_select_GC;        /* GC used for inactive selections. */
   238     GC inverse_select_GC;       /* GC used for active (current) selection. */
   239     GC inact_GC;                /* GC used for inactive selections and */
   240                                 /* panes headers. */
   241     /* -------------------- Color data -------------------- */
   242     unsigned long p_bdr_color;  /* Color of pane border pixmap. */
   243     unsigned long s_bdr_color;  /* Color of selection border pixmap. */
   244     unsigned long p_frg_color;  /* Color of pane foreground pixmap. */
   245     unsigned long s_frg_color;  /* Color of selection pixmap. */
   246     unsigned long bkgnd_color;  /* Color of menu background pixmap. */
   247     /* -------------------- Pixmap data -------------------- */
   248     Pixmap p_bdr_pixmap;        /* Pane border pixmap. */
   249     Pixmap s_bdr_pixmap;        /* Selection border pixmap. */
   250     Pixmap p_frg_pixmap;        /* Pane foreground pixmap. */
   251     Pixmap s_frg_pixmap;        /* Selection foreground pixmap. */
   252     Pixmap bkgnd_pixmap;        /* Menu background pixmap. */
   253     Pixmap inact_pixmap;        /* Menu inactive pixmap. */
   254 } XMenu;
   255 
   256 typedef void (*Wait_func)(void*);
   257 
   258 /* Function for translating GenericEvents.  It is should call
   259    XPutBackEvent on an equivalent artificial core event on any
   260    function it wants to translate.  */
   261 typedef void (*Translate_func)(XEvent *);
   262 
   263 /*
   264  * XMenu library routine declarations.
   265  */
   266 XMenu *XMenuCreate(Display *display, Window parent, char const *def_env);
   267 int XMenuAddPane(Display *display, XMenu *menu, char const *label, int active);
   268 int XMenuAddSelection(Display *display, XMenu *menu, int p_num, char *data, char *label, int active, char const *help);
   269 int XMenuInsertPane(XMenu *menu, int p_num, char *label, int active);
   270 int XMenuInsertSelection(XMenu *menu, int p_num, int s_num, char *data, char *label, int active);
   271 int XMenuFindPane(XMenu *menu, char *label);
   272 int XMenuFindSelection(XMenu *menu, int p_num, char *label);
   273 int XMenuChangePane(XMenu *menu, int p_num, char *label);
   274 int XMenuChangeSelection(Display *display, XMenu *menu, int p_num, int s_num, char *data, int data_sw, char *label, int label_sw);
   275 int XMenuSetPane(XMenu *menu, int p_num, int active);
   276 int XMenuSetSelection(XMenu *menu, int p_num, int s_num, int active);
   277 int XMenuRecompute(Display *display, XMenu *menu);
   278 void XMenuEventHandler(int (*handler) (XEvent *));
   279 int XMenuLocate(Display *display, XMenu *menu, int p_num, int s_num, int x_pos, int y_pos, int *ul_x, int *ul_y, int *width, int *height);
   280 void XMenuSetFreeze(XMenu *menu, int freeze);
   281 void XMenuActivateSetWaitFunction(Wait_func func, void *data);
   282 void XMenuActivateSetTranslateFunction(Translate_func func);
   283 int XMenuActivate(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, unsigned int event_mask, char **data, void (*help_callback) (char const *, int, int));
   284 char *XMenuPost(Display *display, XMenu *menu, int *p_num, int *s_num, int x_pos, int y_pos, int event_mask);
   285 int XMenuDeletePane(Display *display, XMenu *menu, int p_num);
   286 int XMenuDeleteSelection(Display *display, XMenu *menu, int p_num, int s_num);
   287 void XMenuDestroy(Display *display, XMenu *menu);
   288 char const *XMenuError(void);
   289 void XMenuSetAEQ(XMenu *menu, int aeq);
   290 
   291 #endif
   292 /* Don't add after this point. */

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