From 647d8d54b335ba81c5104642daabfd31cca1b475 Mon Sep 17 00:00:00 2001 From: ramiro Date: Mon, 1 Jun 1998 11:42:30 +0000 Subject: [PATCH] Add XfeMenuCreatePulldownPane() and XfeMenuCreateCascadeItem(). --- cmd/xfe/XfeWidgets/Xfe/MenuUtil.c | 133 ++++++++++++++++++++++++++++++ cmd/xfe/XfeWidgets/Xfe/MenuUtil.h | 29 ++++++- 2 files changed, 161 insertions(+), 1 deletion(-) diff --git a/cmd/xfe/XfeWidgets/Xfe/MenuUtil.c b/cmd/xfe/XfeWidgets/Xfe/MenuUtil.c index b1653465e08..f1cca8ed1c3 100644 --- a/cmd/xfe/XfeWidgets/Xfe/MenuUtil.c +++ b/cmd/xfe/XfeWidgets/Xfe/MenuUtil.c @@ -432,3 +432,136 @@ XfeDestroyMenuWidgetTree(WidgetList children, } } /*----------------------------------------------------------------------*/ +/* extern */ Widget +XfeMenuCreateCascadeItem(Widget menu, + Widget pulldown, + String cascade_name, + WidgetClass cascade_widget_class, + Boolean manage_cascade, + ArgList cascade_av, + Cardinal cascade_ac) +{ + Widget cascade = NULL; + Arg av[5]; + Cardinal ac = 0; + + ArgList joined_av = NULL; + Cardinal joined_ac = 0; + + Boolean free_joined_av = False; + + assert( XfeIsAlive(menu) ); + assert( XmIsRowColumn(menu) ); + + assert( cascade_name != NULL ); + assert( cascade_widget_class != NULL ); + + ac = 0; + + if (_XfeIsAlive(pulldown)) + { + XtSetArg(av[ac],XmNsubMenuId, pulldown); ac++; + } + + if (cascade_ac > 0) + { + assert( cascade_av != NULL ); + + if (ac > 0) + { + joined_av = XtMergeArgLists(cascade_av,cascade_ac,av,ac); + joined_ac = cascade_ac + ac; + + free_joined_av = True; + } + else + { + joined_av = cascade_av; + joined_ac = cascade_ac; + } + } + else + { + joined_av = av; + joined_ac = ac; + } + + /* Create the cascade button */ + cascade = XtCreateWidget(cascade_name, + cascade_widget_class, + menu, + joined_av, + joined_ac); + + /* Manage it if needed */ + if (manage_cascade) + { + XtManageChild(cascade); + } + + /* Cleanup allocated memory if needed */ + if (free_joined_av) + { + XtFree((char *) joined_av); + } + + return cascade; +} +/*----------------------------------------------------------------------*/ +/* extern */ void +XfeMenuCreatePulldownPane(Widget menu, + Widget visual_widget, + String cascade_name, + String pulldown_name, + WidgetClass cascade_widget_class, + Boolean manage_cascade, + ArgList cascade_av, + Cardinal cascade_ac, + Widget * cascade_out, + Widget * pulldown_out) +{ + Widget cascade = NULL; + Widget pulldown = NULL; + + assert( XfeIsAlive(menu) ); + assert( XfeIsAlive(visual_widget) ); + + assert( XmIsRowColumn(menu) ); + + assert( cascade_out != NULL ); + assert( pulldown_out != NULL ); + + assert( cascade_name != NULL ); + assert( cascade_widget_class != NULL ); + + assert( XfeVisual(visual_widget) != NULL ); + assert( XfeDepth(visual_widget) > 0 ); + assert( XfeColormap(visual_widget) != None ); + + + /* Create the pulldown only if a name is given for it */ + if (pulldown_name != NULL) + { + Arg av[5]; + Cardinal ac = 0; + + XtSetArg(av[ac],XmNvisual, XfeVisual(visual_widget)); ac++; + XtSetArg(av[ac],XmNdepth, XfeDepth(visual_widget)); ac++; + XtSetArg(av[ac],XmNcolormap, XfeColormap(visual_widget)); ac++; + + pulldown = XmCreatePulldownMenu(menu,pulldown_name,av,ac); + } + + /* Create the cascade button */ + cascade = XfeMenuCreateCascadeItem(menu, + pulldown, + cascade_name, + cascade_widget_class, + manage_cascade, + cascade_av, + cascade_ac); + + *cascade_out = cascade; + *pulldown_out = pulldown; +} +/*----------------------------------------------------------------------*/ diff --git a/cmd/xfe/XfeWidgets/Xfe/MenuUtil.h b/cmd/xfe/XfeWidgets/Xfe/MenuUtil.h index 48663c672e1..6ac382b2a46 100644 --- a/cmd/xfe/XfeWidgets/Xfe/MenuUtil.h +++ b/cmd/xfe/XfeWidgets/Xfe/MenuUtil.h @@ -108,7 +108,34 @@ XfeDisplaySetUserGrabbed (Widget w, /*----------------------------------------------------------------------*/ /* */ -/* Destruction */ +/* Creation of menu hierarchies */ +/* */ +/*----------------------------------------------------------------------*/ +extern Widget +XfeMenuCreateCascadeItem (Widget menu, + Widget pulldown, + String cascade_name, + WidgetClass cascade_widget_class, + Boolean manage_cascade, + ArgList cascade_av, + Cardinal cascade_ac); +/*----------------------------------------------------------------------*/ +extern void +XfeMenuCreatePulldownPane (Widget menu, + Widget visual_widget, + String cascade_name, + String pulldown_name, + WidgetClass cascade_widget_class, + Boolean manage_cascade, + ArgList cascade_av, + Cardinal cascade_ac, + Widget * cascade_out, + Widget * pulldown_out); +/*----------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------*/ +/* */ +/* Destruction of menu hierarchies */ /* */ /*----------------------------------------------------------------------*/ extern void