jkh@ardent.UUCP (Jordan K. Hubbard) (06/16/88)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 7 (of 17)." # Contents: awm/Gadget.c awm/Icons.c awm/menus/rtlmenu.c # Wrapped by jkh@ardent on Thu Jun 16 00:44:13 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'awm/Gadget.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'awm/Gadget.c'\" else echo shar: Extracting \"'awm/Gadget.c'\" \(9143 characters\) sed "s/^X//" >'awm/Gadget.c' <<'END_OF_FILE' X#ident "%W% %G%" X X#ifndef lint static char *rcsid_Gadget_c = "$Header: Gadget.c,v 1.1 88/06/15 15:26:00 jkh Exp $"; X#endif lint X X#include "X11/copyright.h" X/* X * X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca. X * X * Copyright 1987 by Jordan Hubbard. X * X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Ardent Computer X * Corporation or Jordan Hubbard not be used in advertising or publicity X * pertaining to distribution of the software without specific, written X * prior permission. X * X */ X X/* X * MODIFICATION HISTORY X * X * 001 -- Jortan Hubbard, Ardent Computer. X * Gadget boxes in title bars. X * X */ X X#include "awm.h" X#include "X11/Xutil.h" X extern XContext AwmContext; X AwmInfoPtr IsGadgetWin(w, gnum) Window w; int *gnum; X{ X AwmInfoPtr awi; X int i; X X Entry("IsGadgetWin") X X if (!XFindContext(dpy, w, AwmContext, &awi)) { X Window *wp; X X if (!awi->gadgets) X Leave((AwmInfoPtr)NULL) X for (i = 0; i < NumGadgets; i++) X if (awi->gadgets[i] == w) { X if (gnum) X *gnum = i; X Leave(awi) X } X Leave((AwmInfoPtr)NULL) X } X} X Boolean FPutGadgets(w, mask, button, x, y) Window w; int mask, button, x, y; X{ X Entry("FPutGadgets") X X if (w == RootWindow(dpy, scr)) X Leave(FALSE) X PutGadgets(w); X Leave(TRUE) X} X X/* X * This routine adds and gadgets onto title bar 'w' (though just X * about any window would do, I suppose). X */ int PutGadgets(w) Window w; X{ X int i, dir; X int rx, lx, nx, ny; X XWindowAttributes xwa; X XSetWindowAttributes swa; X unsigned long valuemask; X GadgetDecl *gdec; X AwmInfo *awi; X char *cp; X Boolean change = FALSE; X Binding *bptr; X Window tmp; X X Entry("PutGadgets") X X /* are there any gadgets declared? */ X if (NumGadgets < 1) X Leave_void X /* does this window have a title? */ X if (!(awi = IsTitled(w))) X Leave_void X else X w = awi->title; X /* if the window already has gadgets, this is a reshuffle */ X if (awi->gadgets) X change = TRUE; X else X awi->gadgets = (Window *)malloc(sizeof(Window) * NumGadgets + 1); X if (!awi->gadgets) { X fprintf(stderr, "PutGadgets: Can't allocate memory for gadgets!\n"); X Leave(FALSE) X } X if (XGetWindowAttributes(dpy, w, &xwa) == BadWindow) { X fprintf(stderr, "PutGadgets: Can't get attributes for title window %x\n", X w); X Leave_void X } X /* define some initial positioning information */ X dir = RightGadgetGravity; X lx = 0; X rx = xwa.width; X valuemask = CWBackPixel | CWEventMask; X swa.event_mask = (ButtonPressMask | ButtonReleaseMask | ExposureMask); X for (i = 0; i < NumGadgets && Gadgets[i]; i++) { X XGCValues gcv; X X gdec = Gadgets[i]; X X /* Does gadget have its own gravity? */ X if (gdec->gravity != NoGadgetGravity) X dir = gdec->gravity; X ny = xwa.height - gdec->high; X if (ny <= 0) { X ny = 0; X gdec->high = xwa.height; X } X else X ny = (ny / 2) - 1; X if (ny < 0) X ny = 0; X if (dir == LeftGadgetGravity) { X nx = lx + gdec->offset; X if (nx != 0 && nx == lx) /* not first time through, add pad */ X nx = lx + GadgetPad; X if (nx < 0) X nx = 0; X lx = nx + gdec->wide; X dir = RightGadgetGravity; X } X else if (dir == RightGadgetGravity) { X nx = rx - gdec->wide - gdec->offset; X if (!gdec->offset && rx != xwa.width) X nx -= GadgetPad; X if (nx > xwa.width) X nx = xwa.width - gdec->wide - 1; X rx = nx; X dir = LeftGadgetGravity; X } X else /* Center Gravity */ X nx = ((xwa.width - gdec->wide) / 2) + gdec->offset; X if (change == FALSE || !awi->gadgets[i]) { X swa.background_pixel = gdec->backcolor; X tmp = awi->gadgets[i] = XCreateWindow(dpy, w, nx, ny, gdec->wide, X gdec->high, GadgetBorder, X xwa.depth, xwa.class, X xwa.visual, valuemask, &swa); X if (!tmp) { X fprintf(stderr, "PutGadgets: Unable to create gadget window #%d\n", X i); X Leave_void X } X if (gdec->data) { X Pixmap pix; X X pix = XCreatePixmapFromBitmapData(dpy, tmp, gdec->data, X gdec->wide, gdec->high, X gdec->forecolor, gdec->backcolor, X xwa.depth); X if (!pix) { X fprintf(stderr, "PutGadgets: Unable to create pixmap for #%d\n", X i); X fprintf(stderr, "Using grey...\n"); X pix = GrayPixmap; X } X XSetWindowBackgroundPixmap(dpy, tmp, pix); X XFreePixmap(dpy, pix); X } X XMapWindow(dpy, tmp); X XSaveContext(dpy, tmp, AwmContext, awi); X } X else X XMoveWindow(dpy, awi->gadgets[i], nx, ny); X } X if (change == FALSE) /* make sure the window array is null terminated */ X awi->gadgets[i] = (Window)NULL; X PaintGadgets(w); X Leave_void X} X int FreeGadget(n) int n; X{ X Entry("FreeGadget") X X if (Gadgets[n]->data) X XFree(Gadgets[n]->data); X if (Gadgets[n]->name) X free(Gadgets[n]->name); X /* They tell me that this is not necessary for read-only cells. True? X if (Gadgets[n]->forecolor) X XFreeColors(dpy, DefaultColormap(dpy, scr), X &(Gadgets[n]->forecolor), 1, AllPlanes); X if (Gadgets[n]->backcolor) X XFreeColors(dpy, DefaultColormap(dpy, scr), X &(Gadgets[n]->backcolor), 1, AllPlanes); X */ /* color free's commented out */ X} X int CheckGadgets() X{ X int i, status = 0; X X Entry("CheckGadgets") X X for (i = 0; i < NumGadgets; i++) X if (!Gadgets[i]) { X fprintf(stderr, "awm: Gadget #%d is not declared!\n", X i); X fprintf(stderr, "All gadgets from 0 to %d must be declared.\n", X NumGadgets - 1); X status = 1; X } X Leave(status) X} X Boolean ResetGadgets() X{ X int i; X X Entry("ResetGadgets") X X for (i = 0; i < NumGadgets; i++) { X FreeGadget(i); X free(Gadgets[i]); X Gadgets[i] = 0; X } X NumGadgets = 0; X} X Boolean FDestroyGadgets(w, mask, button, x, y) Window w; int mask, button, x, y; X{ X Entry("FDestroyGadgets") X X if (w == RootWindow(dpy, scr)) X Leave(FALSE) X DestroyGadgets(w); X Leave(TRUE) X} X int DestroyGadgets(w) Window w; X{ X int i; X AwmInfoPtr awi; X X Entry("DestroyGadgets") X X if (!(awi = IsTitled(w))) X Leave_void X if (!awi->gadgets) X Leave_void X for (i = 0; i < NumGadgets && Gadgets[i]; i++) { X XDeleteContext(dpy, awi->gadgets[i], AwmContext); X XDestroyWindow(dpy, awi->gadgets[i]); X } X free(awi->gadgets); X awi->gadgets = 0; X Leave_void X} X int PaintGadgets(w) Window w; X{ X int i, y, x = 0; X AwmInfoPtr awi; X GadgetDecl *gdec; X X Entry("PaintGadgets") X X if (!(awi = IsTitled(w))) X Leave_void X if (!awi->gadgets) X Leave_void X for (i = 0; i < NumGadgets && Gadgets[i]; i++) { X gdec = Gadgets[i]; X if (!gdec->data) { X XGCValues gcv; X X gcv.font = gdec->fontInfo->fid; X gcv.foreground = gdec->forecolor; X gcv.background = gdec->backcolor; X XChangeGC(dpy, awi->winGC, (GCFont | GCForeground | GCBackground), X &gcv); X if (strlen(gdec->name) == 1) { /* it's a glyph (we think) */ X XFontStruct *real_font; X XCharStruct char_info; X int char_number, index, byte1, byte2; X X real_font = gdec->fontInfo; X char_number = gdec->name[0]; X char_info = real_font->max_bounds; X index = char_number; X X if (real_font->per_char) { X if (!real_font->min_byte1 && !real_font->max_byte1) { X if (char_number < real_font->min_char_or_byte2 || X char_number > real_font->max_char_or_byte2) X index = real_font->default_char; X index -= real_font->min_char_or_byte2; X } else { X byte2 = index & 0xff; X byte1 = (index>>8) & 0xff; X if (byte1 < real_font->min_byte1 || X byte1 > real_font->max_byte1 || X byte2 < real_font->min_char_or_byte2 || X byte2 > real_font->max_char_or_byte2) { X byte2 = real_font->default_char & 0xff; X byte1 = (real_font->default_char>>8)&0xff; X } X byte1 -= real_font->min_byte1; X byte2 -= real_font->min_char_or_byte2; X index = byte1 * (real_font->max_char_or_byte2 - X real_font->min_char_or_byte2 + 1) + X byte2; X } X char_info = real_font->per_char[index]; X } X x = 0 - char_info.lbearing; X y = char_info.ascent; X } X else { X y = (gdec->high + (gdec->fontInfo->max_bounds.ascent - X gdec->fontInfo->max_bounds.descent)) / 2; X x = 0; X } X XDrawString(dpy, awi->gadgets[i], awi->winGC, x, X y, gdec->name, strlen(gdec->name)); X } X } X Leave(0) X} END_OF_FILE if test 9143 -ne `wc -c <'awm/Gadget.c'`; then echo shar: \"'awm/Gadget.c'\" unpacked with wrong size! fi # end of 'awm/Gadget.c' fi if test -f 'awm/Icons.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'awm/Icons.c'\" else echo shar: Extracting \"'awm/Icons.c'\" \(10358 characters\) sed "s/^X//" >'awm/Icons.c' <<'END_OF_FILE' X#ident "%W% %G%" X X#ifndef lint static char *rcsid_Iconify_c = "$Header: Iconify.c,v 1.1 88/06/15 15:24:56 jkh Exp $"; X#endif lint X X#include "X11/copyright.h" X/* X * X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca. X * X * Copyright 1987 by Jordan Hubbard. X * X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Ardent Computer X * Corporation or Jordan Hubbard not be used in advertising or publicity X * pertaining to distribution of the software without specific, written X * prior permission. X * X */ X X/* X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Digital Equipment X * Corporation not be used in advertising or publicity pertaining to X * distribution of the software without specific, written prior permission. X * X * X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X * SOFTWARE. X */ X X X X/* X * MODIFICATION HISTORY X * X * 000 -- L. Guarino Reid, DEC Ultrix Engineering Group X * 001 -- Jordan Hubbard, Ardent Computer X * Many modifications for titled windows. X */ X X#include "awm.h" X#include "X11/Xutil.h" X extern XContext AwmContext; X X/* the client should pass us a bitmap (single-plane pixmap with background=0 X * and foreground = 1). It is our responsibility to convert it to a pixmap X * of the appropriate depth for a window tile and also color it with the X * appropriate background and foreground pixels. X * X * we'll use the (global) IconGC for the fore/background pixels. X */ X static Pixmap MakePixmapFromBitmap( bitmap, clipmask, width_return, height_return ) Pixmap bitmap, clipmask; unsigned int *width_return, *height_return; X{ X Pixmap tile; X Window junkW; X int junk, width, height; X GC iGC; X XGCValues gcv; X X Entry("MakePixmapFromBitmap") X X if (!XGetGeometry( dpy, bitmap, &junkW, &junk, &junk, X &width, &height, &junk, &junk )) { X Warning( "client passed invalid pixmap for icon." ); X Leave( NULL ) X } X tile = XCreatePixmap( dpy, RootWindow(dpy, scr), width, height, X DefaultDepth(dpy, scr) ); X if (clipmask) X XSetClipMask(dpy, IconGC, clipmask); X gcv.foreground = ITextForeground; X gcv.background = ITextBackground; X iGC = XCreateGC(dpy, RootWindow(dpy, scr), (GCForeground | GCBackground), X &gcv); X XCopyPlane( dpy, bitmap, tile, iGC, 0, 0, width, height, 0, 0, 1 ); X XFreeGC(dpy, iGC); X if (width_return) X *width_return = width; X if (height_return) X *height_return = height; X Leave(tile) X} X char *GetIconName(window) Window window; X{ X char *name; X Status status; X long len, after; X Atom a_type; X int a_form; X X Entry("GetIconName") X X status = XGetWindowProperty(dpy, window, XA_WM_ICON_NAME, 0, 256, X False, XA_STRING, &a_type, &a_form, &len, &after, X &name); X X if (status != Success) { X status = XGetWindowProperty(dpy, window, XA_WM_NAME, 0, NAME_LEN, X False, XA_STRING, &a_type, &a_form, &len, X &after, &name); X if (status != Success) X Leave((char *)NULL) X } X if (a_form == 0) /* we have no bananas */ X Leave((char *)NULL) X if (a_form != 8) { X Warning("Window has icon_name in wrong format"); X if (name) X free(name); X Leave((char *)NULL) X } X if (len > NAME_LEN) { X Warning("Window has icon_name greater than maximum length"); X len = NAME_LEN; X } X if (!len) X Leave((char *)NULL) X name[len] = 0; X Leave(name) X} X Boolean IsIcon(icon, win) Window icon; Window *win; X{ X AwmInfoPtr awi; X X Entry("IsIcon") X X if (win) X *win = 0; X awi = GetAwmInfo(icon); X if (!awi) X Leave(FALSE) X if (awi->icon == icon) { X if (win) X *win = awi->client; X Leave(TRUE) X } X else if (awi->client == icon || awi->frame == icon) { X if (win) X *win = awi->icon; X Leave(FALSE) X } X Leave(FALSE) X} X RemoveIcon(window) Window window; X{ X AwmInfoPtr awi; X X Entry("RemoveIcon") X X if ((awi = GetAwmInfo(window)) != NULL) { X XDeleteContext(dpy, awi->icon, AwmContext); X if (awi->own) { X XDestroyWindow(dpy, awi->icon); X if (awi->iconPixmap != IBackPixmap) X XFreePixmap(dpy, awi->iconPixmap); X } X awi->icon = 0; X awi->state = WINDOW; X } X Leave_void X} X GetDefaultSize(window, icon_w, icon_h) Window window; int *icon_w, *icon_h; X{ X char *name; /* Event window name. */ X X Entry("GetDefaultSize") X X /* X * Determine the size of the icon window. X */ X name = GetIconName(window); X *icon_h = IFontInfo->ascent + IFontInfo->descent; X if (name) { X *icon_w = XTextWidth(IFontInfo, name, strlen(name)); X if (*icon_w == 0) X *icon_w = *icon_h; X } X else X *icon_w = *icon_h; X Leave_void X} X Window MakeIcon(window, x, y, mousePositioned) Window window; /* associated window. */ int x, y; /* Event mouse position. */ Boolean mousePositioned; X{ X Window icon; /* icon window. */ X int icon_x, icon_y; /* Icon U. L. X and Y coordinates. */ X int icon_w, icon_h; /* Icon width and height. */ X int icon_bdr; /* Icon border width. */ X int mask; /* Icon event mask */ X int depth; /* for XGetGeometry */ X XSetWindowAttributes iconValues; /* for icon window creation */ X unsigned long iconValues_mask; /* for above */ X XWMHints *wmhints; /* see if icon position provided */ X XWMHints *XGetWMHints(); X Pixmap clip = 0; X Window AddIcon(); X X Entry("MakeIcon") X X iconValues.background_pixmap = IBackPixmap; X mask = (ExposureMask | StructureNotifyMask | KeyPressMask); X /* X * Process window manager hints. X */ X if (wmhints = XGetWMHints(dpy, window)) { X if (wmhints->flags & IconWindowHint) X Leave(AddIcon(window, wmhints->icon_window, FALSE, X (StructureNotifyMask), (Pixmap)NULL)) X else if (wmhints->flags & IconPixmapHint) { X if (wmhints->flags & IconMaskHint) X clip = wmhints->icon_mask; X iconValues.background_pixmap = X MakePixmapFromBitmap(wmhints->icon_pixmap, clip, X &icon_w, &icon_h ); X if (iconValues.background_pixmap) X mask = (StructureNotifyMask); X else { X iconValues.background_pixmap = IBackPixmap; X wmhints->flags &= ~IconPixmapHint; X GetDefaultSize(window, &icon_w, &icon_h); X } X } X else GetDefaultSize(window, &icon_w, &icon_h); X } X else GetDefaultSize(window, &icon_w, &icon_h); X X /* X * Fix up sizes by padding. X */ X if (!wmhints || !(wmhints->flags & (IconPixmapHint|IconWindowHint))) { X icon_w += (HIconPad << 1); X icon_h += (VIconPad << 1); X } X X /* X * Set the icon border attributes. X */ X if (!wmhints || !(wmhints->flags & IconWindowHint)) { X icon_bdr = IBorderWidth; X iconValues.border_pixel = IBorder; X } X X if (wmhints && (wmhints->flags & IconPositionHint)) { X icon_x = wmhints->icon_x; X icon_y = wmhints->icon_y; X } else { X if (mousePositioned) { X /* X * Determine the coordinates of the icon window; X * normalize so that we don't lose the icon off the X * edge of the screen. X */ X icon_x = x - (icon_w >> 1) + 1; X if (icon_x < 0) icon_x = 0; X icon_y = y - (icon_h >> 1) + 1; X if (icon_y < 0) icon_y = 0; X if ((icon_x - 1 + icon_w + (icon_bdr << 1)) > ScreenWidth) { X icon_x = ScreenWidth - icon_w - (icon_bdr << 1) + 1; X } X if ((icon_y - 1 + icon_h + (icon_bdr << 1)) > ScreenHeight) { X icon_y = ScreenHeight - icon_h - (icon_bdr << 1) + 1; X } X } X else { X icon_x = x + (icon_w >> 1); X icon_y = y + (icon_y >> 1); X } X X } X X /* X * Create the icon window. X */ X iconValues_mask = CWBorderPixel | CWBackPixmap; X /* X * Here we assume that if they want save unders, they'll also want X * backing store on the icons. Perhaps a dangerous assumption, but X * one we have to make at this point. X */ X if (SaveUnder) { X iconValues.backing_store = WhenMapped; X iconValues_mask |= CWBackingStore; X } X Leave(AddIcon(window, X XCreateWindow( X dpy, RootWindow(dpy, scr), X icon_x, icon_y, X icon_w, icon_h, X icon_bdr, 0, CopyFromParent, CopyFromParent, X iconValues_mask, &iconValues), X TRUE, mask, iconValues.background_pixmap)) X X} X Window AddIcon(window, icon, own, mask, background) Window window, icon; Boolean own; int mask; Pixmap background; X{ X Binding *bptr; X AwmInfoPtr awi; X X Entry("AddIcon") X X if (icon == NULL) X Leave(NULL) X /* X * Use the text cursor whenever the mouse is in the icon window. X */ X XDefineCursor(dpy, icon, TextCursor); X X /* X * Select "key pressed", "window exposure" and "unmap window" X * events for the icon window. X */ X XSelectInput(dpy, icon, mask); X /* X * Handle any registered grabs for the icon window. X */ X for (bptr = Blist; bptr; bptr = bptr->next) X if (bptr->context & ICON) X Grab(bptr->mask, icon); X awi = GetAwmInfo(window); X awi->icon = icon; X awi->own = own; X awi->iconPixmap = background; X XSaveContext(dpy, icon, AwmContext, awi); X Leave(icon) X} END_OF_FILE if test 10358 -ne `wc -c <'awm/Icons.c'`; then echo shar: \"'awm/Icons.c'\" unpacked with wrong size! fi # end of 'awm/Icons.c' fi if test -f 'awm/menus/rtlmenu.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'awm/menus/rtlmenu.c'\" else echo shar: Extracting \"'awm/menus/rtlmenu.c'\" \(9320 characters\) sed "s/^X//" >'awm/menus/rtlmenu.c' <<'END_OF_FILE' X#ident "%W% %G%" X X#ifndef lint X static char sccs_id[] = "@(#)rtlmenu.c 2.1 12/16/87 Siemens Corporate Research and Support, Inc."; X#endif X X X/* X RTL Menu Package Version 1.0 X by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987 X X rtlmenu.c: interface level for menu package X */ X X#include "X11/copyright.h" X/* X * X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca. X * X * Copyright 1987 by Jordan Hubbard. X * X * X * All Rights Reserved X * X * Permission to use, copy, modify, and distribute this software and its X * documentation for any purpose and without fee is hereby granted, X * provided that the above copyright notice appear in all copies and that X * both that copyright notice and this permission notice appear in X * supporting documentation, and that the name of Ardent Computer X * Corporation or Jordan Hubbard not be used in advertising or publicity X * pertaining to distribution of the software without specific, written X * prior permission. X * X */ X X/* X X Copyright 1987 by X Siemens Corporate Research and Support, Inc., Princeton, New Jersey X X Permission to use, copy, modify, and distribute this software X and its documentation for any purpose and without fee is X hereby granted, provided that the above copyright notice X appear in all copies and that both that copyright notice and X this permission notice appear in supporting documentation, and X that the name of Siemens not be used in advertising or X publicity pertaining to distribution of the software without X specific, written prior permission. Siemens makes no X representations about the suitability of this software for any X purpose. It is provided "as is" without express or implied X warranty. X X */ X X#include <stdio.h> X#include "X11/Xlib.h" X X#include "menu.h" X#include "menu.def.h" X#include "menu.ext.h" X#include "rtlmenu.h" X#include "dbug.h" X extern Display *dpy; extern int scr; X static RTLPoint menu_pos; static int initialized = 0; X void RTLMenu_Initialize (options_mask) MenuOptionsMask options_mask; X{ X Entry("RTLMenu_Initialize") X X if (initialized) X return; X initialized = 1; X InitMenu ("uwm", options_mask); X Leave_void X} X X/* ------------------------------------------------------------ */ RTLMenu RTLMenu_Create() X{ X Entry("RTLMenu_Create") X /* Create a menu with no name, not in inverse video. */ X X Leave((RTLMenu)NewMenu()) X} X X/* ------------------------------------------------------------ */ void RTLMenu_Destroy( menu ) RTLMenu menu; X{ X Entry("RTLMenu_Destroy") X DisposeMenu ((Menu*) menu); X Leave_void X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X pointer RTLMenu_Data( menu, item ) X/*ARGSUSED*/ RTLMenu menu; RTLMenuItem item; X{ X Entry("RTLMenu_Data") X Leave(ItemData((MenuItem*)item)) X} X X/* ------------------------------------------------------------ */ X RTLMenu RTLMenu_Get_Submenu( menu, str ) RTLMenu menu; char *str; X{ X MenuItem *item = MenuItemByName ((Menu*) menu, str); X X Entry("RTLMenu_Get_Submenu") X X if (!ItemIsNull(item)) X Leave((RTLMenu)ItemSubmenu(item)) X Leave(0) X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X X/*ARGSUSED*/ static void RTLMenu_Client_Send( menu, item ) RTLMenu menu; RTLMenuItem item; X{ X Entry("RTLMenu_Client_Send") X X printf ("RTLMenu_Client_Send not yet implemented for X, string = \"%s\"\n", X (char*) item); X Leave_void X} X X/* ------------------------------------------------------------ */ X RTLMenuItem RTLMenu_Append_String( menu, str, strval ) RTLMenu menu; char *str; char *strval; X{ X MenuItem *item = AddMenuItem((Menu*)menu, str); X X Entry("RTLMenu_Append_String") X X ItemCallback(item) = (Callback)RTLMenu_Client_Send; X ItemData(item) = (pointer) strval; X Leave((RTLMenuItem)item) X} X X/* ------------------------------------------------------------ */ X RTLMenuItem RTLMenu_Append_Callback( menu, backproc ) RTLMenu menu; VoidFunc backproc; X{ X MenuItem *item = AddMenuItem((Menu*)menu, ""); X X Entry("RTLMenu_Append_Callback") X X ItemGenerator(item) = (Callback)backproc; X X Leave((RTLMenuItem)item) X} X X/* ------------------------------------------------------------ */ X RTLMenuItem RTLMenu_Append_Call( menu, str, pix, proc, ptrval ) RTLMenu menu; char *str; char *pix; VoidFunc proc; pointer ptrval; X{ X MenuItem *item = AddMenuItem((Menu*)menu, str, pix); X X Entry("RTLMenu_Append_Call") X X ItemCallback(item) = proc; X ItemData(item) = ptrval; X X Leave((RTLMenuItem)item) X} X X/* ------------------------------------------------------------ */ X RTLMenuItem RTLMenu_Append_Checkback( menu, str, pix, checkproc, proc, ptrval ) RTLMenu menu; char *str; /* Menu string */ char *pix; bool (*checkproc) (); /* Boolean function called when menu entry X is about to be displayed. If true, then X the item appears checked; if false, then X it does not */ VoidFunc proc; /* function to be called when the item X is selected */ pointer ptrval; /* data associated with this item */ X{ X MenuItem *item = AddMenuItem((Menu*)menu, str, pix); X X Entry("RTLMenu_Append_Checkback") X X ItemCallback(item) = proc; X ItemData(item) = ptrval; X ItemCheckproc(item) = checkproc; X X Leave((RTLMenuItem)item) X} X/* ------------------------------------------------------------ */ X RTLMenuItem RTLMenu_Append_Submenu( menu, str, pix, submenu ) RTLMenu menu; char *str; char *pix; RTLMenu submenu; X{ X MenuItem *item = AddMenuItem((Menu*)menu, str, pix); X X Entry("RTLMenu_Append_Submenu") X X ItemSubmenu(item) = (Menu*)submenu; X X Leave((RTLMenuItem)item) X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X void RTLMenu_Replace_Data_Keyed_String( menu, data, str ) RTLMenu menu; pointer data; char *str; X{ X MenuItem *item = MenuItemByName((Menu*) menu, str); X X Entry("RTLMenu_Replace_Keyed_String") X X if (!ItemIsNull(item)) X ItemData(item) = data; X Leave_void X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X void RTLMenu_Activate_Entry( menu, item ) RTLMenu menu; RTLMenuItem item; X{ X Entry("RTLMenu_Activate_Entry") X X (void)SetItemDisable((Menu*)menu, (MenuItem*)item, FALSE); X Leave_void X} X X/* ------------------------------------------------------------ */ X void RTLMenu_Inactivate_Entry( menu, item ) RTLMenu menu; RTLMenuItem item; X{ X Entry("RTLMenu_Inactivate_Entry") X X (void)SetItemDisable((Menu*)menu, (MenuItem*)item, TRUE); X Leave_void X} X void RTLMenu_Label_Entry( menu, item ) RTLMenu menu; RTLMenuItem item; X{ X Entry("RTLMenu_Label_Entry") X X (void)SetItemDeaf((Menu*)menu, (MenuItem*)item, TRUE); X Leave_void X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X bool RTLMenu_Has_Data( menu, val ) RTLMenu menu; pointer val; X{ X MenuItem *item = MenuItemByData((Menu*)menu, val); X Entry("RTLMenu_Has_Data") X X Leave(!ItemIsNull(item)) X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X void RTLMenu_Delete_Entries( menu ) RTLMenu menu; X{ X Entry("RTLMenu_Delete_Entries") X X while (DisposeItem((Menu*)menu, MenuItems((Menu*)menu))); X Leave_void X} X X/* ------------------------------------------------------------ */ X void RTLMenu_Delete_String( menu, str ) RTLMenu menu; char *str; X{ X MenuItem *item = MenuItemByName((Menu*) menu, str); X X Entry("RTLMenu_Delete_String"); X X if (!ItemIsNull(item)) X (void) DisposeItem ((Menu*)menu, item); X Leave_void X} X X/* ------------------------------------------------------------ */ X void RTLMenu_Delete_Data( menu, val ) RTLMenu menu; pointer val; X{ X MenuItem *item = MenuItemByData((Menu*)menu, val); X X Entry("RTLMenu_Delete_Data"); X X if (!ItemIsNull(item)) X (void) DisposeItem((Menu*)menu, item); X Leave_void X} X X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */ X X/*ARGSUSED*/ void RTLMenu_Box( menu ) RTLMenu menu; X{ X /* Commented out */ X} X X/* ------------------------------------------------------------ */ X X/*ARGSUSED*/ void RTLMenu_Enter( menu, butnum, buttime, base_window, pos ) RTLMenu menu; int butnum; Time buttime; Window base_window; RTLPoint pos; X{ X MenuItem *selected; X X Entry("RTLMenu_Enter") X X menu_pos = pos; X selected = TrackMenu ((Menu*) menu, menu_pos.x, menu_pos.y, X butnum, base_window, buttime); X if (!ItemIsNull(selected)) X (ItemCallback(selected)) (menu, selected, base_window); X Leave_void X} X/* ------------------------------------------------------------ */ X RTLPoint RTLMenu_Entry_Pos() X{ X Entry("RTLMenu_Entry_Pos") X /* menu_pos is a global static that gets set by the call to */ X /* XQueryPointer that is used by the TrackMenu call. */ X X Leave(menu_pos) X} X X void RTLMenu_Generate_Items(menu, proc) X/* apply VoidFunc proc to each item in the menu, with */ X/* arguments menu and menuItem */ RTLMenu menu; VoidFunc proc; X{ X MenuItem *item; X X Entry("RTLMenu_Generate_Items") X X for (item = MenuItems((Menu*)menu); X !ItemIsNull(item); item = ItemNext(item)) X { X (proc)((RTLMenu)menu, (RTLMenuItem)item); X } X Leave_void X} END_OF_FILE if test 9320 -ne `wc -c <'awm/menus/rtlmenu.c'`; then echo shar: \"'awm/menus/rtlmenu.c'\" unpacked with wrong size! fi # end of 'awm/menus/rtlmenu.c' fi echo shar: End of archive 7 \(of 17\). cp /dev/null ark7isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 17 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0