Commit 628630f9 authored by Marcus Nordenberg's avatar Marcus Nordenberg

Profinet Configurator: Add help text area, and made objects show up more...

Profinet Configurator: Add help text area, and made objects show up more informative (Order Number etc.)
parent 697a10ac
...@@ -66,6 +66,14 @@ void GsdmlAttrGtk::message( char severity, const char *message) ...@@ -66,6 +66,14 @@ void GsdmlAttrGtk::message( char severity, const char *message)
gtk_label_set_text( GTK_LABEL(msg_label), message); gtk_label_set_text( GTK_LABEL(msg_label), message);
} }
void GsdmlAttrGtk::attr_help_text(const char *help_text)
{
GtkTextBuffer *buffer;
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(this->help_text));
gtk_text_buffer_set_text(buffer, help_text, -1);
}
void GsdmlAttrGtk::set_prompt( const char *prompt) void GsdmlAttrGtk::set_prompt( const char *prompt)
{ {
if ( strcmp(prompt, "") == 0) { if ( strcmp(prompt, "") == 0) {
...@@ -486,6 +494,24 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid, ...@@ -486,6 +494,24 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
attrnav->message_cb = &GsdmlAttr::gsdmlattr_message; attrnav->message_cb = &GsdmlAttr::gsdmlattr_message;
attrnav->change_value_cb = &GsdmlAttr::gsdmlattr_change_value_cb; attrnav->change_value_cb = &GsdmlAttr::gsdmlattr_change_value_cb;
// Attribute Help Text
GtkWidget *help_area = gtk_hbox_new( FALSE, 0);
//We want scrollbars to the right in case the help text is very long
GtkWidget *scroll_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
// Set up the text view
help_text = gtk_text_view_new();
gtk_text_view_set_editable(GTK_TEXT_VIEW(help_text), FALSE);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(help_text), GTK_WRAP_WORD);
gtk_widget_set_can_focus(help_text, FALSE);
gtk_widget_set_size_request(help_text, -1, 100);
//Add the text view to the container and pack it in the layout
gtk_container_add(GTK_CONTAINER(scroll_window), help_text);
gtk_box_pack_start( GTK_BOX(help_area), scroll_window, TRUE, TRUE, 0);
// Status bar and value input // Status bar and value input
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0); GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( ""); msg_label = gtk_label_new( "");
...@@ -523,6 +549,7 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid, ...@@ -523,6 +549,7 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), brow_widget, TRUE, TRUE, 0); gtk_box_pack_start( GTK_BOX(vbox), brow_widget, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), help_area, FALSE, FALSE, 3);
gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3); gtk_box_pack_start( GTK_BOX(vbox), statusbar, FALSE, FALSE, 3);
gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5); gtk_box_pack_start( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
...@@ -545,4 +572,4 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid, ...@@ -545,4 +572,4 @@ GsdmlAttrGtk::GsdmlAttrGtk( GtkWidget *a_parent_wid,
wow = new CoWowGtk( toplevel); wow = new CoWowGtk( toplevel);
*a_sts = attrnav->open( data_filename); *a_sts = attrnav->open( data_filename);
} }
\ No newline at end of file
...@@ -49,9 +49,9 @@ class GsdmlAttrGtk : public GsdmlAttr { ...@@ -49,9 +49,9 @@ class GsdmlAttrGtk : public GsdmlAttr {
GtkWidget *form_widget; GtkWidget *form_widget;
GtkWidget *toplevel; GtkWidget *toplevel;
GtkWidget *msg_label; GtkWidget *msg_label;
GtkWidget *help_text;
GtkWidget *cmd_prompt; GtkWidget *cmd_prompt;
GtkWidget *cmd_input; GtkWidget *cmd_input;
GtkWidget *attrnav_form;
GtkWidget *cmd_ok; GtkWidget *cmd_ok;
GtkWidget *cmd_apply; GtkWidget *cmd_apply;
GtkWidget *cmd_cancel; GtkWidget *cmd_cancel;
...@@ -74,6 +74,12 @@ class GsdmlAttrGtk : public GsdmlAttr { ...@@ -74,6 +74,12 @@ class GsdmlAttrGtk : public GsdmlAttr {
~GsdmlAttrGtk(); ~GsdmlAttrGtk();
void message( char severity, const char *message); void message( char severity, const char *message);
/**
* @brief attr_help_text Set the help text area to display a help text
* @param help_text Help text to display
*/
void attr_help_text(const char *help_text);
void set_prompt( const char *prompt); void set_prompt( const char *prompt);
void change_value(); void change_value();
...@@ -105,4 +111,4 @@ class GsdmlAttrGtk : public GsdmlAttr { ...@@ -105,4 +111,4 @@ class GsdmlAttrGtk : public GsdmlAttr {
//static void valchanged_cmd_input( GtkWidget *w, gpointer data); //static void valchanged_cmd_input( GtkWidget *w, gpointer data);
}; };
#endif #endif
\ No newline at end of file
...@@ -99,4 +99,49 @@ GsdmlAttrNavGtk::~GsdmlAttrNavGtk() ...@@ -99,4 +99,49 @@ GsdmlAttrNavGtk::~GsdmlAttrNavGtk()
void GsdmlAttrNavGtk::set_inputfocus() void GsdmlAttrNavGtk::set_inputfocus()
{ {
gtk_widget_grab_focus( brow_widget); gtk_widget_grab_focus( brow_widget);
} }
\ No newline at end of file
void GsdmlAttrNavGtk::display_attr_help_text()
{
brow_tNode *node_list;
int node_count;
ItemPn *base_item;
brow_GetSelectedNodes( brow->ctx, &node_list, &node_count);
if ( !node_count)
return;
brow_GetUserData( node_list[0], (void **)&base_item);
free( node_list);
switch( base_item->type) {
/*
* The following two item types could make use if the same info_text in the base class as PnEnumValue does
* but since they already contained references to they were used instead...
*/
case attrnav_eItemType_PnParValue:
case attrnav_eItemType_PnParEnum: {
ItemPnParEnum *item = (ItemPnParEnum *)base_item;
gsdml_ValueItem *vi = 0;
if (item->value_ref)
vi = (gsdml_ValueItem *)item->value_ref->Body.ValueItemTarget.p;
//If we do have help available show it
if (vi && vi->Body.Help.p)
((GsdmlAttrGtk*)parent_ctx)->attr_help_text((char*)vi->Body.Help.p);
break;
}
case attrnav_eItemType_PnEnumValue: {
// Do we have an associated info text string to show the user some more info?
if (base_item->info_text)
((GsdmlAttrGtk*)parent_ctx)->attr_help_text(base_item->info_text);
break;
}
default:
((GsdmlAttrGtk*)parent_ctx)->attr_help_text("");
}
}
...@@ -56,6 +56,7 @@ class GsdmlAttrNavGtk : public GsdmlAttrNav { ...@@ -56,6 +56,7 @@ class GsdmlAttrNavGtk : public GsdmlAttrNav {
pwr_tStatus *status); pwr_tStatus *status);
~GsdmlAttrNavGtk(); ~GsdmlAttrNavGtk();
void set_inputfocus(); void set_inputfocus();
void display_attr_help_text();
GtkWidget *parent_wid; GtkWidget *parent_wid;
GtkWidget *brow_widget; GtkWidget *brow_widget;
...@@ -64,4 +65,4 @@ class GsdmlAttrNavGtk : public GsdmlAttrNav { ...@@ -64,4 +65,4 @@ class GsdmlAttrNavGtk : public GsdmlAttrNav {
}; };
#endif #endif
\ No newline at end of file
...@@ -3456,7 +3456,7 @@ void gsdml_ModuleInfo::build() ...@@ -3456,7 +3456,7 @@ void gsdml_ModuleInfo::build()
Body.SubCategory1Ref.p = gsdml->find_category_ref( Body.SubCategory1Ref.ref); Body.SubCategory1Ref.p = gsdml->find_category_ref( Body.SubCategory1Ref.ref);
if ( !Body.SubCategory1Ref.p) if ( !Body.SubCategory1Ref.p)
gsdml->error_message("SubCategory1Ref not found: \"%s\"", Body.SubCategory1Ref.ref); gsdml->error_message("SubCategory1Ref not found: \"%s\"", Body.SubCategory1Ref.ref);
} }
} }
void gsdml_ModuleInfo::print( int ind) void gsdml_ModuleInfo::print( int ind)
...@@ -5068,6 +5068,11 @@ void gsdml_ValueItem::build() ...@@ -5068,6 +5068,11 @@ void gsdml_ValueItem::build()
for ( unsigned int i = 0; i < Assignments->Assign.size(); i++) for ( unsigned int i = 0; i < Assignments->Assign.size(); i++)
Assignments->Assign[i]->build(); Assignments->Assign[i]->build();
} }
if ( strcmp( Body.Help.ref, "") != 0) {
Body.Help.p = gsdml->find_text_ref( Body.Help.ref);
if ( Body.Help.p == noref)
gsdml->error_message("Help not found: \"%s\"", Body.Help.ref);
}
} }
gsdml_ValueItem::~gsdml_ValueItem() gsdml_ValueItem::~gsdml_ValueItem()
......
...@@ -90,6 +90,7 @@ class GsdmlAttr { ...@@ -90,6 +90,7 @@ class GsdmlAttr {
virtual ~GsdmlAttr(); virtual ~GsdmlAttr();
virtual void message( char severity, const char *message) {} virtual void message( char severity, const char *message) {}
virtual void attr_help_text(const char *help_text) {}
virtual void set_prompt( const char *prompt) {} virtual void set_prompt( const char *prompt) {}
virtual void change_value() {} virtual void change_value() {}
...@@ -117,4 +118,4 @@ class GsdmlAttr { ...@@ -117,4 +118,4 @@ class GsdmlAttr {
}; };
#endif #endif
\ No newline at end of file
...@@ -706,9 +706,11 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -706,9 +706,11 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
} }
} }
} }
brow_SelectClear( attrnav->brow->ctx); brow_SelectClear( attrnav->brow->ctx);
brow_SetInverse( object, 1); brow_SetInverse( object, 1);
brow_SelectInsert( attrnav->brow->ctx, object); brow_SelectInsert( attrnav->brow->ctx, object);
attrnav->display_attr_help_text();
if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full)) if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full))
brow_CenterObject( attrnav->brow->ctx, object, 0.25); brow_CenterObject( attrnav->brow->ctx, object, 0.25);
if ( node_count) if ( node_count)
...@@ -743,6 +745,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -743,6 +745,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SelectClear( attrnav->brow->ctx); brow_SelectClear( attrnav->brow->ctx);
brow_SetInverse( object, 1); brow_SetInverse( object, 1);
brow_SelectInsert( attrnav->brow->ctx, object); brow_SelectInsert( attrnav->brow->ctx, object);
attrnav->display_attr_help_text();
if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full)) if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full))
brow_CenterObject( attrnav->brow->ctx, object, 0.75); brow_CenterObject( attrnav->brow->ctx, object, 0.75);
if ( node_count) if ( node_count)
...@@ -780,6 +783,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -780,6 +783,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SelectClear( attrnav->brow->ctx); brow_SelectClear( attrnav->brow->ctx);
brow_SetInverse( event->object.object, 1); brow_SetInverse( event->object.object, 1);
brow_SelectInsert( attrnav->brow->ctx, event->object.object); brow_SelectInsert( attrnav->brow->ctx, event->object.object);
attrnav->display_attr_help_text();
} }
break; break;
default: default:
...@@ -859,6 +863,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event) ...@@ -859,6 +863,7 @@ int GsdmlAttrNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SelectClear( attrnav->brow->ctx); brow_SelectClear( attrnav->brow->ctx);
brow_SetInverse( object, 1); brow_SetInverse( object, 1);
brow_SelectInsert( attrnav->brow->ctx, object); brow_SelectInsert( attrnav->brow->ctx, object);
attrnav->display_attr_help_text();
if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full)) if ( !brow_IsVisible( attrnav->brow->ctx, object, flow_eVisible_Full))
brow_CenterObject( attrnav->brow->ctx, object, 0.25); brow_CenterObject( attrnav->brow->ctx, object, 0.25);
free( node_list); free( node_list);
...@@ -2047,8 +2052,8 @@ int ItemPn::close( GsdmlAttrNav *attrnav, double x, double y) ...@@ -2047,8 +2052,8 @@ int ItemPn::close( GsdmlAttrNav *attrnav, double x, double y)
} }
ItemPnEnumValue::ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num, ItemPnEnumValue::ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num,
int item_type_id, void *attr_value_p, int item_type_id, void *attr_value_p,
brow_tNode dest, flow_eDest dest_code) : brow_tNode dest, flow_eDest dest_code, const char *info_text) : ItemPn(info_text),
num(item_num), type_id(item_type_id), value_p(attr_value_p), first_scan(1) num(item_num), type_id(item_type_id), value_p(attr_value_p), first_scan(1)
{ {
...@@ -2175,10 +2180,11 @@ int ItemPnDevice::open_children( GsdmlAttrNav *attrnav, double x, double y) ...@@ -2175,10 +2180,11 @@ int ItemPnDevice::open_children( GsdmlAttrNav *attrnav, double x, double y)
&attrnav->device_num, node, flow_eDest_IntoLast); &attrnav->device_num, node, flow_eDest_IntoLast);
for ( unsigned int i = 0; i < attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem.size(); i++) { for ( unsigned int i = 0; i < attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem.size(); i++) {
gsdml_DeviceAccessPointItem *item = attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem[i];
char name[80]; char name[80];
strncpy( name, (char *)attrnav->gsdml->ApplicationProcess->DeviceAccessPointList->DeviceAccessPointItem[i]->ModuleInfo->Body.Name.p, sizeof(name)); snprintf(name, sizeof(name), "%s (%s)", (char*)item->ModuleInfo->Body.Name.p, item->ModuleInfo->Body.OrderNumber);
new ItemPnEnumValue( attrnav, name, idx++, pwr_eType_UInt32, new ItemPnEnumValue( attrnav, name, idx++, pwr_eType_UInt32,
&attrnav->device_num, node, flow_eDest_IntoLast); &attrnav->device_num, node, flow_eDest_IntoLast, (char *)item->ModuleInfo->Body.InfoText.p);
} }
brow_SetOpen( node, attrnav_mOpen_Children); brow_SetOpen( node, attrnav_mOpen_Children);
......
...@@ -120,7 +120,7 @@ class ItemPn; ...@@ -120,7 +120,7 @@ class ItemPn;
//! Class for handling of brow. //! Class for handling of brow.
class GsdmlAttrNavBrow { class GsdmlAttrNavBrow {
public: public:
GsdmlAttrNavBrow( BrowCtx *brow_ctx, void *xn) : ctx(brow_ctx), attrnav(xn) {}; GsdmlAttrNavBrow( BrowCtx *brow_ctx, void *xn) : ctx(brow_ctx), attrnav(xn) {}
~GsdmlAttrNavBrow(); ~GsdmlAttrNavBrow();
BrowCtx *ctx; BrowCtx *ctx;
...@@ -184,6 +184,7 @@ class GsdmlAttrNav { ...@@ -184,6 +184,7 @@ class GsdmlAttrNav {
pwr_tStatus *status); pwr_tStatus *status);
virtual ~GsdmlAttrNav(); virtual ~GsdmlAttrNav();
virtual void display_attr_help_text() {}
virtual void set_inputfocus() {} virtual void set_inputfocus() {}
void start_trace( pwr_tObjid Objid, char *object_str); void start_trace( pwr_tObjid Objid, char *object_str);
...@@ -229,11 +230,13 @@ class GsdmlAttrNav { ...@@ -229,11 +230,13 @@ class GsdmlAttrNav {
class ItemPn { class ItemPn {
public: public:
ItemPn() : parent(0) {} ItemPn() : parent(0), info_text(0) {}
ItemPn(const char *info_text) : parent(0), info_text(info_text) {}
attrnav_eItemType type; attrnav_eItemType type;
brow_tNode node; brow_tNode node;
char name[120]; char name[120];
int parent; int parent;
const char *info_text;
virtual ~ItemPn() {} virtual ~ItemPn() {}
...@@ -269,8 +272,7 @@ class ItemPnBase : public ItemPn { ...@@ -269,8 +272,7 @@ class ItemPnBase : public ItemPn {
class ItemPnEnumValue : public ItemPn { class ItemPnEnumValue : public ItemPn {
public: public:
ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num, ItemPnEnumValue( GsdmlAttrNav *attrnav, const char *item_name, int item_num,
int item_type_id, int item_type_id, void *attr_value_p, brow_tNode dest, flow_eDest dest_code, const char *info_text = 0);
void *attr_value_p, brow_tNode dest, flow_eDest dest_code);
int num; int num;
int type_id; int type_id;
void *value_p; void *value_p;
...@@ -686,4 +688,4 @@ class ItemPnEnumSendClock : public ItemPn { ...@@ -686,4 +688,4 @@ class ItemPnEnumSendClock : public ItemPn {
#if defined __cplusplus #if defined __cplusplus
} }
#endif #endif
#endif #endif
\ No newline at end of file
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