Commit 62a5f6e4 authored by Claes Sjofors's avatar Claes Sjofors

Collection window added

parent 2a63b77e
......@@ -426,6 +426,37 @@ void XttGtk::activate_collect_clear( GtkWidget *w, gpointer data)
xtt->xnav->collect_clear();
}
void XttGtk::activate_collect_window( GtkWidget *w, gpointer data)
{
Xtt *xtt = (Xtt *)data;
if ( !xtt->xnav->is_authorized())
return;
xtt->xnav->collect_window( 1);
}
void XttGtk::activate_collect_new_window( GtkWidget *w, gpointer data)
{
Xtt *xtt = (Xtt *)data;
if ( !xtt->xnav->is_authorized())
return;
xtt->xnav->collect_window( 0);
}
void XttGtk::activate_collect_open( GtkWidget *w, gpointer data)
{
Xtt *xtt = (Xtt *)data;
pwr_tCmd cmd = "collect open";
if ( !xtt->xnav->is_authorized())
return;
xtt->xnav->command( cmd);
}
void XttGtk::activate_advanceduser( GtkWidget *w, gpointer data)
{
Xtt *xtt = (Xtt *)data;
......@@ -778,6 +809,18 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
g_signal_connect( functions_collect_clear, "activate",
G_CALLBACK(XttGtk::activate_collect_clear), this);
GtkWidget *functions_collect_window = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Copy to Window"));
g_signal_connect( functions_collect_window, "activate",
G_CALLBACK(XttGtk::activate_collect_window), this);
GtkWidget *functions_collect_new_window = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_New Window"));
g_signal_connect( functions_collect_new_window, "activate",
G_CALLBACK(XttGtk::activate_collect_new_window), this);
GtkWidget *functions_collect_open = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Open"));
g_signal_connect( functions_collect_open, "activate",
G_CALLBACK(XttGtk::activate_collect_open), this);
GtkWidget *functions_collect = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Collect"));
GtkMenu *functions_collect_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
......@@ -785,6 +828,9 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_show);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_remove);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_clear);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_window);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_new_window);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_collect_menu), functions_collect_open);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions_collect),
GTK_WIDGET(functions_collect_menu));
......
......@@ -107,6 +107,9 @@ class XttGtk : public Xtt {
static void activate_collect_show( GtkWidget *w, gpointer data);
static void activate_collect_remove( GtkWidget *w, gpointer data);
static void activate_collect_clear( GtkWidget *w, gpointer data);
static void activate_collect_window( GtkWidget *w, gpointer data);
static void activate_collect_new_window( GtkWidget *w, gpointer data);
static void activate_collect_open( GtkWidget *w, gpointer data);
static void activate_advanceduser( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
......
......@@ -168,6 +168,130 @@ void CoWowGtk::DisplayQuestion( void *ctx, const char *title, const char *text,
gtk_widget_show_all( question_widget);
}
void CoWowGtk::inputdialog_ok_cb( GtkWidget *w, gpointer data)
{
wow_t_inputdialog_cb *cbdata = (wow_t_inputdialog_cb *) data;
char *text;
gchar *textutf8 = gtk_editable_get_chars( GTK_EDITABLE(cbdata->input_widget), 0, -1);
text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL);
g_free( textutf8);
if (cbdata->inputdialogbox_ok)
(cbdata->inputdialogbox_ok)( cbdata->ctx, cbdata->data, text);
gtk_widget_destroy( cbdata->inputdialog_widget);
free( (char *)cbdata);
g_free( text);
}
void CoWowGtk::inputdialog_cancel_cb( GtkWidget *w, gpointer data)
{
wow_t_inputdialog_cb *cbdata = (wow_t_inputdialog_cb *) data;
if (cbdata->inputdialogbox_cancel)
(cbdata->inputdialogbox_cancel)( cbdata->ctx, cbdata->data);
gtk_widget_destroy( cbdata->inputdialog_widget);
free( (char *)cbdata);
}
static gint inputdialog_delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
CoWowGtk::inputdialog_cancel_cb( w, data);
return TRUE;
}
/************************************************************************
*
* Name: CreateInputDialog
*
* Description: Create an input dialog widget
*
*************************************************************************/
void CoWowGtk::CreateInputDialog( void *ctx, const char *title, const char *text,
void (* inputdialogbox_ok) ( void *, void *, char *),
void (* inputdialogbox_cancel) ( void *, void *),
int input_length,
char *init_text,
void *data)
{
GtkWidget *inputdialog_widget;
GtkWidget *inputdialog_label;
wow_t_inputdialog_cb *cbdata;
cbdata = (wow_t_inputdialog_cb *) calloc( 1, sizeof(*cbdata));
cbdata->inputdialogbox_ok = inputdialogbox_ok;
cbdata->inputdialogbox_cancel = inputdialogbox_cancel;
cbdata->inputdialogbox_help = 0;
cbdata->ctx = ctx;
cbdata->data = data;
// Create a inputdialog window
inputdialog_widget = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 150,
"default-width", 400,
"title", translate_utf8(title),
"window-position", GTK_WIN_POS_CENTER,
NULL);
cbdata->inputdialog_widget = inputdialog_widget;
g_signal_connect( inputdialog_widget, "delete_event", G_CALLBACK(inputdialog_delete_event), cbdata);
inputdialog_label = gtk_label_new( translate_utf8( text));
GtkWidget *inputdialog_image = (GtkWidget *)g_object_new( GTK_TYPE_IMAGE,
"stock", GTK_STOCK_DIALOG_QUESTION,
"icon-size", GTK_ICON_SIZE_DIALOG,
"xalign", 0.5,
"yalign", 1.0,
NULL);
GtkWidget *inputdialog_ok = gtk_button_new_with_label( translate_utf8("Yes"));
gtk_widget_set_size_request( inputdialog_ok, 70, 28);
g_signal_connect( inputdialog_ok, "clicked",
G_CALLBACK(inputdialog_ok_cb), cbdata);
GtkWidget *inputdialog_no = gtk_button_new_with_label( translate_utf8("No"));
gtk_widget_set_size_request( inputdialog_no, 70, 28);
g_signal_connect( inputdialog_no, "clicked",
G_CALLBACK(inputdialog_cancel_cb), cbdata);
GtkWidget *textinput = gtk_entry_new_with_max_length( input_length);
cbdata->input_widget = textinput;
g_signal_connect( textinput, "activate",
G_CALLBACK(inputdialog_ok_cb), cbdata);
GtkWidget *inputdialog_hboxtext = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(inputdialog_hboxtext), inputdialog_image, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(inputdialog_hboxtext), inputdialog_label, TRUE, TRUE, 15);
GtkWidget *inputdialog_hboxinput = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(inputdialog_hboxinput), textinput, TRUE, TRUE, 15);
GtkWidget *inputdialog_hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(inputdialog_hboxbuttons), inputdialog_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(inputdialog_hboxbuttons), inputdialog_no, FALSE, FALSE, 0);
GtkWidget *inputdialog_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(inputdialog_vbox), inputdialog_hboxtext, TRUE, TRUE, 20);
gtk_box_pack_start( GTK_BOX(inputdialog_vbox), inputdialog_hboxinput, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(inputdialog_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(inputdialog_vbox), inputdialog_hboxbuttons, FALSE, FALSE, 15);
gtk_container_add( GTK_CONTAINER(inputdialog_widget), inputdialog_vbox);
gtk_widget_show_all( inputdialog_widget);
gint pos = 0;
if ( init_text && strcmp( init_text, "") != 0) {
char *textutf8 = g_convert( text, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
gtk_editable_insert_text( GTK_EDITABLE(textinput), textutf8,
strlen(textutf8), &pos);
g_free( textutf8);
}
}
/************************************************************************
*
* Description: Create an Error message dialog.
......@@ -425,9 +549,9 @@ void *CoWowGtk::CreateList (
G_CALLBACK(CoWowGtk::list_cancel_cb), ctx);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), ok_button, FALSE, FALSE, 20);
if ( show_apply_button)
gtk_box_pack_start( GTK_BOX(hboxbuttons), apply_button, FALSE, FALSE, 20);
gtk_box_pack_start( GTK_BOX(hboxbuttons), ok_button, FALSE, FALSE, 20);
gtk_box_pack_end( GTK_BOX(hboxbuttons), cancel_button, FALSE, FALSE, 20);
GtkWidget *scrolled_window = gtk_scrolled_window_new( NULL, NULL);
......
......@@ -53,6 +53,16 @@ typedef struct {
GtkWidget *question_widget;
} wow_t_question_cb;
typedef struct {
void *ctx;
void *data;
void (* inputdialogbox_ok) ( void *, void *, char *);
void (* inputdialogbox_cancel) ( void *, void *);
void (* inputdialogbox_help) ( void *, void *);
GtkWidget *inputdialog_widget;
GtkWidget *input_widget;
} wow_t_inputdialog_cb;
class CoWowEntryGtk {
public:
CoWowRecall *m_re;
......@@ -114,6 +124,12 @@ class CoWowGtk : public CoWow {
void *data);
void DisplayError( const char *title, const char *text);
void DisplayText( const char *title, const char *text);
void CreateInputDialog( void *ctx, const char *title, const char *text,
void (* inputdialogbox_ok) ( void *, void *, char *),
void (* inputdialogbox_cancel) ( void *, void *),
int input_length,
char *init_text,
void *data);
void *CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (cancel_cb)( void *),
......@@ -142,6 +158,8 @@ class CoWowGtk : public CoWow {
static void SetWindowIcon( GtkWidget *w);
static void question_ok_cb( GtkWidget *w, gpointer data);
static void question_cancel_cb( GtkWidget *w, gpointer data);
static void inputdialog_ok_cb( GtkWidget *w, gpointer data);
static void inputdialog_cancel_cb( GtkWidget *w, gpointer data);
static void warranty_cb( GtkWidget *w, gint response, gpointer data);
static void license_cb( GtkWidget *w, gint response, gpointer data);
static char *translate_utf8( const char *str);
......
......@@ -42,9 +42,12 @@
#include "pwr.h"
#include "cow_wow.h"
#include "co_dcli.h"
bool CoWow::m_autoremove = false;
CoWow::~CoWow() {}
int CoWow::HideWarranty()
{
static int hide = 0;
......@@ -54,3 +57,67 @@ int CoWow::HideWarranty()
return prev;
}
#define FILELIST_TEXTSIZE 80
void *CoWow::CreateFileList(
const char *title,
const char *dir,
const char *pattern,
const char *type,
void (action_cb)( void *, char *),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button
)
{
int sts;
pwr_tFileName file_spec, found_file, stype, item;
char *s;
char *texts;
int i, cnt;
if ( type) {
if ( type[0] == '.')
strncat( stype, type, sizeof(stype));
else {
strcpy( stype, ".");
strncat( stype, type, sizeof(stype)-1);
}
sprintf( file_spec, "%s/%s%s", dir, pattern, stype);
}
else
sprintf( file_spec, "%s/%s", dir, pattern);
// Count number of items
cnt = 0;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while( ODD(sts)) {
cnt++;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT);
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
texts = (char *)calloc( cnt+1, FILELIST_TEXTSIZE);
i = 0;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while( ODD(sts)) {
if (( s = strrchr( found_file, '/')))
strncpy( item, s+1, sizeof(item));
else
strncpy( item, found_file, sizeof(item));
if ( type) {
if ( (s = strstr( item, stype)))
*s = 0;
}
strncpy( &texts[ FILELIST_TEXTSIZE * i], item, FILELIST_TEXTSIZE);
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT);
i++;
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
return CreateList( title, texts, FILELIST_TEXTSIZE, action_cb, cancel_cb,
ctx, show_apply_button);
}
......@@ -105,13 +105,20 @@ class CoWow {
public:
CoWow() {}
virtual ~CoWow() {}
virtual ~CoWow();
virtual void DisplayQuestion( void *ctx, const char *title, const char *text,
void (* questionbox_ok) ( void *, void *),
void (* questionbox_cancel) ( void *, void *),
void *data) {}
virtual void DisplayError( const char *title, const char *text) {}
virtual void DisplayText( const char *title, const char *text) {}
virtual void CreateInputDialog( void *ctx, const char *title, const char *text,
void (* inputdialogbox_ok) ( void *, void *, char *),
void (* inputdialogbox_cancel) ( void *, void *),
int input_length,
char *init_text,
void *data) {}
virtual void *CreateList( const char *title, const char *texts, int textsize,
void (action_cb)( void *, char *),
void (cancel_cb)( void *),
......@@ -130,12 +137,21 @@ class CoWow {
virtual void Wait( float time) {}
static int HideWarranty();
void *CreateFileList( const char *title,
const char *dir,
const char *pattern,
const char *type,
void (action_cb)( void *, char *),
void (cancel_cb)( void *),
void *ctx,
int show_apply_button = 0);
virtual int DisplayWarranty() { return 0;}
virtual void DisplayLicense() {}
virtual CoWowTimer *timer_new() { return 0;}
virtual pwr_tStatus CreateMenuItem( const char *name, void *menu, int pixmap, int append, void *w) { return 0;}
virtual pwr_tStatus DeleteMenuItem( const char *name, void *menu) { return 0;}
static void SetAutoRemove( bool on) { m_autoremove = on;}
};
#endif
......
......@@ -1115,3 +1115,42 @@ int FlowArray::get_last( FlowArrayElem **last)
return 1;
}
int FlowArray::move_up( FlowArrayElem *element)
{
int i;
FlowArrayElem *prev;
for ( i = 0; i < a_size; i++)
{
if ( a[i] == element)
{
if ( i == 0)
return FLOW__NOPREVIOUS;
prev = a[i-1];
a[i-1] = a[i];
a[i] = prev;
return 1;
}
}
return FLOW__NOELEM;
}
int FlowArray::move_down( FlowArrayElem *element)
{
int i;
FlowArrayElem *next;
for ( i = 0; i < a_size; i++)
{
if ( a[i] == element)
{
if ( i == a_size - 1)
return FLOW__NONEXT;
next = a[i+1];
a[i+1] = a[i];
a[i] = next;
return 1;
}
}
return FLOW__NOELEM;
}
......@@ -108,6 +108,8 @@ class FlowArray {
int get_last( FlowArrayElem **last);
int get_previous( FlowArrayElem *element, FlowArrayElem **prev);
int get_next( FlowArrayElem *element, FlowArrayElem **next);
int move_up( FlowArrayElem *element);
int move_down( FlowArrayElem *element);
~FlowArray();
friend class FlowNodeClass;
friend class FlowCtx;
......
......@@ -718,6 +718,16 @@ int brow_GetPreviousSibling( brow_tCtx ctx, brow_tObject object,
return ctx->get_previous_sibling( (FlowArrayElem *)object, (FlowArrayElem **)sibling);
}
int brow_MoveUp( brow_tCtx ctx, brow_tObject object)
{
return ctx->move_up( (FlowArrayElem *)object);
}
int brow_MoveDown( brow_tCtx ctx, brow_tObject object)
{
return ctx->move_down( (FlowArrayElem *)object);
}
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type)
{
return ctx->is_visible( (FlowArrayElem *)object, type);
......
......@@ -240,6 +240,8 @@ int brow_GetNextSibling( brow_tCtx ctx, brow_tObject object,
brow_tObject *sibling);
int brow_GetPreviousSibling( brow_tCtx ctx, brow_tObject object,
brow_tObject *sibling);
int brow_MoveUp( brow_tCtx ctx, brow_tObject object);
int brow_MoveDown( brow_tCtx ctx, brow_tObject object);
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type);
int brow_GetFirstVisible( brow_tCtx ctx, brow_tObject *object);
int brow_GetLastVisible( brow_tCtx ctx, brow_tObject *object);
......
......@@ -362,3 +362,15 @@ void brow_scroll_vertical( BrowCtx *ctx, int value, int bottom)
ctx->y_high * ctx->zoom_factor);
ctx->scroll( 0, y_pix);
}
void BrowCtx::zoom_absolute( double factor)
{
if ( fabs(factor) < DBL_EPSILON)
return;
zoom_factor = factor;
a.zoom();
clear();
draw( 0, 0, window_width, window_height);
nav_zoom();
}
......@@ -78,11 +78,16 @@ class BrowCtx : public FlowCtx {
{ return a.brow_get_next_sibling( element, sibling);};
int get_previous_sibling( FlowArrayElem *element, FlowArrayElem **sibling)
{ return a.brow_get_previous_sibling( element, sibling);};
int move_up( FlowArrayElem *element)
{ return a.move_up( element);};
int move_down( FlowArrayElem *element)
{ return a.move_down( element);};
int is_visible( FlowArrayElem *element, flow_eVisible type);
int get_first_visible( FlowArrayElem **element);
int get_last_visible( FlowArrayElem **element);
void center_object( FlowArrayElem *object, double factor);
int page( double factor);
void zoom_absolute( double factor);
~BrowCtx() {};
double indentation;
......
......@@ -579,7 +579,7 @@ XAttGtk::XAttGtk( GtkWidget *xa_parent_wid,
pane = gtk_vpaned_new();
xattnav = new XAttNavGtk( (void *)this, pane, xattnav_eType_Object,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
"Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
xattnav->message_cb = &message_cb;
xattnav->change_value_cb = &change_value_cb;
xattnav->popup_menu_cb = &xatt_popup_menu_cb;
......
......@@ -71,9 +71,10 @@ XAttNavGtk::XAttNavGtk(
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
GtkWidget **w,
pwr_tStatus *status) :
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, status),
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, xa_userdata, status),
parent_wid(xa_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb, this, &brow_widget);
......
......@@ -52,6 +52,7 @@ class XAttNavGtk : public XAttNav {
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
GtkWidget **w,
pwr_tStatus *status);
~XAttNavGtk();
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund 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.
*/
#ifndef xtt_xcolwind_gtk_h
#define xtt_xcolwind_gtk_h
/* xtt_xcolwind_gtk.h -- Collect window */
#ifndef xtt_xcolwind_h
# include "xtt_xcolwind.h"
#endif
#ifndef cow_wow_gtk_h
# include "cow_wow_gtk.h"
#endif
class XColWindGtk : public XColWind {
public:
XColWindGtk (
GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
char *xa_title,
int xa_advanced_user,
int *xa_sts);
~XColWindGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_input;
GtkWidget *cmd_scrolledinput;
GtkWidget *cmd_scrolledtextview;
GtkWidget *cmd_scrolled_ok;
GtkWidget *cmd_scrolled_ca;
GtkTextBuffer *cmd_scrolled_buffer;
GtkWidget *pane;
static CoWowRecall value_recall;
CoWowEntryGtk *cmd_entry;
CoWowFocusTimerGtk focustimer;
int input_max_length;
void message( char severity, const char *message);
void set_prompt( const char *prompt);
void change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
void set_title( char *title);
void set_window_size( int w, int h);
void get_window_size( int *w, int *h);
static void activate_open( GtkWidget *w, gpointer data);
static void activate_save( GtkWidget *w, gpointer data);
static void activate_saveas( GtkWidget *w, gpointer data);
static void activate_insert( GtkWidget *w, gpointer data);
static void activate_delete( GtkWidget *w, gpointer data);
static void activate_moveup( GtkWidget *w, gpointer data);
static void activate_movedown( GtkWidget *w, gpointer data);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_close_changeval( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_display_object( GtkWidget *w, gpointer data);
static void activate_show_cross( GtkWidget *w, gpointer data);
static void activate_open_classgraph( GtkWidget *w, gpointer data);
static void activate_open_plc( GtkWidget *w, gpointer data);
static void activate_zoomin( GtkWidget *w, gpointer data);
static void activate_zoomout( GtkWidget *w, gpointer data);
static void activate_zoomreset( GtkWidget *w, gpointer data);
static void activate_scantime1(GtkWidget *w, gpointer data);
static void activate_scantime2(GtkWidget *w, gpointer data);
static void activate_scantime3(GtkWidget *w, gpointer data);
static void activate_scantime4(GtkWidget *w, gpointer data);
static void activate_scantime5(GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void valchanged_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_input( GtkWidget *w, gpointer data);
static void activate_cmd_scrolled_ok( GtkWidget *w, gpointer data);
static void activate_cmd_scrolled_ca( GtkWidget *w, gpointer data);
static void action_text_inserted( GtkTextBuffer *w, GtkTextIter *iter, gchar *str, gint len, gpointer data);
};
#endif
......@@ -195,7 +195,7 @@ XCrrGtk::XCrrGtk(
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
xcrrnav = new XAttNavGtk( (void *)this, vbox, xattnav_eType_CrossRef,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
"Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
xcrrnav->close_cb = &xcrr_close_cb;
......
......@@ -74,6 +74,7 @@ typedef void *Widget;
#include "xtt_menu.h"
#include "xtt_xatt_gtk.h"
#include "xtt_xcrr_gtk.h"
#include "xtt_xcolwind_gtk.h"
#include "xtt_ge_gtk.h"
#include "xtt_block_gtk.h"
#include "xtt_trend_gtk.h"
......@@ -204,6 +205,12 @@ XCrr *XNavGtk::xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
return new XCrrGtk( form_widget, this, arp, advanced_user, sts);
}
XColWind *XNavGtk::xcolwind_new( pwr_tAttrRef *ar_list, char *title, int advanced_user,
pwr_tStatus *sts)
{
return new XColWindGtk( form_widget, this, ar_list, title, advanced_user, sts);
}
Ev *XNavGtk::ev_new( char *eve_name, char *ala_name, char *blk_name,
pwr_tObjid ev_user, int display_ala, int display_eve,
int display_blk, int display_return, int display_ack,
......
......@@ -65,6 +65,8 @@ class XNavGtk : public XNav {
RtTrace *plctrace_new( pwr_tOid oid, pwr_tStatus *sts);
XAtt *xatt_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts);
XCrr *xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts);
XColWind *xcolwind_new( pwr_tAttrRef *ar_list, char *title, int advanced_user,
pwr_tStatus *sts);
Ev *ev_new( char *eve_name, char *ala_name, char *blk_name,
pwr_tObjid ev_user, int display_ala, int display_eve,
int display_blk, int display_return, int display_ack,
......
......@@ -533,7 +533,7 @@ XAttMotif::XAttMotif( Widget xa_parent_wid,
XtUnmanageChild( cmd_scrolled_ca);
xattnav = new XAttNavMotif( (void *)this, xattnav_form, xattnav_eType_Object,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
"Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
xattnav->message_cb = &message_cb;
xattnav->change_value_cb = &change_value_cb;
xattnav->popup_menu_cb = &xatt_popup_menu_cb;
......
......@@ -80,9 +80,10 @@ XAttNavMotif::XAttNavMotif(
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
Widget *w,
pwr_tStatus *status) :
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, status),
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, xa_userdata, status),
parent_wid(xa_parent_wid)
{
form_widget = ScrolledBrowCreate( parent_wid, name, NULL, 0,
......
......@@ -52,6 +52,7 @@ class XAttNavMotif : public XAttNav {
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
Widget *w,
pwr_tStatus *status);
~XAttNavMotif();
......
......@@ -226,7 +226,7 @@ XCrrMotif::XCrrMotif(
XtManageChild( toplevel);
xcrrnav = new XAttNavMotif( (void *)this, xcrrnav_form, xattnav_eType_CrossRef,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
"Plant", &objar, xa_advanced_user, 0, &brow_widget, &sts);
xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
xcrrnav->close_cb = &xcrr_close_cb;
......
......@@ -227,7 +227,7 @@ RtTrace *XNavMotif::plctrace_new( pwr_tOid oid, pwr_tStatus *sts)
XAtt *XNavMotif::xatt_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
{
return new XAttMotif( form_widget, this, arp, advanced_user, sts);
return new XAttMotif( form_widget, this, arp, advanced_user, 0, sts);
}
XCrr *XNavMotif::xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
......
......@@ -77,14 +77,15 @@ XAttNav::XAttNav(
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
pwr_tStatus *status) :
parent_ctx(xa_parent_ctx),
type(xa_type), objar(*xa_objar),
advanced_user(xa_advanced_user),
advanced_user(xa_advanced_user), userdata(xa_userdata),
bypass(0),
trace_started(0), message_cb(NULL), close_cb(0), change_value_cb(0),
popup_menu_cb(0), start_trace_cb(0), is_authorized_cb(0),
displayed(0)
displayed(0), scantime(500)
{
strcpy( name, xa_name);
*status = 1;
......@@ -95,6 +96,8 @@ XAttNav::XAttNav(
//
XAttNav::~XAttNav()
{
if ( userdata)
free( userdata);
}
//
......@@ -355,8 +358,7 @@ int XAttNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
switch ( item->type) {
case xnav_eItemType_Attr:
case xnav_eItemType_AttrArrayElem:
case xnav_eItemType_AttrObject:
case xnav_eItemType_Collect: {
case xnav_eItemType_AttrObject: {
pwr_tAName attr_str;
sts = gdh_ObjidToName( item->objid,
......@@ -374,6 +376,16 @@ int XAttNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
break;
}
case xnav_eItemType_Collect: {
sts = gdh_NameToAttrref( pwr_cNObjid, item->name, &attrref);
if ( EVEN(sts)) return sts;
(xattnav->popup_menu_cb)( xattnav->parent_ctx, attrref,
(unsigned long)xmenu_eItemType_Attribute,
(unsigned long)xmenu_mUtility_AttrEditor, NULL, x, y);
break;
}
case xnav_eItemType_Crossref: {
ItemCrossref *itemc = (ItemCrossref *)item;
......@@ -407,6 +419,7 @@ int XAttNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
switch( item->type) {
case xnav_eItemType_Attr:
case xnav_eItemType_AttrArrayElem:
case xnav_eItemType_Collect:
sts = item->open_children( xattnav->brow, 0, 0);
if (ODD(sts)) break;
......@@ -522,7 +535,8 @@ int XAttNav::trace_connect_bc( brow_tObject object, char *name,
case xnav_eItemType_Attr:
case xnav_eItemType_Enum:
case xnav_eItemType_Mask:
case xnav_eItemType_AttrArrayElem: {
case xnav_eItemType_AttrArrayElem:
case xnav_eItemType_Collect: {
ItemAttr *item;
item = (ItemAttr *) base_item;
......@@ -569,6 +583,7 @@ int XAttNav::trace_scan_bc( brow_tObject object, void *p)
{
case xnav_eItemType_Attr:
case xnav_eItemType_AttrArrayElem:
case xnav_eItemType_Collect:
{
ItemAttr *item;
......@@ -640,12 +655,11 @@ int XAttNav::trace_scan_bc( brow_tObject object, void *p)
void XAttNav::trace_scan( void *data)
{
XAttNav *xattnav = (XAttNav *)data;
int time = 200;
if ( xattnav->trace_started) {
brow_TraceScan( xattnav->brow->ctx);
xattnav->trace_timerid->add( time, trace_scan, xattnav);
xattnav->trace_timerid->add( xattnav->scantime, trace_scan, xattnav);
}
}
......@@ -798,6 +812,54 @@ int XAttNav::object_attr()
return XATT__SUCCESS;
}
int XAttNav::collect_add( pwr_tAttrRef *areflist)
{
ItemCollect *item;
int sts;
pwr_tAName attr;
char *s;
pwr_tTypeId a_type_id;
unsigned int a_size;
unsigned int a_offset;
unsigned int a_dim;
pwr_tTid a_tid;
pwr_tAName name;
pwr_tAttrRef *arp;
if ( !areflist)
return XATT__SUCCESS;
brow_SetNodraw( brow->ctx);
for ( arp = areflist; cdh_ObjidIsNotNull( arp->Objid); arp++) {
sts = gdh_AttrrefToName ( arp, name, sizeof(name), cdh_mNName);
if ( EVEN(sts)) return sts;
if ( !arp->Flags.b.Object && !arp->Flags.b.ObjectAttr) {
if ( (s = strchr( name, '.')) == 0)
return 0;
strcpy( attr, s+1);
sts = gdh_GetAttributeCharAttrref( arp, &a_type_id, &a_size, &a_offset,
&a_dim);
if ( EVEN(sts)) return sts;
sts = gdh_GetAttrRefTid( arp, &a_tid);
if ( EVEN(sts)) return sts;
}
else
continue;
item = new ItemCollect( brow, arp->Objid, attr, NULL,
flow_eDest_IntoLast, a_type_id, a_tid, a_size, 0);
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
return XATT__SUCCESS;
}
void XAttNav::enable_events()
{
brow_EnableEvent( brow->ctx, flow_eEvent_MB1Click, flow_eEventType_CallBack,
......@@ -860,6 +922,9 @@ int XAttNav::init_brow_cb( FlowCtx *fctx, void *client_data)
case xattnav_eType_CrossRef:
xattnav->crossref();
break;
case xattnav_eType_Collect:
xattnav->collect_add( (pwr_tAttrRef *)xattnav->userdata);
break;
default:
;
}
......@@ -917,6 +982,7 @@ int XAttNav::set_attr_value( brow_tObject node, char *name, char *value_str)
switch( base_item->type) {
case xnav_eItemType_AttrArrayElem:
case xnav_eItemType_Attr:
case xnav_eItemType_Collect:
{
ItemAttr *item = (ItemAttr *)base_item;
......@@ -1018,6 +1084,31 @@ void XAttNav::start_trace()
}
}
int XAttNav::get_select( pwr_tAttrRef *arp)
{
brow_tNode *node_list;
int node_count;
ItemCollect *item;
pwr_tStatus sts;
brow_GetSelectedNodes( brow->ctx, &node_list, &node_count);
if ( node_count != 1)
return 0;
brow_GetUserData( node_list[0], (void **)&item);
free( node_list);
switch( item->type) {
case xnav_eItemType_Collect:
sts = gdh_NameToAttrref( pwr_cNObjid, item->name, arp);
if ( EVEN(sts)) return sts;
break;
default:
return 0;
}
return XATT__SUCCESS;
}
void XAttNav::swap( int mode)
{
if ( mode == 0) {
......@@ -1036,6 +1127,30 @@ void XAttNav::swap( int mode)
}
//
// Get zoom
//
void XAttNav::get_zoom( double *zoom_factor)
{
brow_GetZoom( brow->ctx, zoom_factor);
}
//
// Zoom
//
void XAttNav::zoom( double zoom_factor)
{
brow_Zoom( brow->ctx, zoom_factor);
}
//
// Return to base zoom factor
//
void XAttNav::unzoom()
{
brow_UnZoom( brow->ctx);
}
......
......@@ -60,7 +60,8 @@
typedef enum {
xattnav_eType_Object,
xattnav_eType_CrossRef
xattnav_eType_CrossRef,
xattnav_eType_Collect
} xattnav_eType;
class CoWow;
......@@ -74,6 +75,7 @@ class XAttNav {
const char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
void *xa_userdata,
pwr_tStatus *status);
virtual ~XAttNav();
......@@ -83,6 +85,7 @@ class XAttNav {
XNavBrow *brow;
pwr_sAttrRef objar;
int advanced_user;
void *userdata;
int bypass;
CoWowTimer *trace_timerid;
int trace_started;
......@@ -95,6 +98,7 @@ class XAttNav {
int (*is_authorized_cb)(void *, unsigned int);
int displayed;
CoWow *wow;
int scantime;
virtual void popup_position( int x_event, int y_event, int *x, int *y) {}
virtual void set_inputfocus() {}
......@@ -103,17 +107,23 @@ class XAttNav {
int set_attr_value( brow_tObject node, char *name, char *value_str);
int check_attr( int *multiline, brow_tObject *node, char *name,
char **init_value, int *size);
int get_select( pwr_sAttrRef *attrref, int *is_attr);
void message( char sev, const char *text);
void force_trace_scan();
int object_attr();
int crossref();
int collect_add( pwr_tAttrRef *areflist);
int object_exist( brow_tObject object);
void redraw();
void enable_events();
int select_by_name( char *name);
void start_trace();
void swap( int mode);
int get_select( pwr_tAttrRef *arp);
void set_scantime( int t) { scantime = t;}
int get_scantime() { return scantime;}
void zoom( double zoom_factor);
void get_zoom( double *zoom_factor);
void unzoom();
static void trace_scan( void *data);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund 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.
*/
/* xtt_xcolwind.cpp -- Collect window */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_lng.h"
#include "xtt_xcolwind.h"
#include "xtt_xattnav.h"
#include "xtt_xnav.h"
#include "xtt_item.h"
#include "rt_xatt_msg.h"
void XColWind::message_cb( void *xcolwind, char severity, const char *message)
{
((XColWind *)xcolwind)->message( severity, message);
}
void XColWind::change_value_cb( void *xcolwind)
{
((XColWind *)xcolwind)->change_value(1);
}
//
// Callbackfunctions from menu entries
//
void XColWind::activate_open()
{
pwr_tCmd cmd = "collect open";
if ( command_cb)
(command_cb) ( parent_ctx, cmd);
}
void XColWind::activate_save()
{
pwr_tFileName fname;
ItemCollect *item;
brow_tObject *object_list;
int object_cnt;
int i;
int width, height;
double scantime, zoomfactor;
if ( strcmp( filename, "") == 0)
activate_saveas();
dcli_translate_filename( fname, filename);
ofstream fp( fname);
if ( !fp) {
message( 'E', "Unable to open file");
return;
}
get_window_size( &width, &height);
scantime = double(xattnav->get_scantime()) / 1000;
xattnav->get_zoom( &zoomfactor);
fp <<
"#" << endl <<
"# Xtt collection file" << endl <<
"#" << endl;
brow_GetObjectList( xattnav->brow->ctx, &object_list, &object_cnt);
for ( i = 0; i < object_cnt; i++) {
brow_GetUserData( object_list[i], (void **)&item);
switch( item->type) {
case xnav_eItemType_Collect:
if ( i == object_cnt - 1) {
if ( i == 0)
fp << "collect /name=" << item->name << " /newwindow /last" <<
" /width=" << width <<
" /height=" << height <<
" /zoomfactor=" << zoomfactor <<
" /scantime=" << scantime <<
" /title=\"" << title << "\"" << endl;
else
fp << "collect /name=" << item->name << " /addwindow /last" << endl;
}
else {
if ( i == 0)
fp << "collect /name=" << item->name << " /newwindow" <<
" /width=" << width <<
" /height=" << height <<
" /zoomfactor=" << zoomfactor <<
" /scantime=" << scantime <<
" /title=\"" << title << "\"" << endl;
else
fp << "collect /name=" << item->name << " /addwindow" << endl;
}
break;
default:
;
}
}
fp.close();
}
void XColWind::file_selected_cb( void *ctx, void *data, char *text)
{
XColWind *xcolwind = (XColWind *)ctx;
xcolwind->set_filename( text);
xcolwind->set_title( text);
xcolwind->activate_save();
}
void XColWind::activate_saveas()
{
wow->CreateInputDialog( this, "Save as", "Enter filename",
file_selected_cb, 0, 40, 0, 0);
}
void XColWind::activate_display_object()
{
pwr_tAttrRef aref;
int sts;
sts = xattnav->get_select( &aref);
if ( EVEN(sts)) return;
if ( call_method_cb) {
(call_method_cb)( parent_ctx,
"$Object-RtNavigator",
"$Object-RtNavigatorFilter",
aref,
xmenu_eItemType_Object,
xmenu_mUtility_AttrEditor, NULL);
}
}
void XColWind::activate_show_cross()
{
pwr_tAttrRef aref;
int sts;
sts = xattnav->get_select( &aref);
if ( EVEN(sts)) return;
if ( call_method_cb) {
(call_method_cb)( parent_ctx,
"$Object-OpenCrossref",
"$Object-OpenCrossrefFilter",
aref,
xmenu_eItemType_Object,
xmenu_mUtility_AttrEditor, NULL);
}
}
void XColWind::activate_open_classgraph()
{
pwr_tAttrRef aref;
int sts;
sts = xattnav->get_select( &aref);
if ( EVEN(sts)) return;
if ( call_method_cb) {
(call_method_cb)( parent_ctx,
"$Object-OpenObjectGraph",
"$Object-OpenObjectGraphFilter",
aref,
xmenu_eItemType_Object,
xmenu_mUtility_AttrEditor, NULL);
}
}
void XColWind::activate_open_plc()
{
pwr_tAttrRef aref;
int sts;
sts = xattnav->get_select( &aref);
if ( EVEN(sts)) return;
if ( call_method_cb) {
(call_method_cb)( parent_ctx,
"$Object-OpenTrace",
"$Object-OpenTraceFilter",
aref,
xmenu_eItemType_Object,
xmenu_mUtility_AttrEditor, NULL);
}
}
void XColWind::activate_collect_insert()
{
pwr_tAttrRef aref, oaref;
int is_attr;
int sts;
pwr_tOName attr;
if ( get_select_cb) {
sts = (get_select_cb)( parent_ctx, &aref, &is_attr);
if ( EVEN(sts)) return;
if ( !aref.Flags.b.Object && !aref.Flags.b.ObjectAttr) {
collect_insert( &aref);
}
else {
sts = XNav::get_trace_attr( &aref, attr);
if ( EVEN(sts)) return;
sts = gdh_ArefANameToAref( &aref, attr, &oaref);
if ( EVEN(sts)) return;
collect_insert( &oaref);
}
}
}
void XColWind::activate_collect_delete()
{
brow_tNode *node_list;
int node_count;
brow_GetSelectedNodes( xattnav->brow->ctx, &node_list, &node_count);
if ( node_count > 0)
brow_DeleteNode( xattnav->brow->ctx, node_list[0]);
}
void XColWind::activate_moveup()
{
brow_tNode *node_list;
int node_count;
brow_GetSelectedNodes( xattnav->brow->ctx, &node_list, &node_count);
if ( node_count == 1) {
brow_MoveUp( xattnav->brow->ctx, node_list[0]);
brow_Redraw( xattnav->brow->ctx, 0);
}
}
void XColWind::activate_movedown()
{
brow_tNode *node_list;
int node_count;
brow_GetSelectedNodes( xattnav->brow->ctx, &node_list, &node_count);
if ( node_count == 1) {
brow_MoveDown( xattnav->brow->ctx, node_list[0]);
brow_Redraw( xattnav->brow->ctx, 0);
}
}
void XColWind::activate_help()
{
// Not yet implemented
}
int XColWind::open_changevalue( char *name)
{
int sts;
sts = ((XAttNav*)xattnav)->select_by_name( name);
if ( EVEN(sts)) return sts;
change_value(0);
return XATT__SUCCESS;
}
void XColWind::swap( int mode)
{
xattnav->swap( mode);
}
XColWind::~XColWind()
{
}
XColWind::XColWind(
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar_list,
char *xa_title,
int xa_advanced_user,
int *xa_sts) :
parent_ctx(xa_parent_ctx),
objar_list(xa_objar_list),
input_open(0), input_multiline(0),
close_cb(0), redraw_cb(0), popup_menu_cb(0), call_method_cb(0),
command_cb(0), get_select_cb(0), client_data(0)
{
if ( xa_title && strcmp( xa_title, "") != 0) {
strcpy( title, xa_title);
set_filename( title);
}
else {
strcpy( title, "Collection");
strcpy( filename, "");
}
*xa_sts = XATT__SUCCESS;
}
void XColWind::set_filename( char *name)
{
if ( !strchr( name, '/')) {
strcpy( filename, "$pwrp_load/");
strcat( filename, name);
}
else
strcpy( filename, name);
if ( !strchr( name, '.'))
strcat( filename, ".rtt_col");
}
void XColWind::collect_insert( pwr_tAttrRef *aref)
{
pwr_tAttrRef *areflist = (pwr_tAttrRef *) calloc( 2, sizeof(pwr_tAttrRef));
areflist[0] = *aref;
xattnav->collect_add( areflist);
free( areflist);
}
void XColWind::xcolwind_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
char *arg, int x, int y)
{
if ( ((XColWind *)ctx)->popup_menu_cb)
(((XColWind *)ctx)->popup_menu_cb) ( ((XColWind *)ctx)->parent_ctx, attrref,
item_type, utility, arg, x, y);
}
int XColWind::xcolwind_is_authorized_cb( void *ctx, unsigned int access)
{
XColWind *xcolwind = (XColWind *)ctx;
if ( xcolwind->is_authorized_cb)
return (xcolwind->is_authorized_cb)( xcolwind->parent_ctx, access);
return 0;
}
void XColWind::activate_zoomin()
{
double zoom_factor;
xattnav->get_zoom( &zoom_factor);
if ( zoom_factor > 40)
return;
xattnav->zoom( 1.18);
}
void XColWind::activate_zoomout()
{
double zoom_factor;
xattnav->get_zoom( &zoom_factor);
if ( zoom_factor < 15)
return;
xattnav->zoom( 1.0 / 1.18);
}
void XColWind::set_scantime( int t)
{
xattnav->set_scantime(t);
}
void XColWind::zoom( double zoom_factor)
{
brow_ZoomAbsolute( xattnav->brow->ctx, zoom_factor);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2011 SSAB Oxelosund 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.
*/
#ifndef xtt_xcolwind_h
#define xtt_xcolwind_h
/* xtt_xcolwind.h -- Object attribute editor */
#ifndef pwr_h
# include "pwr.h"
#endif
#include "cow_wow.h"
class XAttNav;
class CoWow;
class XColWind {
public:
XColWind(
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar_list,
char *xa_title,
int xa_advanced_user,
int *xa_sts);
virtual ~XColWind();
void *parent_ctx;
pwr_sAttrRef* objar_list;
char name[80];
XAttNav *xattnav;
void *root_item;
int input_open;
int input_multiline;
void *object;
void (*close_cb) ( void *, void *);
void (*redraw_cb) (void *);
void (*popup_menu_cb)( void *, pwr_sAttrRef, unsigned long,
unsigned long, char *, int x, int y);
int (*call_method_cb)(void *, const char *, const char *, pwr_sAttrRef,
unsigned long, unsigned long, char *);
int (*is_authorized_cb)(void *, unsigned int);
void (*command_cb)( void *, char *);
int (*get_select_cb)( void *, pwr_tAttrRef *, int *);
void *client_data;
brow_tObject input_node;
char input_name[80];
pwr_tFileName filename;
CoWow *wow;
char title[80];
virtual void message( char severity, const char *message) {}
virtual void set_prompt( const char *prompt) {}
virtual void change_value( int set_focus) {}
virtual void change_value_close() {}
virtual void pop() {}
virtual void set_title( char *title) {}
virtual void set_window_size( int w, int h) {}
virtual void get_window_size( int *w, int *h) {}
int open_changevalue( char *name);
void swap( int mode);
void set_filename( char *name);
void collect_insert( pwr_tAttrRef *aref);
void zoom( double zoom_factor);
void set_scantime( int t);
void activate_open();
void activate_save();
void activate_saveas();
void activate_collect_insert();
void activate_collect_delete();
void activate_moveup();
void activate_movedown();
void activate_display_object();
void activate_show_cross();
void activate_open_classgraph();
void activate_open_plc();
void activate_zoomin();
void activate_zoomout();
void activate_help();
static void xcolwind_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
char *arg, int x, int y);
static int xcolwind_is_authorized_cb( void *ctx, unsigned int access);
static void message_cb( void *xcolwind, char severity, const char *message);
static void change_value_cb( void *xcolwind);
static void file_selected_cb( void *ctx, void *data, char *text);
};
#endif
......@@ -69,6 +69,7 @@
#include "xtt_menu.h"
#include "xtt_xatt.h"
#include "xtt_xcrr.h"
#include "xtt_xcolwind.h"
#include "xtt_ge.h"
#include "xtt_ev.h"
#include "xtt_op.h"
......@@ -1022,12 +1023,13 @@ int XNav::open_object( pwr_sAttrRef *arp)
}
else {
xatt = xatt_new( arp, gbl.advanced_user, &sts);
if ( ODD(sts))
if ( ODD(sts)) {
xatt->close_cb = xatt_close_cb;
xatt->popup_menu_cb = xnav_popup_menu_cb;
xatt->call_method_cb = xnav_call_method_cb;
xatt->is_authorized_cb = is_authorized_cb;
appl.insert( applist_eType_Attr, (void *)xatt, arp, "", NULL);
}
}
return XNAV__SUCCESS;
}
......@@ -1042,11 +1044,12 @@ int XNav::open_crossref( pwr_sAttrRef *arp)
}
else {
xcrr = xcrr_new( arp, gbl.advanced_user, &sts);
if ( ODD(sts))
if ( ODD(sts)) {
xcrr->close_cb = xcrr_close_cb;
xcrr->popup_menu_cb = xnav_popup_menu_cb;
xcrr->start_trace_cb = xnav_start_trace_cb;
appl.insert( applist_eType_Crossref, (void *)xcrr, arp, "", NULL);
}
}
return XNAV__SUCCESS;
}
......@@ -1091,7 +1094,8 @@ XNav::XNav(
menu_tree(NULL), ev(0), op(0), clog(0), closing_down(0), opplace_p(0),
base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), displayed(0),
current_logging_index(-1), search_last_found(0), search_compiled(0),
attach_audio(0), audio(0), op_close_button(xn_op_close_button), cologin(0), scctx(0)
attach_audio(0), audio(0), op_close_button(xn_op_close_button), cologin(0), scctx(0),
last_xcolwind(0)
{
strcpy( name, xn_name);
strcpy( opplace_name, xn_opplace_name);
......
......@@ -110,6 +110,7 @@ extern "C" {
class CoWowTimer;
class XAtt;
class XCrr;
class XColWind;
class Block;
class XttTrend;
class XttSevHist;
......@@ -117,7 +118,6 @@ class XttFast;
class XAttOne;
class GeCurve;
class GeCurveData;
class XCrr;
class CoWow;
class XttAudio;
class Ev;
......@@ -346,6 +346,7 @@ class XNav {
static xmenu_sMenuCall *mcp;
CoLogin *cologin;
sevcli_tCtx scctx;
XColWind *last_xcolwind;
virtual void set_inputfocus() {}
virtual void pop() {}
......@@ -356,6 +357,8 @@ class XNav {
virtual RtTrace *plctrace_new( pwr_tOid oid, pwr_tStatus *sts) {return 0;}
virtual XAtt *xatt_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts) {return 0;}
virtual XCrr *xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts) {return 0;}
virtual XColWind *xcolwind_new( pwr_tAttrRef *ar_list, char *title, int advanced_user,
pwr_tStatus *sts) {return 0;}
virtual Ev *ev_new( char *eve_name, char *ala_name, char *blk_name,
pwr_tObjid ev_user, int display_ala, int display_eve,
int display_blk, int display_return, int display_ack,
......@@ -411,6 +414,7 @@ class XNav {
int collect_insert( pwr_sAttrRef *attrref);
int collect_remove();
int collect_show();
int collect_window( int copy);
void collect_clear();
void clear();
void message( char sev, const char *text);
......
......@@ -73,6 +73,7 @@
#include "xtt_item.h"
#include "xtt_xnav_crr.h"
#include "xtt_xattone.h"
#include "xtt_xcolwind.h"
#include "co_dcli_msg.h"
#include "rt_xnav_msg.h"
#include "cow_xhelp.h"
......@@ -171,6 +172,7 @@ static void xnav_trend_close_cb( void *ctx, XttTrend *trend);
static void xnav_trend_help_cb( void *ctx, const char *key);
static void xnav_sevhist_help_cb( void *ctx, const char *key);
static int xnav_sevhist_get_select_cb( void *ctx, pwr_tOid *oid, char *aname, char *oname);
static int xnav_get_select_cb( void *ctx, pwr_tAttrRef *aref, int *is_attr);
static void xnav_fast_close_cb( void *ctx, XttFast *fast);
static void xnav_fast_help_cb( void *ctx, const char *key);
static void xnav_xao_close_cb( void *ctx, XAttOne *xao);
......@@ -325,7 +327,8 @@ dcli_tCmdTable xnav_command_table[] = {
{
"COLLECT",
&xnav_collect_func,
{ "dcli_arg1", "/NAME", ""}
{ "dcli_arg1", "/NAME", "/NEWWINDOW", "/ADDWINDOW", "/LAST", "/TITLE",
"/WIDTH", "/HEIGHT", "/SCANTIME", "/ZOOMFACTOR", ""}
},
{
"CROSSREFERENCE",
......@@ -4199,6 +4202,13 @@ static int xnav_sevhist_get_select_cb( void *ctx, pwr_tOid *oid, char *aname, ch
return XNAV__SUCCESS;
}
static int xnav_get_select_cb( void *ctx, pwr_tAttrRef *aref, int *is_attr)
{
XNav *xnav = (XNav *) ctx;
return xnav->get_select( aref, is_attr);
}
static void xnav_fast_close_cb( void *ctx, XttFast *fast)
{
XNav *xnav = (XNav *) ctx;
......@@ -4482,6 +4492,16 @@ static int xnav_delete_func( void *client_data,
return XNAV__SUCCESS;
}
static void xnav_collect_open_cb( void *ctx, char *text)
{
XNav *xnav = (XNav *)ctx;
pwr_tCmd cmd;
sprintf( cmd, "@\"$pwrp_load/%s.rtt_col\"", text);
xnav->command( cmd);
}
static int xnav_collect_func( void *client_data,
void *client_flag)
{
......@@ -4491,32 +4511,132 @@ static int xnav_collect_func( void *client_data,
pwr_tAName name_str;
pwr_sAttrRef attrref;
int is_attr;
double scantime, zoomfactor;
IF_NOGDH_RETURN;
if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str))))
{
if ( ODD( dcli_get_qualifier( "/NAME", name_str, sizeof(name_str))))
{
if ( EVEN( dcli_get_qualifier( "dcli_arg1", arg1_str, sizeof(arg1_str)))) {
int newwindow;
int addwindow;
int last;
char title_str[80] = "";
int width, height;
char str[80];
int num;
if ( ODD( dcli_get_qualifier( "/NAME", name_str, sizeof(name_str)))) {
sts = gdh_NameToAttrref( pwr_cNObjid, name_str, &attrref);
if ( EVEN(sts))
{
if ( EVEN(sts)) {
xnav->message('E', "No such object");
return XNAV__HOLDCOMMAND;
}
}
else
{
else {
sts = xnav->get_select( &attrref, &is_attr);
if ( EVEN(sts))
{
if ( EVEN(sts)) {
xnav->message('E', "Enter name or select object");
return XNAV__SUCCESS;
}
}
sts = xnav->collect_insert( &attrref);
newwindow = ODD( dcli_get_qualifier( "/NEWWINDOW", 0, 0));
addwindow = ODD( dcli_get_qualifier( "/ADDWINDOW", 0, 0));
last = ODD( dcli_get_qualifier( "/LAST", 0, 0));
if ( ODD( dcli_get_qualifier( "/WIDTH", str, sizeof(str)))) {
num = sscanf( str, "%d", &width);
if ( num != 1) {
xnav->message('E', "Width syntax error");
return XNAV__SUCCESS;
}
}
else
width = 0;
if ( ODD( dcli_get_qualifier( "/HEIGHT", str, sizeof(str)))) {
num = sscanf( str, "%d", &height);
if ( num != 1) {
xnav->message('E', "Height syntax error");
return XNAV__SUCCESS;
}
}
else
height = 0;
if ( ODD( dcli_get_qualifier( "/ZOOMFACTOR", str, sizeof(str)))) {
num = sscanf( str, "%lf", &zoomfactor);
if ( num != 1) {
xnav->message('E', "Zoomfactor syntax error");
return XNAV__SUCCESS;
}
}
else
zoomfactor = 0;
if ( ODD( dcli_get_qualifier( "/SCANTIME", str, sizeof(str)))) {
num = sscanf( str, "%lf", &scantime);
if ( num != 1) {
xnav->message('E', "Scantime syntax error");
return XNAV__SUCCESS;
}
}
else
scantime = 0;
if ( newwindow) {
// Create a new window and insert into window
pwr_tAttrRef *arlist = (pwr_tAttrRef *) calloc( 2, sizeof(pwr_tAttrRef));
arlist[0] = attrref;
dcli_get_qualifier( "/TITLE", title_str, sizeof(title_str));
xnav->last_xcolwind = xnav->xcolwind_new( arlist, title_str, xnav->gbl.advanced_user,
&sts);
if ( EVEN(sts)) {
xnav->last_xcolwind = 0;
return XNAV__SUCCESS;
}
// xnav->last_xcolwind->close_cb = xatt_close_cb;
xnav->last_xcolwind->popup_menu_cb = xnav_popup_menu_cb;
xnav->last_xcolwind->call_method_cb = xnav_call_method_cb;
xnav->last_xcolwind->is_authorized_cb = xnav->is_authorized_cb;
xnav->last_xcolwind->command_cb = xnav_op_command_cb;
xnav->last_xcolwind->get_select_cb = xnav_get_select_cb;
if ( width != 0 && height != 0)
xnav->last_xcolwind->set_window_size( width, height);
if ( zoomfactor != 0)
xnav->last_xcolwind->zoom( zoomfactor);
if ( scantime != 0)
xnav->last_xcolwind->set_scantime( int(scantime * 1000 + 0.5));
if ( last)
xnav->last_xcolwind = 0;
}
else if ( addwindow ) {
// Add to last created window
if ( !xnav->last_xcolwind) {
xnav->message('E', "No last collection window");
return XNAV__SUCCESS;
}
xnav->last_xcolwind->collect_insert( &attrref);
if ( last)
xnav->last_xcolwind = 0;
}
else {
sts = xnav->collect_insert( &attrref);
}
return sts;
}
else if ( cdh_NoCaseStrncmp( arg1_str, "OPEN", strlen( arg1_str)) == 0)
{
xnav->wow->CreateFileList( "Open Collection", "$pwrp_load", "*", "rtt_col",
xnav_collect_open_cb, 0, xnav, 1);
return XNAV__SUCCESS;
}
else if ( cdh_NoCaseStrncmp( arg1_str, "SHOW", strlen( arg1_str)) == 0)
{
sts = xnav->collect_show();
......@@ -7789,3 +7909,53 @@ pwr_tStatus XNav::get_instance_classgraph( char *instance_str, pwr_tFileName fil
strcpy( filename, fname);
return XNAV__SUCCESS;
}
int XNav::collect_window( int copy)
{
brow_tNode *node_list;
int node_count;
Item *item;
int sts;
pwr_sAttrRef *ap;
int i;
XColWind *xcolwind;
if ( copy) {
brow_GetObjectList( collect_brow->ctx, &node_list, &node_count);
if ( !node_count)
return 0;
ap = (pwr_sAttrRef *) calloc( node_count + 1, sizeof(pwr_sAttrRef));
for ( i = 0; i < node_count; i++) {
brow_GetUserData( node_list[i], (void **)&item);
switch( item->type) {
case xnav_eItemType_Collect:
sts = gdh_NameToAttrref( pwr_cNObjid, item->name, &ap[i]);
if ( EVEN(sts)) return sts;
break;
default: ;
}
}
xcolwind = xcolwind_new( ap, 0, gbl.advanced_user, &sts);
}
else
xcolwind = xcolwind_new( 0, 0, gbl.advanced_user, &sts);
if ( ODD(sts)) {
xcolwind->close_cb = xatt_close_cb;
xcolwind->popup_menu_cb = xnav_popup_menu_cb;
xcolwind->call_method_cb = xnav_call_method_cb;
xcolwind->is_authorized_cb = is_authorized_cb;
xcolwind->command_cb = xnav_op_command_cb;
xcolwind->get_select_cb = xnav_get_select_cb;
if ( copy)
collect_clear();
}
return XNAV__SUCCESS;
}
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