Commit 187dd659 authored by claes's avatar claes

Popupmenu moved from uil to c

parent ca8d1f10
......@@ -116,15 +116,6 @@ struct s_widgets
of the menu */
Widget edit_togg; /* togg under the function entry
of the menu */
Widget pop_attribute;
Widget pop_subwindow;
Widget pop_getobj ;
Widget pop_delete;
Widget pop_paste;
Widget pop_copy;
Widget pop_cut;
Widget pop_printselect;
Widget pop_helpclass;
Widget con_palette;
Widget node_palette;
Widget nav_palette;
......
......@@ -62,93 +62,6 @@
#define GRE_NORMAL_CURSOR
#if 0
typedef struct {
int Level;
int Sensitive;
char Name[20];
void (*Callback)();
void *CallbackData;
} foe_sMenuItem;
static void foe_popup_unmap_cb( Widget w, foe_ctx foectx,
XmAnyCallbackStruct *data)
{
}
static Widget BuildMenu (
Widget Parent,
foe_sMenuItem *Items,
int x,
int y
)
{
Widget Menu, W;
int i;
WidgetClass Class;
Arg ArgList[5];
foe_sMenuItem *Item;
i = 0;
XtSetArg(ArgList[i], XmNx, x); i++;
XtSetArg(ArgList[i], XmNy, y); i++;
Menu = XmCreatePopupMenu(Parent, "_popup", ArgList, i);
Item = Items;
for ( i = 0; Item->Level != 0 && Item->Level >= Items->Level; i++)
{
Class = xmPushButtonGadgetClass;
W = XtVaCreateManagedWidget( Item->Name,
Class, Menu,
XmNsensitive, (Boolean)(Items->Sensitive == 1),
NULL);
/*
XtAddCallback(W, XmNactivateCallback, Item->Callback, (XtPointer)
Item->CallbackData);
*/
Item++;
}
return Menu;
}
int foe_create_popup( foe_ctx foectx)
{
foe_sMenuItem *menu_items, *item;
int x_pix, y_pix;
menu_items = (foe_sMenuItem *) XtCalloc( 4, sizeof(foe_sMenuItem));
item = menu_items;
item->Level = 1;
item->Sensitive = 1;
strcpy( item->Name, "Copy");
/*
item->Callback = foe_activate_copy;
item->CallbackData = (void *) foectx;
*/
item++;
item->Level = 1;
item->Sensitive = 1;
strcpy( item->Name, "Paste");
/*
item->Callback = foe_activate_copy;
item->CallbackData = (void *) foectx;
*/
item++;
item->Level = 0;
x_pix = 0;
y_pix = 0;
foectx->widgets.popupmenu =
BuildMenu( foectx->grectx->flow_widget, menu_items, x_pix, y_pix);
XtAddCallback( foectx->widgets.popupmenu, XmNunmapCallback,
(XtCallbackProc)foe_popup_unmap_cb, foectx);
XtManageChild (foectx->widgets.popupmenu);
return 1;
}
#endif
/*************************************************************************
*
* Name: foe_gre_setup_window ()
......
......@@ -20,6 +20,11 @@
#include <Xm/Text.h>
#include <Xm/ToggleB.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Xm/RowColumn.h>
#include <Xm/PushBG.h>
#include "wb_ldh.h"
#include "wb_foe_msg.h"
......@@ -35,6 +40,7 @@
#include "wb_foe_api.h"
#include "co_api.h"
#include "pwr_baseclasses.h"
#include "flow_x.h"
#define BEEP putchar( '\7' );
......@@ -2602,78 +2608,6 @@ foectx->widgets.subpane = w ;
XtUninstallTranslations( w);
}
static void foe_create_pop_attribute ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_attribute = w ;
}
static void foe_create_pop_subwindow ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_subwindow = w ;
}
static void foe_create_pop_getobj ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_getobj = w ;
}
static void foe_create_pop_delete ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_delete = w ;
}
static void foe_create_pop_paste ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_paste = w ;
}
static void foe_create_pop_copy ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_copy = w ;
}
static void foe_create_pop_cut ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_cut = w ;
}
static void foe_create_pop_printselect ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_printselect = w ;
}
static void foe_create_pop_helpclass ( w , foectx, data)
Widget w;
foe_ctx foectx;
XmAnyCallbackStruct *data;
{
foectx->widgets.pop_helpclass = w ;
}
static void foe_create_palette_object ( w , foectx, data)
Widget w;
foe_ctx foectx;
......@@ -2963,15 +2897,6 @@ int foe_register_callbacks (
{"foe_yes_popupmsg",(XtPointer)foe_yes_popupmsg},
{"foe_no_popupmsg",(XtPointer)foe_no_popupmsg},
{"foe_cancel_popupmsg",(XtPointer)foe_cancel_popupmsg},
{"foe_create_pop_attribute",(XtPointer)foe_create_pop_attribute},
{"foe_create_pop_subwindow",(XtPointer)foe_create_pop_subwindow},
{"foe_create_pop_getobj",(XtPointer)foe_create_pop_getobj},
{"foe_create_pop_paste",(XtPointer)foe_create_pop_paste},
{"foe_create_pop_copy",(XtPointer)foe_create_pop_copy},
{"foe_create_pop_cut",(XtPointer)foe_create_pop_cut},
{"foe_create_pop_delete",(XtPointer)foe_create_pop_delete},
{"foe_create_pop_printselect",(XtPointer)foe_create_pop_printselect},
{"foe_create_pop_helpclass",(XtPointer)foe_create_pop_helpclass},
{"foe_popdown_pop",(XtPointer)foe_popdown_pop}
};
......@@ -3079,3 +3004,76 @@ static void foe_exit_nosave(
foe_quit( foectx);
}
static void foe_popup_unmap_cb(Widget w, foe_ctx foectx)
{
XtDestroyWidget(w);
}
/*************************************************************************
*
* Name: foe_modify_popup()
*
* Type void
*
* Type Parameter IOGF Description
* foe_ctx foectx I foe context
*
* Description:
* Modifies the popupmenu.
**************************************************************************/
int foe_modify_popup (
foe_ctx foectx,
unsigned long popupmenu_mask
)
{
static char buttontext[][40] = { "ObjectEditor", "SubWindow", "Connect", "Delete",
"Paste", "Copy", "Cut", "PrintSelect", "HelpClass"};
static XtCallbackProc callback[] = { foe_activate_attribute,
foe_activate_subwindow,
foe_activate_getobj,
foe_activate_delete,
foe_activate_paste,
foe_activate_copy,
foe_activate_cut,
foe_activate_printselect,
foe_activate_helpclass};
Widget Menu, w;
int i;
Arg ArgList[5];
XmFontList fontlist;
XFontStruct *font;
XmFontListEntry fontentry;
foectx->popupmenu_mask = popupmenu_mask;
// Set default fontlist
font = XLoadQueryFont( flow_Display(foectx->widgets.pane),
"-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
fontentry = XmFontListEntryCreate( "tag1", XmFONT_IS_FONT, font);
fontlist = XmFontListAppendEntry( NULL, fontentry);
XtFree( (char *)fontentry);
i = 0;
XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
Menu = XmCreatePopupMenu( foectx->widgets.pane, "_popup", ArgList, i);
XtAddCallback( Menu, XmNunmapCallback,
(XtCallbackProc)foe_popup_unmap_cb, foectx);
XmFontListFree( fontlist);
for ( i = 0; i < 9; i++) {
if ( foectx->popupmenu_mask & (1 << i)) {
w = XtVaCreateManagedWidget( buttontext[i], xmPushButtonGadgetClass,
Menu, NULL);
XtAddCallback( w, XmNactivateCallback, (XtCallbackProc) callback[i],
(XtPointer) foectx);
}
}
foectx->widgets.popupmenu = Menu;
return FOE__SUCCESS ;
}
......@@ -2219,16 +2219,6 @@ static foe_ctx foe_create_window(
foe_function_setup ( foectx ) ;
/* SG 10.02.91 popup : Ask DRM to fetch the popup */
if (MrmFetchWidget (s_MrmH,
"edit_popup",
// foectx->grectx->flow_widget,
foectx->widgets.pane,
&foectx->widgets.popupmenu,
&dclass) != MrmSUCCESS)
printf("can't fetch popup\n");
MrmCloseHierarchy(s_MrmH);
if (compiled_translations == NULL)
......@@ -2875,93 +2865,6 @@ static int foe_view_set_entries (
return FOE__SUCCESS ;
}
/*************************************************************************
*
* Name: foe_modify_popup()
*
* Type void
*
* Type Parameter IOGF Description
* foe_ctx foectx I foe context
*
* Description:
* Modifies the popupmenu.
**************************************************************************/
int foe_modify_popup (
foe_ctx foectx,
unsigned long popupmenu_mask
)
{
if ( (foectx->popupmenu_mask & foe_e_popupmenu_attribute) &&
!(popupmenu_mask & foe_e_popupmenu_attribute) )
XtUnmanageChild(foectx->widgets.pop_attribute);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_attribute) &&
(popupmenu_mask & foe_e_popupmenu_attribute) )
XtManageChild(foectx->widgets.pop_attribute);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_subwindow) &&
!(popupmenu_mask & foe_e_popupmenu_subwindow) )
XtUnmanageChild(foectx->widgets.pop_subwindow);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_subwindow) &&
(popupmenu_mask & foe_e_popupmenu_subwindow) )
XtManageChild(foectx->widgets.pop_subwindow);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_connect) &&
!(popupmenu_mask & foe_e_popupmenu_connect) )
XtUnmanageChild(foectx->widgets.pop_getobj);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_connect) &&
(popupmenu_mask & foe_e_popupmenu_connect) )
XtManageChild(foectx->widgets.pop_getobj);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_delete) &&
!(popupmenu_mask & foe_e_popupmenu_delete) )
XtUnmanageChild(foectx->widgets.pop_delete);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_delete) &&
(popupmenu_mask & foe_e_popupmenu_delete) )
XtManageChild(foectx->widgets.pop_delete);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_paste) &&
!(popupmenu_mask & foe_e_popupmenu_paste) )
XtUnmanageChild(foectx->widgets.pop_paste);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_paste) &&
(popupmenu_mask & foe_e_popupmenu_paste) )
XtManageChild(foectx->widgets.pop_paste);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_copy) &&
!(popupmenu_mask & foe_e_popupmenu_copy) )
XtUnmanageChild(foectx->widgets.pop_copy);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_copy) &&
(popupmenu_mask & foe_e_popupmenu_copy) )
XtManageChild(foectx->widgets.pop_copy);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_cut) &&
!(popupmenu_mask & foe_e_popupmenu_cut) )
XtUnmanageChild(foectx->widgets.pop_cut);
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_cut) &&
(popupmenu_mask & foe_e_popupmenu_cut) )
XtManageChild(foectx->widgets.pop_cut);
if ( (foectx->popupmenu_mask & foe_e_popupmenu_printselect ) &&
!(popupmenu_mask & foe_e_popupmenu_printselect ) )
XtUnmanageChild(foectx->widgets.pop_printselect );
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_printselect ) &&
(popupmenu_mask & foe_e_popupmenu_printselect ) )
XtManageChild(foectx->widgets.pop_printselect );
if ( (foectx->popupmenu_mask & foe_e_popupmenu_helpclass ) &&
!(popupmenu_mask & foe_e_popupmenu_helpclass ) )
XtUnmanageChild(foectx->widgets.pop_helpclass );
else if ( !(foectx->popupmenu_mask & foe_e_popupmenu_helpclass ) &&
(popupmenu_mask & foe_e_popupmenu_helpclass ) )
XtManageChild(foectx->widgets.pop_helpclass );
foectx->popupmenu_mask = popupmenu_mask;
return FOE__SUCCESS ;
}
/*************************************************************************
......
......@@ -2272,18 +2272,16 @@ int gre_flow_cb( FlowCtx *ctx, flow_tEvent event)
current_node = 0;
/* If there is no selected object, select current object */
if ( grectx->popupmenu_mode == GRE_POPUPMENUMODE_OBJECT)
{
flow_GetSelectList( ctx, &select_list, &select_cnt);
if ( !select_cnt)
{
if ( !select_cnt) {
if ( event->object.object_type == flow_eObjectType_Node)
/* Get the current object */
flow_GetUserData( event->object.object, (void **)&current_node);
}
}
if ( current_node || select_cnt == 1)
grectx->popupmenu_mode = GRE_POPUPMENUMODE_OBJECT;
else
grectx->popupmenu_mode = GRE_POPUPMENUMODE_AREA;
(grectx->gre_popupmenu) (grectx, x_pix, y_pix,
grectx->popupmenu_mode, current_node);
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment