Commit eaa09420 authored by Claes Sjofors's avatar Claes Sjofors

Plc helptext objects added

parent f4f2b038
......@@ -208,6 +208,19 @@ void *CnvXtthelpToHtml::insert( navh_eItemType item_type, const char *text1,
strcat( fname, "#");
strcat( fname, link_bookmark);
}
else if ( file_name && strcmp( file_name, "") != 0) {
char *s = (char *)strrchr( file_name, '/');
if ( s)
strcpy( fname, s+1);
else
strcpy( fname, file_name);
s = strchr( fname, '.');
if ( s)
*s = 0;
strcat( fname, "_");
strcat( fname, link);
strcat( fname, ".html");
}
}
if ( !in_table)
cf->f << "<A HREF=\"" << fname << "\">";
......
......@@ -1622,6 +1622,39 @@ cdh_VolumeIdToString (
return ls;
}
//! Converts a volume identifier, 'vid' to a filename string.
/*!
The output string will be in the format:
The output string will be in the format:
xxx_xxx_xxx_xxx
where xxx are the volume id in decimal form.
If 's' is non null the resultant string will be catenated
to 's', otherwise the resultant string will be returned.
*/
char *
cdh_VolumeIdToFnString (
char *s,
pwr_tVolumeId vid
)
{
cdh_uVolumeId lvid;
static char str[40];
lvid.pwr = vid;
sprintf( str, "%3.3u_%3.3u_%3.3u_%3.3u", lvid.v.vid_3,
lvid.v.vid_2, lvid.v.vid_1, lvid.v.vid_0);
if (s != NULL)
return strcat(s, str);
else
return str;
}
//! Converts a subscription identifier, 'sid' to a string.
/*!
......
......@@ -973,6 +973,12 @@ cdh_VolumeIdToString (
int suffix
);
char *
cdh_VolumeIdToFnString (
char *s,
pwr_tVolumeId vid
);
char *
cdh_SubidToString (
char *s,
......
......@@ -67,6 +67,10 @@
%# define load_cNameRttSignals "rtt_crrs_%3.3d_%3.3d_%3.3d_%3.3d.dat"
%# define load_cNamePkg "pwrp_pkg_%s_%04d.tgz"
%# define load_cNameCustomBuild "$pwrp_exe/custom_build.sh"
%# define load_cNameBaseXttHelp "$pwr_lang/xtt_help.dat"
%# define load_cNameBaseWttHelp "$pwr_lang/wtt_help.dat"
%# define load_cNameProjectXttHelp "$pwrp_exe/xtt_help.dat"
%# define load_cNamePlcXttHelp "$pwrp_exe/xtthelp_%s_plc.dat"
%#endif
%
%
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2014 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_helptext.wb_load -- Defines the class HelpText.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcEdit
! @Summary Help text in plc document
! Help text in plc document.
!
! Makes it possible to insert a text that also will be available as
! an help text and has html pages.
!
! The help text can be opened from
! - help entry in the PlcPgm popup menu.
! - help on plcpgm entry in Plc editor and Plc trace menu.
!
! Some help text tags can be used. h1, h2 and b should be placed in
! the first position of the row.
! <h1> Large header
! <h2> Header
! <b> Bold text
! <image> Display a gif or png image. The image is displayed
! in the help viewer, but not it the plc document.
! <link> Link to another help topic. The link will work in the help
! viewer, but not in the plc document.
!
! The maximum size for the text is 1023 characters. For larger texts
! se HelpTextL.
!
! @b See also
! @classlink HelpTextL pwrb_helptextl.html
!*/
Object HelpText $ClassDef 632
Body SysBody
Attr Flags |= pwr_mClassDef_DevOnly
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_DevBodyOnly
EndBody
Object DevBody $ObjBodyDef 2
!/**
! The attribute influence the appearance of the text. The
! following values are used:
! @image orm_en1-26.gif
!*/
Object TextAttribute $Intern 1
Body SysBody
Attr TypeRef = "pwrb:Type-TextAttrEnum"
EndBody
EndObject
!/**
! Specifies if the text is to be surrounded by a some
! kind of frame.
! @image orm_en1-27.gif
!*/
Object FrameAttribute $Intern 2
Body SysBody
Attr TypeRef = "pwrb:Type-FrameAttrEnum"
EndBody
EndObject
!/**
! If the object has a frame the attributes will determine
! the size of the frame.
!
! 0, 0 means the size of the frame is accommodated to the
! current text.
! If the object is used only to frame other objects the
! attributes have to be increased in suitable way.
!*/
Object FrameWidth $Intern 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object FrameHeight $Intern 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PlcNode $Buffer 5
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Specifies the text to be shown.
!*/
Object Text $Intern 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Text1024"
Attr GraphName = "Text"
Attr NiNaAnnot = 1
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 1
Attr parameters[2] = 0
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 3
Attr graphindex = 2
Attr default_mask[0] = 0
Attr default_mask[1] = 0
Attr segname_annotation = 0
Attr devbody_annotation = 1
Attr compmethod = 2
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr objname = "HelpText"
Attr graphname = "HelpText"
Attr debugpar = ""
EndBody
EndObject
Object Template HelpText
Body DevBody
Attr TextAttribute = 1
Attr FrameAttribute = 2
EndBody
EndObject
EndObject
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2014 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_helptextl.wb_load -- Defines the class HelpTextL.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Plc,PlcEdit
! @Summary Help text in plc document
! Help text in plc document.
!
! Makes it possible to insert a text that also will be available as
! an help text and has html pages.
!
! The function is identical with HelpText, but HelpTextL has a larger
! text buffer and can contain 8191 characters.
!
! @b See also
! @classlink HelpText pwrb_helptext.html
!*/
Object HelpTextL $ClassDef 633
Body SysBody
Attr Flags |= pwr_mClassDef_DevOnly
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_DevBodyOnly
EndBody
Object DevBody $ObjBodyDef 2
!/**
! The attribute influence the appearance of the text. The
! following values are used:
! @image orm_en1-26.gif
!*/
Object TextAttribute $Intern 1
Body SysBody
Attr TypeRef = "pwrb:Type-TextAttrEnum"
EndBody
EndObject
!/**
! Specifies if the text is to be surrounded by a some
! kind of frame.
! @image orm_en1-27.gif
!*/
Object FrameAttribute $Intern 2
Body SysBody
Attr TypeRef = "pwrb:Type-FrameAttrEnum"
EndBody
EndObject
!/**
! If the object has a frame the attributes will determine
! the size of the frame.
!
! 0, 0 means the size of the frame is accommodated to the
! current text.
! If the object is used only to frame other objects the
! attributes have to be increased in suitable way.
!*/
Object FrameWidth $Intern 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object FrameHeight $Intern 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
Object PlcNode $Buffer 5
Body SysBody
Attr Class = pwr_eClass_PlcNode
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Specifies the text to be shown.
!*/
Object Text $Intern 6
Body SysBody
Attr TypeRef = "pwrs:Type-$Text8192"
Attr GraphName = "Text"
Attr NiNaAnnot = 1
EndBody
EndObject
EndObject
Object GraphPlcNode $GraphPlcNode
Body SysBody
Attr object_type = 11
Attr parameters[0] = 0
Attr parameters[1] = 1
Attr parameters[2] = 0
Attr parameters[3] = 0
Attr subwindows = 0
Attr graphmethod = 3
Attr graphindex = 2
Attr default_mask[0] = 0
Attr default_mask[1] = 0
Attr segname_annotation = 0
Attr devbody_annotation = 1
Attr compmethod = 2
Attr compindex = 0
Attr tracemethod = 0
Attr traceindex = 0
Attr objname = "HelpTextL"
Attr graphname = "HelpTextL"
Attr debugpar = ""
EndBody
EndObject
Object Template HelpTextL
Body DevBody
Attr TextAttribute = 1
Attr FrameAttribute = 2
EndBody
EndObject
EndObject
EndSObject
......@@ -799,6 +799,8 @@ palette PlcEditorPalette
class DocUser2
class Frame
class Head
class HelpText
class HelpTextL
class Point
class ShowPlcAttr
class Text
......
......@@ -697,6 +697,26 @@ void WFoeGtk::activate_help( GtkWidget *w, gpointer data)
foe->activate_help();
}
//
// Display help for the plc window
//
void WFoeGtk::activate_helpplc( GtkWidget *w, gpointer data)
{
WFoe *foe = (WFoe *)data;
foe->activate_helpplc();
}
//
// Display help for all the plcpmgs
//
void WFoeGtk::activate_helpplclist( GtkWidget *w, gpointer data)
{
WFoe *foe = (WFoe *)data;
foe->activate_helpplclist();
}
//
// Display class help for selected object
//
......@@ -1816,8 +1836,16 @@ pwr_tStatus WFoeGtk::create_window( int x_top,
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_helpplc = gtk_image_menu_item_new_with_mnemonic("H_elp on PlcPgm");
g_signal_connect(help_helpplc, "activate", G_CALLBACK(WFoeGtk::activate_helpplc), this);
GtkWidget *help_helpplclist = gtk_image_menu_item_new_with_mnemonic("He_lp PlcPgm Overview");
g_signal_connect(help_helpplclist, "activate", G_CALLBACK(WFoeGtk::activate_helpplclist), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_helpplc);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_helpplclist);
GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
......
......@@ -281,6 +281,8 @@ class WFoeGtk : public WFoe {
static void activate_expand( GtkWidget *w, gpointer data);
static void activate_compress( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_helpplc( GtkWidget *w, gpointer data);
static void activate_helpplclist( GtkWidget *w, gpointer data);
static void activate_helpclass( GtkWidget *w, gpointer data);
static void activate_trace_togg( GtkWidget *w, gpointer data);
static void activate_simulate_togg( GtkWidget *w, gpointer data);
......
......@@ -48,6 +48,7 @@
#include "wb_build.h"
#include "wb_name.h"
#include "wb_lfu.h"
#include "wb_foe.h"
#include "wb_merep.h"
#include "wb_log.h"
......@@ -484,6 +485,7 @@ void wb_build::rootvolume( pwr_tVid vid)
MsgWindow::message('I', msg, msgw_ePop_No);
}
WFoe::create_volume_xtthelpfile( &m_session, m_session.vid());
m_sts = sumsts;
}
......@@ -1125,6 +1127,7 @@ void wb_build::webhandler( pwr_tOid oid)
pwr_tTime modtime;
pwr_tString80 file_name, name;
pwr_tFileName fname;
pwr_tFileName srcname;
pwr_tTime ftime;
pwr_tTime xtthelp_time, html_time;
char *s;
......@@ -1175,14 +1178,14 @@ void wb_build::webhandler( pwr_tOid oid)
}
// Check if xtthelp should be converted to html
dcli_translate_filename( fname, "$pwrp_exe/xtt_help.dat");
dcli_translate_filename( fname, load_cNameProjectXttHelp);
fsts = dcli_file_time( fname, &xtthelp_time);
if ( EVEN(fsts)) return;
dcli_translate_filename( fname, "$pwrp_web/xtt_help_index.html");
fsts = dcli_file_time( fname, &html_time);
if ( opt.force || EVEN(fsts) || time_Acomp( &xtthelp_time, &html_time) == 1) {
system( "co_convert -d $pwrp_web -t $pwrp_exe/xtt_help.dat");
system( "co_convert -d $pwrp_web -t " load_cNameProjectXttHelp);
char msg[200];
sprintf( msg, "Build: WebHandler xtt_help.dat converted to html");
......@@ -1190,6 +1193,27 @@ void wb_build::webhandler( pwr_tOid oid)
m_sts = PWRB__SUCCESS;
}
// Check if plc xtthelp should be converted to html
sprintf( srcname, load_cNamePlcXttHelp, cdh_VolumeIdToFnString(0, oid.vid));
dcli_translate_filename( fname, srcname);
fsts = dcli_file_time( fname, &xtthelp_time);
if ( EVEN(fsts)) return;
sprintf( fname, "$pwrp_web/xtthelp_%s_plc_index.html", cdh_VolumeIdToFnString(0, oid.vid));
dcli_translate_filename( fname, fname);
fsts = dcli_file_time( fname, &html_time);
if ( opt.force || EVEN(fsts) || time_Acomp( &xtthelp_time, &html_time) == 1) {
char msg[200];
pwr_tCmd cmd;
sprintf( cmd, "co_convert -d $pwrp_web -t %s", srcname);
system( cmd);
sprintf( msg, "Build: WebHandler plc xtthelp-file converted to html");
MsgWindow::message( 'I', msg, msgw_ePop_No, oid);
m_sts = PWRB__SUCCESS;
}
// Generate wb history html file
pwr_tCmd cmd;
strcpy( cmd, "generate history");
......
......@@ -49,6 +49,8 @@
#include "co_msg.h"
#include "cow_login.h"
#include "wb_wtt.h"
#include "wb_vldh.h"
#include "rt_load.h"
static pwr_tStatus configure_parse_attr( ldh_sMenuCall *ip, pwr_tAttrRef *parent, char *str);
......@@ -639,7 +641,24 @@ static pwr_tStatus Help( ldh_sMenuCall *ip)
int size;
char cmd[200];
char *topic;
pwr_tCid cid;
sts = ldh_GetObjectClass(ip->PointedSession, ip->Pointed.Objid, &cid);
if (EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_plc: {
pwr_tOid woid;
sts = ldh_GetChild( ip->PointedSession, ip->Pointed.Objid, &woid);
if ( EVEN(sts)) return LDH__SUCCESS;
sprintf( cmd, "help plcw_%s /helpfile=\"" load_cNamePlcXttHelp "\"",
vldh_IdToStr(0, woid),
vldh_VolumeIdToStr(woid.vid));
break;
}
default:
sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
"HelpTopic", &topic, &size);
if ( EVEN(sts))
......@@ -654,6 +673,7 @@ static pwr_tStatus Help( ldh_sMenuCall *ip)
snprintf( cmd, sizeof(cmd), "help %s /strict", topic);
free( topic);
}
ip->wnav->command( cmd);
return 1;
......@@ -664,7 +684,15 @@ static pwr_tStatus HelpFilter( ldh_sMenuCall *ip)
pwr_tStatus sts;
int size;
char *topic;
pwr_tCid cid;
sts = ldh_GetObjectClass(ip->PointedSession, ip->Pointed.Objid, &cid);
if (EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_plc:
return 1;
default:
sts = ldh_GetObjectPar( ip->PointedSession, ip->Pointed.Objid, "RtBody",
"HelpTopic", &topic, &size);
if ( EVEN(sts))
......@@ -676,6 +704,7 @@ static pwr_tStatus HelpFilter( ldh_sMenuCall *ip)
free( topic);
return 0;
}
}
return 1;
}
......
......@@ -51,6 +51,7 @@
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_msg.h"
#include "rt_load.h"
#include "wb_ldh.h"
#include "wb_foe_msg.h"
#include "wb_vldh_msg.h"
......@@ -117,6 +118,7 @@ void WFoe::activate_save()
enable_ldh_cb();
error_msg( sts);
sts = create_flow();
sts = create_xtthelpfile();
normal_cursor();
......@@ -773,6 +775,8 @@ void WFoe::activate_changetext()
switch ( nodelist[0]->ln.cid) {
case pwr_cClass_Text:
case pwr_cClass_BodyText:
case pwr_cClass_HelpText:
case pwr_cClass_HelpTextL:
case pwr_cClass_Head:
case pwr_cClass_Title:
attr_create( nodelist[0]);
......@@ -1338,7 +1342,26 @@ void WFoe::activate_compress()
//
void WFoe::activate_help()
{
CoXHelp::dhelp( "plc editor", 0, navh_eHelpFile_Base, 0, 1);
CoXHelp::dhelp( "plceditor_refman", 0, navh_eHelpFile_Base, 0, 1);
}
void WFoe::activate_helpplc()
{
pwr_tFileName filename;
char key[80];
sprintf( filename, load_cNamePlcXttHelp, cdh_VolumeIdToFnString(0, gre->wind->lw.oid.vid));
sprintf( key, "plcw_%s", cdh_ObjidToFnString(0, gre->wind->lw.oid));
CoXHelp::dhelp( key, 0, navh_eHelpFile_Other, filename, 1);
}
void WFoe::activate_helpplclist()
{
pwr_tFileName filename;
sprintf( filename, load_cNamePlcXttHelp, cdh_VolumeIdToFnString(0, gre->wind->lw.oid.vid));
CoXHelp::dhelp( "index", 0, navh_eHelpFile_Other, filename, 1);
}
//
......@@ -1459,6 +1482,7 @@ void WFoe::exit_save( WFoe *foe)
sts = vldh_wind_save( foe->gre->wind);
foe->error_msg( sts);
sts = foe->create_flow();
sts = foe->create_xtthelpfile();
foe->normal_cursor();
if ( sts == VLDH__PLCNOTSAVED ) {
......@@ -1559,6 +1583,8 @@ void WFoe::gre_node_created( WGre *gre, unsigned long current_node_type,
switch ( cid) {
case pwr_cClass_Text:
case pwr_cClass_BodyText:
case pwr_cClass_HelpText:
case pwr_cClass_HelpTextL:
case pwr_cClass_Head:
case pwr_cClass_Title:
((WFoe *)gre->parent_ctx)->attr_create(node);
......@@ -1582,6 +1608,8 @@ void WFoe::gre_node_floating_created( WGre *gre, vldh_t_node node)
switch ( node->ln.cid) {
case pwr_cClass_Text:
case pwr_cClass_BodyText:
case pwr_cClass_HelpText:
case pwr_cClass_HelpTextL:
case pwr_cClass_Head:
case pwr_cClass_Title:
((WFoe *)gre->parent_ctx)->attr_create(node);
......@@ -2018,7 +2046,7 @@ void WFoe::gre_message( WGre *gre, const char *message)
SG 19.03.91
send the message received from gre modules to the foe routine
that will write them on the label widget . The backcalls routines
gre_xxx should never erase a message because there is chance that
gre_yyy should never erase a message because there is chance that
the message to be erased has just been set by a gre routine
*/
......@@ -3908,6 +3936,7 @@ void WFoe::edit_exit_save( WFoe *foe)
}
foe->create_flow();
foe->create_xtthelpfile();
unsigned int opt;
if ( foe->options & foe_mOption_EnableComment)
......@@ -4050,6 +4079,195 @@ int WFoe::create_flow()
return sts;
}
//
// Create xtt helpfile from HelpText objects.
//
int WFoe::create_xtthelpfile()
{
int sts;
pwr_tOName name;
pwr_tOName subw_name;
int size;
pwr_tFileName fname;
int objcnt = 0;
pwr_tOid *objlist;
FILE *fp;
vldh_t_wind wind = gre->wind;
char *textp;
vldh_t_node *nodelist;
unsigned long nodecnt;
int subw_found;
sts = vldh_get_nodes( wind, &nodecnt, &nodelist);
if ( EVEN(sts)) return sts;
if ( !nodecnt)
return FOE__SUCCESS;
for ( unsigned int i = 0; i < nodecnt; i++) {
if ( nodelist[i]->ln.cid == pwr_cClass_HelpText ||
nodelist[i]->ln.cid == pwr_cClass_HelpTextL) {
objcnt++;
}
}
if ( !objcnt) {
free( nodelist);
return FOE__SUCCESS;
}
objlist = (pwr_tOid *)calloc( objcnt, sizeof(pwr_tOid));
objcnt = 0;
for ( unsigned int i = 0; i < nodecnt; i++) {
if ( nodelist[i]->ln.cid == pwr_cClass_HelpText ||
nodelist[i]->ln.cid == pwr_cClass_HelpTextL) {
objlist[objcnt++] = nodelist[i]->ln.oid;
}
}
sts = ldh_ObjidToName( wind->hw.ldhses, wind->lw.oid, ldh_eName_Hierarchy,
name, sizeof( name), &size);
if ( EVEN(sts)) return sts;
sprintf( fname, "$pwrp_obj/xtthelp_%s.dat", vldh_IdToStr(0, wind->lw.oid));
dcli_translate_filename( fname, fname);
fp = fopen( fname, "w");
if ( !fp)
return FOE__NOFILE;
fprintf( fp, "<topic> plcw_%s\n", vldh_IdToStr(0, wind->lw.oid));
fprintf( fp, "%s\n", name);
// Create links to subwindows
subw_found = 0;
for ( unsigned int i = 0; i < nodecnt; i++) {
if ( nodelist[i]->ln.subwindow & 1 || nodelist[i]->ln.subwindow & 2) {
subw_found = 1;
break;
}
}
if ( subw_found) {
// fprintf( fp, "<h2>Subwindows\n");
for ( unsigned int i = 0; i < nodecnt; i++) {
if ( nodelist[i]->ln.subwindow & 1) {
sts = ldh_ObjidToName( wind->hw.ldhses, nodelist[i]->ln.subwind_oid[0],
ldh_eName_Hierarchy,
subw_name, sizeof( subw_name), &size);
if ( EVEN(sts)) return sts;
fprintf( fp, "%s <link>plcw_%s,," load_cNamePlcXttHelp "\n", &subw_name[strlen(name)+1],
vldh_IdToStr(0, nodelist[i]->ln.subwind_oid[0]), vldh_VolumeIdToStr(wind->lw.oid.vid));
}
if ( nodelist[i]->ln.subwindow & 2) {
sts = ldh_ObjidToName( wind->hw.ldhses, nodelist[i]->ln.subwind_oid[1],
ldh_eName_Hierarchy,
subw_name, sizeof( subw_name), &size);
if ( EVEN(sts)) return sts;
fprintf( fp, "%s <link>plcw_%s,," load_cNamePlcXttHelp "\n", &subw_name[strlen(name)+1],
vldh_IdToStr(0, nodelist[i]->ln.subwind_oid[1]), vldh_VolumeIdToStr(wind->lw.oid.vid));
}
}
fprintf( fp, "\n");
}
for ( int i = 0; i < objcnt; i++) {
sts = ldh_GetObjectPar( wind->hw.ldhses, objlist[i], "DevBody", "Text",
&textp, &size);
if ( EVEN(sts)) return sts;
fprintf( fp, "%s", textp);
fprintf( fp, "\n");
}
fprintf( fp, "</topic>\n");
fclose( fp);
free( nodelist);
free( objlist);
return sts;
}
static void copy_helpfile( FILE *fp, pwr_tOid woid)
{
FILE *fwp;
int c;
pwr_tFileName fname;
sprintf( fname, "$pwrp_obj/xtthelp_%s.dat", vldh_IdToStr(0, woid));
dcli_translate_filename( fname, fname);
fwp = fopen(fname, "r");
if ( !fwp)
return;
while( (c = getc(fwp)) != EOF)
putc( c, fp);
fclose( fwp);
}
int WFoe::create_volume_xtthelpfile( ldh_tSession ldhses, pwr_tVid vid)
{
pwr_tFileName fname;
FILE *fp;
pwr_tOName name;
int size;
pwr_tStatus sts;
char *desc;
pwr_tOid oid, woid;
sprintf( fname, load_cNamePlcXttHelp, vldh_VolumeIdToStr(vid));
dcli_translate_filename( fname, fname);
fp = fopen( fname, "w");
if ( !fp) return FOE__NOFILE;
// Insert a list of all PlcPgm
fprintf( fp, "<topic> index\nPlcPgm List\n");
for ( sts = ldh_GetClassList( ldhses, pwr_cClass_plc, &oid);
ODD(sts);
sts = ldh_GetNextObject( ldhses, oid, &oid)) {
sts = ldh_ObjidToName( ldhses, oid, ldh_eName_Hierarchy,
name, sizeof( name), &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectPar( ldhses, oid, "RtBody", "Description",
&desc, &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetChild( ldhses, oid, &woid);
if ( EVEN(sts)) continue;
fprintf( fp, "%s <t><t>%s<link> plcw_%s,," load_cNamePlcXttHelp "\n",
name, desc, vldh_IdToStr(0, woid), vldh_VolumeIdToStr(vid));
free(desc);
}
fprintf( fp, "</topic>\n\n");
// Insert xtthelp for all plc windows
for ( sts = ldh_GetClassList( ldhses, pwr_cClass_windowplc, &woid);
ODD(sts);
sts = ldh_GetNextObject( ldhses, woid, &woid))
copy_helpfile( fp, woid);
for ( sts = ldh_GetClassList( ldhses, pwr_cClass_windoworderact, &woid);
ODD(sts);
sts = ldh_GetNextObject( ldhses, woid, &woid))
copy_helpfile( fp, woid);
for ( sts = ldh_GetClassList( ldhses, pwr_cClass_windowcond, &woid);
ODD(sts);
sts = ldh_GetNextObject( ldhses, woid, &woid))
copy_helpfile( fp, woid);
for ( sts = ldh_GetClassList( ldhses, pwr_cClass_windowsubstep, &woid);
ODD(sts);
sts = ldh_GetNextObject( ldhses, woid, &woid))
copy_helpfile( fp, woid);
fclose(fp);
return FOE__SUCCESS;
}
/* API routines */
#if 0
......
......@@ -258,6 +258,8 @@ class WFoe : public WUtility {
void activate_expand();
void activate_compress();
void activate_help();
void activate_helpplc();
void activate_helpplclist();
void activate_helpclass();
void activate_trace_togg( int set);
void activate_simulate_togg( int set);
......@@ -293,6 +295,7 @@ class WFoe : public WUtility {
int change_mode( int new_mode);
int redraw_and_save();
int create_flow();
int create_xtthelpfile();
static WFoe *get( pwr_tOid oid);
static void reset_current_node( WFoe *foe);
......@@ -352,6 +355,7 @@ class WFoe : public WUtility {
static void gre_message( WGre *gre, const char *message);
static void pal_select_cb( void *ctx, pwr_tCid cid);
static int create_volume_xtthelpfile( ldh_tSession ldhses, pwr_tVid vid);
};
......
......@@ -125,6 +125,7 @@ int goen_create_nodetype_m3(
int line_width;
flow_eAnnotType annot_type;
int annot_rows;
int graph_index = graphbody->graphindex;
static int idx = 0;
sts = ldh_ClassIdToName(ldhses, cid, name, sizeof(name), &size);
......@@ -250,11 +251,17 @@ int goen_create_nodetype_m3(
else
annot_type = flow_eAnnotType_MultiLine;
if ( graph_index == 2)
annot_type = flow_eAnnotType_HelpText;
flow_MeasureAnnotText( ctx, parvalue,
text_type, text_size, annot_type,
&width, &height, &annot_rows);
free((char *) parvalue);
if ( annot_rows == 0)
annot_rows = 1;
f_height = (floor( (height + f_delta*2)/ GOEN_F_GRID) + 1) * GOEN_F_GRID - f_delta*2;
f_width = co_max( width + f_strlength *2, f_defwidth) - f_delta*2;
if ( (height < GOEN_F_GRID-f_delta*2) && (f_height > GOEN_F_GRID))
......@@ -285,6 +292,10 @@ int goen_create_nodetype_m3(
f_height, line_type, line_width, flow_mDisplayLevel_1);
}
if ( annot_type == flow_eAnnotType_HelpText)
flow_AddAnnot( nc, f_strlength, 0, 0, text_type, text_size,
annot_type, flow_mDisplayLevel_1);
else
flow_AddAnnot( nc, f_strlength, (f_height - height)/2 +
height/annot_rows - f_yoffs, 0, text_type, text_size,
annot_type, flow_mDisplayLevel_1);
......
......@@ -352,8 +352,12 @@ PalItemClass::PalItemClass( Pal *pal, char *item_name,
case pwr_cClass_CStoSattr:
pixmap = pal->pixmap_stop;
break;
case pwr_cClass_BodyText:
case pwr_cClass_HelpText:
case pwr_cClass_HelpTextL:
pixmap = pal->pixmap_bodytext;
break;
case pwr_cClass_Text: pixmap = pal->pixmap_text; break;
case pwr_cClass_BodyText: pixmap = pal->pixmap_bodytext; break;
case pwr_cClass_Head: pixmap = pal->pixmap_head; break;
case pwr_cClass_Title: pixmap = pal->pixmap_title; break;
case pwr_cClass_Frame: pixmap = pal->pixmap_frame; break;
......
......@@ -110,7 +110,7 @@ CoHelpMain::CoHelpMain( int argc, char *argv[], int *return_sts) :
type = navh_eHelpFile_Other;
if ( strcmp(topic, "index") == 0)
strcpy( topic, "overview");
strcpy( helpfile, "$pwr_lang/wtt_help.dat");
strcpy( helpfile, load_cNameBaseWttHelp);
}
else if ( strcmp( argv[i], "-d") == 0) {
type = navh_eHelpFile_Other;
......@@ -123,7 +123,7 @@ CoHelpMain::CoHelpMain( int argc, char *argv[], int *return_sts) :
type = navh_eHelpFile_Other;
if ( strcmp(topic, "index") == 0)
strcpy( topic, "overview");
strcpy( helpfile, "$pwr_exe/xtt_help.dat");
strcpy( helpfile, load_cNameBaseXttHelp);
}
else if ( strcmp( argv[i], "-g") == 0) {
type = navh_eHelpFile_Other;
......
......@@ -59,13 +59,17 @@
#include "flow_browapi.h"
#endif
#ifndef rt_load_h
#include "rt_load.h"
#endif
#ifndef flow_browwidget_motif_h
// #include "flow_browwidget_motif.h"
#endif
#define xhelp_cFile_BaseXtt "$pwr_lang/xtt_help.dat"
#define xhelp_cFile_BaseWtt "$pwr_lang/wtt_help.dat"
#define xhelp_cFile_Project "$pwrp_exe/xtt_help.dat"
#define xhelp_cFile_BaseXtt load_cNameBaseXttHelp
#define xhelp_cFile_BaseWtt load_cNameBaseWttHelp
#define xhelp_cFile_Project load_cNameProjectXttHelp
#define XHELPNAV_BROW_MAX 25
typedef enum {
......
......@@ -142,7 +142,8 @@ typedef enum {
typedef enum {
flow_eAnnotType_OneLine,
flow_eAnnotType_MultiLine
flow_eAnnotType_MultiLine,
flow_eAnnotType_HelpText
} flow_eAnnotType;
typedef enum {
......
This diff is collapsed.
......@@ -47,6 +47,7 @@
#include "co_ccm_msg.h"
#include "co_dcli.h"
#include "co_cnf.h"
#include "rt_load.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "glow.h"
......@@ -587,12 +588,12 @@ int Graph::generate_web_help()
system( "cp $pwr_exe/pwr_css.css $pwrp_web/");
// If $pwrp_exe/xtt_help.dat exist convert this to html
sts = dcli_search_file( "$pwrp_exe/xtt_help.dat", fname,
sts = dcli_search_file( load_cNameProjectXttHelp, fname,
DCLI_DIR_SEARCH_INIT);
if ( ODD(sts)) {
system( "co_convert -d $pwrp_web -t $pwrp_exe/xtt_help.dat");
system( "co_convert -d $pwrp_web -t " load_cNameProjectXttHelp);
}
sts = dcli_search_file( "$pwrp_exe/xtt_help.dat", fname,
sts = dcli_search_file( load_cNameProjectXttHelp, fname,
DCLI_DIR_SEARCH_END);
return 1;
}
......
......@@ -237,6 +237,13 @@ void RtTraceGtk::activate_helpplc(GtkWidget *w, gpointer data)
tractx->activate_helpplc();
}
void RtTraceGtk::activate_helpplclist(GtkWidget *w, gpointer data)
{
RtTrace *tractx = (RtTrace *)data;
tractx->activate_helpplclist();
}
RtTraceGtk::~RtTraceGtk()
{
trace_tNode *node, *fnode;
......@@ -594,13 +601,18 @@ RtTraceGtk::RtTraceGtk( void *tr_parent_ctx, GtkWidget *tr_parent_wid, pwr_tObji
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_plcpgm = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _PlcPgm"));
GtkWidget *help_plcpgm = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("On _PlcPgm"));
g_signal_connect( help_plcpgm, "activate",
G_CALLBACK(activate_helpplc), this);
GtkWidget *help_plclist = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("P_lcPgm Overview"));
g_signal_connect( help_plclist, "activate",
G_CALLBACK(activate_helpplclist), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_plcpgm);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_plclist);
GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
......
......@@ -85,6 +85,7 @@ class RtTraceGtk : public RtTrace {
static void activate_scantime5(GtkWidget *w, gpointer data);
static void activate_help(GtkWidget *w, gpointer data);
static void activate_helpplc(GtkWidget *w, gpointer data);
static void activate_helpplclist(GtkWidget *w, gpointer data);
};
#endif
......
......@@ -44,6 +44,7 @@
#include "xtt_url.h"
#include "rt_xnav_msg.h"
#include "rt_gdh.h"
#include "rt_load.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "cow_wow.h"
......@@ -1074,12 +1075,30 @@ static pwr_tStatus Help( xmenu_sMenuCall *ip)
pwr_tString40 helptopic;
pwr_tCmd cmd;
pwr_sAttrRef *objar;
pwr_tCid cid;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &cid);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_plc: {
pwr_tOid woid;
sts = gdh_GetChild( objar->Objid, &woid);
if ( EVEN(sts)) return XNAV__SUCCESS;
sprintf( cmd, "help plcw_%s /helpfile=\"" load_cNamePlcXttHelp "\"",
cdh_ObjidToFnString(0, woid),
cdh_VolumeIdToFnString(0, woid.vid));
break;
}
default:
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -1092,7 +1111,7 @@ static pwr_tStatus Help( xmenu_sMenuCall *ip)
return 0;
sprintf( cmd, "help %s", helptopic);
}
sts = ((XNav *)ip->EditorContext)->command( cmd);
return XNAV__SUCCESS;
......@@ -1105,12 +1124,20 @@ static pwr_tStatus HelpFilter( xmenu_sMenuCall *ip)
pwr_tAName name;
pwr_tString40 helptopic;
pwr_sAttrRef *objar;
pwr_tCid cid;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &cid);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_plc:
return XNAV__SUCCESS;
default:
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -1121,7 +1148,7 @@ static pwr_tStatus HelpFilter( xmenu_sMenuCall *ip)
if ( strcmp( helptopic, "") == 0)
return XNAV__INVISIBLE;
}
return XNAV__SUCCESS;
}
......
......@@ -53,6 +53,7 @@
#include "cow_wow.h"
#include "co_trace.h"
#include "rt_gdh.h"
#include "rt_load.h"
#include "xtt_trace.h"
#include "xtt_menu.h"
......@@ -671,19 +672,29 @@ void RtTrace::activate_view()
void RtTrace::activate_help()
{
if ( help_cb)
(help_cb)(this, "opg_trace");
(help_cb)(this, "opg_trace", 0);
}
void RtTrace::activate_helpplc()
{
pwr_tOName name;
int sts;
pwr_tFileName filename;
char key[80];
sts = gdh_ObjidToName( objid, name, sizeof(name), cdh_mNName);
if (EVEN(sts)) return;
sprintf( filename, load_cNamePlcXttHelp, cdh_VolumeIdToFnString(0, objid.vid));
sprintf( key, "plcw_%s", cdh_ObjidToFnString(0, objid));
if ( help_cb)
(help_cb)(this, key, filename);
}
void RtTrace::activate_helpplclist()
{
pwr_tFileName filename;
sprintf( filename, load_cNamePlcXttHelp, cdh_VolumeIdToFnString(0, objid.vid));
if ( help_cb)
(help_cb)(this, name);
(help_cb)(this, "index", filename);
}
......
......@@ -74,7 +74,7 @@ class RtTrace {
pwr_tObjid objid;
double scan_time;
void (*close_cb) (RtTrace *);
void (*help_cb) (RtTrace *, const char *);
void (*help_cb) (RtTrace *, const char *, const char *);
void (*subwindow_cb) (void *parent_ctx, pwr_tObjid objid);
void (*display_object_cb) (void *parent_ctx, pwr_tObjid objid);
void (*collect_insert_cb) (void *parent_ctx, pwr_tObjid objid);
......@@ -124,6 +124,7 @@ class RtTrace {
void activate_view();
void activate_help();
void activate_helpplc();
void activate_helpplclist();
protected:
void get_trace_attr( flow_tObject object,
......
......@@ -1885,7 +1885,7 @@ void XNav::trace_close_cb( RtTrace *tractx)
delete tractx;
}
void XNav::trace_help_cb( RtTrace *tractx, const char *key)
void XNav::trace_help_cb( RtTrace *tractx, const char *key, const char *file)
{
XNav *xnav = (XNav *) tractx->parent_ctx;
int sts;
......@@ -1894,6 +1894,14 @@ void XNav::trace_help_cb( RtTrace *tractx, const char *key)
pwr_tObjid objid;
char objid_str[40];
if ( file) {
sts = CoXHelp::dhelp( key, "", navh_eHelpFile_Other, file, 0);
if ( EVEN(sts))
xnav->message( 'E', "Unable to find topic");
else
xnav->message( ' ', null_str);
}
else {
sts = CoXHelp::dhelp( key, "", navh_eHelpFile_Project, NULL, 0);
if ( EVEN(sts)) {
// Try to convert to objid and search for objid as topic
......@@ -1909,6 +1917,7 @@ void XNav::trace_help_cb( RtTrace *tractx, const char *key)
xnav->message( 'E', "Unable to find topic");
else
xnav->message( ' ', null_str);
}
// xnav->pop();
}
......
......@@ -477,7 +477,7 @@ class XNav {
static int is_authorized_cb( void *xnav, unsigned int access);
static void trace_collect_insert_cb( void *ctx, pwr_tObjid objid);
static void trace_close_cb( RtTrace *tractx);
static void trace_help_cb( RtTrace *tractx, const char *key);
static void trace_help_cb( RtTrace *tractx, const char *key, const char *file);
static void xatt_close_cb( void *xnav, void *xatt);
static void xcrr_close_cb( void *xnav, void *xcrr);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
......
......@@ -48,6 +48,7 @@
#include "co_cdh.h"
#include "co_dcli.h"
#include "rt_load.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
......@@ -141,8 +142,8 @@ int XNav::help( char *help_key, char *help_bookmark,
int sts;
brow_tNode bookmark_node;
brow_tNode prev, first;
NavHelp *navhelp = new NavHelp( (void *)this, "$pwr_exe/xtt_help.dat",
"$pwrp_exe/xtt_help.dat");
NavHelp *navhelp = new NavHelp( (void *)this, load_cNameBaseXttHelp,
load_cNameProjectXttHelp);
navhelp->insert_cb = xnav_help_insert_cb;
if ( pop)
......@@ -194,8 +195,8 @@ int XNav::help_index( navh_eHelpFile file_type, char *file_name, int pop)
int sts;
brow_tObject *object_list;
int object_cnt;
NavHelp *navhelp = new NavHelp( (void *)this, "$pwr_exe/xtt_help.dat",
"$pwrp_exe/xtt_help.dat");
NavHelp *navhelp = new NavHelp( (void *)this, load_cNameBaseXttHelp,
load_cNameProjectXttHelp);
navhelp->insert_cb = xnav_help_insert_cb;
if (pop)
......
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