Commit a8df17f5 authored by claes's avatar claes

Reference object pulldown menu method

parent c7aad57a
......@@ -36,7 +36,12 @@ extern "C" {
//
static pwr_tStatus OpenObject( xmenu_sMenuCall *ip)
{
((XNav *)ip->EditorContext)->open_object( &ip->Pointed);
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
((XNav *)ip->EditorContext)->open_object( objar);
return 1;
}
......@@ -61,7 +66,12 @@ static pwr_tStatus OpenObjectFilter( xmenu_sMenuCall *ip)
//
static pwr_tStatus OpenCrossref( xmenu_sMenuCall *ip)
{
((XNav *)ip->EditorContext)->open_crossref( &ip->Pointed);
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
((XNav *)ip->EditorContext)->open_crossref( objar);
return 1;
}
......@@ -72,8 +82,12 @@ static pwr_tStatus OpenCrossrefFilter( xmenu_sMenuCall *ip)
{
pwr_tClassId classid;
pwr_tStatus sts;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetObjectClass( ip->Pointed.Objid, &classid);
sts = gdh_GetObjectClass( objar->Objid, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_eClass_PlantHier)
......@@ -90,8 +104,12 @@ static pwr_tStatus HistEvent( xmenu_sMenuCall *ip)
char cmd[200];
char name[120];
int sts;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -106,7 +124,12 @@ static pwr_tStatus HistEvent( xmenu_sMenuCall *ip)
//
static pwr_tStatus HistEventFilter( xmenu_sMenuCall *ip)
{
if ( ip->Pointed.Flags.b.Object)
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
if ( objar->Flags.b.Object)
return 1;
return 0;
}
......@@ -125,21 +148,25 @@ static pwr_tStatus OpenTrace( xmenu_sMenuCall *ip)
bool in_plc = false;
pwr_tCid classid;
pwr_sAttrRef plcconnect;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
// Check if object reside in plc
for ( sts = gdh_GetParent( ip->Pointed.Objid, &parent);
for ( sts = gdh_GetParent( objar->Objid, &parent);
ODD(sts);
sts = gdh_GetParent( parent, &parent)) {
gdh_GetObjectClass( parent, &classid);
if ( classid == pwr_cClass_plc) {
in_plc = true;
oid = ip->Pointed.Objid;
oid = objar->Objid;
gdh_GetParent( oid, &parent);
break;
}
}
if ( !in_plc) {
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".PlcConnect");
......@@ -171,12 +198,16 @@ static pwr_tStatus OpenTraceFilter( xmenu_sMenuCall *ip)
pwr_tClassId classid;
pwr_sAttrRef plcconnect;
char name[240];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
if ( ip->Caller == xmenu_mUtility_Trace ||
ip->Caller == xmenu_mUtility_Simulate)
return XNAV__INVISIBLE;
for ( sts = gdh_GetParent( ip->Pointed.Objid, &parent);
for ( sts = gdh_GetParent( objar->Objid, &parent);
ODD(sts);
sts = gdh_GetParent( parent, &parent)) {
gdh_GetObjectClass( parent, &classid);
......@@ -185,7 +216,7 @@ static pwr_tStatus OpenTraceFilter( xmenu_sMenuCall *ip)
}
// Try PlcConnect attribute
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".PlcConnect");
......@@ -215,8 +246,12 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
pwr_tClassId classid;
int found;
pwr_sAttrRef deftrend;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsTrend || classid == pwr_cClass_PlotGroup) {
......@@ -231,7 +266,7 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
}
// Look for attribute DefTrend
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -259,7 +294,7 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
return 0;
found = 0;
sts = gdh_GetChild( ip->Pointed.Objid, &child);
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
......@@ -292,8 +327,12 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
pwr_tClassId classid;
pwr_sAttrRef deftrend;
char name[120];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsTrend || classid == pwr_cClass_PlotGroup) {
......@@ -301,7 +340,7 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
}
// Check if attribute DefTrend exist
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -316,10 +355,10 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
}
// Check if object has a DsTrend as child
if ( !ip->Pointed.Flags.b.Object)
if ( !objar->Flags.b.Object)
return XNAV__INVISIBLE;
sts = gdh_GetChild( ip->Pointed.Objid, &child);
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
......@@ -344,12 +383,16 @@ static pwr_tStatus OpenFast( xmenu_sMenuCall *ip)
pwr_tClassId classid;
int found;
pwr_sAttrRef deffast;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsFastCurve) {
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -360,7 +403,7 @@ static pwr_tStatus OpenFast( xmenu_sMenuCall *ip)
}
// Look for attribute DefFast
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -388,7 +431,7 @@ static pwr_tStatus OpenFast( xmenu_sMenuCall *ip)
return 0;
found = 0;
sts = gdh_GetChild( ip->Pointed.Objid, &child);
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
......@@ -421,15 +464,19 @@ static pwr_tStatus OpenFastFilter( xmenu_sMenuCall *ip)
pwr_tClassId classid;
pwr_sAttrRef deffast;
char name[120];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsFastCurve)
return XNAV__SUCCESS;
// Check if attribute DefFast exist
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -444,10 +491,10 @@ static pwr_tStatus OpenFastFilter( xmenu_sMenuCall *ip)
}
// Check if object has a DsFastCurve as child
if ( !ip->Pointed.Flags.b.Object)
if ( !objar->Flags.b.Object)
return XNAV__INVISIBLE;
sts = gdh_GetChild( ip->Pointed.Objid, &child);
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
......@@ -463,7 +510,12 @@ static pwr_tStatus OpenFastFilter( xmenu_sMenuCall *ip)
// Open runtime navigator object
static pwr_tStatus RtNavigator( xmenu_sMenuCall *ip)
{
((XNav *)ip->EditorContext)->display_object( &ip->Pointed, 0);
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
((XNav *)ip->EditorContext)->display_object( objar, 0);
((XNav *)ip->EditorContext)->pop();
return 1;
......@@ -472,7 +524,10 @@ static pwr_tStatus RtNavigator( xmenu_sMenuCall *ip)
// Open runtime navigator filter
static pwr_tStatus RtNavigatorFilter( xmenu_sMenuCall *ip)
{
if ( ip->Caller == xmenu_mUtility_XNav)
if ( ip->Caller == xmenu_mUtility_XNav &&
cdh_ObjidIsEqual( ip->Pointed.Objid,
ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
return XNAV__INVISIBLE;
return XNAV__SUCCESS;
}
......@@ -484,15 +539,19 @@ static pwr_tStatus OpenClassGraph( xmenu_sMenuCall *ip)
char name[120];
char cmd[200];
pwr_sAttrRef aref;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed,
sts = gdh_AttrrefToName( objar,
name, sizeof(name), cdh_mNName);
if ( EVEN(sts)) return sts;
// Check if object is mounted with other name
sts = gdh_NameToAttrref( pwr_cNObjid, name, &aref);
if ( EVEN(sts)) {
sts = gdh_AttrrefToName( &ip->Pointed,
sts = gdh_AttrrefToName( objar,
name, sizeof(name), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
}
......@@ -511,8 +570,12 @@ static pwr_tStatus OpenClassGraphFilter( xmenu_sMenuCall *ip)
char classname[80];
char fname[120];
char found_file[120];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
for ( sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
for ( sts = gdh_GetAttrRefTid( objar, &classid);
ODD(sts);
sts = gdh_GetSuperClass( classid, &classid)) {
......@@ -548,8 +611,12 @@ static pwr_tStatus OpenGraph( xmenu_sMenuCall *ip)
pwr_tObjid objid;
pwr_tClassId classid;
char cmd[200];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
aref = ip->Pointed;
aref = *objar;
sts = XNAV__SUCCESS;
while( ODD(sts)) {
sts = gdh_AttrrefToName( &aref, name, sizeof(name),
......@@ -574,7 +641,7 @@ static pwr_tStatus OpenGraph( xmenu_sMenuCall *ip)
}
}
if ( !ip->Pointed.Flags.b.Object)
if ( !objar->Flags.b.Object)
break;
sts = gdh_GetParent( aref.Objid, &objid);
......@@ -595,8 +662,12 @@ static pwr_tStatus OpenGraphFilter( xmenu_sMenuCall *ip)
pwr_tClassId classid;
char action[80];
char *s;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
aref = ip->Pointed;
aref = *objar;
sts = XNAV__SUCCESS;
while( ODD(sts)) {
sts = gdh_AttrrefToName( &aref, name, sizeof(name),
......@@ -629,7 +700,7 @@ static pwr_tStatus OpenGraphFilter( xmenu_sMenuCall *ip)
return XNAV__SUCCESS;
}
}
if ( !ip->Pointed.Flags.b.Object)
if ( !objar->Flags.b.Object)
break;
sts = gdh_GetParent( aref.Objid, &objid);
......@@ -643,8 +714,14 @@ static pwr_tStatus OpenGraphFilter( xmenu_sMenuCall *ip)
static pwr_tStatus Collect( xmenu_sMenuCall *ip)
{
int sts;
pwr_sAttrRef aref;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = ((XNav *)ip->EditorContext)->collect_insert( &ip->Pointed);
aref = *objar;
sts = ((XNav *)ip->EditorContext)->collect_insert( &aref);
if ( EVEN(sts)) {
wow_DisplayError( (Widget) ip->WindowContext, "Collect error",
XNav::get_message(sts));
......@@ -658,10 +735,17 @@ static pwr_tStatus CollectFilter( xmenu_sMenuCall *ip)
{
char attr[80];
int sts;
pwr_sAttrRef aref;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
if ( ip->ItemType == xmenu_eItemType_Object ||
ip->ItemType == xmenu_eItemType_AttrObject) {
sts = xnav_get_trace_attr( &ip->Pointed, attr);
aref = *objar;
// Note, get_trace_attr replaces the value in aref for channels
sts = xnav_get_trace_attr( &aref, attr);
if ( EVEN(sts))
return XNAV__INVISIBLE;
}
......@@ -675,8 +759,12 @@ static pwr_tStatus Help( xmenu_sMenuCall *ip)
char name[140];
pwr_tString40 helptopic;
char cmd[200];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -700,8 +788,12 @@ static pwr_tStatus HelpFilter( xmenu_sMenuCall *ip)
int sts;
char name[140];
pwr_tString40 helptopic;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -721,8 +813,12 @@ static pwr_tStatus DataSheet( xmenu_sMenuCall *ip)
int sts;
char name[140];
pwr_tURL datasheet;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -743,8 +839,12 @@ static pwr_tStatus DataSheetFilter( xmenu_sMenuCall *ip)
int sts;
char name[140];
pwr_tURL datasheet;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -764,8 +864,12 @@ static pwr_tStatus Photo( xmenu_sMenuCall *ip)
int sts;
char name[140];
pwr_tURL photo;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -793,8 +897,12 @@ static pwr_tStatus PhotoFilter( xmenu_sMenuCall *ip)
int sts;
char name[140];
pwr_tURL photo;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -816,8 +924,12 @@ static pwr_tStatus CircuitDiagram( xmenu_sMenuCall *ip)
char name[140];
pwr_tObjid objid;
bool is_parent = false;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
objid = ip->Pointed.Objid;
objid = objar->Objid;
sts = XNAV__SUCCESS;
while( ODD(sts)) {
sts = gdh_ObjidToName( objid, name, sizeof(name),
......@@ -851,8 +963,12 @@ static pwr_tStatus CircuitDiagramFilter( xmenu_sMenuCall *ip)
char name[140];
pwr_tObjid objid;
bool is_parent = false;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
objid = ip->Pointed.Objid;
objid = objar->Objid;
sts = XNAV__SUCCESS;
while( ODD(sts)) {
sts = gdh_ObjidToName( objid, name, sizeof(name),
......@@ -884,8 +1000,12 @@ static pwr_tStatus HelpClass( xmenu_sMenuCall *ip)
pwr_tClassId classid;
char classname[80];
char cmd[200];
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToName( cdh_ClassIdToObjid( classid),
......@@ -907,9 +1027,13 @@ static pwr_tStatus HelpClassFilter( xmenu_sMenuCall *ip)
{
int sts;
pwr_tClassId classid;
pwr_sAttrRef *objar =
cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid) ?
objar = &ip->Pointed :
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
if ( ip->Caller == xmenu_mUtility_Ge) {
sts = gdh_GetAttrRefTid( &ip->Pointed, &classid);
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_eClass_PlantHier)
......
......@@ -85,9 +85,18 @@ static int getAllMenuItems (
pwr_tObjid objid,
pwr_tUInt32 Level,
int *nItems,
int AddSeparator);
int AddSeparator,
pwr_sAttrRef *CurrentObject);
static int xnav_GetMethod( char *name,
pwr_tStatus (**method)( xmenu_sMenuCall *));
static int xnav_GetObjectMenu(
xmenu_sMenuCall *ip,
pwr_tCid classid,
xmenu_sMenuItem **Item,
pwr_tUInt32 Level,
int *nItems,
int AddSeparator,
pwr_sAttrRef *CurrentObject);
static Widget xnav_build_menu(
Widget Parent,
......@@ -154,17 +163,14 @@ static Widget xnav_build_menu(
Level = Items[*idx].Level;
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++)
{
if (Items[*idx].Item == xmenu_eMenuItem_Cascade)
{
if (MenuType == MENU_OPTION)
{
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
if (Items[*idx].Item == xmenu_eMenuItem_Cascade ||
Items[*idx].Item == xmenu_eMenuItem_Ref) {
if (MenuType == MENU_OPTION) {
XtWarning("You can't have submenus from option menu items.");
return NULL;
}
else
{
else {
i = *idx;
(*idx)++;
xnav_build_menu(Menu, MENU_PULLDOWN,
......@@ -173,8 +179,7 @@ static Widget xnav_build_menu(
(*idx)--;
}
}
else
{
else {
if (Items[*idx].Item == xmenu_eMenuItem_Separator)
Class = xmSeparatorGadgetClass;
else
......@@ -201,14 +206,16 @@ static int getAllMenuItems (
pwr_tObjid objid,
pwr_tUInt32 Level,
int *nItems,
int AddSeparator
int AddSeparator,
pwr_sAttrRef *CurrentObject
)
{
int sts;
pwr_tClassId classid;
pwr_tCid classid;
pwr_tObjid child;
pwr_sMenuButton *mbp;
pwr_sMenuCascade *mcp;
pwr_sMenuRef *mrp;
pwr_tStatus (*filter)( xmenu_sMenuCall *);
int sensitive;
int i;
......@@ -239,6 +246,7 @@ static int getAllMenuItems (
}
// Call any filter method
(*Item)->CurrentObject = *CurrentObject;
sensitive = 1;
if ( strcmp( mbp->FilterName, "") != 0) {
sts = xnav_GetMethod( mbp->FilterName, &filter);
......@@ -281,6 +289,7 @@ static int getAllMenuItems (
if ( EVEN(sts)) return sts;
// Call any filter method
(*Item)->CurrentObject = *CurrentObject;
if ( strcmp( mcp->FilterName, "") != 0) {
sts = xnav_GetMethod( mcp->FilterName, &filter);
if ( ODD(sts)) {
......@@ -301,12 +310,92 @@ static int getAllMenuItems (
sts = gdh_GetChild( objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems(ip, Item, child, Level, nItems, 0);
sts = getAllMenuItems(ip, Item, child, Level, nItems, 0, CurrentObject);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
}
else if ( classid == pwr_eClass_MenuRef &&
cdh_ObjidIsNull( CurrentObject->Objid)) {
char aname[240];
pwr_sAttrRef currentar;
pwr_tCid current_cid;
pwr_tTid a_tid;
pwr_tUInt32 a_size, a_offs, a_elem;
sts = gdh_ObjidToPointer( objid, (void **) &mrp);
if ( EVEN(sts)) return sts;
// Call any filter method
(*Item)->CurrentObject = *CurrentObject;
if ( strcmp( mrp->FilterName, "") != 0) {
sts = xnav_GetMethod( mrp->FilterName, &filter);
if ( ODD(sts)) {
sts = (filter) ( ip);
}
}
else
sts = XNAV__SUCCESS;
if ( ODD(sts)) {
sts = gdh_AttrrefToName( &ip->Pointed, aname, sizeof(aname), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( aname, ".");
strcat( aname, mrp->RefAttribute);
sts = gdh_GetAttributeCharacteristics( aname, &a_tid, &a_size,
&a_offs, &a_elem);
if ( ODD(sts)) {
switch ( a_tid) {
case pwr_eType_AttrRef:
sts = gdh_GetObjectInfo( aname, &currentar, sizeof(currentar));
break;
case pwr_eType_Objid: {
pwr_tOid oid;
currentar = pwr_cNAttrRef;
sts = gdh_GetObjectInfo( aname, &oid, sizeof(oid));
currentar = cdh_ObjidToAref( oid);
break;
}
default:
sts = 0;
}
}
if ( ODD(sts) && cdh_ObjidIsNotNull( currentar.Objid)) {
(*Item)->Level = Level;
(*Item)->Item = xmenu_eMenuItem_Ref;
(*Item)->Flags.f.Sensitive = 1;
strcpy((*Item)->Name, mrp->ButtonName);
(*Item)->MenuObject = objid;
(*Item)++;
(*nItems)++;
// Create a label with current object name
sts = gdh_AttrrefToName( &currentar, aname, sizeof(aname),
cdh_mNName);
if ( ODD(sts)) {
(*Item)->Level = Level;
(*Item)->Item = xmenu_eMenuItem_Button;
(*Item)->MenuObject = pwr_cNObjid;
strcpy((*Item)->Name, aname);
(*Item)->MenuObject = pwr_cNObjid;
(*Item)->CurrentObject = currentar;
(*Item)->Flags.f.Sensitive = 1;
strcpy( (*Item)->Method, "$Object-OpenObject");
(*Item)++;
(*nItems)++;
}
sts = gdh_GetAttrRefTid( &currentar, &current_cid);
if ( EVEN(sts)) return sts;
sts = xnav_GetObjectMenu(ip, current_cid, Item, Level, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
}
}
}
}
return XNAV__SUCCESS;
}
......@@ -314,20 +403,45 @@ static int getAllMenuItems (
static int xnav_GetMenu( xmenu_sMenuCall *ip)
{
pwr_tClassId classid;
xmenu_sMenuItem *Item = (xmenu_sMenuItem *) &xmenu_lMenuItem;
int nItems = 0;
pwr_tCid classid;
pwr_sAttrRef current = pwr_cNAttrRef;
pwr_tStatus sts;
if ( cdh_ObjidIsNotNull( ip->Selected[0].Objid)) {
sts = gdh_GetAttrRefTid ( &ip->Selected[0], &classid);
if ( EVEN(sts)) return sts;
xnav_GetObjectMenu( ip, classid, &Item, 0, &nItems, 0, &current);
}
Item->Level = 0;
ip->ItemCount = nItems - 1;
return XNAV__SUCCESS;
}
static int xnav_GetObjectMenu(
xmenu_sMenuCall *ip,
pwr_tCid classid,
xmenu_sMenuItem **Item,
pwr_tUInt32 Level,
int *nItems,
int AddSeparator,
pwr_sAttrRef *CurrentObject)
{
int sts;
pwr_tObjid child;
xmenu_sMenuItem *Item = (xmenu_sMenuItem *) &xmenu_lMenuItem;
pwr_tObjid menu_objid;
char menu[80];
char classname[120];
int nItems = 0;
pwr_sAttrRef currentar = pwr_cNAttrRef;
pwr_tCid supercid;
if ( cdh_ObjidIsNotNull( mcp->Selected[0].Objid)) {
sts = gdh_GetObjectClass( mcp->Selected[0].Objid, &classid);
if ( EVEN(sts)) return sts;
if ( cdh_ObjidIsNotNull( CurrentObject->Objid))
currentar = *CurrentObject;
if ( mcp->ItemType == xmenu_eItemType_Object) {
if ( ip->ItemType == xmenu_eItemType_Object) {
// Popup-menu for an object
// Get the RtXtt common menu-objects
......@@ -336,13 +450,34 @@ static int xnav_GetMenu( xmenu_sMenuCall *ip)
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, &Item, child, 0, &nItems, 0);
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
// Get the RtXtt menu-objects for this class
// Get the RtXtt menu-objects for superclasses
// TODO shadow overlayed methods...
sts = gdh_GetSuperClass( classid, &supercid);
while ( ODD(sts)) {
sts = gdh_ObjidToName( cdh_ClassIdToObjid( supercid), classname,
sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
sprintf( menu, "%s-RtXtt", classname);
sts = gdh_NameToObjid( menu, &menu_objid);
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
sts = gdh_GetSuperClass( supercid, &supercid);
}
// Get the RtXtt menu-objects for this class, or for superclasses
sts = gdh_ObjidToName( cdh_ClassIdToObjid( classid), classname,
sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -352,13 +487,13 @@ static int xnav_GetMenu( xmenu_sMenuCall *ip)
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, &Item, child, 0, &nItems, 0);
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
}
else if ( mcp->ItemType == xmenu_eItemType_AttrObject) {
else if ( ip->ItemType == xmenu_eItemType_AttrObject) {
// Find attribute object methods...
// Get the RtXtt common menu-objects
strcpy( menu, "pwrs:Class-$Object-RtXttAttrObject");
......@@ -366,13 +501,29 @@ static int xnav_GetMenu( xmenu_sMenuCall *ip)
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, &Item, child, 0, &nItems, 0);
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
// Get the RtXtt menu-objects for this class
sts = gdh_ObjidToName( cdh_ClassIdToObjid( classid), classname,
sizeof(classname), cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
sprintf( menu, "%s-RtXtt", classname);
sts = gdh_NameToObjid( menu, &menu_objid);
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
}
else if ( mcp->ItemType == xmenu_eItemType_Attribute) {
else if ( ip->ItemType == xmenu_eItemType_Attribute) {
// Find attribute methods...
// Get the RtXttAttribute common menu-objects
strcpy( menu, "pwrs:Class-$Object-RtXttAttribute");
......@@ -380,13 +531,13 @@ static int xnav_GetMenu( xmenu_sMenuCall *ip)
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, &Item, child, 0, &nItems, 0);
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
}
else if ( mcp->ItemType == xmenu_eItemType_Crossref) {
else if ( ip->ItemType == xmenu_eItemType_Crossref) {
// Find attribute methods...
// Get the RtXttCrossref common menu-objects
strcpy( menu, "pwrs:Class-$Object-RtXttCrossref");
......@@ -394,19 +545,13 @@ static int xnav_GetMenu( xmenu_sMenuCall *ip)
if ( ODD(sts)) {
sts = gdh_GetChild( menu_objid, &child);
while( ODD(sts)) {
sts = getAllMenuItems( ip, &Item, child, 0, &nItems, 0);
sts = getAllMenuItems( ip, Item, child, 0, nItems, 0, &currentar);
if ( EVEN(sts)) return sts;
sts = gdh_GetNextSibling( child, &child);
}
}
}
}
else {
// Find no object methods...
}
Item->Level = 0;
ip->ItemCount = nItems - 1;
return XNAV__SUCCESS;
}
......
......@@ -47,6 +47,7 @@ typedef enum {
xmenu_eMenuItem_Button,
xmenu_eMenuItem_Cascade,
xmenu_eMenuItem_Separator,
xmenu_eMenuItem_Ref,
xmenu_eMenuItem_
} xmenu_eMenuItem;
......@@ -76,6 +77,7 @@ struct xmenu_s_MenuItem {
xmenu_eMenuItem Item;
xmenu_mMenuFlags Flags;
pwr_tString80 Method;
pwr_sAttrRef CurrentObject;
pwr_tObjid MenuObject;
pwr_tString40 MethodArguments[5];
pwr_tString40 FilterArguments[5];
......
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