Commit d252cd8a authored by claes's avatar claes

Commandot 'replace attribute' implementerat

parent 78eb209c
......@@ -91,6 +91,28 @@ int GeDyn::instance_to_number( int instance)
return inst;
}
void GeDyn::replace_attribute( char *attribute, int attr_size, char *from, char *to, int *cnt, int strict)
{
char str[200];
char tmp[200];
char *s;
int offs;
strncpy( str, attribute, sizeof(str));
if ( !strict)
cdh_ToLower( str, str);
s = strstr( str, from);
if ( s) {
offs = (int)( s - str);
strcpy( tmp, s + strlen(from));
strncpy( &attribute[offs], to, attr_size - offs);
attribute[attr_size-1] = 0;
strncat( attribute, tmp, attr_size-strlen(attribute));
(*cnt)++;
}
}
GeDyn::GeDyn( const GeDyn& x) :
elements(0), graph(x.graph), dyn_type(x.dyn_type), total_dyn_type(x.total_dyn_type),
action_type(x.action_type), total_action_type(x.total_action_type), access(x.access),
......@@ -441,6 +463,12 @@ void GeDyn::set_attribute( grow_tObject object, char *attr_name, int second)
graph->message( 'E', "Nothing to connect for this object");
}
void GeDyn::replace_attribute( char *from, char *to, int *cnt, int strict)
{
for ( GeDynElem *elem = elements; elem; elem = elem->next)
elem->replace_attribute( from, to, cnt, strict);
}
void GeDyn::set_color( grow_tObject object, glow_eDrawType color)
{
int sts = 0;
......@@ -906,7 +934,7 @@ int GeDyn::connect( grow_tObject object, glow_sTraceData *trace_data)
cycle = glow_eCycle_Slow;
if ( dyn_type & ge_mDynType_Inherit)
dyn_type = ge_mDynType( dyn_type & ~ge_mDynType_Inherit);
if ( dyn_type & ge_mDynType_Inherit)
if ( action_type & ge_mActionType_Inherit)
action_type = ge_mActionType( action_type & ~ge_mActionType_Inherit);
}
......@@ -975,6 +1003,18 @@ void GeDyn::export_java( grow_tObject object, ofstream& fp, char *var_name)
{
int inherit_dyn_type, inherit_action_type;
if ( grow_GetObjectType( object) == glow_eObjectType_GrowBar ||
grow_GetObjectType( object) == glow_eObjectType_GrowTable ||
grow_GetObjectType( object) == glow_eObjectType_GrowWindow ||
grow_GetObjectType( object) == glow_eObjectType_GrowTrend) {
if ( cycle == glow_eCycle_Inherit)
cycle = glow_eCycle_Slow;
if ( dyn_type & ge_mDynType_Inherit)
dyn_type = ge_mDynType( dyn_type & ~ge_mDynType_Inherit);
if ( action_type & ge_mActionType_Inherit)
action_type = ge_mActionType( action_type & ~ge_mActionType_Inherit);
}
if ( dyn_type & ge_mDynType_Inherit) {
grow_GetObjectClassDynType( object, &inherit_dyn_type, &inherit_action_type);
total_dyn_type = ge_mDynType( dyn_type | inherit_dyn_type);
......@@ -1086,6 +1126,11 @@ void GeDigLowColor::set_attribute( grow_tObject object, char *attr_name, int *cn
}
}
void GeDigLowColor::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
int GeDigLowColor::set_color( grow_tObject object, glow_eDrawType color)
{
char msg[200];
......@@ -1326,6 +1371,11 @@ void GeDigColor::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigColor::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
int GeDigColor::set_color( grow_tObject object, glow_eDrawType color)
{
char msg[200];
......@@ -1505,6 +1555,11 @@ void GeDigWarning::set_attribute( grow_tObject object, char *attr_name, int *cnt
}
}
void GeDigWarning::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigWarning::save( ofstream& fp)
{
fp << int(ge_eSave_DigWarning) << endl;
......@@ -1641,6 +1696,11 @@ void GeDigError::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigError::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigError::save( ofstream& fp)
{
fp << int(ge_eSave_DigError) << endl;
......@@ -1794,6 +1854,11 @@ void GeDigFlash::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigFlash::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
int GeDigFlash::set_color( grow_tObject object, glow_eDrawType color)
{
char msg[200];
......@@ -1977,6 +2042,11 @@ void GeInvisible::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeInvisible::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeInvisible::save( ofstream& fp)
{
fp << int(ge_eSave_Invisible) << endl;
......@@ -2104,6 +2174,11 @@ void GeDigBorder::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigBorder::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigBorder::save( ofstream& fp)
{
fp << int(ge_eSave_DigBorder) << endl;
......@@ -2251,6 +2326,11 @@ void GeDigText::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigText::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigText::save( ofstream& fp)
{
fp << int(ge_eSave_DigText) << endl;
......@@ -2393,6 +2473,11 @@ void GeValue::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeValue::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeValue::save( ofstream& fp)
{
fp << int(ge_eSave_Value) << endl;
......@@ -2956,6 +3041,11 @@ void GeAnalogColor::set_attribute( grow_tObject object, char *attr_name, int *cn
}
}
void GeAnalogColor::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
int GeAnalogColor::set_color( grow_tObject object, glow_eDrawType color)
{
char msg[200];
......@@ -3234,6 +3324,11 @@ void GeRotate::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeRotate::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeRotate::save( ofstream& fp)
{
fp << int(ge_eSave_Rotate) << endl;
......@@ -3436,6 +3531,14 @@ void GeMove::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeMove::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( move_x_attribute, sizeof(move_x_attribute), from, to, cnt, strict);
GeDyn::replace_attribute( move_y_attribute, sizeof(move_y_attribute), from, to, cnt, strict);
GeDyn::replace_attribute( scale_x_attribute, sizeof(scale_x_attribute), from, to, cnt, strict);
GeDyn::replace_attribute( scale_y_attribute, sizeof(scale_y_attribute), from, to, cnt, strict);
}
void GeMove::save( ofstream& fp)
{
fp << int(ge_eSave_Move) << endl;
......@@ -3735,6 +3838,11 @@ void GeAnalogShift::set_attribute( grow_tObject object, char *attr_name, int *cn
}
}
void GeAnalogShift::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeAnalogShift::save( ofstream& fp)
{
fp << int(ge_eSave_AnalogShift) << endl;
......@@ -3869,6 +3977,11 @@ void GeDigShift::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeDigShift::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeDigShift::save( ofstream& fp)
{
fp << int(ge_eSave_DigShift) << endl;
......@@ -4001,6 +4114,11 @@ void GeAnimation::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeAnimation::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeAnimation::open( ifstream& fp)
{
int type;
......@@ -4272,6 +4390,11 @@ void GeBar::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeBar::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeBar::save( ofstream& fp)
{
fp << int(ge_eSave_Bar) << endl;
......@@ -4416,6 +4539,12 @@ void GeTrend::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeTrend::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute1, sizeof(attribute1), from, to, cnt, strict);
GeDyn::replace_attribute( attribute2, sizeof(attribute2), from, to, cnt, strict);
}
void GeTrend::save( ofstream& fp)
{
fp << int(ge_eSave_Trend) << endl;
......@@ -4778,6 +4907,12 @@ void GeTable::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeTable::replace_attribute( char *from, char *to, int *cnt, int strict)
{
for ( int i = 0; i < TABLE_MAX_COL; i++)
GeDyn::replace_attribute( attribute[i], sizeof(attribute[0]), from, to, cnt, strict);
}
void GeTable::save( ofstream& fp)
{
fp << int(ge_eSave_Table) << endl;
......@@ -5228,6 +5363,40 @@ int GeTable::action( grow_tObject object, glow_tEvent event)
return 1;
}
int GeTable::export_java( grow_tObject object, ofstream& fp, bool first, char *var_name)
{
glow_sTableInfo info;
grow_GetTableInfo( object, &info);
columns = info.columns;
rows = info.rows;
if ( first)
fp << " ";
else
fp << " ,";
fp << "new GeDynTable(" << var_name << ".dd, new String[] {";
for ( int i = 0; i < columns; i++) {
if ( i != 0)
fp << ",";
fp << "\"" << attribute[i] << "\"";
}
fp << "}, new String[] {";
for ( int i = 0; i < columns; i++) {
if ( i != 0)
fp << ",";
fp << "\"" << format[i] << "\"";
}
fp << "}, new String[] {";
for ( int i = 0; i < columns; i++) {
if ( i != 0)
fp << ",";
fp << "\"" << sel_attribute[i] << "\"";
}
fp << "}," << rows << "," << columns << ")" << endl;
return 1;
}
void GeFillLevel::get_attributes( attr_sItem *attrinfo, int *item_count)
{
int i = *item_count;
......@@ -5279,6 +5448,11 @@ void GeFillLevel::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeFillLevel::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeFillLevel::save( ofstream& fp)
{
fp << int(ge_eSave_FillLevel) << endl;
......@@ -5472,6 +5646,11 @@ void GePopupMenu::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GePopupMenu::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( ref_object, sizeof(ref_object), from, to, cnt, strict);
}
void GePopupMenu::save( ofstream& fp)
{
fp << int(ge_eSave_PopupMenu) << endl;
......@@ -5702,6 +5881,11 @@ void GeSetDig::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeSetDig::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeSetDig::save( ofstream& fp)
{
fp << int(ge_eSave_SetDig) << endl;
......@@ -5856,6 +6040,11 @@ void GeResetDig::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeResetDig::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeResetDig::save( ofstream& fp)
{
fp << int(ge_eSave_ResetDig) << endl;
......@@ -5973,6 +6162,11 @@ void GeToggleDig::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeToggleDig::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeToggleDig::save( ofstream& fp)
{
fp << int(ge_eSave_ToggleDig) << endl;
......@@ -6091,6 +6285,11 @@ void GeStoDig::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeStoDig::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeStoDig::save( ofstream& fp)
{
fp << int(ge_eSave_StoDig) << endl;
......@@ -6466,6 +6665,11 @@ void GeIncrAnalog::set_attribute( grow_tObject object, char *attr_name, int *cnt
}
}
void GeIncrAnalog::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeIncrAnalog::save( ofstream& fp)
{
fp << int(ge_eSave_IncrAnalog) << endl;
......@@ -6583,6 +6787,11 @@ void GeRadioButton::set_attribute( grow_tObject object, char *attr_name, int *cn
}
}
void GeRadioButton::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeRadioButton::save( ofstream& fp)
{
fp << int(ge_eSave_RadioButton) << endl;
......@@ -6966,6 +7175,11 @@ void GeOpenGraph::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeOpenGraph::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( graph_object, sizeof(graph_object), from, to, cnt, strict);
}
void GeOpenGraph::save( ofstream& fp)
{
fp << int(ge_eSave_OpenGraph) << endl;
......@@ -7571,6 +7785,11 @@ void GeSlider::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeSlider::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeSlider::save( ofstream& fp)
{
fp << int(ge_eSave_Slider) << endl;
......@@ -7919,6 +8138,11 @@ void GeFastCurve::set_attribute( grow_tObject object, char *attr_name, int *cnt)
}
}
void GeFastCurve::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( fast_object, sizeof(fast_object), from, to, cnt, strict);
}
void GeFastCurve::save( ofstream& fp)
{
fp << int(ge_eSave_FastCurve) << endl;
......@@ -9073,6 +9297,11 @@ void GeOptionMenu::set_attribute( grow_tObject object, char *attr_name, int *cnt
}
}
void GeOptionMenu::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeOptionMenu::save( ofstream& fp)
{
fp << int(ge_eSave_OptionMenu) << endl;
......@@ -9650,6 +9879,11 @@ void GeAnalogText::set_attribute( grow_tObject object, char *attr_name, int *cnt
}
}
void GeAnalogText::replace_attribute( char *from, char *to, int *cnt, int strict)
{
GeDyn::replace_attribute( attribute, sizeof(attribute), from, to, cnt, strict);
}
void GeAnalogText::save( ofstream& fp)
{
fp << int(ge_eSave_AnalogText) << endl;
......
......@@ -617,9 +617,10 @@ class GeDyn {
void export_java_object( grow_tObject object, ofstream& fp, char *var_name);
GeDynElem *create_dyn_element( int mask, int instance);
GeDynElem *create_action_element( int mask, int instance);
void replace_attribute( char *from, char *to, int *cnt, int strict);
static char *cmd_cnv( char *instr);
static int instance_to_number( int instance);
static void replace_attribute( char *attribute, int attr_size, char *from, char *to, int *cnt, int strict);
};
//! Virtual baseclass for dynamic elements.
......@@ -728,6 +729,15 @@ class GeDynElem {
*/
virtual int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name) { return 0;}
//! Replace an attribute string
/*!
\param from Attribute string to replace.
\param to New attribute string.
\param cnt Counter of replaced attributes.
\param strict If 1 the comparation is case sensitive.
*/
virtual void replace_attribute( char *from, char *to, int *cnt, int strict) {}
//! Destructor
virtual ~GeDynElem() {};
};
......@@ -761,6 +771,7 @@ class GeDigLowColor : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int set_color( grow_tObject object, glow_eDrawType color);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -794,6 +805,7 @@ class GeDigColor : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int set_color( grow_tObject object, glow_eDrawType color);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -824,6 +836,7 @@ class GeDigWarning : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -854,6 +867,7 @@ class GeDigError : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -887,6 +901,7 @@ class GeDigFlash : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int set_color( grow_tObject object, glow_eDrawType color);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
......@@ -918,6 +933,7 @@ class GeInvisible : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -950,6 +966,7 @@ class GeDigBorder : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -983,6 +1000,7 @@ class GeDigText : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1017,6 +1035,7 @@ class GeValue : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1085,6 +1104,7 @@ class GeAnalogColor : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int set_color( grow_tObject object, glow_eDrawType color);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
......@@ -1120,6 +1140,7 @@ class GeRotate : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1189,6 +1210,7 @@ class GeMove : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1219,6 +1241,7 @@ class GeAnalogShift : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1249,6 +1272,7 @@ class GeDigShift : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1283,6 +1307,7 @@ class GeAnimation : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1339,6 +1364,7 @@ class GeFillLevel : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1359,6 +1385,7 @@ class GePopupMenu : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1381,6 +1408,7 @@ class GeSetDig : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1403,6 +1431,7 @@ class GeResetDig : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1424,6 +1453,7 @@ class GeToggleDig : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1445,6 +1475,7 @@ class GeStoDig : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1529,6 +1560,7 @@ class GeIncrAnalog : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1561,6 +1593,7 @@ class GeRadioButton : public GeDynElem {
int scan( grow_tObject object);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1622,6 +1655,7 @@ class GeOpenGraph : public GeDynElem {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1716,6 +1750,7 @@ class GeSlider : public GeDynElem {
int action( grow_tObject object, glow_tEvent event);
void update() { first_scan = true;}
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1746,6 +1781,7 @@ class GeBar : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
};
......@@ -1784,6 +1820,7 @@ class GeTrend : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
};
//! Dynamics for a trend object.
......@@ -1822,6 +1859,7 @@ class GeFastCurve : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
};
//! Dynamics for a table object.
......@@ -1865,6 +1903,8 @@ class GeTable : public GeDynElem {
int scan( grow_tObject object);
int action( grow_tObject object, glow_tEvent event);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
//! Pulldown menu.
......@@ -1950,6 +1990,7 @@ class GeOptionMenu : public GeDynElem {
int disconnect( grow_tObject object);
int scan( grow_tObject object);
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int get_transtab( char **tt);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......@@ -1969,6 +2010,7 @@ class GeAnalogText : public GeOptionMenu {
void open( ifstream& fp);
int action( grow_tObject object, glow_tEvent event) { return 1;}
void set_attribute( grow_tObject object, char *attr_name, int *cnt);
void replace_attribute( char *from, char *to, int *cnt, int strict);
int export_java( grow_tObject object, ofstream& fp, bool first, char *var_name);
};
......
......@@ -926,6 +926,14 @@ class Graph {
*/
int export_TrendTraceAttr( ofstream& fp, grow_tObject object, int cnt);
//! Export java code for dynamics of a table object.
/*!
\param fp Output file.
\param object Object.
\param cnt Index for javabean name.
*/
int export_TableTraceAttr( ofstream& fp, grow_tObject object, int cnt);
//! Export java code for dynamics of a slider object.
/*!
\param fp Output file.
......
......@@ -41,6 +41,7 @@ extern "C" {
#include "co_dcli_msg.h"
#include "ge_msg.h"
#include "ge.h"
#include "ge_dyn.h"
extern "C" {
#include "flow_x.h"
......@@ -2307,16 +2308,10 @@ static int graph_replace_func( void *client_data,
{
grow_tObject *sel_list;
int sel_count;
glow_sTraceData *trace_data;
bool modified;
char *s;
char tmp[120];
char from_str[120];
char to_str[120];
int offs;
int replace_cnt = 0;
int strict;
char str[120];
if ( EVEN( dcli_get_qualifier( "/FROM", from_str))) {
graph->message('E', "Syntax error");
......@@ -2341,46 +2336,16 @@ static int graph_replace_func( void *client_data,
case glow_eObjectType_GrowNode:
case glow_eObjectType_GrowSlider:
case glow_eObjectType_GrowTrend:
case glow_eObjectType_GrowBar:
grow_GetTraceAttr( sel_list[i], &trace_data);
modified = false;
for ( int j = 0;
j < (int)(sizeof( trace_data->data)/sizeof(trace_data->data[0]));
j++) {
strncpy( str, trace_data->data[j], sizeof(str));
if ( !strict)
cdh_ToLower( str, str);
s = strstr( str, from_str);
if ( s) {
offs = (int)( s - str);
strcpy( tmp, s + strlen(from_str));
strncpy( &trace_data->data[j][offs], to_str,
sizeof(trace_data->data[0]) - offs);
trace_data->data[j][sizeof(trace_data->data[0])-1] = 0;
strncat( trace_data->data[j], tmp,
sizeof(trace_data->data[0])-strlen(trace_data->data[j]));
modified = true;
}
}
strncpy( str, trace_data->ref_object, sizeof(str));
if ( !strict)
cdh_ToLower( str, str);
s = strstr( str, from_str);
if ( s) {
offs = (int)( s - str);
strcpy( tmp, s + strlen(from_str));
strncpy( &trace_data->ref_object[offs], to_str,
sizeof(trace_data->ref_object) - offs);
trace_data->ref_object[sizeof(trace_data->ref_object)-1] = 0;
strncat( trace_data->ref_object, tmp,
sizeof(trace_data->ref_object)-strlen(trace_data->ref_object));
modified = true;
}
if ( modified) {
grow_SetTraceAttr( sel_list[i], trace_data);
replace_cnt++;
}
case glow_eObjectType_GrowTable:
case glow_eObjectType_GrowWindow:
case glow_eObjectType_GrowFolder:
case glow_eObjectType_GrowBar: {
GeDyn *dyn;
grow_GetUserData( sel_list[i], (void **)&dyn);
dyn->replace_attribute( from_str, to_str, &replace_cnt, strict);
break;
}
default:
;
}
......@@ -2408,12 +2373,6 @@ static void graph_group_replace_attr( grow_tObject group, char *from_str, char *
{
grow_tObject *objectlist;
int object_cnt;
glow_sTraceData *trace_data;
bool modified;
char *s;
char tmp[120];
int offs;
char str[120];
grow_GetGroupObjectList( group, &objectlist, &object_cnt);
for ( int i = 0; i < object_cnt; i++) {
......@@ -2425,47 +2384,16 @@ static void graph_group_replace_attr( grow_tObject group, char *from_str, char *
case glow_eObjectType_GrowNode:
case glow_eObjectType_GrowSlider:
case glow_eObjectType_GrowTrend:
case glow_eObjectType_GrowBar:
grow_GetTraceAttr( objectlist[i], &trace_data);
modified = false;
for ( int j = 0;
j < (int)(sizeof( trace_data->data)/sizeof(trace_data->data[0]));
j++) {
strncpy( str, trace_data->data[j], sizeof(str));
if ( strict)
cdh_ToLower( str, str);
s = strstr( str, from_str);
if ( s) {
offs = (int)( s - str);
strcpy( tmp, s + strlen(from_str));
strncpy( &trace_data->data[j][offs], to_str,
sizeof(trace_data->data[0]) - offs);
trace_data->data[j][sizeof(trace_data->data[0])-1] = 0;
strncat( trace_data->data[j], tmp,
sizeof(trace_data->data[0])-strlen(trace_data->data[j]));
modified = true;
}
}
strncpy( str, trace_data->ref_object, sizeof(str));
if ( strict)
cdh_ToLower( str, str);
s = strstr( str, from_str);
if ( s) {
offs = (int)( s - str);
strcpy( tmp, s + strlen(from_str));
strncpy( &trace_data->ref_object[offs], to_str,
sizeof(trace_data->ref_object) - offs);
trace_data->ref_object[sizeof(trace_data->ref_object)-1] = 0;
strncat( trace_data->ref_object, tmp,
sizeof(trace_data->ref_object)-strlen(trace_data->ref_object));
modified = true;
}
if ( modified) {
grow_SetTraceAttr( objectlist[i], trace_data);
(*replace_cnt)++;
}
case glow_eObjectType_GrowTable:
case glow_eObjectType_GrowWindow:
case glow_eObjectType_GrowFolder:
case glow_eObjectType_GrowBar: {
GeDyn *dyn;
grow_GetUserData( objectlist[i], (void **)&dyn);
dyn->replace_attribute( from_str, to_str, replace_cnt, strict);
break;
}
default:
;
}
......
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