[comp.windows.x] Problem with HP menu widgets

greg@ait.trl.oz (Greg Aumann) (11/22/89)

I am having some trouble trying to use the Xhp menu widgets.  I am new
to X and widgets so it is probably something simple.  I have taken the
example menu program from section 4.5 of the hp widgets documentation.
It works fine, the menu is posted by <Btn1Down> and the item is
selected by <Btn3Down>.  Below is a modified version of the program to
try and implement a drag style of menu.  The menu is posted but nothing
can be selected using any button, up or down.  But the only mod has
been to change the post and select events.  If I try to implement a
double click menu by changing the post and select to <Btn3Down> then
only the outline of the menu appears and then vanishes straight away.
At the end of section 4.2.1 of the hp documentation it says that drag
and double click style menus can be implemented by changing the post
and select button actions.  I would be grateful for any help.

I am using X11R3 on a SUN 3/50 running SUNOS 4.0 and OpenLook 1.0beta2.
The widgets were obtained from expo.lcs.mit.edu about 6 weeks ago.

Version Information
Some RCS ids from Xlib.h and Intrinsic.h:
/* $XConsortium: Xlib.h,v 11.150 88/10/04 17:57:37 jim Exp $ */
* $XConsortium: Intrinsic.h,v 1.88 88/10/18 10:41:40 swick Exp $
* $oHeader: Intrinsic.h,v 1.10 88/09/01 10:33:34 asente Exp $

part of README.R3 from Xhp set
Patches applied to this (relative to the original R3 distribution)

	Xhp.patch.works - Martin Friedmann's original patch
	Xhp.patch.works.ptch[12] - John Carlson's fixes
	An privately communicated fix by Martin Friedmann
	
	- moraes@csri.toronto.edu (Mark Moraes)

Greg Aumann
-----------
Artificial Intelligence Systems         ACSnet:    greg@trlamct.trl.oz
Telecom Research Laboratories           Internet:  greg@trlamct.trl.oz.au
Melbourne, AUSTRALIA                    Voice:     +61 3 541 6222

----------------------------cut here--------------------------------------
#! /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 shell archive."
# Contents:  hpmenu.c
# Wrapped by greg@brainiac on Wed Nov 22 13:17:31 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'hpmenu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'hpmenu.c'\"
else
echo shar: Extracting \"'hpmenu.c'\" \(6649 characters\)
sed "s/^X//" >'hpmenu.c' <<'END_OF_FILE'
X#include <X11/Xlib.h>
X#include <X11/IntrinsicP.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xatom.h>
X#include <X11/StringDefs.h>
X#include <X11/Label.h>
X#include <X11/Shell.h>
X#include <Xw/Xw.h>
X#include <Xw/XwP.h>
X#include <Xw/MenuBtn.h>
X#include <Xw/Cascade.h>
X#include <Xw/PopupMgr.h>
X#include <Xw/BBoard.h>
XWidget toplevel, bboard;
XWidget mmgrshell, mmgr;
XWidget paneshellA, paneshellB, paneshellC;
XWidget menupaneA, menupaneB, menupaneC;
XWidget buttona1;
XWidget buttonb1, buttonb2, buttonb3;
XWidget buttonc1, buttonc2, buttonc3;
X
X/****** Widget & Children ArgLists ******/
Xstatic Arg toplevelArgs [] = {
X   {XtNallowShellResize, (XtArgVal) True}
X};
Xstatic Arg bboardArgs [] = {
X   {XtNwidth, (XtArgVal) 200},
X   {XtNheight, (XtArgVal) 300}
X};
X
X/****** Menu Manager ArgLists ******/
X
Xstatic Arg menumgrArgs [] = {
X   {XtNassociateChildren, (XtArgVal) True},
X   {XtNstickyMenus, (XtArgVal) True},
X   {XtNmenuPost, (XtArgVal) "<Btn3Down>"},
X   {XtNmenuSelect, (XtArgVal) "<Btn3Up>"},
X};
X
X
X/****** Menu Pane ArgLists ******/
X
Xstatic Arg menupaneAArgs [] = {
X   {XtNattachTo, (XtArgVal) "mmgr"}
X};
Xstatic Arg menupaneBArgs [] = {
X   {XtNattachTo, (XtArgVal) "more"}
X};
Xstatic Arg menupaneCArgs [] = {
X   {XtNattachTo, (XtArgVal) "stillmore"}
X};
X
X/****** Menu Buttons (pane A) ArgLists ******/
Xstatic Arg buttona1Args [] = {
X   {XtNlabel, (XtArgVal) "More"},
X};
X
X/****** Menu Buttons (pane B) ArgLists ******/
Xstatic Arg buttonb1Args [] = {
X   {XtNlabel, (XtArgVal) "Hello"},
X};
Xstatic Arg buttonb2Args [] = {
X   {XtNlabel, (XtArgVal) "GoodBye"},
X};
Xstatic Arg buttonb3Args [] = {
X   {XtNlabel, (XtArgVal) "Still More"},
X};
X
X/****** Menu Buttons (pane C) ArgLists ******/
Xstatic Arg buttonc1Args [] = {
X   {XtNlabel, (XtArgVal) "Boy"},
X};
Xstatic Arg buttonc2Args [] = {
X   {XtNlabel, (XtArgVal) "Girl"},
X};
Xstatic Arg buttonc3Args [] = {
X   {XtNlabel, (XtArgVal) "??"},
X};
X
X/*******************************/
Xvoid Hello()
X{
X   printf ("Hello!!\n");
X}
X/*******************************/
Xvoid Goodbye()
X{
X   printf ("Goodbye!!\n");
X}
X/*******************************/
Xvoid Boy()
X{
X   printf ("Boy!!\n");
X}
X/*******************************/
Xvoid Girl()
X{
X   printf ("Girl!!\n");
X}
X/*******************************/
X
X
Xvoid Question()
X{
X   printf ("??\n");
X}
X/*******************************/
X
Xvoid
Xmain(argc, argv)
X    int argc;
X    char **argv;
X{
X   Widget children[20];
X   /*******************************/
X   /* Create the top level widget */
X   /*******************************/
X   toplevel = XtInitialize (argv[0], "menusample", NULL, 0, &argc, argv);
X   XtSetValues (toplevel, toplevelArgs, XtNumber(toplevelArgs));
X
X   /*******************************************/
X   /* A bulletin board will be our primary widget */
X   /*******************************************/
X   bboard = XtCreateManagedWidget("bboard", XwbulletinWidgetClass, toplevel,
X                                bboardArgs, XtNumber(bboardArgs));
X
X   /*************************/
X   /* Create a menu manager */
X   /*************************/
X   mmgrshell = XtCreatePopupShell("mgrshell", shellWidgetClass,
X                                bboard, NULL, 0);
X   mmgr = XtCreateManagedWidget("mmgr", XwpopupmgrWidgetClass,
X                                 mmgrshell, menumgrArgs, XtNumber(menumgrArgs));
X
X   /**********************************************************************/
X   /* Create 3 menu panes, which will be used to build the menu hierarchy */
X   /**********************************************************************/
X   paneshellA = XtCreatePopupShell("paneshellA", shellWidgetClass, mmgr,
X                                   NULL, 0);
X   menupaneA = XtCreateManagedWidget("menupaneA", XwcascadeWidgetClass,
X                                   paneshellA, menupaneAArgs,
X                                   XtNumber(menupaneAArgs));
X   paneshellB = XtCreatePopupShell("paneshellB", shellWidgetClass, mmgr,
X                                   NULL, 0);
X   menupaneB = XtCreateManagedWidget("menupaneB", XwcascadeWidgetClass,
X                                   paneshellB, menupaneBArgs,
X                                   XtNumber(menupaneBArgs));
X   paneshellC = XtCreatePopupShell("paneshellC", shellWidgetClass, mmgr,
X                                   NULL, 0);
X   menupaneC = XtCreateManagedWidget("menupaneC", XwcascadeWidgetClass,
X                                   paneshellC, menupaneCArgs,
X                                   XtNumber(menupaneCArgs));
X
X   /*****************************************/
X   /* Create the menu buttons for menu pane A */
X   /*****************************************/
X   buttona1 = XtCreateManagedWidget ("more", XwmenubuttonWidgetClass,
X                  menupaneA, buttona1Args, XtNumber (buttona1Args));
X
X   /*****************************************/
X   /* Create the menu buttons for menu pane B */
X   /*****************************************/
X   children[0] = buttonb1 = XtCreateWidget ("hello",
X                  XwmenubuttonWidgetClass, menupaneB, buttonb1Args,
X                  XtNumber (buttonb1Args));
X   children[1] = buttonb2 = XtCreateWidget ("goodbye",
X                  XwmenubuttonWidgetClass, menupaneB, buttonb2Args,
X                  XtNumber (buttonb2Args));
X   children[2] = buttonb3 = XtCreateWidget ("stillmore",
X                  XwmenubuttonWidgetClass, menupaneB, buttonb3Args,
X                  XtNumber (buttonb3Args));
X   XtManageChildren (children, 3);
X
X
X   /*****************************************/
X   /* Create the menu buttons for menu pane C */
X   /*****************************************/
X   children[0] = buttonc1 = XtCreateWidget ("boy", XwmenubuttonWidgetClass,
X                  menupaneC, buttonc1Args, XtNumber (buttonc1Args));
X   children[1] = buttonc2 = XtCreateWidget ("girl", XwmenubuttonWidgetClass,
X                  menupaneC, buttonc2Args, XtNumber (buttonc2Args));
X   children[2] = buttonc3 = XtCreateWidget ("question",
X                  XwmenubuttonWidgetClass, menupaneC, buttonc3Args,
X                  XtNumber (buttonc3Args));
X   XtManageChildren (children, 3);
X
X   /*******************************/
X   /* Attach all action callbacks */
X   /*******************************/
X   XtAddCallback (buttonb1, XtNselect, Hello, NULL);
X   XtAddCallback (buttonb2, XtNselect, Goodbye, NULL);
X   XtAddCallback (buttonc1, XtNselect, Boy, NULL);
X   XtAddCallback (buttonc2, XtNselect, Girl, NULL);
X   XtAddCallback (buttonc3, XtNselect, Question, NULL);
X   /********************************************************/
X   /* Realize the widget tree, and start processing events */
X   /********************************************************/
X   XtRealizeWidget (toplevel);
X   XtMainLoop();
X}
X
X
END_OF_FILE
if test 6649 -ne `wc -c <'hpmenu.c'`; then
    echo shar: \"'hpmenu.c'\" unpacked with wrong size!
fi
# end of 'hpmenu.c'
fi
echo shar: End of shell archive.
exit 0
Artificial Intelligence Systems         ACSnet:    greg@trlamct.trl.oz
Telecom Research Laboratories           Internet:  greg@trlamct.trl.oz.au
Melbourne, AUSTRALIA                    Voice:     +61 3 541 6222