Commit 06dc3b77 authored by Claes Sjofors's avatar Claes Sjofors

Ge dynamic methodspulldownmenu and methodtoolbar type Simulate added

parent c2b62bcc
......@@ -648,8 +648,9 @@ public class Dyn {
public static final int eSave_SetValue_instance = 7002;
public static final int eSave_SetValue_instance_mask = 7003;
public static final int eSave_MethodToolbar_method_object = 7100;
public static final int eSave_MethodToolbar_toolbar_type = 7101;
public static final int eSave_MethodPulldownMenu_method_object = 7200;
public static final int eSave_MethodPulldownMenu_help_menu = 7201;
public static final int eSave_MethodPulldownMenu_menu_type = 7201;
public static final int eSave_Script_script_len = 7300;
public static final int eSave_Script_script = 7301;
......@@ -670,6 +671,13 @@ public class Dyn {
public static final int ePwrStatus_Error = 3;
public static final int ePwrStatus_Fatal = 4;
public static final int eMethodsMenuType_Object = 0;
public static final int eMethodsMenuType_Help = 1;
public static final int eMethodsMenuType_Simulate = 2;
public static final int eMethodToolbarType_Object = 0;
public static final int eMethodToolbarType_Simulate = 1;
public static final boolean debug = false;
Vector<DynElem> elements = new Vector<DynElem>();
......@@ -3664,7 +3672,7 @@ public class Dyn {
}
oldValueF = value;
}
else if ( a_typeid == Pwr.eType_Int32) {
else if ( a_typeid == Pwr.eType_Int32 || a_typeid == Pwr.eType_UInt32) {
int value = dyn.graph.getGdh().getObjectRefInfoInt( p);
int i;
if ( !firstScan) {
......@@ -12016,6 +12024,7 @@ public class Dyn {
public class DynMethodToolbar extends DynElem {
String method_object;
int toolbar_type;
public DynMethodToolbar( Dyn dyn) {
super(dyn, 0, 0, Dyn.mActionType1_MethodToolbar, 0, Dyn.eDynPrio_MethodToolbar);
......@@ -12044,6 +12053,9 @@ public class Dyn {
if ( token.hasMoreTokens())
method_object = token.nextToken();
break;
case Dyn.eSave_MethodToolbar_toolbar_type:
toolbar_type = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_End:
end_found = true;
break;
......@@ -12157,6 +12169,9 @@ public class Dyn {
if ( !dyn.graph.isAuthorized( Pwr.mAccess_RtPlc | Pwr.mAccess_System))
insensitive_mntmask |= Pwrb.mXttMntMethodsMask_OpenTrace;
if ( toolbar_type == eMethodToolbarType_Simulate)
opmask = 0;
object.configure( method_toolbar_op_subgraph, method_toolbar_mnt_subgraph,
method_toolbar_op_cnt, method_toolbar_mnt_cnt, opmask, mntmask,
insensitive_opmask, insensitive_mntmask);
......@@ -12232,7 +12247,7 @@ public class Dyn {
public class DynMethodPulldownMenu extends DynElem {
String method_object;
int help_menu;
int menu_type;
int opmask;
int mntmask;
GrowMenu menu_object;
......@@ -12265,8 +12280,8 @@ public class Dyn {
if ( token.hasMoreTokens())
method_object = token.nextToken();
break;
case Dyn.eSave_MethodPulldownMenu_help_menu:
help_menu = Integer.valueOf(token.nextToken());
case Dyn.eSave_MethodPulldownMenu_menu_type:
menu_type = Integer.valueOf(token.nextToken());
break;
case Dyn.eSave_End:
end_found = true;
......@@ -12402,7 +12417,9 @@ public class Dyn {
if ( menu_idx >= 32)
break;
if ( help_menu != 0 && (Dyn.method_toolbar_op_helpmask & (1 << i)) == 0)
if ( menu_type == eMethodsMenuType_Help && (Dyn.method_toolbar_op_helpmask & (1 << i)) == 0)
continue;
if ( menu_type == eMethodsMenuType_Simulate)
continue;
if ( (opmask & (1 << i)) != 0) {
......@@ -12418,7 +12435,7 @@ public class Dyn {
if ( menu_idx >= 32)
break;
if ( help_menu != 0 && (Dyn.method_toolbar_mnt_helpmask & (1 << i)) == 0)
if ( menu_type == eMethodsMenuType_Help && (Dyn.method_toolbar_mnt_helpmask & (1 << i)) == 0)
continue;
if ( (mntmask & (1 << i)) != 0) {
......@@ -12471,7 +12488,9 @@ public class Dyn {
int found = 0;
for ( int i = 0; i < Dyn.method_toolbar_op_cnt; i++) {
if ( help_menu != 0 && (Dyn.method_toolbar_op_helpmask & (1 << i)) == 0)
if ( menu_type != eMethodsMenuType_Help && (Dyn.method_toolbar_op_helpmask & (1 << i)) == 0)
continue;
if ( menu_type != eMethodsMenuType_Simulate)
continue;
if ( (opmask & (1 << i)) != 0)
......@@ -12488,7 +12507,7 @@ public class Dyn {
if ( found == 0) {
for ( int i = 0; i < Dyn.method_toolbar_mnt_cnt; i++) {
if ( help_menu != 0 && (Dyn.method_toolbar_mnt_helpmask & (1 << i)) == 0)
if ( menu_type == eMethodsMenuType_Help && (Dyn.method_toolbar_mnt_helpmask & (1 << i)) == 0)
continue;
if ( (mntmask & (1 << i)) != 0)
......
......@@ -48,7 +48,8 @@ public class GrowMenu extends GrowRect {
int text_color_disabled; //!< Color for disabled button text.
int item_cnt; //!< Number of menu items.
double item_height; //!< Menu item height in pixel.
int current_item; //!< Hot item.
int current_item = -1; //!< Hot item.
int current_idx = -1; //!< Hot index.
int new_item; //!< New current item.
int old_item; //!< Current item in previous event.
GlowArrayElem parent_menu; //!< Parent menu.
......@@ -217,10 +218,10 @@ public class GrowMenu extends GrowRect {
item = item_cnt - 1;
if ( item < 0)
item = 0;
if ( item != current_item) {
if ( item != current_idx) {
new_item = 1;
old_item = current_item;
current_item = item;
current_idx = item;
for ( int i = 0, item_idx = 0; i < 32; i++) {
if ( !info.item[i].occupied)
continue;
......
......@@ -65,6 +65,8 @@ public class JopgCcm {
ccm.registerFunction( new CcmFuncCutObjectName("CutObjectName"));
ccm.registerFunction( new CcmFuncGetCurrentObject("GetCurrentObject"));
ccm.registerFunction( new CcmFuncGetCurrentText("GetCurrentText"));
ccm.registerFunction( new CcmFuncGetUser("GetUser"));
ccm.registerFunction( new CcmFuncGetPrivileges("GetPrivileges"));
CcmFileReturn fret;
if ( cmd != null)
......@@ -762,6 +764,7 @@ public class JopgCcm {
return ret;
}
}
public class CcmFuncGetCurrentText extends CcmSysFunc {
public CcmFuncGetCurrentText( String name) {
super(name);
......@@ -781,4 +784,42 @@ public class JopgCcm {
return ret;
}
}
public class CcmFuncGetUser extends CcmSysFunc {
public CcmFuncGetUser( String name) {
super(name);
}
public CcmReturn func( CcmFileCtx filectx, CcmArg[] args) {
int sts;
CcmReturn ret = new CcmReturn();
if ( args.length != 0) {
ret.sts = Ccm.CCM__ARGMISM;
return ret;
}
ret.rstring = gdh.getUser();
ret.decl = Ccm.K_DECL_STRING;
return ret;
}
}
public class CcmFuncGetPrivileges extends CcmSysFunc {
public CcmFuncGetPrivileges( String name) {
super(name);
}
public CcmReturn func( CcmFileCtx filectx, CcmArg[] args) {
int sts;
CcmReturn ret = new CcmReturn();
if ( args.length != 0) {
ret.sts = Ccm.CCM__ARGMISM;
return ret;
}
ret.rint = gdh.getPrivilege();
ret.decl = Ccm.K_DECL_INT;
return ret;
}
}
}
......@@ -994,6 +994,17 @@ static attrnav_sEnumElement elem_optionmenu_type[] = {
{ (unsigned int) ge_eOptionMenuType_Dynamic, "Dynamic"},
{ 0, ""}};
static attrnav_sEnumElement elem_methodsmenu_type[] = {
{ (unsigned int) ge_eMethodsMenuType_Object, "Object"},
{ (unsigned int) ge_eMethodsMenuType_Help, "Help"},
{ (unsigned int) ge_eMethodsMenuType_Simulate,"Simulate"},
{ 0, ""}};
static attrnav_sEnumElement elem_methodtoolbar_type[] = {
{ (unsigned int) ge_eMethodToolbarType_Object, "Object"},
{ (unsigned int) ge_eMethodToolbarType_Simulate,"Simulate"},
{ 0, ""}};
static attrnav_sEnum enum_types[] = {
{ (unsigned int) glow_eType_Direction, (attrnav_sEnumElement *) &elem_direction},
{ (unsigned int) glow_eType_Color, (attrnav_sEnumElement *) &elem_color},
......@@ -1015,6 +1026,8 @@ static attrnav_sEnum enum_types[] = {
{ (unsigned int) glow_eType_AppMotion, (attrnav_sEnumElement *) &elem_app_motion},
{ (unsigned int) glow_eType_AnnotType, (attrnav_sEnumElement *) &elem_annot_type},
{ (unsigned int) ge_eAttrType_OptionMenuType, (attrnav_sEnumElement *) &elem_optionmenu_type},
{ (unsigned int) ge_eAttrType_MethodsMenuType, (attrnav_sEnumElement *) &elem_methodsmenu_type},
{ (unsigned int) ge_eAttrType_MethodToolbarType, (attrnav_sEnumElement *) &elem_methodtoolbar_type},
{ 0, NULL}};
static attrnav_sEnum mask_types[] = {
......@@ -1155,6 +1168,8 @@ int attrnav_attr_string_to_value( int type_id, char *value_str,
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
case ge_eAttrType_MethodsMenuType:
case ge_eAttrType_MethodToolbarType:
{
if ( sscanf( value_str, "%u", (int *)buffer_ptr) != 1)
return ATTRNAV__INPUT_SYNTAX;
......@@ -1237,6 +1252,8 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
case ge_eAttrType_MethodsMenuType:
case ge_eAttrType_MethodToolbarType:
{
attrnav_sEnumElement *elem_p;
attrnav_sEnum *enum_p;
......@@ -2341,6 +2358,8 @@ ItemLocal::ItemLocal( AttrNav *attrnav, const char *item_name, const char *attr,
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
case ge_eAttrType_MethodsMenuType:
case ge_eAttrType_MethodToolbarType:
if ( !noedit)
{
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_attrarray);
......
......@@ -17329,6 +17329,11 @@ void GeMethodToolbar::get_attributes( attr_sItem *attrinfo, int *item_count)
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( method_object);
strcpy( attrinfo[i].name, "MethodToolbar.ToolbarType");
attrinfo[i].value = &toolbar_type;
attrinfo[i].type = ge_eAttrType_MethodToolbarType;
attrinfo[i++].size = sizeof( toolbar_type);
dyn->display_access = true;
*item_count = i;
}
......@@ -17355,6 +17360,7 @@ void GeMethodToolbar::save( ofstream& fp)
{
fp << int(ge_eSave_MethodToolbar) << endl;
fp << int(ge_eSave_MethodToolbar_method_object) << FSPACE << method_object << endl;
fp << int(ge_eSave_MethodToolbar_toolbar_type) << FSPACE << (int) toolbar_type << endl;
fp << int(ge_eSave_End) << endl;
}
......@@ -17363,6 +17369,7 @@ void GeMethodToolbar::open( ifstream& fp)
int type;
int end_found = 0;
char dummy[40];
int tmp;
for (;;)
{
......@@ -17380,6 +17387,7 @@ void GeMethodToolbar::open( ifstream& fp)
fp.get();
fp.getline( method_object, sizeof(method_object));
break;
case ge_eSave_MethodToolbar_toolbar_type: fp >> tmp; toolbar_type = (ge_eMethodToolbarType)tmp; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeMethodToolbar:open syntax error" << endl;
......@@ -17430,6 +17438,9 @@ int GeMethodToolbar::connect( grow_tObject object, glow_sTraceData *trace_data)
if ( !dyn->graph->is_authorized( pwr_mAccess_RtPlc | pwr_mAccess_System))
insensitive_mntmask |= pwr_mXttMntMethodsMask_OpenTrace;
if ( toolbar_type == ge_eMethodToolbarType_Simulate)
opmask = 0;
grow_ToolbarConfigure( object, (char *)GeMethods::op_subgraph, (char *)GeMethods::mnt_subgraph,
GeMethods::opmeth_size, GeMethods::mntmeth_size, opmask, mntmask,
insensitive_opmask, insensitive_mntmask);
......@@ -17502,10 +17513,10 @@ void GeMethodPulldownMenu::get_attributes( attr_sItem *attrinfo, int *item_count
attrinfo[i].type = glow_eType_String;
attrinfo[i++].size = sizeof( method_object);
strcpy( attrinfo[i].name, "MethodPulldownMenu.HelpMenu");
attrinfo[i].value = &help_menu;
attrinfo[i].type = glow_eType_Boolean;
attrinfo[i++].size = sizeof( help_menu);
strcpy( attrinfo[i].name, "MethodPulldownMenu.MenuType");
attrinfo[i].value = &menu_type;
attrinfo[i].type = ge_eAttrType_MethodsMenuType;
attrinfo[i++].size = sizeof( menu_type);
dyn->display_access = true;
*item_count = i;
......@@ -17515,7 +17526,7 @@ void GeMethodPulldownMenu::save( ofstream& fp)
{
fp << int(ge_eSave_MethodPulldownMenu) << endl;
fp << int(ge_eSave_MethodPulldownMenu_method_object) << FSPACE << method_object << endl;
fp << int(ge_eSave_MethodPulldownMenu_help_menu) << FSPACE << help_menu << endl;
fp << int(ge_eSave_MethodPulldownMenu_menu_type) << FSPACE << menu_type << endl;
fp << int(ge_eSave_End) << endl;
}
......@@ -17524,6 +17535,7 @@ void GeMethodPulldownMenu::open( ifstream& fp)
int type;
int end_found = 0;
char dummy[40];
int tmp;
for (;;)
{
......@@ -17541,7 +17553,7 @@ void GeMethodPulldownMenu::open( ifstream& fp)
fp.get();
fp.getline( method_object, sizeof(method_object));
break;
case ge_eSave_MethodPulldownMenu_help_menu: fp >> help_menu; break;
case ge_eSave_MethodPulldownMenu_menu_type: fp >> tmp; menu_type = (ge_eMethodsMenuType)tmp; break;
case ge_eSave_End: end_found = 1; break;
default:
cout << "GeMethodPulldownMenu:open syntax error" << endl;
......@@ -17695,7 +17707,9 @@ int GeMethodPulldownMenu::action( grow_tObject object, glow_tEvent event)
if ( strcmp( GeMethods::op_name[i], "") == 0)
continue;
if ( help_menu && !(GeMethods::op_helpmask & (1 << i)))
if ( menu_type == ge_eMethodsMenuType_Help && !(GeMethods::op_helpmask & (1 << i)))
continue;
if ( menu_type == ge_eMethodsMenuType_Simulate)
continue;
if ( opmask & (1 << i)) {
......@@ -17714,7 +17728,7 @@ int GeMethodPulldownMenu::action( grow_tObject object, glow_tEvent event)
if ( strcmp( GeMethods::mnt_name[i], "") == 0)
continue;
if ( help_menu && !(GeMethods::mnt_helpmask & (1 << i)))
if ( menu_type == ge_eMethodsMenuType_Help && !(GeMethods::mnt_helpmask & (1 << i)))
continue;
if ( mntmask & (1 << i)) {
......@@ -17772,7 +17786,9 @@ int GeMethodPulldownMenu::action( grow_tObject object, glow_tEvent event)
int found = 0;
for ( int i = 0; i < GeMethods::opmeth_size; i++) {
if ( help_menu && !(GeMethods::op_helpmask & (1 << i)))
if ( menu_type == ge_eMethodsMenuType_Help && !(GeMethods::op_helpmask & (1 << i)))
continue;
if ( menu_type == ge_eMethodsMenuType_Simulate)
continue;
if ( opmask & (1 << i))
......@@ -17789,7 +17805,7 @@ int GeMethodPulldownMenu::action( grow_tObject object, glow_tEvent event)
if ( !found) {
for ( int i = 0; i < GeMethods::mntmeth_size; i++) {
if ( help_menu && !(GeMethods::mnt_helpmask & (1 << i)))
if ( menu_type == ge_eMethodsMenuType_Help && !(GeMethods::mnt_helpmask & (1 << i)))
continue;
if ( mntmask & (1 << i))
......
......@@ -117,6 +117,19 @@
ge_ePwrStatus_Fatal
} ge_ePwrStatus;
//! MethodsPulldownMenu types
typedef enum {
ge_eMethodsMenuType_Object,
ge_eMethodsMenuType_Help,
ge_eMethodsMenuType_Simulate
} ge_eMethodsMenuType;
//! MethodToolbar types
typedef enum {
ge_eMethodToolbarType_Object,
ge_eMethodToolbarType_Simulate
} ge_eMethodToolbarType;
//! Priority order for dyntypes and actiontypes. Lower value gives higher priority.
typedef enum {
......@@ -735,8 +748,9 @@
ge_eSave_SetValue_instance = 7002,
ge_eSave_SetValue_instance_mask = 7003,
ge_eSave_MethodToolbar_method_object = 7100,
ge_eSave_MethodToolbar_toolbar_type = 7101,
ge_eSave_MethodPulldownMenu_method_object = 7200,
ge_eSave_MethodPulldownMenu_help_menu = 7201,
ge_eSave_MethodPulldownMenu_menu_type = 7201,
ge_eSave_Script_script_len = 7300,
ge_eSave_Script_script = 7301
} ge_eSave;
......@@ -2888,25 +2902,16 @@ class GeSetValue : public GeDynElem {
class GeMethodToolbar : public GeDynElem {
public:
pwr_tAName method_object;
ge_eMethodToolbarType toolbar_type;
static unsigned int method_toolbar_op_helpmask;
static unsigned int method_toolbar_mnt_helpmask;
#if 0
static int method_toolbar_op_cnt;
static char method_toolbar_op_subgraph[32][80];
static char method_toolbar_op_methods[32][80];
static char method_toolbar_op_tooltip[32][80];
static int method_toolbar_mnt_cnt;
static char method_toolbar_mnt_subgraph[32][80];
static char method_toolbar_mnt_methods[32][80];
static char method_toolbar_mnt_tooltip[32][80];
#endif
GeMethodToolbar( GeDyn *e_dyn, ge_mInstance e_instance = ge_mInstance_1) :
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_MethodToolbar, ge_mActionType2_No, ge_eDynPrio_MethodToolbar)
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_MethodToolbar, ge_mActionType2_No, ge_eDynPrio_MethodToolbar), toolbar_type(ge_eMethodToolbarType_Object)
{ strcpy( method_object, ""); instance = e_instance;}
GeMethodToolbar( const GeMethodToolbar& x) :
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio)
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio), toolbar_type(x.toolbar_type)
{ strcpy( method_object, x.method_object);
instance = x.instance, instance_mask = x.instance_mask;}
void get_attributes( attr_sItem *attrinfo, int *item_count);
......@@ -2924,7 +2929,7 @@ class GeMethodToolbar : public GeDynElem {
class GeMethodPulldownMenu : public GeDynElem {
public:
pwr_tAName method_object;
pwr_tBoolean help_menu;
ge_eMethodsMenuType menu_type;
grow_tObject menu_object;
pwr_tTime focus_gained_time;
unsigned int opmask;
......@@ -2932,10 +2937,10 @@ class GeMethodPulldownMenu : public GeDynElem {
GeMethodPulldownMenu( GeDyn *e_dyn) :
GeDynElem(e_dyn, ge_mDynType1_No, ge_mDynType2_No, ge_mActionType1_MethodPulldownMenu, ge_mActionType2_No, ge_eDynPrio_MethodPulldownMenu),
help_menu(0), menu_object(0)
menu_type(ge_eMethodsMenuType_Object), menu_object(0)
{ strcpy( method_object, "");}
GeMethodPulldownMenu( const GeMethodPulldownMenu& x) :
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio), help_menu(x.help_menu),
GeDynElem(x.dyn,x.dyn_type1,x.dyn_type2,x.action_type1,x.action_type2,x.prio), menu_type(x.menu_type),
menu_object(0)
{ strcpy( method_object, x.method_object);
instance = x.instance, instance_mask = x.instance_mask;}
......
......@@ -101,6 +101,8 @@ typedef enum {
ge_eAttrType_ScaleType = 1008, //!< Scale type.
ge_eAttrType_CurveDataType = 1009, //!< Data type for XY_Curve.
ge_eAttrType_OptionMenuType = 1010, //!< OptionMenu type.
ge_eAttrType_MethodsMenuType = 1011, //!< MethodsMenu type.
ge_eAttrType_MethodToolbarType = 1012, //!< MethodToolbar type.
ge_eAttrType_DynType2 = glow_eType_DynType2, //!< DynType mask 2.
ge_eAttrType_ActionType2 = glow_eType_ActionType2, //!< ActionType mask 2.
} ge_eAttrType;
......
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