/* * GlobalMenu.h -- MCDE: the menu bar of the active program in the top bar * * License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. * * The protocol between a program and the top bar (programs/dtbar), all of it * ordinary X11: a selection, properties and client messages. * * _MCDE_BAR_S selection owned by the top bar while it runs. A * program exports its menu bars only then; it watches * the owner's window and shows its own menu bars * again when the bar goes away. * _MCDE_MENU property (UTF8_STRING) on the program's shell * window: its menu bar, as McdeMenuWrite writes it. * _MCDE_ACTIVE_MENU property (WINDOW) on the root window: the shell that * had the focus last. The program sets it on FocusIn; * the bar shows that shell's _MCDE_MENU. * _MCDE_MENU_ACTIVATE client message, bar to shell: l[0] the item (its * line number in _MCDE_MENU), l[1] the time stamp. * _MCDE_MENU_REFRESH client message, bar to shell: write _MCDE_MENU anew * (the bar sends it when the pointer comes to it, so * the menus show sensitivity and toggle states of now). * * The text form is one line per item, the tree given by the depth: * * DEPTH TAB KIND TAB FLAGS TAB MNEMONIC TAB ACCELERATOR TAB LABEL * * KIND is C (cascade), P (push button), T (toggle), S (separator) or L * (label); FLAGS is "-" or some of s (sensitive), x (checked), r (one of a * radio group); MNEMONIC is one character or "-"; ACCELERATOR the text the * menu shows ("Ctrl+C") or "-". Tabs and newlines in a label become spaces. * * C99 and POSIX only in the model (McdeMenuModel.c, its test test_menumodel.c); * the X side is lib/DtSvc/DtUtil2/McdeGlobalMenu.c and programs/dtbar. */ #ifndef _Mcde_GlobalMenu_h #define _Mcde_GlobalMenu_h #include #define MCDE_MENU_MAX 512 /* items in one menu bar */ enum McdeMenuKind { MCDE_MENU_CASCADE = 'C', MCDE_MENU_PUSH = 'P', MCDE_MENU_TOGGLE = 'T', MCDE_MENU_SEPARATOR = 'S', MCDE_MENU_LABEL = 'L' }; #define MCDE_MENU_SENSITIVE 0x1 #define MCDE_MENU_CHECKED 0x2 #define MCDE_MENU_RADIO 0x4 typedef struct { int depth; /* 0: in the bar itself */ int kind; /* enum McdeMenuKind */ int flags; /* MCDE_MENU_* */ char mnemonic; /* '\0': none */ char accelerator[32]; /* "" : none */ char label[96]; } McdeMenuItem; /* * Write N items as text into BUF (LEN bytes, NUL-terminated). Returns the * length, or -1 if it does not fit or an item is not valid (a depth that * grows by more than one, an unknown kind). */ extern int McdeMenuWrite(const McdeMenuItem *items, int n, char *buf, size_t len); /* * Read TEXT into ITEMS (at most MAX). Returns the number of items, or -1 if * a line is not of the form above. */ extern int McdeMenuParse(const char *text, McdeMenuItem *items, int max); /* * The end of the subtree of item I: the first item after I whose depth is not * greater than that of I (or N). The menu of a cascade I is I+1 .. end-1, * those of depth items[I].depth + 1 being its own entries. */ extern int McdeMenuEnd(const McdeMenuItem *items, int n, int i); #ifdef _XtIntrinsic_h /* * The program side (lib/DtSvc/DtUtil2/McdeGlobalMenu.c, in libDtSvc). * DtInitialize() calls it; a program that does not call DtInitialize (dtterm) * calls it itself, after XtAppInitialize and before it makes a menu bar. */ extern void _DtMcdeGlobalMenuInitialize(Display *dpy, Widget toplevel); #endif #endif /* _Mcde_GlobalMenu_h */