Commit bf001ac4 authored by claes's avatar claes

GTK added

parent 033479b9
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
* Proview $Id: xtt_block_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_block_gtk.cpp -- Alarm blocking window in xtt. */
#include <gtk/gtk.h>
#include "pwr_class.h"
#include "pwr_privilege.h"
#include "rt_gdh.h"
#include "rt_mh_outunit.h"
#include "co_cdh.h"
#include "xtt_block_gtk.h"
#include "co_lng.h"
#include "co_wow_gtk.h"
#include "co_msg.h"
int BlockGtk::execute()
{
mh_eEventPrio prio;
pwr_tStatus sts;
if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggleA)))
prio = mh_eEventPrio_A;
else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggleB)))
prio = mh_eEventPrio_B;
else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggleC)))
prio = mh_eEventPrio_C;
else if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggleD)))
prio = mh_eEventPrio_D;
else
prio = (mh_eEventPrio) 0;
sts = mh_OutunitBlock( oar.Objid, prio);
if (EVEN(sts)) {
char msg[80];
msg_GetMsg( sts, msg, sizeof(msg));
wow->DisplayError( "Block Error", msg);
}
return sts;
}
void BlockGtk::update()
{
pwr_tStatus sts;
mh_uEventInfo block_level;
sts = gdh_GetAlarmInfo( oar.Objid, NULL, NULL, (pwr_tUInt32 *) &block_level,
NULL, NULL);
switch ( block_level.Event.Prio) {
case mh_eEventPrio_A:
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(toggleA), TRUE);
break;
case mh_eEventPrio_B:
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(toggleB), TRUE);
break;
case mh_eEventPrio_C:
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(toggleC), TRUE);
break;
case mh_eEventPrio_D:
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(toggleD), TRUE);
break;
case 0:
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(toggleNo), TRUE);
break;
default:
break;
}
}
void BlockGtk::activate_apply( GtkWidget *w, gpointer data)
{
Block *blk = (Block *)data;
blk->execute();
}
void BlockGtk::activate_ok( GtkWidget *w, gpointer data)
{
Block *blk = (Block *)data;
pwr_tStatus sts;
sts = blk->execute();
if ( ODD(sts))
delete blk;
}
void BlockGtk::activate_cancel( GtkWidget *w, gpointer data)
{
Block *blk = (Block *)data;
delete blk;
}
BlockGtk::~BlockGtk()
{
delete wow;
gtk_widget_destroy( toplevel);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
BlockGtk::activate_cancel( w, data);
return TRUE;
}
BlockGtk::BlockGtk( void *b_parent_ctx,
GtkWidget *b_parent_wid,
pwr_sAttrRef *b_oar,
char *name,
unsigned int priv,
pwr_tStatus *sts):
Block( b_parent_ctx, b_oar, name, priv, sts), parent_wid(b_parent_wid)
{
char title[400];
pwr_tAName aname;
*sts = gdh_AttrrefToName( &oar, aname, sizeof(aname), cdh_mNName);
if ( EVEN(*sts)) return;
strcpy( title, name);
strcat( title, " ");
strcat( title, aname);
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 300,
"default-width", 500,
"title", title,
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
CoWowGtk::SetWindowIcon( toplevel);
toggleA = gtk_check_button_new_with_label( "A Alarm");
toggleB = gtk_check_button_new_with_label( "B Alarm");
toggleC = gtk_check_button_new_with_label( "C Alarm");
toggleD = gtk_check_button_new_with_label( "D Alarm");
toggleNo = gtk_check_button_new_with_label( "No Blocking");
GtkWidget *toggle_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(toggle_vbox), toggleA, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(toggle_vbox), toggleB, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(toggle_vbox), toggleC, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(toggle_vbox), toggleD, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(toggle_vbox), toggleNo, FALSE, FALSE, 7);
buttonOk = gtk_button_new_with_label( "Ok");
gtk_widget_set_size_request( buttonOk, 70, 25);
g_signal_connect( buttonOk, "clicked", G_CALLBACK(activate_ok), this);
buttonApply = gtk_button_new_with_label( "Apply");
gtk_widget_set_size_request( buttonApply, 70, 25);
g_signal_connect( buttonApply, "clicked", G_CALLBACK(activate_apply), this);
GtkWidget *buttonCancel = gtk_button_new_with_label( "Cancel");
gtk_widget_set_size_request( buttonCancel, 70, 25);
g_signal_connect( buttonCancel, "clicked", G_CALLBACK(activate_cancel), this);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), buttonOk, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(hboxbuttons), buttonApply, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hboxbuttons), buttonCancel, FALSE, FALSE, 0);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), toggle_vbox, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 15);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
if ( !(priv & pwr_mPrv_RtEvents ||
priv & pwr_mPrv_System)) {
gtk_widget_set_sensitive( buttonOk, FALSE);
gtk_widget_set_sensitive( buttonApply, FALSE);
gtk_widget_set_sensitive( toggleA, FALSE);
gtk_widget_set_sensitive( toggleB, FALSE);
gtk_widget_set_sensitive( toggleC, FALSE);
gtk_widget_set_sensitive( toggleD, FALSE);
gtk_widget_set_sensitive( toggleNo, FALSE);
}
wow = new CoWowGtk( parent_wid);
update();
#if 0
char uid_filename[120] = {"xtt_block.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
int msts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char title[200];
pwr_tAName aname;
static MrmRegisterArg reglist[] = {
{ "blk_ctx", 0 },
{"blk_activate_cancel",(caddr_t)activate_cancel },
{"blk_activate_ok",(caddr_t)activate_ok },
{"blk_activate_apply",(caddr_t)activate_apply },
{"blk_create_ok",(caddr_t)create_ok },
{"blk_create_apply",(caddr_t)create_apply },
{"blk_create_toggleA",(caddr_t)create_toggleA },
{"blk_create_toggleB",(caddr_t)create_toggleB },
{"blk_create_toggleC",(caddr_t)create_toggleC },
{"blk_create_toggleD",(caddr_t)create_toggleD },
{"blk_create_toggleNo",(caddr_t)create_toggleNo }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*sts = 1;
Lng::get_uid( uid_filename, uid_filename);
*sts = gdh_AttrrefToName( &oar, aname, sizeof(aname), cdh_mNName);
if ( EVEN(*sts)) return;
strcpy( title, name);
strcat( title, " ");
strcat( title, aname);
reglist[0].value = (caddr_t) this;
// Gtk
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
msts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (msts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
msts = MrmFetchWidgetOverride( s_DRMh, "blk_window", parent_wid,
name, args, 1, &toplevel, &dclass);
if (msts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
i = 0;
XtSetArg(args[i],XmNwidth,500);i++;
XtSetArg(args[i],XmNheight,200);i++;
XtSetValues( toplevel, args, i);
XtManageChild( toplevel);
XtPopup( parent_wid, XtGrabNone);
if ( !(priv & pwr_mPrv_RtEvents ||
priv & pwr_mPrv_System)) {
Arg sensitive[1];
// No access to block
// XtUnmanageChild( ok);
// XtUnmanageChild( apply);
XtSetArg( sensitive[0],XmNsensitive, 0);
XtSetValues( buttonOk, sensitive, 1);
XtSetValues( buttonApply, sensitive, 1);
XtSetValues( toggleA, sensitive, 1);
XtSetValues( toggleB, sensitive, 1);
XtSetValues( toggleC, sensitive, 1);
XtSetValues( toggleD, sensitive, 1);
XtSetValues( toggleNo, sensitive, 1);
}
wow = new CoWowGtk( parent_wid);
update();
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid,
(XtCallbackProc)activate_cancel, this);
#endif
}
/*
* Proview $Id: xtt_block_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_block_gtk_h
#define xtt_block_gtk_h
/* xtt_block_gtk.h -- Alarm blocking window */
#ifndef xtt_block_h
# include "xtt_block.h"
#endif
class BlockGtk : public Block {
public:
BlockGtk( void *b_parent_ctx,
GtkWidget *b_parent_wid,
pwr_sAttrRef *b_oar,
char *name,
unsigned int priv,
pwr_tStatus *status);
~BlockGtk();
int execute();
void update();
GtkWidget *parent_wid;
GtkWidget *toplevel;
GtkWidget *form;
GtkWidget *toggleA;
GtkWidget *toggleB;
GtkWidget *toggleC;
GtkWidget *toggleD;
GtkWidget *toggleNo;
GtkWidget *buttonOk;
GtkWidget *buttonApply;
static void activate_ok( GtkWidget *w, gpointer data);
static void activate_cancel( GtkWidget *w, gpointer data);
static void activate_apply( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: xtt_clog_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_clog_gtk.cpp -- Console log in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "co_lng.h"
#include "co_wow_gtk.h"
#include "xtt_clog.h"
#include "rt_xnav_msg.h"
#include "xtt_clog_gtk.h"
#include "xtt_clognav_gtk.h"
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
CLogGtk::activate_exit( w, data);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
CLogGtk::CLogGtk( void *clog_parent_ctx,
GtkWidget *clog_parent_wid,
char *clog_name,
pwr_tStatus *status) :
CLog( clog_parent_ctx, clog_name, status), parent_wid(clog_parent_wid), filter_form(0),
clock_cursor(0)
{
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 800,
"default-width", 1000,
"title", clog_name,
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( toplevel);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_filter = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Filter"));
g_signal_connect( file_filter, "activate",
G_CALLBACK(activate_filter), this);
GtkWidget *file_select_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Select File"));
g_signal_connect( file_select_file, "activate",
G_CALLBACK(activate_select_file), this);
GtkWidget *file_next_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Next File"));
g_signal_connect( file_next_file, "activate",
G_CALLBACK(activate_next_file), this);
gtk_widget_add_accelerator( file_next_file, "activate", accel_g,
'n', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *file_prev_file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Previous File"));
g_signal_connect( file_prev_file, "activate",
G_CALLBACK(activate_prev_file), this);
gtk_widget_add_accelerator( file_prev_file, "activate", accel_g,
'p', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *file_update = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Update"));
g_signal_connect( file_update, "activate",
G_CALLBACK(activate_update), this);
gtk_widget_add_accelerator( file_update, "activate", accel_g,
'u', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_filter);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_select_file);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_next_file);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_prev_file);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_update);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// View menu
GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in),
gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out),
gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset),
gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Menu Help
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help on ConsoleLog"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_msg = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Help on _Selected Message"));
g_signal_connect( help_msg, "activate",
G_CALLBACK(activate_helpmsg), 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_msg);
GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
clognav = new CLogNavGtk( this, vbox, &clognav_widget);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(clognav_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
wow = new CoWowGtk( toplevel);
*status = 1;
}
//
// Delete clog
//
CLogGtk::~CLogGtk()
{
free_cursor();
delete clognav;
if ( filter_form)
gtk_widget_destroy( filter_form);
gtk_widget_destroy( toplevel);
}
void CLogGtk::pop()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
void CLogGtk::set_clock_cursor()
{
if ( !clock_cursor)
clock_cursor = gdk_cursor_new_for_display( gtk_widget_get_display( toplevel),
GDK_WATCH);
gdk_window_set_cursor( toplevel->window, clock_cursor);
gdk_display_flush( gtk_widget_get_display( toplevel));
}
void CLogGtk::reset_cursor()
{
gdk_window_set_cursor( toplevel->window, NULL);
}
void CLogGtk::free_cursor()
{
if (clock_cursor)
gdk_cursor_unref( clock_cursor);
}
gboolean CLogGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
CLogGtk *clog = (CLogGtk *)data;
if ( clog && clog->clog_displayed)
clog->clognav->set_input_focus();
return FALSE;
}
void CLogGtk::activate_exit( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
if ( clog->close_cb)
(clog->close_cb)( clog->parent_ctx);
else
delete clog;
}
void CLogGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->clognav->zoom( 1.2);
}
void CLogGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->clognav->zoom( 5.0/6);
}
void CLogGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->clognav->unzoom();
}
void CLogGtk::activate_filter( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
bool success, info, warning, error, fatal, text;
((CLogGtk *)clog)->create_filter_dialog();
clog->clognav->get_filter( &success, &info, &warning, &error, &fatal, &text);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_success_w), success ? TRUE : FALSE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_info_w), info ? TRUE : FALSE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_warning_w), warning ? TRUE : FALSE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_error_w), error ? TRUE : FALSE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_fatal_w), fatal ? TRUE : FALSE);
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_text_w), text ? TRUE : FALSE);
}
void CLogGtk::activate_select_file( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
char *s;
pwr_tString80 *str;
str = (pwr_tString80 *) calloc( clog->clognav->file_list.size() + 1, sizeof( *str));
for ( int i = 0; i < (int)clog->clognav->file_list.size(); i++) {
time_AtoAscii( &clog->clognav->file_list[i].time, time_eFormat_ComprDateAndTime,
str[i], sizeof(str[i]));
str[i][17] = 0;
strcat( str[i], " ");
s = strrchr( clog->clognav->file_list[i].name, '/');
if ( s)
strcat( str[i], s+1);
else
strcat( str[i], clog->clognav->file_list[i].name);
}
clog->wow->CreateList( "Select File", (char *)str, file_selected_cb, clog);
free( str);
}
void CLogGtk::file_selected_cb( void *ctx, char *text)
{
CLog *clog = (CLog *)ctx;
int idx = -1;
char *s;
// Indentify the index of the selected text
for ( int i = 0; i < (int) clog->clognav->file_list.size(); i++) {
s = strrchr( clog->clognav->file_list[i].name, '/');
if ( s)
s++;
else
s = clog->clognav->file_list[i].name;
if ( strcmp( s, &text[21]) == 0) {
idx = i + 1;
break;
}
}
if ( idx == -1)
return;
clog->set_clock_cursor();
clog->clognav->read( &idx, 1);
clog->reset_cursor();
}
void CLogGtk::activate_next_file( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->activate_next_file();
}
void CLogGtk::activate_prev_file( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->activate_prev_file();
}
void CLogGtk::activate_update( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->set_clock_cursor();
clog->clognav->update();
clog->reset_cursor();
}
void CLogGtk::activate_help( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->activate_help();
}
void CLogGtk::activate_helpmsg( GtkWidget *w, gpointer data)
{
}
void CLogGtk::filter_ok_cb( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
filter_apply_cb( w, data);
g_object_set( ((CLogGtk *)clog)->filter_form, "visible", FALSE, NULL);
}
void CLogGtk::filter_cancel_cb( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
g_object_set( ((CLogGtk *)clog)->filter_form, "visible", FALSE, NULL);
}
void CLogGtk::filter_apply_cb( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
char *str;
bool success = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_success_w));
bool info = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_info_w));
bool warning = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_warning_w));
bool error = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_error_w));
bool fatal = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_fatal_w));
bool text = (bool) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((CLogGtk *)clog)->show_text_w));
str = gtk_editable_get_chars( GTK_EDITABLE(((CLogGtk *)clog)->filter_string_w), 0, -1);
clog->set_clock_cursor();
clog->clognav->set_filter( success, info, warning, error, fatal, text, str);
clog->reset_cursor();
g_free( str);
}
static gboolean filter_delete_event( GtkWidget *w, GdkEvent *event, gpointer clog)
{
g_object_set( ((CLogGtk *)clog)->filter_form, "visible", FALSE, NULL);
return TRUE;
}
void CLogGtk::create_filter_dialog()
{
if ( filter_form) {
g_object_set( filter_form, "visible", TRUE, NULL);
return;
}
// Create the options dialog
filter_form = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 300,
"default-width", 450,
"title", "Filter Messages",
NULL);
g_signal_connect( filter_form, "delete_event", G_CALLBACK(filter_delete_event), this);
GtkWidget *severity_label = gtk_label_new( "Message Severity");
gtk_misc_set_alignment( GTK_MISC(severity_label), 0.0, 0.05);
gtk_widget_set_size_request( severity_label, 140, -1);
GtkWidget *string_label = gtk_label_new( "String");
gtk_misc_set_alignment( GTK_MISC(string_label), 0.0, 0.5);
gtk_widget_set_size_request( string_label, 140, -1);
filter_string_w = gtk_entry_new();
show_success_w = gtk_check_button_new_with_label( "Success");
show_info_w = gtk_check_button_new_with_label( "Info");
show_warning_w = gtk_check_button_new_with_label( "Warning");
show_error_w = gtk_check_button_new_with_label( "Error");
show_fatal_w = gtk_check_button_new_with_label( "Fatal");
show_text_w = gtk_check_button_new_with_label( "Text");
GtkWidget *severity_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_success_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_info_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_warning_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_error_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_fatal_w, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_vbox), show_text_w, FALSE, FALSE, 7);
GtkWidget *severity_hbox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(severity_hbox), severity_label, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(severity_hbox), severity_vbox, FALSE, FALSE, 7);
GtkWidget *string_hbox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(string_hbox), string_label, FALSE, FALSE, 7);
gtk_box_pack_start( GTK_BOX(string_hbox), filter_string_w, TRUE, TRUE, 7);
GtkWidget *filter_ok = gtk_button_new_with_label( "Ok");
gtk_widget_set_size_request( filter_ok, 70, 25);
g_signal_connect( filter_ok, "clicked",
G_CALLBACK(filter_ok_cb), this);
GtkWidget *filter_apply = gtk_button_new_with_label( "Apply");
gtk_widget_set_size_request( filter_apply, 70, 25);
g_signal_connect( filter_apply, "clicked",
G_CALLBACK(filter_apply_cb), this);
GtkWidget *filter_cancel = gtk_button_new_with_label( "Cancel");
gtk_widget_set_size_request( filter_cancel, 70, 25);
g_signal_connect( filter_cancel, "clicked",
G_CALLBACK(filter_cancel_cb), this);
GtkWidget *filter_hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(filter_hboxbuttons), filter_ok, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(filter_hboxbuttons), filter_apply, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(filter_hboxbuttons), filter_cancel, FALSE, FALSE, 0);
GtkWidget *filter_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(filter_vbox), severity_hbox, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(filter_vbox), string_hbox, TRUE, TRUE, 15);
gtk_box_pack_start( GTK_BOX(filter_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(filter_vbox), filter_hboxbuttons, FALSE, FALSE, 15);
gtk_container_add( GTK_CONTAINER(filter_form), filter_vbox);
gtk_widget_show_all( filter_form);
}
/*
* Proview $Id: xtt_clog_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_clog_gtk_h
#define xtt_clog_gtk_h
/* xtt_clog_gtk.h -- Alarm and event windows in xtt */
#ifndef xtt_clog_h
# include "xtt_clog.h"
#endif
class CLogGtk : public CLog {
public:
CLogGtk( void *clog_parent_ctx,
GtkWidget *clog_parent_wid,
char *clog_name,
pwr_tStatus *status);
~CLogGtk();
GtkWidget *parent_wid;
GtkWidget *parent_wid_clog;
GtkWidget *toplevel;
GtkWidget *form_clog;
GtkWidget *clognav_widget;
GtkWidget *filter_form;
GtkWidget *show_success_w;
GtkWidget *show_info_w;
GtkWidget *show_warning_w;
GtkWidget *show_error_w;
GtkWidget *show_fatal_w;
GtkWidget *show_text_w;
GtkWidget *filter_string_w;
GtkWidget *filesel_form;
GtkWidget *filesel_list_w;
GdkCursor *clock_cursor;
void pop();
void set_clock_cursor();
void reset_cursor();
void free_cursor();
void create_filter_dialog();
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget*w, gpointer data);
static void activate_select_file( GtkWidget*w, gpointer data);
static void activate_next_file( GtkWidget*w, gpointer data);
static void activate_prev_file( GtkWidget*w, gpointer data);
static void activate_update( GtkWidget*w, gpointer data);
static void activate_zoom_in( GtkWidget*w, gpointer data);
static void activate_zoom_out( GtkWidget*w, gpointer data);
static void activate_zoom_reset( GtkWidget*w, gpointer data);
static void activate_filter( GtkWidget*w, gpointer data);
static void activate_help( GtkWidget*w, gpointer data);
static void activate_helpmsg( GtkWidget*w, gpointer data);
static void filter_ok_cb( GtkWidget*w, gpointer data);
static void filter_apply_cb( GtkWidget*w, gpointer data);
static void filter_cancel_cb( GtkWidget*w, gpointer data);
static void file_selected_cb( void *ctx, char *text);
};
#endif
/*
* Proview $Id: xtt_clognav_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_clognav_gtk.cpp -- Console message window. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_syi.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "xtt_clognav_gtk.h"
#include "xtt_menu.h"
CLogNavGtk::CLogNavGtk( void *clog_parent_ctx,
GtkWidget *clog_parent_wid,
GtkWidget **w) :
CLogNav( clog_parent_ctx), parent_wid(clog_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
*w = form_widget;
}
//
// Delete ev
//
CLogNavGtk::~CLogNavGtk()
{
delete brow;
gtk_widget_destroy( form_widget);
}
void CLogNavGtk::set_input_focus()
{
gtk_widget_grab_focus( brow_widget);
}
/*
* Proview $Id: xtt_clognav_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_clognav_gtk_h
#define xtt_clognav_gtk_h
/* xtt_clognav_gtk.h -- Console message window. */
// Status is defined as int i xlib...
#ifndef xtt_clognav_h
# include "xtt_clognav.h"
#endif
class CLogNavGtk : public CLogNav {
public:
CLogNavGtk( void *ev_parent_ctx,
GtkWidget *ev_parent_wid,
GtkWidget **w);
~CLogNavGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
void set_input_focus();
};
#endif
/*
* Proview $Id: xtt_ev_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_ev_gtk.cpp -- Alarm and event window in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "co_wow_gtk.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "rt_mh_util.h"
#include "co_lng.h"
#include "xtt_evlist_gtk.h"
#include "xtt_ev_gtk.h"
#include "rt_xnav_msg.h"
static gint eve_delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
EvGtk::eve_activate_exit( w, data);
return TRUE;
}
static void eve_destroy_event( GtkWidget *w, gpointer data)
{
}
static gint ala_delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
EvGtk::ala_activate_exit( w, data);
return TRUE;
}
static void ala_destroy_event( GtkWidget *w, gpointer data)
{
}
static gint blk_delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
EvGtk::blk_activate_exit( w, data);
return TRUE;
}
static void blk_destroy_event( GtkWidget *w, gpointer data)
{
}
EvGtk::EvGtk( void *ev_parent_ctx,
GtkWidget *ev_parent_wid,
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,
int ev_beep,
pwr_tStatus *status) :
Ev( ev_parent_ctx, eve_name, ala_name, blk_name, ev_user, display_ala, display_eve,
display_blk, display_return, display_ack, ev_beep, status),
parent_wid(ev_parent_wid), parent_wid_eve(NULL), parent_wid_ala(NULL)
{
pwr_tStatus sts;
pwr_sClass_User *userobject_ptr;
const int eve_width = 700;
const int eve_height = 600;
const int ala_width = 700;
const int ala_height = 300;
const int blk_width = 700;
const int blk_height = 300;
*status = 1;
// Check user object
if ( cdh_ObjidIsNull( user)) {
*status = XNAV__NOUSER;
return;
}
sts = gdh_ObjidToPointer( user, (pwr_tAddress *) &userobject_ptr);
if ( EVEN(sts)) {
*status = XNAV__NOUSER;
return;
}
ala_size = userobject_ptr->MaxNoOfAlarms;
eve_size = userobject_ptr->MaxNoOfEvents;
blk_size = 0;
create_aliaslist( userobject_ptr);
// Gtk
// Eve Window
{
parent_wid_eve = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", eve_height,
"default-width", eve_width,
"title", eve_name,
NULL);
g_signal_connect( parent_wid_eve, "delete_event", G_CALLBACK(eve_delete_event), this);
g_signal_connect( parent_wid_eve, "destroy", G_CALLBACK(eve_destroy_event), this);
g_signal_connect( parent_wid_eve, "focus-in-event", G_CALLBACK(eve_action_inputfocus), this);
CoWowGtk::SetWindowIcon( parent_wid_eve);
GtkWidget *eve_vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(parent_wid_eve), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print),
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(eve_activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(eve_activate_exit), this);
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *functions_ack_last = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Acknowledge"));
g_signal_connect( functions_ack_last, "activate",
G_CALLBACK(eve_activate_ack_last), this);
gtk_widget_add_accelerator( functions_ack_last, "activate", accel_g,
'k', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(eve_activate_open_plc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display object in Navigator"));
g_signal_connect( functions_display_object, "activate",
G_CALLBACK(eve_activate_display_in_xnav), this);
gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_last);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View entry
GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in),
gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_in, "activate",
G_CALLBACK(eve_activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out),
gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_out, "activate",
G_CALLBACK(eve_activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset),
gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_reset, "activate",
G_CALLBACK(eve_activate_zoom_reset), this);
gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
'b', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_disp_hundredth = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display hundredth"));
g_signal_connect( view_disp_hundredth, "activate",
G_CALLBACK(eve_activate_disp_hundredth), this);
GtkWidget *view_hide_object = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Hide Event Name"));
g_signal_connect( view_hide_object, "activate",
G_CALLBACK(eve_activate_hide_object), this);
GtkWidget *view_hide_text = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Hide _Event Text"));
g_signal_connect( view_hide_text, "activate",
G_CALLBACK(eve_activate_hide_text), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_disp_hundredth);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_object);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_text);
GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(eve_activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_helpevent = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Help Selected Event"));
g_signal_connect( help_helpevent, "activate",
G_CALLBACK(eve_activate_helpevent), 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_helpevent);
GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Create eve evlist
eve = new EvListGtk( this, eve_vbox, ev_eType_EventList, eve_size, &eve_widget);
eve->start_trace_cb = &eve_start_trace_cb;
eve->display_in_xnav_cb = &eve_display_in_xnav_cb;
eve->name_to_alias_cb = &ev_name_to_alias_cb;
eve->popup_menu_cb = &ev_popup_menu_cb;
gtk_box_pack_start( GTK_BOX(eve_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(eve_vbox), GTK_WIDGET(eve_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(parent_wid_eve), eve_vbox);
// gtk_widget_show_all( parent_wid_eve);
}
// Ala Window
{
parent_wid_ala = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", ala_height,
"default-width", ala_width,
"title", ala_name,
NULL);
g_signal_connect( parent_wid_ala, "delete_event", G_CALLBACK(ala_delete_event), this);
g_signal_connect( parent_wid_ala, "destroy", G_CALLBACK(ala_destroy_event), this);
g_signal_connect( parent_wid_ala, "focus-in-event", G_CALLBACK(ala_action_inputfocus), this);
CoWowGtk::SetWindowIcon( parent_wid_ala);
GtkWidget *ala_vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(parent_wid_ala), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print),
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(ala_activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(ala_activate_exit), this);
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *functions_ack_last = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Acknowledge"));
g_signal_connect( functions_ack_last, "activate",
G_CALLBACK(ala_activate_ack_last), this);
gtk_widget_add_accelerator( functions_ack_last, "activate", accel_g,
'k', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(ala_activate_open_plc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display object in Navigator"));
g_signal_connect( functions_display_object, "activate",
G_CALLBACK(ala_activate_display_in_xnav), this);
gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_ack_last);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View entry
GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in),
gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_in, "activate",
G_CALLBACK(ala_activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out),
gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_out, "activate",
G_CALLBACK(ala_activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset),
gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_reset, "activate",
G_CALLBACK(ala_activate_zoom_reset), this);
gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
'b', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_disp_hundredth = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display hundredth"));
g_signal_connect( view_disp_hundredth, "activate",
G_CALLBACK(ala_activate_disp_hundredth), this);
GtkWidget *view_hide_object = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Hide Event Name"));
g_signal_connect( view_hide_object, "activate",
G_CALLBACK(ala_activate_hide_object), this);
GtkWidget *view_hide_text = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Hide _Event Text"));
g_signal_connect( view_hide_text, "activate",
G_CALLBACK(ala_activate_hide_text), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_disp_hundredth);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_object);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_text);
GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Help"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(ala_activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_helpevent = gtk_check_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Help Selected Event"));
g_signal_connect( help_helpevent, "activate",
G_CALLBACK(ala_activate_helpevent), 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_helpevent);
GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Create ala evlist
ala = new EvListGtk( this, ala_vbox, ev_eType_AlarmList, ala_size, &ala_widget);
ala->start_trace_cb = &ala_start_trace_cb;
ala->display_in_xnav_cb = &ala_display_in_xnav_cb;
ala->name_to_alias_cb = &ev_name_to_alias_cb;
ala->popup_menu_cb = &ev_popup_menu_cb;
gtk_box_pack_start( GTK_BOX(ala_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(ala_vbox), GTK_WIDGET(ala_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(parent_wid_ala), ala_vbox);
// gtk_widget_show_all( parent_wid_ala);
}
// Blk Window
{
parent_wid_blk = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", blk_height,
"default-width", blk_width,
"title", blk_name,
NULL);
g_signal_connect( parent_wid_blk, "delete_event", G_CALLBACK(blk_delete_event), this);
g_signal_connect( parent_wid_blk, "destroy", G_CALLBACK(blk_destroy_event), this);
g_signal_connect( parent_wid_blk, "focus-in-event", G_CALLBACK(blk_action_inputfocus), this);
CoWowGtk::SetWindowIcon( parent_wid_blk);
GtkWidget *blk_vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(parent_wid_blk), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print),
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(blk_activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(blk_activate_exit), this);
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *functions_block_remove = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Remove Blocking"));
g_signal_connect( functions_block_remove, "activate",
G_CALLBACK(blk_activate_block_remove), this);
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(blk_activate_open_plc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display object in Navigator"));
g_signal_connect( functions_display_object, "activate",
G_CALLBACK(blk_activate_display_in_xnav), this);
gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_block_remove);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View entry
GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in),
gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_in, "activate",
G_CALLBACK(blk_activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out),
gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_out, "activate",
G_CALLBACK(blk_activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset),
gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_reset, "activate",
G_CALLBACK(blk_activate_zoom_reset), this);
gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
'b', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
GtkWidget *view = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Help"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(blk_activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Create blk evlist
blk = new EvListGtk( this, blk_vbox, ev_eType_BlockList, blk_size, &blk_widget);
blk->start_trace_cb = &blk_start_trace_cb;
blk->display_in_xnav_cb = &blk_display_in_xnav_cb;
blk->name_to_alias_cb = &ev_name_to_alias_cb;
blk->popup_menu_cb = &ev_popup_menu_cb;
gtk_box_pack_start( GTK_BOX(blk_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(blk_vbox), GTK_WIDGET(blk_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(parent_wid_blk), blk_vbox);
// gtk_widget_show_all( parent_wid_blk);
}
// Store this for the mh callbacks
ev = this;
if ( display_eve) {
gtk_widget_show_all( parent_wid_eve);
eve_displayed = 1;
}
else {
gtk_widget_show_all( parent_wid_eve);
g_object_set( parent_wid_eve, "visible", FALSE, NULL);
}
if ( display_ala) {
gtk_widget_show_all( parent_wid_ala);
ala_displayed = 1;
}
else {
gtk_widget_show_all( parent_wid_ala);
g_object_set( parent_wid_ala, "visible", FALSE, NULL);
}
if ( display_blk) {
gtk_widget_show_all( parent_wid_blk);
blk_displayed = 1;
}
else {
gtk_widget_show_all( parent_wid_blk);
g_object_set( parent_wid_blk, "visible", FALSE, NULL);
}
sts = outunit_connect( user);
if ( EVEN(sts))
*status = sts;
}
//
// Delete ev
//
EvGtk::~EvGtk()
{
if ( connected)
mh_OutunitDisconnect();
if ( parent_wid_eve)
gtk_widget_destroy( parent_wid_eve);
if ( parent_wid_ala)
gtk_widget_destroy( parent_wid_ala);
if ( parent_wid_blk)
gtk_widget_destroy( parent_wid_blk);
if ( eve)
delete eve;
if ( ala)
delete ala;
ev = NULL;
}
void EvGtk::map_eve()
{
gtk_window_present( GTK_WINDOW(parent_wid_eve));
eve_displayed = 1;
}
void EvGtk::map_ala()
{
gtk_window_present( GTK_WINDOW(parent_wid_ala));
ala_displayed = 1;
}
void EvGtk::map_blk()
{
gtk_window_present( GTK_WINDOW(parent_wid_blk));
blk_displayed = 1;
}
void EvGtk::unmap_eve()
{
if ( eve_displayed) {
g_object_set( parent_wid_eve, "visible", FALSE, NULL);
eve_displayed = 0;
}
}
void EvGtk::unmap_ala()
{
if ( ala_displayed) {
g_object_set( parent_wid_ala, "visible", FALSE, NULL);
ala_displayed = 0;
}
}
void EvGtk::unmap_blk()
{
if ( blk_displayed) {
g_object_set( parent_wid_blk, "visible", FALSE, NULL);
blk_displayed = 0;
}
}
gboolean EvGtk::eve_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
Ev *ev = (Ev *)data;
if ( ev && ev->eve_displayed)
ev->eve->set_input_focus();
return FALSE;
}
gboolean EvGtk::ala_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
Ev *ev = (Ev *)data;
if ( ev && ev->ala_displayed)
ev->ala->set_input_focus();
return FALSE;
}
gboolean EvGtk::blk_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
Ev *ev = (Ev *)data;
if ( ev && ev->blk_displayed)
ev->blk->set_input_focus();
return FALSE;
}
void EvGtk::eve_activate_exit( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->unmap_eve();
ev->eve_displayed = 0;
}
void EvGtk::ala_activate_exit( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->unmap_ala();
ev->ala_displayed = 0;
}
void EvGtk::blk_activate_exit( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->unmap_blk();
ev->blk_displayed = 0;
}
void EvGtk::eve_activate_print( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve_activate_print();
}
void EvGtk::ala_activate_print( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala_activate_print();
}
void EvGtk::blk_activate_print( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk_activate_print();
}
void EvGtk::eve_activate_ack_last( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve_activate_ack_last();
}
void EvGtk::ala_activate_ack_last( GtkWidget *w, gpointer data)
{
eve_activate_ack_last( w, data);
}
void EvGtk::eve_activate_zoom_in( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve->zoom( 1.2);
}
void EvGtk::ala_activate_zoom_in( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala->zoom( 1.2);
}
void EvGtk::blk_activate_zoom_in( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->zoom( 1.2);
}
void EvGtk::eve_activate_zoom_out( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve->zoom( 5.0/6);
}
void EvGtk::ala_activate_zoom_out( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala->zoom( 5.0/6);
}
void EvGtk::blk_activate_zoom_out( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->zoom( 5.0/6);
}
void EvGtk::eve_activate_zoom_reset( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve->unzoom();
}
void EvGtk::ala_activate_zoom_reset( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala->unzoom();
}
void EvGtk::blk_activate_zoom_reset( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->unzoom();
}
void EvGtk::blk_activate_block_remove( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->block_remove();
}
void EvGtk::eve_activate_open_plc( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve->start_trace();
}
void EvGtk::ala_activate_open_plc( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala->start_trace();
}
void EvGtk::blk_activate_open_plc( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->start_trace();
}
void EvGtk::eve_activate_display_in_xnav( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve->display_in_xnav();
}
void EvGtk::ala_activate_display_in_xnav( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala->display_in_xnav();
}
void EvGtk::blk_activate_display_in_xnav( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk->display_in_xnav();
}
void EvGtk::eve_activate_disp_hundredth( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->eve->set_display_hundredth( set);
}
void EvGtk::ala_activate_disp_hundredth( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->ala->set_display_hundredth( set);
}
void EvGtk::eve_activate_hide_object( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->eve->set_hide_object( set);
}
void EvGtk::ala_activate_hide_object( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->ala->set_hide_object( set);
}
void EvGtk::eve_activate_hide_text( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->eve->set_hide_text( set);
}
void EvGtk::ala_activate_hide_text( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
ev->ala->set_hide_text( set);
}
void EvGtk::eve_activate_help( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve_activate_help();
}
void EvGtk::eve_activate_helpevent( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->eve_activate_helpevent();
}
void EvGtk::ala_activate_help( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala_activate_help();
}
void EvGtk::ala_activate_helpevent( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->ala_activate_helpevent();
}
void EvGtk::blk_activate_help( GtkWidget *w, gpointer data)
{
Ev *ev = (Ev *)data;
ev->blk_activate_help();
}
/*
* Proview $Id: xtt_ev_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_ev_gtk_h
#define xtt_ev_gtk_h
/* xtt_ev_gtk.h -- Alarm and event windows in xtt */
#ifndef xtt_ev_h
# include "xtt_ev.h"
#endif
class EvGtk : public Ev {
public:
EvGtk(
void *ev_parent_ctx,
GtkWidget *ev_parent_wid,
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,
int ev_beep,
pwr_tStatus *status);
~EvGtk();
GtkWidget *parent_wid;
GtkWidget *parent_wid_eve;
GtkWidget *parent_wid_ala;
GtkWidget *parent_wid_blk;
GtkWidget *toplevel_ala;
GtkWidget *toplevel_eve;
GtkWidget *toplevel_blk;
GtkWidget *form_ala;
GtkWidget *form_eve;
GtkWidget *form_blk;
GtkWidget *eve_widget;
GtkWidget *ala_widget;
GtkWidget *blk_widget;
void map_eve();
void map_ala();
void map_blk();
void unmap_eve();
void unmap_ala();
void unmap_blk();
static gboolean eve_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static gboolean ala_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static gboolean blk_action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void eve_activate_exit( GtkWidget *w, gpointer data);
static void ala_activate_exit( GtkWidget *w, gpointer data);
static void blk_activate_exit( GtkWidget *w, gpointer data);
static void eve_activate_print( GtkWidget *w, gpointer data);
static void ala_activate_print( GtkWidget *w, gpointer data);
static void blk_activate_print( GtkWidget *w, gpointer data);
static void eve_activate_ack_last( GtkWidget *w, gpointer data);
static void ala_activate_ack_last( GtkWidget *w, gpointer data);
static void eve_activate_zoom_in( GtkWidget *w, gpointer data);
static void ala_activate_zoom_in( GtkWidget *w, gpointer data);
static void blk_activate_zoom_in( GtkWidget *w, gpointer data);
static void eve_activate_zoom_out( GtkWidget *w, gpointer data);
static void ala_activate_zoom_out( GtkWidget *w, gpointer data);
static void blk_activate_zoom_out( GtkWidget *w, gpointer data);
static void eve_activate_zoom_reset( GtkWidget *w, gpointer data);
static void ala_activate_zoom_reset( GtkWidget *w, gpointer data);
static void blk_activate_zoom_reset( GtkWidget *w, gpointer data);
static void blk_activate_block_remove( GtkWidget *w, gpointer data);
static void eve_activate_open_plc( GtkWidget *w, gpointer data);
static void ala_activate_open_plc( GtkWidget *w, gpointer data);
static void blk_activate_open_plc( GtkWidget *w, gpointer data);
static void eve_activate_display_in_xnav( GtkWidget *w, gpointer data);
static void ala_activate_display_in_xnav( GtkWidget *w, gpointer data);
static void blk_activate_display_in_xnav( GtkWidget *w, gpointer data);
static void eve_activate_disp_hundredth( GtkWidget *w, gpointer data);
static void ala_activate_disp_hundredth( GtkWidget *w, gpointer data);
static void eve_activate_hide_object( GtkWidget *w, gpointer data);
static void ala_activate_hide_object( GtkWidget *w, gpointer data);
static void eve_activate_hide_text( GtkWidget *w, gpointer data);
static void ala_activate_hide_text( GtkWidget *w, gpointer data);
static void eve_activate_help( GtkWidget *w, gpointer data);
static void ala_activate_help( GtkWidget *w, gpointer data);
static void blk_activate_help( GtkWidget *w, gpointer data);
static void eve_activate_helpevent( GtkWidget *w, gpointer data);
static void ala_activate_helpevent( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: xtt_evlist_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_evlist_gtk.cpp -- Alarm or event list in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "co_wow_gtk.h"
#include "co_lng.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "xtt_evlist_gtk.h"
EvListGtk::EvListGtk( void *ev_parent_ctx,
GtkWidget *ev_parent_wid,
ev_eType ev_type,
int ev_size,
GtkWidget **w) :
EvList( ev_parent_ctx, ev_type, ev_size), parent_wid(ev_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
*w = form_widget;
}
//
// Delete ev
//
EvListGtk::~EvListGtk()
{
delete brow;
gtk_widget_destroy( form_widget);
}
void EvListGtk::set_input_focus()
{
gtk_widget_grab_focus( brow_widget);
}
void EvListGtk::bell()
{
gdk_display_beep( gtk_widget_get_display( brow_widget));
}
void EvListGtk::popup_position( int x_event, int y_event, int *x, int *y)
{
CoWowGtk::PopupPosition( brow_widget, x_event, y_event, x, y);
}
/*
* Proview $Id: xtt_evlist_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_evlist_gtk_h
#define xtt_evlist_gtk_h
/* xtt_evlist_gtk.h -- Alarm and event windows in xtt */
#ifndef xtt_evlist_h
# include "xtt_evlist.h"
#endif
class EvListGtk : public EvList {
public:
EvListGtk(
void *ev_parent_ctx,
GtkWidget *ev_parent_wid,
ev_eType ev_type,
int ev_size,
GtkWidget **w);
~EvListGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
void set_input_focus();
void bell();
void popup_position( int x_event, int y_event, int *x, int *y);
};
#endif
/*
* Proview $Id: xtt_fast_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "rt_fast.h"
#include "xtt_fast_gtk.h"
#include "ge_curve_gtk.h"
XttFastGtk::XttFastGtk( void *parent_ctx,
GtkWidget *parent_wid,
char *name,
GtkWidget **w,
pwr_sAttrRef *fast_arp,
int *sts) :
XttFast( parent_ctx, name, fast_arp, sts), parent_widget(parent_wid)
{
char title[250];
*sts = XNAV__SUCCESS;
curve = new GeCurveGtk( this, parent_widget, title, NULL, gcd, 0);
curve->close_cb = fast_close_cb;
curve->help_cb = fast_help_cb;
wow = new CoWowGtk( parent_widget);
timerid = wow->timer_new();
timerid->add( 1000, fast_scan, this);
}
XttFastGtk::~XttFastGtk()
{
timerid->remove();
for ( int i = 0; i < fast_cnt; i++) {
gdh_UnrefObjectInfo( new_subid);
}
delete curve;
}
/*
* Proview $Id: xtt_fast_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_fast_gtk_h
#define xtt_fast_gtk_h
/* xtt_fast_gtk.h -- Fast curves */
#ifndef xtt_fast_h
# include "xtt_fast.h"
#endif
class XttFastGtk : public XttFast {
public:
GtkWidget *parent_widget; //!< Parent widget.
XttFastGtk( void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
char *xn_name,
GtkWidget **w,
pwr_sAttrRef *fast_arp,
int *sts);
~XttFastGtk();
};
#endif
/*
* Proview $Id: xtt_ge_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
typedef void *Widget;
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "glow.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "co_lng.h"
#include "xtt_ge_gtk.h"
#include "ge_graph_gtk.h"
#include "xtt_xnav.h"
gboolean XttGeGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
XttGe *ge = (XttGe *)data;
if ( ge->graph)
ge->graph->set_inputfocus(1);
return FALSE;
}
void XttGeGtk::set_size( int width, int height)
{
int default_width;
int default_height;
GdkGeometry geometry;
default_width = width + 20;
default_height = height + 20;
gtk_window_resize( GTK_WINDOW(toplevel), default_width, default_height);
geometry.min_aspect = geometry.max_aspect = gdouble(default_width)/default_height;
gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
&geometry, GDK_HINT_ASPECT);
}
void XttGeGtk::ge_change_value_cb( void *ge_ctx, void *value_object, char *text)
{
XttGeGtk *ge = (XttGeGtk *)ge_ctx;
if ( ge->value_input_open) {
g_object_set( ge->value_dialog, "visible", FALSE, NULL);
ge->value_input_open = 0;
return;
}
g_object_set( ge->value_dialog, "visible", TRUE, NULL);
ge->message( ' ', "");
gtk_widget_grab_focus( ge->value_input);
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(ge->value_input), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(ge->value_input), text, strlen(text), &pos);
gtk_editable_set_position( GTK_EDITABLE(ge->value_input), -1);
gtk_editable_select_region( GTK_EDITABLE(ge->value_input), 0, -1);
ge->value_input_open = 1;
ge->current_value_object = value_object;
}
void XttGeGtk::confirm_cb( void *ge_ctx, void *confirm_object, char *text)
{
XttGe *ge = (XttGe *)ge_ctx;
if ( ge->confirm_open) {
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
ge->confirm_open = 0;
return;
}
((XttGeGtk *)ge)->create_confirm_dialog();
ge->message( ' ', "");
gtk_label_set_text( GTK_LABEL(((XttGeGtk *)ge)->confirm_label), text);
ge->confirm_open = 1;
ge->current_confirm_object = confirm_object;
}
void XttGeGtk::message_dialog_cb( void *ge_ctx, char *text)
{
XttGe *ge = (XttGe *)ge_ctx;
g_object_set( ((XttGeGtk *)ge)->message_dia_widget, "visible", TRUE, NULL);
gtk_label_set_text( GTK_LABEL(((XttGeGtk *)ge)->message_dia_label), text);
}
void XttGeGtk::activate_value_input( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
char *text;
text = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1);
if ( ge->value_input_open) {
ge->graph->change_value( ge->current_value_object, text);
g_object_set( ((XttGeGtk *)ge)->value_dialog, "visible", FALSE, NULL);
ge->value_input_open = 0;
}
g_free( text);
}
void XttGeGtk::activate_confirm_ok( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
ge->confirm_open = 0;
ge->graph->confirm_ok( ge->current_confirm_object);
}
void XttGeGtk::activate_confirm_cancel( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
ge->confirm_open = 0;
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
}
void XttGeGtk::activate_exit( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
delete ge;
}
void XttGeGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
ge->graph->zoom( 1.2);
}
void XttGeGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
ge->graph->zoom( 5.0/6);
}
void XttGeGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
ge->graph->unzoom();
}
void XttGeGtk::activate_help( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
char key[80];
if ( ge->help_cb) {
cdh_ToLower( key, ge->name);
(ge->help_cb)( ge, key);
}
}
void XttGeGtk::action_resize( GtkWidget *w, GtkAllocation *allocation, gpointer data)
{
XttGe *ge = (XttGe *)data;
if ( ge->graph && !ge->scrollbar && !ge->navigator && ge->graph->grow)
ge->graph->set_default_layout();
}
XttGeGtk::~XttGeGtk()
{
if ( close_cb)
(close_cb)( this);
if ( nav_shell)
gtk_widget_destroy( nav_shell);
delete graph;
gtk_widget_destroy( toplevel);
}
void XttGeGtk::pop()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer ge)
{
XttGeGtk::activate_exit(w, ge);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
static gint nav_delete_event( GtkWidget *w, GdkEvent *event, gpointer ge)
{
return TRUE;
}
XttGeGtk::XttGeGtk( GtkWidget *xg_parent_wid, void *xg_parent_ctx, char *xg_name, char *xg_filename,
int xg_scrollbar, int xg_menu, int xg_navigator, int xg_width, int xg_height,
int x, int y, double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int)) :
XttGe( xg_parent_ctx, xg_name, xg_filename, xg_scrollbar, xg_menu, xg_navigator, xg_width,
xg_height, x, y, scan_time, object_name, use_default_access, access,
xg_command_cb, xg_get_current_objects_cb, xg_is_authorized_cb),
parent_wid(xg_parent_wid), nav_shell(0), value_dialog(0), confirm_widget(0)
{
int window_width = 600;
int window_height = 500;
GdkGeometry geometry;
pwr_tStatus sts;
GtkMenuBar *menu_bar;
char title[300];
if ( xg_width != 0 && xg_height != 0) {
window_width = xg_width;
window_height = xg_height;
}
cdh_StrncpyCutOff( title, name, sizeof(title), 1);
// Gtk
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", window_height,
"default-width", window_width,
"title", title,
NULL);
geometry.min_aspect = geometry.max_aspect = gdouble(window_width)/window_height;
gtk_window_set_geometry_hints( GTK_WINDOW(toplevel), GTK_WIDGET(toplevel),
&geometry, GDK_HINT_ASPECT);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( toplevel);
if ( xg_menu) {
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File Entry
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// View menu
GtkWidget *view_zoom_in = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);
g_signal_connect(view_zoom_in, "activate", G_CALLBACK(activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);
g_signal_connect(view_zoom_out, "activate", G_CALLBACK(activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_100, NULL);
g_signal_connect(view_zoom_reset, "activate", G_CALLBACK(activate_zoom_reset), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Menu Help
GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
}
graph_form = gtk_vbox_new( FALSE, 0);
graph = new GraphGtk( this, graph_form, "Plant",
&grow_widget, &sts, "pwrp_exe:", graph_eMode_Runtime,
scrollbar, 1, object_name, 0, 0);
// graph->set_scantime( scan_time);
graph->message_cb = &message_cb;
graph->close_cb = &graph_close_cb;
graph->init_cb = &graph_init_cb;
graph->change_value_cb = &ge_change_value_cb;
graph->confirm_cb = &confirm_cb;
graph->message_dialog_cb = &message_dialog_cb;
graph->command_cb = &ge_command_cb;
graph->display_in_xnav_cb = &ge_display_in_xnav_cb;
graph->is_authorized_cb = &ge_is_authorized_cb;
graph->get_current_objects_cb = &ge_get_current_objects_cb;
graph->popup_menu_cb = &ge_popup_menu_cb;
graph->call_method_cb = &ge_call_method_cb;
graph->sound_cb = &ge_sound_cb;
//g_signal_connect( graph_form, "check_resize", G_CALLBACK(action_resize), this);
g_signal_connect( ((GraphGtk *)graph)->grow_widget, "size_allocate", G_CALLBACK(action_resize), this);
if ( xg_menu)
gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(graph_form), GTK_WIDGET(grow_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(toplevel), graph_form);
gtk_widget_show_all( toplevel);
if ( navigator) {
// Create navigator popup
nav_shell = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 200,
"default-width", 200,
"title", "Navigator",
NULL);
g_signal_connect( nav_shell, "delete_event", G_CALLBACK(nav_delete_event), this);
((GraphGtk *)graph)->create_navigator( nav_shell);
gtk_container_add( GTK_CONTAINER(nav_shell), ((GraphGtk *)graph)->nav_widget);
gtk_widget_show_all( nav_shell);
((Graph *)graph)->set_nav_background_color();
if ( !(x == 0 && y == 0)) {
// Set position
gtk_window_move( GTK_WINDOW(toplevel), x, y);
}
}
}
static gint confirm_delete_event( GtkWidget *w, GdkEvent *event, gpointer ge)
{
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
return TRUE;
}
void XttGeGtk::create_confirm_dialog()
{
if ( confirm_widget) {
g_object_set( confirm_widget, "visible", TRUE, NULL);
return;
}
// Create a confirm window
confirm_widget = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 150,
"default-width", 400,
"title", "Confirm",
NULL);
g_signal_connect( confirm_widget, "delete_event", G_CALLBACK(confirm_delete_event), this);
confirm_label = gtk_label_new("");
GtkWidget *confirm_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 *confirm_ok = gtk_button_new_with_label( "Yes");
gtk_widget_set_size_request( confirm_ok, 70, 25);
g_signal_connect( confirm_ok, "clicked",
G_CALLBACK(activate_confirm_ok), this);
GtkWidget *confirm_cancel = gtk_button_new_with_label( "No");
gtk_widget_set_size_request( confirm_cancel, 70, 25);
g_signal_connect( confirm_cancel, "clicked",
G_CALLBACK(activate_confirm_cancel), this);
GtkWidget *confirm_hboxtext = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(confirm_hboxtext), confirm_image, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(confirm_hboxtext), confirm_label, TRUE, TRUE, 15);
GtkWidget *confirm_hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(confirm_hboxbuttons), confirm_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(confirm_hboxbuttons), confirm_cancel, FALSE, FALSE, 0);
GtkWidget *confirm_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(confirm_vbox), confirm_hboxtext, TRUE, TRUE, 30);
gtk_box_pack_start( GTK_BOX(confirm_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(confirm_vbox), confirm_hboxbuttons, FALSE, FALSE, 15);
gtk_container_add( GTK_CONTAINER(confirm_widget), confirm_vbox);
gtk_widget_show_all( confirm_widget);
}
/*
* Proview $Id: xtt_ge_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_ge_gtk_h
#define xtt_ge_gtk_h
#ifndef xtt_ge_h
# include "xtt_ge.h"
#endif
class XttGeGtk : public XttGe {
public:
GtkWidget *parent_wid;
GtkWidget *grow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *nav_shell;
GtkWidget *nav_widget;
GtkWidget *menu_widget;
GtkWidget *graph_form;
GtkWidget *value_input;
GtkWidget *value_dialog;
GtkWidget *confirm_widget;
GtkWidget *confirm_label;
GtkWidget *message_dia_widget;
GtkWidget *message_dia_label;
XttGeGtk( GtkWidget *parent_wid, void *parent_ctx, char *name, char *filename,
int scrollbar, int menu, int navigator, int width, int height,
int x, int y, double scan_time, char *object_name, int use_default_access,
unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int));
~XttGeGtk();
void pop();
void set_size( int width, int height);
void create_confirm_dialog();
static void ge_change_value_cb( void *ge_ctx, void *value_object, char *text);
static void confirm_cb( void *ge_ctx, void *confirm_object, char *text);
static void message_dialog_cb( void *ge_ctx, char *text);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_value_input( GtkWidget *w, gpointer data);
static void activate_confirm_ok( GtkWidget *w, gpointer data);
static void activate_confirm_cancel( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void create_graph_form( GtkWidget *w, gpointer data);
static void create_message_dia( GtkWidget *w, gpointer data);
static void create_menu( GtkWidget *w, gpointer data);
static void create_value_input( GtkWidget *w, gpointer data);
static void action_resize( GtkWidget *w, GtkAllocation *allocation, gpointer data);
};
#endif
/*
* Proview $Id: xtt_hist_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_hist_gtk.cpp -- Historical event window in xtt
Author: Jonas Nylund.
Last modification: 030217
*/
#if defined OS_LINUX
using namespace std;
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "rt_mh_util.h"
#include "rt_elog.h"
#include "co_dcli.h"
extern "C" {
#include <db.h>
}
#include <deque>
#include <algorithm>
#include "co_lng.h"
#include "xtt_hist_gtk.h"
#include "rt_xnav_msg.h"
#include "xtt_evlist_gtk.h"
#define SENS 1
#define INSENS 0
#define DONT_SET_SENS -1
/* 24 hours in seconds */
#define ONEDAY 86400
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
HistGtk::activate_exit( w, data);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
HistGtk::HistGtk( void *hist_parent_ctx,
GtkWidget *hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status) :
Hist( hist_parent_ctx, hist_name, objid, status),
parent_wid(hist_parent_wid), parent_wid_hist(NULL)
{
const int hist_width = 800;
const int hist_height = 700;
//shall be MessageHandler.EventLogSize
hist_size = 100000;
// Gtk
parent_wid_hist = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", hist_height,
"default-width", hist_width,
"title", CoWowGtk::translate_utf8(hist_name),
NULL);
g_signal_connect( parent_wid_hist, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( parent_wid_hist, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( parent_wid_hist, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( parent_wid_hist);
GtkWidget *hist_vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(parent_wid_hist), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print),
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(activate_open_plc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Display object in Navigator"));
g_signal_connect( functions_display_object, "activate",
G_CALLBACK(activate_display_in_xnav), this);
gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_search = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Search"));
g_signal_connect( functions_search, "activate",
G_CALLBACK(ok_btn), this);
gtk_widget_add_accelerator( functions_search, "activate", accel_g,
'f', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_search);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// View entry
GtkWidget *view_zoom_in = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _In"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_in),
gtk_image_new_from_stock( "gtk-zoom-in", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_in, "activate",
G_CALLBACK(activate_zoom_in), this);
gtk_widget_add_accelerator( view_zoom_in, "activate", accel_g,
'i', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_out = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Out"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_out),
gtk_image_new_from_stock( "gtk-zoom-out", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_out, "activate",
G_CALLBACK(activate_zoom_out), this);
gtk_widget_add_accelerator( view_zoom_out, "activate", accel_g,
'o', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_zoom_reset = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Zoom _Reset"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(view_zoom_reset),
gtk_image_new_from_stock( "gtk-zoom-100", GTK_ICON_SIZE_MENU));
g_signal_connect( view_zoom_reset, "activate",
G_CALLBACK(activate_zoom_reset), this);
gtk_widget_add_accelerator( view_zoom_reset, "activate", accel_g,
'b', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *view_disp_hundredth = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Display hundredth"));
g_signal_connect( view_disp_hundredth, "activate",
G_CALLBACK(activate_disp_hundredth), this);
GtkWidget *view_hide_object = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Hide Event Name"));
g_signal_connect( view_hide_object, "activate",
G_CALLBACK(activate_hide_object), this);
GtkWidget *view_hide_text = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Hide _Event Text"));
g_signal_connect( view_hide_text, "activate",
G_CALLBACK(activate_hide_text), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_in);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_reset);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_disp_hundredth);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_object);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_hide_text);
GtkWidget *view = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_View"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), GTK_WIDGET(view_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *help_helpevent = gtk_check_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Help Selected Event"));
g_signal_connect( help_helpevent, "activate",
G_CALLBACK(activate_helpevent), 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_helpevent);
GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Search dialog
// Time box
GtkWidget *sea_time_start_label = gtk_label_new( CoWowGtk::translate_utf8("Start time"));
gtk_widget_set_size_request( sea_time_start_label, 120, -1);
gtk_misc_set_alignment( GTK_MISC(sea_time_start_label), 0.0, 0.5);
start_time_entry_w = gtk_entry_new();
gtk_widget_set_size_request( start_time_entry_w, 140, -1);
GtkWidget *sea_time_stop_label = gtk_label_new( CoWowGtk::translate_utf8("Stop time"));
gtk_widget_set_size_request( sea_time_stop_label, 120, -1);
stop_time_entry_w = gtk_entry_new();
gtk_widget_set_size_request( start_time_entry_w, 140, -1);
// Time option menu
GtkWidget *sea_time_all = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("All "));
g_signal_connect( sea_time_all, "activate", G_CALLBACK( all_cb), this);
GtkWidget *sea_time_today = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("Today"));
g_signal_connect( sea_time_today, "activate", G_CALLBACK( today_cb), this);
GtkWidget *sea_time_yesterday = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("Yesterday"));
g_signal_connect( sea_time_yesterday, "activate", G_CALLBACK( yesterday_cb), this);
GtkWidget *sea_time_thisw = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("This Week"));
g_signal_connect( sea_time_thisw, "activate", G_CALLBACK( thisw_cb), this);
GtkWidget *sea_time_lastw = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("Last Week"));
g_signal_connect( sea_time_lastw, "activate", G_CALLBACK( lastw_cb), this);
GtkWidget *sea_time_thism = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("This Month"));
g_signal_connect( sea_time_thism, "activate", G_CALLBACK( thisw_cb), this);
GtkWidget *sea_time_lastm = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("Last Month"));
g_signal_connect( sea_time_lastm, "activate", G_CALLBACK( lastw_cb), this);
GtkWidget *sea_time_time = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8("Time"));
g_signal_connect( sea_time_time, "activate", G_CALLBACK( time_cb), this);
GtkMenu *sea_time_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_all);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_today);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_yesterday);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_thisw);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_lastw);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_thism);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_lastm);
gtk_menu_shell_append( GTK_MENU_SHELL(sea_time_menu), sea_time_time);
GtkWidget *sea_time_omenu = (GtkWidget *)g_object_new( GTK_TYPE_OPTION_MENU,
"menu", sea_time_menu, NULL);
gtk_option_menu_set_history( GTK_OPTION_MENU(sea_time_omenu), 0);
GtkWidget *sea_timebox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_timebox), sea_time_start_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_timebox), start_time_entry_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_timebox), sea_time_stop_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_timebox), stop_time_entry_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_timebox), sea_time_omenu, FALSE, FALSE, 10);
// Event type box
GtkWidget *sea_type_label = gtk_label_new( CoWowGtk::translate_utf8("Event type"));
gtk_widget_set_size_request( sea_type_label, 120, -1);
gtk_misc_set_alignment( GTK_MISC(sea_type_label), 0.0, 0.5);
alarm_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("Active"));
gtk_widget_set_size_request( alarm_toggle_w, 100, -1);
info_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("Message"));
gtk_widget_set_size_request( info_toggle_w, 100, -1);
ret_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("Return"));
gtk_widget_set_size_request( ret_toggle_w, 100, -1);
ack_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("Ack"));
gtk_widget_set_size_request( ack_toggle_w, 100, -1);
GtkWidget *sea_typebox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_typebox), sea_type_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_typebox), alarm_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_typebox), info_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_typebox), ret_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_typebox), ack_toggle_w, FALSE, FALSE, 0);
// Event priority box
GtkWidget *sea_prio_label = gtk_label_new( CoWowGtk::translate_utf8("Priority"));
gtk_widget_set_size_request( sea_prio_label, 120, -1);
gtk_misc_set_alignment( GTK_MISC(sea_prio_label), 0.0, 0.5);
prioA_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("A-Alarm"));
gtk_widget_set_size_request( prioA_toggle_w, 100, -1);
prioB_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("B-Alarm"));
gtk_widget_set_size_request( prioB_toggle_w, 100, -1);
prioC_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("C-Alarm"));
gtk_widget_set_size_request( prioC_toggle_w, 100, -1);
prioD_toggle_w = gtk_check_button_new_with_label( CoWowGtk::translate_utf8("D-Alarm"));
gtk_widget_set_size_request( prioD_toggle_w, 100, -1);
GtkWidget *sea_priobox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_priobox), sea_prio_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_priobox), prioA_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_priobox), prioB_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_priobox), prioC_toggle_w, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_priobox), prioD_toggle_w, FALSE, FALSE, 0);
// Event name box
GtkWidget *sea_eventname_label = gtk_label_new( CoWowGtk::translate_utf8("Event name"));
gtk_widget_set_size_request( sea_eventname_label, 120, -1);
gtk_misc_set_alignment( GTK_MISC(sea_eventname_label), 0.0, 0.5);
event_name_entry_w = gtk_entry_new();
GtkWidget *sea_eventnamebox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_eventnamebox), sea_eventname_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_eventnamebox), event_name_entry_w, TRUE, TRUE, 0);
// Event text box
GtkWidget *sea_eventtext_label = gtk_label_new( CoWowGtk::translate_utf8("Event text"));
gtk_widget_set_size_request( sea_eventtext_label, 120, -1);
gtk_misc_set_alignment( GTK_MISC(sea_eventtext_label), 0.0, 0.5);
event_text_entry_w = gtk_entry_new();
GtkWidget *sea_eventtextbox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_eventtextbox), sea_eventtext_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_eventtextbox), event_text_entry_w, TRUE, TRUE, 0);
// Number of events box
GtkWidget *sea_numevents_label = gtk_label_new( CoWowGtk::translate_utf8("Number of Events:"));
gtk_widget_set_size_request( sea_numevents_label, 140, -1);
gtk_misc_set_alignment( GTK_MISC(sea_numevents_label), 0.0, 0.5);
nrofevents_string_lbl_w = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(nrofevents_string_lbl_w), 0.0, 0.5);
GtkWidget *sea_search_button = gtk_button_new_with_label( CoWowGtk::translate_utf8("Search"));
gtk_widget_set_size_request( sea_search_button, 80, 25);
g_signal_connect( sea_search_button, "clicked", G_CALLBACK( ok_btn), this);
GtkWidget *sea_numeventsbox = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_numeventsbox), sea_numevents_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_numeventsbox), nrofevents_string_lbl_w, TRUE, TRUE, 0);
gtk_box_pack_end( GTK_BOX(sea_numeventsbox), sea_search_button, FALSE, FALSE, 50);
// Searchcondition box 1
search_string_lbl_w = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(search_string_lbl_w), 0.0, 0.5);
search_string2_lbl_w = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(search_string2_lbl_w), 0.0, 0.5);
search_string3_lbl_w = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(search_string3_lbl_w), 0.0, 0.5);
search_string4_lbl_w = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(search_string4_lbl_w), 0.0, 0.5);
GtkWidget *sea_stringbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_stringbox), search_string_lbl_w, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(sea_stringbox), search_string2_lbl_w, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(sea_stringbox), search_string3_lbl_w, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(sea_stringbox), search_string4_lbl_w, FALSE, FALSE, 2);
GtkWidget *sea_stringframe = gtk_frame_new( CoWowGtk::translate_utf8("Search Condition"));
// gtk_frame_set_shadow_type( GTK_FRAME(sea_stringframe), GTK_SHADOW_ETCHED_IN);
gtk_container_add( GTK_CONTAINER(sea_stringframe), sea_stringbox);
GtkWidget *sea_vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_timebox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_typebox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_priobox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_eventnamebox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_eventtextbox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), gtk_hseparator_new(), FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_numeventsbox, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(sea_vbox), sea_stringframe, FALSE, FALSE, 3);
GtkWidget *hist_pane = gtk_vpaned_new();
// Create hist
hist = new EvListGtk( this, hist_pane, ev_eType_HistList, hist_size, &hist_widget);
hist->start_trace_cb = &hist_start_trace_cb;
hist->display_in_xnav_cb = &hist_display_in_xnav_cb;
hist->popup_menu_cb = &hist_popup_menu_cb;
gtk_paned_pack1( GTK_PANED(hist_pane), GTK_WIDGET(sea_vbox), TRUE, TRUE);
gtk_paned_pack2( GTK_PANED(hist_pane), GTK_WIDGET(hist_widget), TRUE, TRUE);
gtk_box_pack_start( GTK_BOX(hist_vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hist_vbox), GTK_WIDGET(hist_pane), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(parent_wid_hist), hist_vbox);
gtk_widget_show_all( parent_wid_hist);
gtk_paned_set_position( GTK_PANED(hist_pane), 300);
// Init start and stop time
pwr_tStatus sts;
pwr_tOName name_str;
gint pos = 0;
char buf[80];
pwr_tTime StopTime;
pwr_tTime StartTime;
strcpy( buf, "1970-05-05 00:00:00");
gtk_editable_insert_text( GTK_EDITABLE(start_time_entry_w), buf,
strlen(buf), &pos);
gtk_widget_set_sensitive( start_time_entry_w, FALSE);
sts = clock_gettime(CLOCK_REALTIME, &StopTime);
sts = AdjustForDayBreak( this, &StopTime, &StartTime);
StopTime = StartTime;
StopTime.tv_sec += ONEDAY;
time_AtoFormAscii(&StopTime, SWE, SECOND, buf, sizeof(buf));
gtk_editable_insert_text( GTK_EDITABLE(stop_time_entry_w), buf,
strlen(buf), &pos);
gtk_widget_set_sensitive( stop_time_entry_w, FALSE);
// If objid is applied, search for this object
pos = 0;
sts = gdh_ObjidToName( objid, name_str, sizeof(name_str), cdh_mName_pathStrict);
if (ODD(sts)) {
gtk_editable_insert_text( GTK_EDITABLE(event_name_entry_w), name_str,
strlen(name_str), &pos);
this->eventName_str = name_str;
get_hist_list();
}
*status = 1;
}
//
// Delete hist
//
HistGtk::~HistGtk()
{
if ( hist)
delete hist;
gtk_widget_destroy( parent_wid_hist);
}
gboolean HistGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
HistGtk *hist = (HistGtk *)data;
hist->hist->set_input_focus();
return FALSE;
}
void HistGtk::ok_btn( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
brow_DeleteAll(histOP->hist->brow->ctx);
histOP->eventType_Alarm = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(((HistGtk *)histOP)->alarm_toggle_w));
histOP->eventType_Ack = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->ack_toggle_w));
histOP->eventType_Info = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->info_toggle_w));
histOP->eventType_Return = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->ret_toggle_w));
histOP->eventPrio_A = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->prioA_toggle_w));
histOP->eventPrio_B = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->prioB_toggle_w));
histOP->eventPrio_C = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->prioC_toggle_w));
histOP->eventPrio_D = (bool)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( ((HistGtk *)histOP)->prioD_toggle_w));
histOP->minTime_str = gtk_editable_get_chars( GTK_EDITABLE(((HistGtk *)histOP)->start_time_entry_w), 0, -1);
histOP->maxTime_str = gtk_editable_get_chars( GTK_EDITABLE(((HistGtk *)histOP)->stop_time_entry_w), 0, -1);
histOP->eventText_str = gtk_editable_get_chars( GTK_EDITABLE(((HistGtk *)histOP)->event_text_entry_w), 0, -1);
histOP->eventName_str = gtk_editable_get_chars( GTK_EDITABLE(((HistGtk *)histOP)->event_name_entry_w), 0, -1);
histOP->get_hist_list();
g_free(histOP->minTime_str);
g_free(histOP->maxTime_str);
g_free(histOP->eventText_str);
g_free(histOP->eventName_str);
}
void HistGtk::activate_exit( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->close_cb(histOP);
}
void HistGtk::activate_print( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->activate_print();
}
void HistGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->hist->zoom( 1.2);
}
void HistGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->hist->zoom( 5.0/6);
}
void HistGtk::activate_zoom_reset( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->hist->unzoom();
}
void HistGtk::activate_open_plc( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->hist->start_trace();
}
void HistGtk::activate_display_in_xnav( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->hist->display_in_xnav();
}
void HistGtk::activate_disp_hundredth( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
histOP->hist->set_display_hundredth( set);
}
void HistGtk::activate_hide_object( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
histOP->hist->set_hide_object( set);
}
void HistGtk::activate_hide_text( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM(w));
histOP->hist->set_hide_text( set);
}
void HistGtk::activate_help( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->activate_help();
}
void HistGtk::activate_helpevent( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->activate_helpevent();
}
//callbackfunctions from the searchdialog
void HistGtk::cancel_cb( GtkWidget *w, gpointer data)
{
// printf("hist_cancel_cb\n");
}
void HistGtk::today_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->today_cb();
}
void HistGtk::yesterday_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->yesterday_cb();
}
void HistGtk::thisw_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->thisw_cb();
}
void HistGtk::lastw_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->lastw_cb();
}
void HistGtk::thism_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->thism_cb();
}
void HistGtk::lastm_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->lastm_cb();
}
void HistGtk::all_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->all_cb();
}
void HistGtk::time_cb( GtkWidget *w, gpointer data)
{
Hist *histOP = (Hist *)data;
histOP->time_cb();
}
void HistGtk::set_num_of_events( int nrOfEvents)
{
char buf[20];
sprintf(buf, " %u", nrOfEvents);
gtk_label_set_text( GTK_LABEL(this->nrofevents_string_lbl_w), buf);
}
void HistGtk::set_search_string( const char *s1, const char *s2,
const char *s3, const char *s4)
{
gtk_label_set_text( GTK_LABEL(this->search_string_lbl_w), s1);
gtk_label_set_text( GTK_LABEL(this->search_string2_lbl_w), s2);
gtk_label_set_text( GTK_LABEL(this->search_string3_lbl_w), s3);
gtk_label_set_text( GTK_LABEL(this->search_string4_lbl_w), s4);
}
/************************************************************************
*
* Name: SetListTime
*
* Type:
*
* TYPE PARAMETER IOGF DESCRIPTION
*
*
* Description: Sets the Time field for start and stop
*
*************************************************************************/
void HistGtk::SetListTime( pwr_tTime StartTime, pwr_tTime StopTime,
int Sensitive)
{
char timestr[32];
/* Show the resulting times */
time_AtoFormAscii(&StopTime,SWE, SECOND,timestr,sizeof(timestr));
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(stop_time_entry_w), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(stop_time_entry_w), timestr,
strlen(timestr), &pos);
time_AtoFormAscii(&StartTime,SWE, SECOND,timestr,sizeof(timestr));
pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(start_time_entry_w), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(start_time_entry_w), timestr,
strlen(timestr), &pos);
if (Sensitive != DONT_SET_SENS) {
gtk_widget_set_sensitive( start_time_entry_w, Sensitive ? TRUE : FALSE);
gtk_widget_set_sensitive( stop_time_entry_w, Sensitive ? TRUE : FALSE);
}
}/* SetListTime */
#endif
/*
* Proview $Id: xtt_hist_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_hist_gtk_h
#define xtt_hist_gkt_h
/* xtt_hist_gtk.h -- Historical event window in xtt */
#if defined OS_LINUX
#ifndef xtt_hist_h
# include "xtt_hist.h"
#endif
class HistGtk : public Hist {
public:
HistGtk( void *hist_parent_ctx,
GtkWidget *hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status);
~HistGtk();
GtkWidget *parent_wid;
GtkWidget *parent_wid_hist;
GtkWidget *toplevel_hist;
GtkWidget *toplevel_search;
GtkWidget *form_hist;
GtkWidget *hist_widget;
GtkWidget *start_time_help_lbl_w;
GtkWidget *start_time_entry_w;
GtkWidget *stop_time_entry_w;
GtkWidget *event_text_entry_w;
GtkWidget *event_name_entry_w;
GtkWidget *alarm_toggle_w;
GtkWidget *info_toggle_w;
GtkWidget *ack_toggle_w;
GtkWidget *ret_toggle_w;
GtkWidget *prioA_toggle_w;
GtkWidget *prioB_toggle_w;
GtkWidget *prioC_toggle_w;
GtkWidget *prioD_toggle_w;
GtkWidget *nrofevents_string_lbl_w;
GtkWidget *search_string_lbl_w;
GtkWidget *search_string2_lbl_w;
GtkWidget *search_string3_lbl_w;
GtkWidget *search_string4_lbl_w;
void set_num_of_events( int nrOfEvents);
void set_search_string( const char *s1, const char *s2,
const char *s3, const char *s4);
void SetListTime( pwr_tTime StartTime, pwr_tTime StopTime,
int Sensitive);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_open_plc( GtkWidget *w, gpointer data);
static void activate_display_in_xnav( GtkWidget *w, gpointer data);
static void activate_disp_hundredth( GtkWidget *w, gpointer data);
static void activate_hide_object( GtkWidget *w, gpointer data);
static void activate_hide_text( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_helpevent( GtkWidget *w, gpointer data);
static void create_form( GtkWidget *w, gpointer data);
static void ok_btn( GtkWidget *w, gpointer data);
//callbackfunctions from the searchdialog
static void cancel_cb( GtkWidget *w, gpointer data);
static void today_cb( GtkWidget *w, gpointer data);
static void yesterday_cb( GtkWidget *w, gpointer data);
static void thisw_cb( GtkWidget *w, gpointer data);
static void lastw_cb( GtkWidget *w, gpointer data);
static void thism_cb( GtkWidget *w, gpointer data);
static void lastm_cb( GtkWidget *w, gpointer data);
static void all_cb( GtkWidget *w, gpointer data);
static void time_cb( GtkWidget *w, gpointer data);
};
#else
// Dummy for other platforms then OS_LINUX
class Hist {
public:
Hist(
void *hist_parent_ctx,
Widget hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status) : parent_ctx(hist_parent_ctx) {}
void *parent_ctx;
void (*close_cb)( void *);
void (*start_trace_cb)( void *, pwr_tObjid, char *);
void (*display_in_xnav_cb)( void *, pwr_tObjid);
void (*update_info_cb)( void *);
void (*help_cb)( void *, char *);
void (*popup_menu_cb)( void *, pwr_sAttrRef, unsigned long,
unsigned long, char *, Widget * );
};
#endif
#endif
/*
* Proview $Id: xtt_hotkey_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
Interface for global function keys.
The XLib function XGrabKey is used because gdk doesn't have any corresponding function.
The syntax of the definition file is
['Modifier1'] ['Modifier2'] ['Modifier3'] <Key>'keysym' : 'action'('argument')
where
Modifier1,2 and 3 can be Control, Alt or Shift.
keysym any key symbol, for example F10.
action, the name of a registred action function: SetDig, ResetDig, ToggleDig or Command.
argument, argument to the action function (an attribute, or a command)
Example
Control <Key>F11 : ToggleDig( Test-Dv1.ActualValue)
Shift <Key>F11 : ToggleDig( Test-Dv2.ActualValue)
Control Shift <Key>F11 : ToggleDig( Test-Dv3.ActualValue)
Alt <Key>F11 : ToggleDig( Test-Dv4.ActualValue)
Control Alt <Key>F11 : ToggleDig( Test-Dv5.ActualValue)
Control Shift Alt <Key>F11 : ToggleDig( Test-Dv6.ActualValue)
<Key>F10 : SetDig( Test-Dv2.ActualValue)
<Key>F12 : Command ( open graph gtest)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/keysym.h>
#include "xtt_hotkey_gtk.h"
#include "co_cdh.h"
#include "co_dcli.h"
void XttHotkey::register_action( char *name, void (* action)(char *,void *), void *userdata)
{
HotkeyAction a( name, action);
m_actions.push_back( a);
for ( int i = 0; i < (int)m_keys.size(); i++) {
m_keys[i].set_action( &m_actions[m_actions.size() - 1], userdata);
}
}
XttHotkey::XttHotkey( char *filename)
{
strcpy( m_filename, filename);
read_file();
}
XttHotkey::~XttHotkey()
{
}
int XttHotkey::read_file()
{
FILE *fp;
char line[200];
int row = 0;
char p1[2][200];
char p2[10][200];
int i, n;
char *s;
dcli_translate_filename( m_filename, m_filename);
fp = fopen( m_filename, "r");
if ( !fp)
return 0;
while ( dcli_read_line( line, sizeof(line), fp)) {
int mod = 0;
int keysym;
char keystr[20] = "";
char action_arg[200];
char action_name[200];
row++;
dcli_trim( line, line);
if ( line[0] == 0 || line[0] == '#')
continue;
n = dcli_parse( line, ":", "", (char *)p1,
sizeof( p1) / sizeof( p1[0]), sizeof( p1[0]), 0);
if ( n != 2) {
printf( "Syntax error, %s, row %d\n", m_filename, row);
continue;
}
dcli_trim( p1[0], p1[0]);
dcli_trim( p1[1], p1[1]);
n = dcli_parse( p1[0], " ", "", (char *)p2,
sizeof( p2) / sizeof( p2[0]), sizeof( p2[0]), 0);
if ( n < 1) {
printf( "Syntax error, %s, row %d\n", m_filename, row);
continue;
}
for ( i = 0; i < n; i++) {
if ( cdh_NoCaseStrcmp( p2[i], "Control") == 0)
mod |= ControlMask;
else if ( cdh_NoCaseStrcmp( p2[i], "Shift") == 0)
mod |= ShiftMask;
else if ( cdh_NoCaseStrcmp( p2[i], "Alt") == 0)
mod |= Mod1Mask;
else if ( cdh_NoCaseStrncmp( p2[i], "<key>", 5) == 0) {
strcpy( keystr, &p2[i][5]);
dcli_trim( keystr, keystr);
}
else {
printf( "Syntax error, %s, row %d\n", m_filename, row);
break;
}
}
n = dcli_parse( p1[1], "(", "", (char *)p2,
sizeof( p2) / sizeof( p2[0]), sizeof( p2[0]), 0);
if ( n < 2) {
printf( "Syntax error, %s, row %d\n", m_filename, row);
continue;
}
strcpy( action_name, p2[0]);
dcli_trim( action_name, action_name);
strcpy( action_arg, p2[1]);
if ( (s = strrchr( action_arg, ')')))
*s = 0;
else {
printf( "Syntax error, %s, row %d\n", m_filename, row);
continue;
}
keysym = XStringToKeysym( keystr);
if ( !keysym) {
printf( "Syntax error, %s, row %d\n", m_filename, row);
continue;
}
HotkeyKey key( mod, keysym, action_name, action_arg);
m_keys.push_back( key);
}
fclose( fp);
for ( i = 0; i < (int)m_keys.size(); i++) {
grab_key( m_keys[i].m_keysym, m_keys[i].m_mod);
}
return 1;
}
int XttHotkey::event_handler( GdkXEvent *xevent, gpointer data)
{
XttHotkey *hotkey = (XttHotkey *)data;
XKeyEvent *e = (XKeyEvent *)xevent;
if ( e->type == KeyPress) {
int key = e->keycode;
int keysym = XKeycodeToKeysym( GDK_DISPLAY(), key, 0);
for ( int i = 0; i < (int)hotkey->m_keys.size(); i++) {
if ( hotkey->m_keys[i].m_keysym == keysym &&
hotkey->m_keys[i].m_mod == (int)(e->state & ~LockMask
& ~Mod2Mask & ~Mod3Mask & ~Mod4Mask & ~Mod5Mask)) {
if ( hotkey->m_keys[i].m_action)
(hotkey->m_keys[i].m_action)( hotkey->m_keys[i].m_action_arg,
hotkey->m_keys[i].m_userdata);
}
}
}
return GDK_FILTER_CONTINUE;
}
int XttHotkey::grab_key( int keysym, int modifier)
{
GdkDisplay *display = gdk_display_get_default();
int n_screens = gdk_display_get_n_screens( display);
Display *dp = gdk_x11_display_get_xdisplay( display);
int mode = GrabModeAsync;
int keycode = XKeysymToKeycode( dp, keysym);
if ( !keycode)
return 0;
gdk_error_trap_push();
for ( int i = 0; i < n_screens; i++) {
GdkWindow *root = gdk_screen_get_root_window( gdk_display_get_screen( display, i));
Window w = gdk_x11_drawable_get_xid( root);
XGrabKey( dp, keycode, modifier, w, True, mode, mode);
XGrabKey( dp, keycode, modifier | LockMask, w, True, mode, mode);
XGrabKey( dp, keycode, modifier | Mod2Mask, w, True, mode, mode);
XGrabKey( dp, keycode, modifier | LockMask | Mod2Mask, w, True, mode, mode);
}
gdk_flush();
gdk_error_trap_pop();
return 1;
}
/*
* Proview $Id: xtt_hotkey_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_hotkey_gtk_h
#define xtt_hotkey_gtk_h
#include <vector.h>
#include "pwr.h"
class HotkeyAction {
public:
char m_name[80];
void (* m_action)(char *,void *);
HotkeyAction( char *name, void (* action)(char *,void *)) : m_action(action) {
strcpy( m_name, name);
}
HotkeyAction( const HotkeyAction& x) : m_action(x.m_action) {
strcpy( m_name, x.m_name);
}
};
class HotkeyKey {
public:
int m_mod;
int m_keysym;
char m_action_name[80];
char m_action_arg[200];
void (* m_action)(char *,void *);
void *m_userdata;
HotkeyKey( int mod, int keysym, char *action_name, char *action_arg) :
m_mod(mod), m_keysym(keysym), m_action(0), m_userdata(0) {
strcpy( m_action_name, action_name);
strcpy( m_action_arg, action_arg);
}
HotkeyKey( const HotkeyKey& x) : m_mod(x.m_mod), m_keysym(x.m_keysym),
m_action(x.m_action), m_userdata(x.m_userdata) {
strcpy( m_action_name, x.m_action_name);
strcpy( m_action_arg, x.m_action_arg);
}
void set_action( HotkeyAction *action, void *userdata) {
if ( strcmp( m_action_name, action->m_name) == 0) {
m_action = action->m_action;
m_userdata = userdata;
}
}
};
class XttHotkey {
public:
pwr_tFileName m_filename;
vector<HotkeyAction> m_actions;
vector<HotkeyKey> m_keys;
XttHotkey( char *filename);
~XttHotkey();
void register_action( char *name, void (* action)(char *,void *), void *userdata);
int read_file();
int grab_key( int keysym, int modifier);
static int event_handler( GdkXEvent *xevent, gpointer data);
};
#endif
/*
* Proview $Id: xtt_op_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_op_gtk.cpp -- Alarm and event window in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "co_wow_gtk.h"
#include "co_lng.h"
#include "xtt_op_gtk.h"
#include "rt_xnav_msg.h"
#define OP_HEIGHT_MIN 75
#define OP_HEIGHT_INC 20
#define OP_HEIGHT_MAX (OP_HEIGHT_MIN + 3 * OP_HEIGHT_INC)
OpGtk::OpGtk( void *op_parent_ctx,
GtkWidget *op_parent_wid,
char *opplace,
pwr_tStatus *status) :
Op( op_parent_ctx, opplace, status), parent_wid(op_parent_wid), a_height(2),
text_size(12)
{
memset( a_exist, 0, sizeof(a_exist));
memset( a_active, 0, sizeof(a_active));
GdkColor red_color;
gdk_color_parse( "#FF7575", &red_color);
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", OP_HEIGHT_MIN,
"default-width", 1100,
NULL);
gtk_window_set_decorated( GTK_WINDOW(toplevel), FALSE);
pwr_tFileName fname;
dcli_translate_filename( fname, "$pwr_exe/wtt_messages.png");
aalarm_active[0] = gtk_image_new_from_file( fname);
aalarm_active[1] = gtk_image_new_from_file( fname);
aalarm_active[2] = gtk_image_new_from_file( fname);
aalarm_active[3] = gtk_image_new_from_file( fname);
aalarm_active[4] = gtk_image_new_from_file( fname);
aalarm_label[0] = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(aalarm_label[0]), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(aalarm_label[0]), TRUE);
aalarm_label[1] = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(aalarm_label[1]), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(aalarm_label[1]), TRUE);
aalarm_label[2] = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(aalarm_label[2]), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(aalarm_label[2]), TRUE);
aalarm_label[3] = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(aalarm_label[3]), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(aalarm_label[3]), TRUE);
aalarm_label[4] = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(aalarm_label[4]), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(aalarm_label[4]), TRUE);
alarmcnt_label = gtk_label_new("");
GtkWidget *aalarm_mark = gtk_label_new("A");
balarm_active = gtk_image_new_from_file( fname);
balarm_mark = gtk_label_new("");
balarm_label = gtk_label_new("");
gtk_misc_set_alignment( GTK_MISC(balarm_label), 0.02, 0.5);
gtk_label_set_use_markup( GTK_LABEL(balarm_label), TRUE);
aalarm_box[0] = gtk_hbox_new( FALSE, 0);
GtkWidget *ebox1 = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(ebox1), aalarm_label[0]);
gtk_widget_modify_bg( ebox1, GTK_STATE_NORMAL, &red_color);
GtkWidget *abox1 = gtk_event_box_new();
gtk_widget_set_size_request( abox1, 20, 20);
gtk_container_add( GTK_CONTAINER(abox1), aalarm_active[0]);
gtk_box_pack_start( GTK_BOX(aalarm_box[0]), abox1, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(aalarm_box[0]), ebox1, TRUE, TRUE, 0);
gtk_widget_set_size_request( aalarm_label[0], -1, 20);
gtk_widget_set_size_request( aalarm_active[0], -1, 20);
aalarm_box[1] = gtk_hbox_new( FALSE, 0);
GtkWidget *ebox2 = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(ebox2), aalarm_label[1]);
gtk_widget_modify_bg( ebox2, GTK_STATE_NORMAL, &red_color);
GtkWidget *abox2 = gtk_event_box_new();
gtk_widget_set_size_request( abox2, 20, 20);
gtk_container_add( GTK_CONTAINER(abox2), aalarm_active[1]);
gtk_box_pack_start( GTK_BOX(aalarm_box[1]), abox2, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(aalarm_box[1]), ebox2, TRUE, TRUE, 0);
gtk_widget_set_size_request( aalarm_label[1], -1, 20);
gtk_widget_set_size_request( aalarm_active[1], -1, 20);
aalarm_box[2] = gtk_hbox_new( FALSE, 0);
GtkWidget *ebox3 = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(ebox3), aalarm_label[2]);
gtk_widget_modify_bg( ebox3, GTK_STATE_NORMAL, &red_color);
GtkWidget *abox3 = gtk_event_box_new();
gtk_widget_set_size_request( abox3, 20, 20);
gtk_container_add( GTK_CONTAINER(abox3), aalarm_active[2]);
gtk_box_pack_start( GTK_BOX(aalarm_box[2]), abox3, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(aalarm_box[2]), ebox3, TRUE, TRUE, 0);
gtk_widget_set_size_request( aalarm_label[2], -1, 20);
gtk_widget_set_size_request( aalarm_active[2], -1, 20);
aalarm_box[3] = gtk_hbox_new( FALSE, 0);
GtkWidget *ebox4 = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(ebox4), aalarm_label[3]);
gtk_widget_modify_bg( ebox4, GTK_STATE_NORMAL, &red_color);
GtkWidget *abox4 = gtk_event_box_new();
gtk_widget_set_size_request( abox4, 20, 20);
gtk_container_add( GTK_CONTAINER(abox4), aalarm_active[3]);
gtk_box_pack_start( GTK_BOX(aalarm_box[3]), abox4, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(aalarm_box[3]), ebox4, TRUE, TRUE, 0);
gtk_widget_set_size_request( aalarm_label[3], -1, 20);
gtk_widget_set_size_request( aalarm_active[3], -1, 20);
aalarm_box[4] = gtk_hbox_new( FALSE, 0);
GtkWidget *ebox5 = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(ebox5), aalarm_label[4]);
gtk_widget_modify_bg( ebox5, GTK_STATE_NORMAL, &red_color);
GtkWidget *abox5 = gtk_event_box_new();
gtk_widget_set_size_request( abox5, 20, 20);
gtk_container_add( GTK_CONTAINER(abox5), aalarm_active[4]);
gtk_box_pack_start( GTK_BOX(aalarm_box[4]), abox5, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(aalarm_box[4]), ebox5, TRUE, TRUE, 0);
gtk_widget_set_size_request( aalarm_label[4], -1, 20);
gtk_widget_set_size_request( aalarm_active[4], -1, 20);
GtkWidget *vbox_aalarm = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox_aalarm), aalarm_box[0], FALSE, FALSE, 1);
gtk_box_pack_start( GTK_BOX(vbox_aalarm), aalarm_box[1], FALSE, FALSE, 1);
gtk_box_pack_start( GTK_BOX(vbox_aalarm), aalarm_box[2], FALSE, FALSE, 1);
gtk_box_pack_start( GTK_BOX(vbox_aalarm), aalarm_box[3], FALSE, FALSE, 1);
gtk_box_pack_start( GTK_BOX(vbox_aalarm), aalarm_box[4], FALSE, FALSE, 1);
balarm_ebox = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(balarm_ebox), balarm_label);
GtkWidget *bbox = gtk_event_box_new();
gtk_container_add( GTK_CONTAINER(bbox), balarm_active);
gtk_widget_set_size_request( bbox, 20, 20);
balarm_box = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(balarm_box), bbox, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(balarm_box), balarm_ebox, TRUE, TRUE, 0);
// Acknowledge button for a alarms
GtkWidget *aalarm_ack = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_acknowledge.png");
gtk_container_add( GTK_CONTAINER(aalarm_ack),
gtk_image_new_from_file( fname));
gtk_widget_set_size_request( aalarm_ack, 30, 20);
gtk_widget_set_size_request( aalarm_mark, -1, 20);
g_signal_connect(aalarm_ack, "clicked", G_CALLBACK(activate_aalarm_ack), this);
// Increment size button
GtkWidget *incr_button = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_down.png");
gtk_container_add( GTK_CONTAINER(incr_button),
gtk_image_new_from_file( fname));
gtk_widget_set_size_request( incr_button, 30, 20);
gtk_widget_set_size_request( alarmcnt_label, -1, 20);
g_signal_connect(incr_button, "clicked", G_CALLBACK(activate_aalarm_incr), this);
// Decrement size button
decr_button = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_up.png");
gtk_container_add( GTK_CONTAINER(decr_button),
gtk_image_new_from_file( fname));
gtk_widget_set_size_request( decr_button, 30, 20);
g_signal_connect(decr_button, "clicked", G_CALLBACK(activate_aalarm_decr), this);
// Acknowledge button for b alarms
GtkWidget *balarm_ack = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_acknowledge.png");
gtk_container_add( GTK_CONTAINER(balarm_ack),
gtk_image_new_from_file( fname));
gtk_widget_set_size_request( balarm_ack, 30, 20);
gtk_widget_set_size_request( balarm_mark, -1, 20);
g_signal_connect(balarm_ack, "clicked", G_CALLBACK(activate_balarm_ack), this);
GtkWidget *hbox_abutton = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_abutton), aalarm_ack, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(hbox_abutton), aalarm_mark, FALSE, FALSE, 2);
GtkWidget *hbox_incrbutton = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_incrbutton), incr_button, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(hbox_incrbutton), alarmcnt_label, FALSE, FALSE, 2);
GtkWidget *hbox_decrbutton = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_decrbutton), decr_button, FALSE, FALSE, 2);
GtkWidget *vbox_abutton = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox_abutton), hbox_abutton, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(vbox_abutton), hbox_incrbutton, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(vbox_abutton), hbox_decrbutton, FALSE, FALSE, 2);
GtkWidget *hbox_bbutton = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_bbutton), balarm_ack, FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(hbox_bbutton), balarm_mark, FALSE, FALSE, 2);
GtkWidget *hbox_a = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_a), vbox_abutton, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_a), vbox_aalarm, TRUE, TRUE, 0);
GtkWidget *hbox_b = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_b), hbox_bbutton, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_b), balarm_box, TRUE, TRUE, 0);
GtkWidget *vbox_ala = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox_ala), hbox_a, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox_ala), gtk_hseparator_new(), FALSE, FALSE, 2);
gtk_box_pack_end( GTK_BOX(vbox_ala), hbox_b, FALSE, FALSE, 0);
// Toolbar
GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);
GtkWidget *tools_zoom_in = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/ge_zoom_in.png");
gtk_container_add( GTK_CONTAINER(tools_zoom_in),
gtk_image_new_from_file( fname));
g_signal_connect(tools_zoom_in, "clicked", G_CALLBACK(activate_zoom_in), this);
gtk_toolbar_append_widget( tools, tools_zoom_in, "Zoom in", "");
GtkWidget *tools_zoom_out = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/ge_zoom_out.png");
gtk_container_add( GTK_CONTAINER(tools_zoom_out),
gtk_image_new_from_file( fname));
g_signal_connect(tools_zoom_out, "clicked", G_CALLBACK(activate_zoom_out), this);
gtk_toolbar_append_widget( tools, tools_zoom_out, "Zoom out", "");
GtkWidget *tools_help = gtk_button_new();
gtk_container_add( GTK_CONTAINER(tools_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_SMALL_TOOLBAR));
g_signal_connect(tools_help, "clicked", G_CALLBACK(activate_help), this);
gtk_toolbar_append_widget( tools, tools_help, "Help", "");
GtkWidget *tools_navigator = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_navigator.png");
gtk_container_add( GTK_CONTAINER( tools_navigator),
gtk_image_new_from_file( fname));
g_signal_connect(tools_navigator, "clicked", G_CALLBACK(activate_navigator), this);
gtk_toolbar_append_widget( tools, tools_navigator, "Open Navigator", "");
// System pushbuttons
GtkWidget *alarmlist_button = gtk_button_new_with_label("Alarmlist");
gtk_widget_set_size_request( alarmlist_button, 90, 25);
g_signal_connect( alarmlist_button, "clicked", G_CALLBACK(activate_alarmlist), this);
GtkWidget *eventlist_button = gtk_button_new_with_label("Eventlist");
gtk_widget_set_size_request( eventlist_button, 90, 25);
g_signal_connect( eventlist_button, "clicked", G_CALLBACK(activate_eventlist), this);
eventlog_button = gtk_button_new_with_label("Eventlog");
gtk_widget_set_size_request( eventlog_button, 90, 25);
g_signal_connect( eventlog_button, "clicked", G_CALLBACK(activate_eventlog), this);
help_button = gtk_button_new_with_label("Help");
gtk_widget_set_size_request( help_button, 90, 25);
g_signal_connect( help_button, "clicked", G_CALLBACK(activate_help), this);
GtkWidget *sysbutton_box = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(sysbutton_box), GTK_WIDGET(tools), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sysbutton_box), alarmlist_button, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sysbutton_box), eventlist_button, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sysbutton_box), eventlog_button, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(sysbutton_box), help_button, FALSE, FALSE, 0);
gtk_widget_set_size_request( sysbutton_box, 130, -1);
// Main window
configure( opplace);
GtkWidget *hbox_conf = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_conf), sysbutton_box, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(hbox_conf), gtk_hseparator_new(), FALSE, FALSE, 2);
gtk_box_pack_start( GTK_BOX(hbox_conf), appl_form, TRUE, TRUE, 0);
GtkWidget *pane = gtk_hpaned_new();
gtk_paned_pack1( GTK_PANED(pane), vbox_ala, TRUE, TRUE);
gtk_paned_pack2( GTK_PANED(pane), hbox_conf, FALSE, TRUE);
GtkWidget *frame = gtk_frame_new( NULL);
GdkColor background;
gdk_color_parse( "black", &background);
gtk_widget_modify_bg( frame, GTK_STATE_NORMAL, &background);
gtk_container_add( GTK_CONTAINER(frame), pane);
gtk_container_add( GTK_CONTAINER(toplevel), frame);
gtk_widget_show_all(toplevel);
if ( start_jop) {
jop = new Jop( (void *)this);
jop->command_cb = &jop_command_cb;
}
gtk_paned_set_position( GTK_PANED(pane), 500);
g_object_set( aalarm_box[0], "visible", FALSE, NULL);
g_object_set( aalarm_box[1], "visible", FALSE, NULL);
g_object_set( aalarm_box[2], "visible", FALSE, NULL);
g_object_set( aalarm_box[3], "visible", FALSE, NULL);
g_object_set( aalarm_box[4], "visible", FALSE, NULL);
g_object_set( balarm_box, "visible", FALSE, NULL);
g_object_set( help_button, "visible", FALSE, NULL);
g_object_set( eventlog_button, "visible", FALSE, NULL);
g_object_set( decr_button, "visible", FALSE, NULL);
int width, height;
GdkWindow *rootwindow = gtk_widget_get_root_window( toplevel);
gdk_drawable_get_size( rootwindow, &width, &height);
// gtk_window_get_size( GTK_WINDOW(toplevel), &width, &height);
if ( width / height >= 2)
// Assume two screens
width = width / 2;
gtk_window_resize( GTK_WINDOW(toplevel), width - 6, OP_HEIGHT_MIN);
gtk_window_move( GTK_WINDOW(toplevel), 0, 0);
wow = new CoWowGtk( toplevel);
wow->DisplayWarranty();
*status = 1;
}
//
// Delete op
//
OpGtk::~OpGtk()
{
if ( jop)
delete jop;
gtk_widget_destroy( toplevel);
}
void OpGtk::map()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
void OpGtk::update_alarm_info()
{
evlist_sAlarmInfo info;
int sts;
int i;
int height, active_height;
char str[40];
char text[500];
int fsize = text_size * 1024;
if ( get_alarm_info_cb) {
sts = (get_alarm_info_cb)( parent_ctx, &info);
if ( EVEN(sts)) return;
GdkColor red_color, bg_color;
gdk_color_parse( "Red", &red_color);
gdk_color_parse( "Gray", &bg_color);
height = 22;
active_height = 22;
sprintf( str, "%d", info.alarms_total);
gtk_label_set_text( GTK_LABEL(alarmcnt_label), str);
for ( i = 0; i < 5; i++) {
a_exist[i] = info.a_alarm_exist[i];
a_active[i] = info.a_alarm_active[i];
if ( info.a_alarm_exist[i]) {
sprintf( text, "<span size=\"%d\">%s %s</span>",
fsize, info.a_alarm_alias[i], info.a_alarm_text[i]);
gtk_label_set_markup( GTK_LABEL(aalarm_label[i]), text);
// gtk_widget_modify_bg( aalarm_box[i], GTK_STATE_NORMAL, &red_color);
if ( i < a_height) {
g_object_set( aalarm_box[i], "visible", TRUE, NULL);
if ( info.a_alarm_active[i]) {
g_object_set( aalarm_active[i], "visible", TRUE, NULL);
}
else {
g_object_set( aalarm_active[i], "visible", FALSE, NULL);
}
}
}
else {
gtk_label_set_text( GTK_LABEL(aalarm_label[i]), "");
// gtk_widget_modify_bg( aalarm_box[i], GTK_STATE_NORMAL, &bg_color);
g_object_set( aalarm_active[i], "visible", FALSE, NULL);
g_object_set( aalarm_box[i], "visible", FALSE, NULL);
}
}
if ( info.b_alarm_exist[0]) {
GdkColor yellow_color;
gdk_color_parse( "Yellow", &yellow_color);
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_B;
sprintf( text, "<span size=\"%d\">%s %s</span>",
fsize, info.b_alarm_alias[0], info.b_alarm_text[0]);
gtk_label_set_markup( GTK_LABEL(balarm_label), text);
gtk_widget_modify_bg( balarm_ebox, GTK_STATE_NORMAL, &yellow_color);
g_object_set( balarm_box, "visible", TRUE, NULL);
gtk_label_set_text( GTK_LABEL(balarm_mark), "B");
if ( info.b_alarm_active[0]) {
g_object_set( balarm_active, "visible", TRUE, NULL);
}
else {
g_object_set( balarm_active, "visible", FALSE, NULL);
}
}
else if ( info.c_alarm_exist[0]) {
GdkColor blue_color;
gdk_color_parse( "Lightblue", &blue_color);
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_C;
sprintf( text, "<span size=\"%d\">%s %s</span>",
fsize, info.c_alarm_alias[0], info.c_alarm_text[0]);
gtk_label_set_markup( GTK_LABEL(balarm_label), text);
gtk_widget_modify_bg( balarm_ebox, GTK_STATE_NORMAL, &blue_color);
g_object_set( balarm_box, "visible", TRUE, NULL);
gtk_label_set_text( GTK_LABEL(balarm_mark), "C");
if ( info.b_alarm_active[0]) {
g_object_set( balarm_active, "visible", TRUE, NULL);
}
else {
g_object_set( balarm_active, "visible", FALSE, NULL);
}
}
else if ( info.d_alarm_exist[0])
{
GdkColor violet_color;
gdk_color_parse( "Violet", &violet_color);
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_D;
sprintf( text, "<span size=\"%d\">%s %s</span>",
fsize, info.d_alarm_alias[0], info.d_alarm_text[0]);
gtk_label_set_markup( GTK_LABEL(balarm_label), text);
gtk_widget_modify_bg( balarm_ebox, GTK_STATE_NORMAL, &violet_color);
g_object_set( balarm_box, "visible", TRUE, NULL);
gtk_label_set_text( GTK_LABEL(balarm_mark), "D");
if ( info.b_alarm_active[0]) {
g_object_set( balarm_active, "visible", TRUE, NULL);
}
else {
g_object_set( balarm_active, "visible", FALSE, NULL);
}
}
else if ( info.i_alarm_exist[0])
{
GdkColor green_color;
gdk_color_parse( "Green", &green_color);
balarm_type = evlist_eEventType_Info;
sprintf( text, "<span size=\"%d\">%s %s</span>",
fsize, info.i_alarm_alias[0], info.i_alarm_text[0]);
gtk_label_set_markup( GTK_LABEL(balarm_label), text);
gtk_widget_modify_bg( balarm_ebox, GTK_STATE_NORMAL, &green_color);
g_object_set( balarm_box, "visible", TRUE, NULL);
gtk_label_set_text( GTK_LABEL(balarm_mark), "I");
if ( info.b_alarm_active[0]) {
g_object_set( balarm_active, "visible", TRUE, NULL);
}
else {
g_object_set( balarm_active, "visible", FALSE, NULL);
}
}
else {
gtk_label_set_text( GTK_LABEL(balarm_label), "");
gtk_widget_modify_bg( balarm_ebox, GTK_STATE_NORMAL, &bg_color);
gtk_label_set_text( GTK_LABEL(balarm_mark), "");
g_object_set( balarm_box, "visible", FALSE, NULL);
g_object_set( balarm_active, "visible", FALSE, NULL);
}
}
}
int OpGtk::configure( char *opplace_str)
{
int sts;
int i;
pwr_tObjid opplace;
pwr_tObjid user;
pwr_sClass_OpPlace *opplace_p;
pwr_sClass_User *user_p;
pwr_sAttrRef attrref;
sts = gdh_NameToObjid( opplace_str, &opplace);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( opplace, (void **) &opplace_p);
if ( EVEN(sts)) return sts;
// Fix
if ( strncmp( opplace_p->OpWinProgram, "Jop", 3) == 0)
start_jop = 1;
// Find matching user object
sts = gdh_GetClassList( pwr_cClass_User, &user);
while ( ODD (sts)) {
sts = gdh_ObjidToPointer( user, (void **) &user_p);
if ( EVEN(sts)) return sts;
if ( user_p->OpNumber == opplace_p->OpNumber)
break;
sts = gdh_GetNextObject( user, &user);
}
if ( EVEN(sts)) return sts;
// Examine Graph objects
button_cnt = user_p->NoFastAvail;
if ( button_cnt > 15)
button_cnt = 15;
for ( i = 0; i < button_cnt; i++) {
if ( i >= 15)
break;
memset( &attrref, 0, sizeof(attrref));
sts = gdh_ClassAttrToAttrref( pwr_cClass_XttGraph, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
attrref = cdh_ArefAdd( &user_p->FastAvail[i], &attrref);
sts = gdh_GetObjectInfoAttrref( &attrref, (void *)button_title[i],
sizeof(button_title[0]));
if ( EVEN(sts))
strcpy( button_title[i], "");
button_objid[i] = attrref.Objid;
}
// Create the application buttons
GtkWidget *b[15];
for ( i = 0; i < button_cnt; i++) {
b[i] = gtk_button_new_with_label(button_title[i]);
gtk_widget_set_size_request( b[i], -1, 25);
switch ( i) {
case 0:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl1), this);
break;
case 1:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl2), this);
break;
case 2:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl3), this);
break;
case 3:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl4), this);
break;
case 4:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl5), this);
break;
case 5:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl6), this);
break;
case 6:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl7), this);
break;
case 7:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl8), this);
break;
case 8:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl9), this);
break;
case 9:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl10), this);
break;
case 10:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl11), this);
break;
case 11:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl12), this);
break;
case 12:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl13), this);
break;
case 13:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl14), this);
break;
case 14:
g_signal_connect( b[i], "clicked", G_CALLBACK(activate_appl15), this);
break;
}
}
appl_form = gtk_vbox_new( FALSE, 0);
GtkWidget *bbox[3];
for ( i = 0; i < button_cnt; i++) {
if ( i == 0) {
bbox[0] = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(appl_form), bbox[0], FALSE, FALSE, 0);
}
else if ( i == 4) {
bbox[1] = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(appl_form), bbox[1], FALSE, FALSE, 0);
}
else if ( i == 9) {
bbox[2] = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(appl_form), bbox[2], FALSE, FALSE, 0);
}
if ( i < 5)
gtk_box_pack_start( GTK_BOX(bbox[0]), b[i], TRUE, TRUE, 0);
else if ( i < 10)
gtk_box_pack_start( GTK_BOX(bbox[1]), b[i], TRUE, TRUE, 0);
else if ( i < 15)
gtk_box_pack_start( GTK_BOX(bbox[2]), b[i], TRUE, TRUE, 0);
}
return XNAV__SUCCESS;
}
void OpGtk::activate_exit( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_exit();
}
void OpGtk::activate_aalarm_ack( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_aalarm_ack();
}
void OpGtk::activate_balarm_ack( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_balarm_ack();
}
void OpGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
OpGtk *op = (OpGtk *)data;
if ( op->text_size >= 18)
return;
op->text_size += 2;
op->update_alarm_info();
}
void OpGtk::activate_zoom_out( GtkWidget *w, gpointer data)
{
OpGtk *op = (OpGtk *)data;
if ( op->text_size <= 8)
return;
op->text_size -= 2;
op->update_alarm_info();
}
void OpGtk::activate_aalarm_incr( GtkWidget *w, gpointer data)
{
OpGtk *op = (OpGtk *)data;
int width, height;
gtk_window_get_size( GTK_WINDOW(op->toplevel), &width, &height);
if ( op->a_height == 5)
return;
op->a_height++;
height = OP_HEIGHT_MIN + (op->a_height - 2) * OP_HEIGHT_INC;
if ( op->a_height == 3) {
g_object_set( op->decr_button, "visible", TRUE, NULL);
}
else if ( op->a_height == 4) {
g_object_set( op->eventlog_button, "visible", TRUE, NULL);
}
else if ( op->a_height == 5) {
g_object_set( op->help_button, "visible", TRUE, NULL);
}
for ( int i = 2; i < 5; i++) {
if ( i < op->a_height) {
if ( op->a_exist[i]) {
g_object_set( op->aalarm_box[i], "visible", TRUE, NULL);
if ( op->a_active[i]) {
g_object_set( op->aalarm_active[i], "visible", TRUE, NULL);
}
else {
g_object_set( op->aalarm_active[i], "visible", FALSE, NULL);
}
}
}
}
gtk_window_resize( GTK_WINDOW(op->toplevel), width, height);
}
void OpGtk::activate_aalarm_decr( GtkWidget *w, gpointer data)
{
OpGtk *op = (OpGtk *)data;
int width, height;
gtk_window_get_size( GTK_WINDOW(op->toplevel), &width, &height);
if ( op->a_height == 2)
return;
op->a_height--;
height = OP_HEIGHT_MIN + (op->a_height - 2) * OP_HEIGHT_INC;
if ( op->a_height == 2) {
g_object_set( op->decr_button, "visible", FALSE, NULL);
}
else if ( op->a_height == 3) {
g_object_set( op->eventlog_button, "visible", FALSE, NULL);
}
else if ( op->a_height == 4) {
g_object_set( op->help_button, "visible", FALSE, NULL);
}
for ( int i = 2; i < 5; i++) {
if ( i >= op->a_height) {
if ( op->a_exist[i]) {
g_object_set( op->aalarm_box[i], "visible", FALSE, NULL);
g_object_set( op->aalarm_active[i], "visible", FALSE, NULL);
}
}
}
gtk_window_resize( GTK_WINDOW(op->toplevel), width, height);
}
void OpGtk::activate_alarmlist( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_alarmlist();
}
void OpGtk::activate_eventlist( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_eventlist();
}
void OpGtk::activate_eventlog( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_eventlog();
}
void OpGtk::activate_navigator( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_navigator();
}
void OpGtk::activate_help( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->activate_help();
}
void OpGtk::activate_appl1( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(0);
}
void OpGtk::activate_appl2( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(1);
}
void OpGtk::activate_appl3( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(2);
}
void OpGtk::activate_appl4( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(3);
}
void OpGtk::activate_appl5( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(4);
}
void OpGtk::activate_appl6( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(5);
}
void OpGtk::activate_appl7( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(6);
}
void OpGtk::activate_appl8( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(7);
}
void OpGtk::activate_appl9( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(8);
}
void OpGtk::activate_appl10( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(9);
}
void OpGtk::activate_appl11( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(10);
}
void OpGtk::activate_appl12( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(11);
}
void OpGtk::activate_appl13( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(12);
}
void OpGtk::activate_appl14( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(13);
}
void OpGtk::activate_appl15( GtkWidget *w, gpointer data)
{
Op *op = (Op*)data;
op->appl_action(14);
}
/*
* Proview $Id: xtt_op_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_op_gtk_h
#define xtt_op_gtk_h
/* xtt_op_gtk.h -- Operator window in xtt */
#ifndef xtt_op_h
# include "xtt_op.h"
#endif
class OpGtk : public Op {
public:
OpGtk( void *op_parent_ctx,
GtkWidget *op_parent_wid,
char *opplace,
pwr_tStatus *status);
~OpGtk();
GtkWidget *parent_wid;
GtkWidget *parent_wid_op;
GtkWidget *toplevel;
GtkWidget *alarmcnt_label;
GtkWidget *aalarm_label[5];
GtkWidget *aalarm_active[5];
GtkWidget *aalarm_box[5];
GtkWidget *balarm_label;
GtkWidget *balarm_active;
GtkWidget *balarm_box;
GtkWidget *balarm_ebox;
GtkWidget *balarm_mark;
GtkWidget *appl_form;
GtkWidget *eventlog_button;
GtkWidget *help_button;
GtkWidget *decr_button;
int a_height;
int a_exist[5];
int a_active[5];
int text_size;
void map();
int configure( char *opplace_str);
void update_alarm_info();
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_aalarm_ack( GtkWidget *w, gpointer data);
static void activate_balarm_ack( GtkWidget *w, gpointer data);
static void activate_aalarm_incr( GtkWidget *w, gpointer data);
static void activate_aalarm_decr( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_alarmlist( GtkWidget *w, gpointer data);
static void activate_eventlist( GtkWidget *w, gpointer data);
static void activate_eventlog( GtkWidget *w, gpointer data);
static void activate_navigator( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_appl1( GtkWidget *w, gpointer data);
static void activate_appl2( GtkWidget *w, gpointer data);
static void activate_appl3( GtkWidget *w, gpointer data);
static void activate_appl4( GtkWidget *w, gpointer data);
static void activate_appl5( GtkWidget *w, gpointer data);
static void activate_appl6( GtkWidget *w, gpointer data);
static void activate_appl7( GtkWidget *w, gpointer data);
static void activate_appl8( GtkWidget *w, gpointer data);
static void activate_appl9( GtkWidget *w, gpointer data);
static void activate_appl10( GtkWidget *w, gpointer data);
static void activate_appl11( GtkWidget *w, gpointer data);
static void activate_appl12( GtkWidget *w, gpointer data);
static void activate_appl13( GtkWidget *w, gpointer data);
static void activate_appl14( GtkWidget *w, gpointer data);
static void activate_appl15( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: xtt_trend_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_trend_gtk.h"
#include "ge_curve_gtk.h"
XttTrendGtk::XttTrendGtk( void *parent_ctx,
GtkWidget *parent_wid,
char *name,
GtkWidget **w,
pwr_sAttrRef *trend_list,
pwr_sAttrRef *plotgroup,
int *sts) :
XttTrend( parent_ctx, name, trend_list, plotgroup, sts), parent_widget(parent_wid)
{
*sts = XNAV__SUCCESS;
curve = new GeCurveGtk( this, parent_widget, name, NULL, gcd, 1);
curve->close_cb = trend_close_cb;
curve->help_cb = trend_help_cb;
wow = new CoWowGtk( parent_widget);
timerid = wow->timer_new();
timerid->add( 1000, trend_scan, this);
}
XttTrendGtk::~XttTrendGtk()
{
timerid->remove();
for ( int i = 0; i < trend_cnt; i++) {
gdh_UnrefObjectInfo( subid[i]);
}
delete curve;
}
/*
* Proview $Id: xtt_trend_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_trend_gtk_h
#define xtt_trend_gtk_h
/* xtt_trend_gtk.h -- DsTrend curves */
#ifndef xtt_trend_h
# include "xtt_trend.h"
#endif
class XttTrendGtk : public XttTrend {
public:
GtkWidget *parent_widget;
XttTrendGtk( void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
char *xn_name,
GtkWidget **w,
pwr_sAttrRef *objid,
pwr_sAttrRef *plotgroup,
int *sts);
~XttTrendGtk();
};
#endif
/*
* Proview $Id: xtt_xatt_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xatt.cpp -- Display object attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.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_xatt_gtk.h"
#include "xtt_xattnav_gtk.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
CoWowRecall XAttGtk::value_recall;
void XAttGtk::message( char severity, char *message)
{
gtk_label_set_text( GTK_LABEL(msg_label), message);
}
void XAttGtk::set_prompt( char *prompt)
{
if ( strcmp(prompt, "") == 0) {
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( msg_label, "visible", TRUE, NULL);
}
else {
g_object_set( msg_label, "visible", FALSE, NULL);
g_object_set( cmd_prompt, "visible", TRUE, NULL);
}
}
void XAttGtk::change_value( int set_focus)
{
int sts;
GtkWidget *text_w;
int multiline;
char *value;
int input_size;
if ( input_open) {
g_object_set( cmd_input, "visible", FALSE, NULL);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
return;
}
sts = xattnav->check_attr( &multiline, &input_node, input_name,
&value, &input_size);
if ( EVEN(sts)) {
if ( sts == XATT__NOATTRSEL)
message( 'E', "No attribute is selected");
else
message( 'E', XNav::get_message( sts));
return;
}
if ( multiline) {
text_w = cmd_scrolledinput;
g_object_set( text_w, "visible", TRUE, NULL);
int w, h;
gdk_drawable_get_size( pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(pane), h - 170);
if ( set_focus)
gtk_widget_grab_focus( cmd_scrolledtextview);
input_multiline = 1;
}
else {
text_w = cmd_input;
g_object_set( text_w, "visible", TRUE, NULL);
if ( set_focus)
gtk_widget_grab_focus( cmd_input);
input_multiline = 0;
}
message( ' ', "");
if ( value) {
if ( multiline) {
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
gtk_text_buffer_delete( cmd_scrolled_buffer, &start_iter, &end_iter);
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_insert( cmd_scrolled_buffer, &start_iter, value, -1);
// Select the text
// gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
// gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
// gtk_text_buffer_select_range( cmd_scrolled_buffer, &start_iter, &end_iter);
}
else {
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
gtk_editable_insert_text( GTK_EDITABLE(text_w), value, strlen(value), &pos);
// Select the text
gtk_editable_set_position( GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region( GTK_EDITABLE(cmd_input), 0, -1);
}
}
else {
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
}
message( ' ', "");
set_prompt( Lng::translate("value >"));
input_open = 1;
}
//
// Callbackfunctions from menu entries
//
void XAttGtk::activate_change_value( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->change_value(1);
}
void XAttGtk::activate_close_changeval( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->change_value_close();
}
void XAttGtk::activate_exit( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
if ( xatt->close_cb)
(xatt->close_cb)( xatt->parent_ctx, (void *)xatt);
else
delete xatt;
}
void XAttGtk::activate_display_object( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_display_object();
}
void XAttGtk::activate_show_cross( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_show_cross();
}
void XAttGtk::activate_open_classgraph( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_open_classgraph();
}
void XAttGtk::activate_open_plc( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_open_plc();
}
void XAttGtk::activate_help( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_help();
}
gboolean XAttGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
XAttGtk *xatt = (XAttGtk *)data;
gboolean scrolledinput_visible;
gboolean input_visible;
g_object_get( xatt->cmd_scrolledinput, "visible", &scrolledinput_visible, NULL);
g_object_get( xatt->cmd_input, "visible", &input_visible, NULL);
if ( scrolledinput_visible)
gtk_widget_grab_focus( xatt->cmd_scrolledtextview);
else if ( input_visible)
gtk_widget_grab_focus( xatt->cmd_input);
else if ( xatt->xattnav)
xatt->xattnav->set_inputfocus();
return FALSE;
}
#if 0
void XAttGtk::valchanged_cmd_input( Widget w, XEvent *event)
{
XAtt *xatt;
int sts;
char *text;
Arg args[2];
XtSetArg(args[0], XmNuserData, &xatt);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)XAtt::value_recall, sizeof(XAtt::value_recall[0]),
sizeof( XAtt::value_recall)/sizeof(XAtt::value_recall[0]),
&xatt->value_current_recall);
if ( sts)
{
text = XmTextGetString( w);
if ( xatt->input_open)
{
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
XtUnmanageChild( w);
xatt->set_prompt( "");
xatt->input_open = 0;
if ( xatt->redraw_cb)
(xatt->redraw_cb)( xatt);
xatt->xattnav->set_inputfocus();
}
}
}
#endif
void XAttGtk::change_value_close()
{
int sts;
if ( input_open) {
if ( input_multiline) {
gchar *text;
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
text = gtk_text_buffer_get_text( cmd_scrolled_buffer, &start_iter, &end_iter,
FALSE);
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
int w, h;
gdk_drawable_get_size( pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(pane), h - 50);
xattnav->redraw();
xattnav->set_inputfocus();
}
else {
char *text;
text = gtk_editable_get_chars( GTK_EDITABLE(cmd_input), 0, -1);
sts = xattnav->set_attr_value( input_node,
input_name, text);
g_free( text);
g_object_set( cmd_input, "visible", FALSE, NULL);
set_prompt( "");
input_open = 0;
if ( redraw_cb)
(redraw_cb)( this);
xattnav->set_inputfocus();
}
}
}
void XAttGtk::activate_cmd_input( GtkWidget *w, gpointer data)
{
char *text;
XAttGtk *xatt = (XAttGtk *)data;
int sts;
g_object_set( xatt->cmd_prompt, "visible", FALSE, NULL);
g_object_set( xatt->cmd_input, "visible", FALSE, NULL);
xatt->xattnav->set_inputfocus();
text = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1);
if ( xatt->input_open) {
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
g_object_set( w, "visible", FALSE, NULL);
xatt->set_prompt( "");
xatt->input_open = 0;
if ( xatt->redraw_cb)
(xatt->redraw_cb)( xatt);
}
g_free( text);
}
void XAttGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
{
XAttGtk *xatt = (XAttGtk *)data;
gchar *text;
int sts;
if ( xatt->input_open) {
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( xatt->cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( xatt->cmd_scrolled_buffer, &end_iter);
text = gtk_text_buffer_get_text( xatt->cmd_scrolled_buffer, &start_iter, &end_iter,
FALSE);
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
g_object_set( xatt->cmd_scrolledinput, "visible", FALSE, NULL);
xatt->set_prompt( "");
xatt->input_open = 0;
int w, h;
gdk_drawable_get_size( xatt->pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(xatt->pane), h - 50);
xatt->xattnav->redraw();
xatt->xattnav->set_inputfocus();
g_free( text);
}
}
void XAttGtk::activate_cmd_scrolled_ca( GtkWidget *w, gpointer data)
{
XAttGtk *xatt = (XAttGtk *)data;
if ( xatt->input_open) {
g_object_set( xatt->cmd_scrolledinput, "visible", FALSE, NULL);
int w, h;
gdk_drawable_get_size( xatt->pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(xatt->pane), h - 50);
xatt->set_prompt( "");
xatt->input_open = 0;
xatt->xattnav->set_inputfocus();
}
}
void XAttGtk::pop()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
XAttGtk::~XAttGtk()
{
delete (XAttNav *)xattnav;
delete cmd_entry;
gtk_widget_destroy( toplevel);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
XAttGtk *xatt = (XAttGtk *)data;
if ( xatt->close_cb)
(xatt->close_cb)( xatt->parent_ctx, (void *)xatt);
else
delete xatt;
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
XAttGtk::XAttGtk( GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
XAtt( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
parent_wid(xa_parent_wid)
{
int sts;
pwr_tAName title;
*xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
cdh_StrncpyCutOff( title, title, 100, 1);
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 600,
"default-width", 420,
"title", title,
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( toplevel);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *func_changevalue = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Change _Value"));
g_signal_connect( func_changevalue, "activate",
G_CALLBACK(activate_change_value), this);
gtk_widget_add_accelerator( func_changevalue, "activate", accel_g,
'q', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *func_close_changeval = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("C_lose Change Value"));
g_signal_connect( func_close_changeval, "activate",
G_CALLBACK(activate_close_changeval), this);
gtk_widget_add_accelerator( func_close_changeval, "activate", accel_g,
't', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(activate_open_plc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_display_object = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("_Display object in Navigator"));
g_signal_connect( functions_display_object, "activate",
G_CALLBACK(activate_display_object), this);
gtk_widget_add_accelerator( functions_display_object, "activate", accel_g,
'd', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_show_cross = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Show C_rossreferences"));
g_signal_connect( functions_show_cross, "activate",
G_CALLBACK(activate_show_cross), this);
gtk_widget_add_accelerator( functions_show_cross, "activate", accel_g,
'r', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkWidget *functions_open_classgraph = gtk_menu_item_new_with_mnemonic(
CoWowGtk::translate_utf8("Open _ClassGraph"));
g_signal_connect( functions_open_classgraph, "activate",
G_CALLBACK(activate_open_classgraph), this);
gtk_widget_add_accelerator( functions_open_classgraph, "activate", accel_g,
'g', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_changevalue);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), func_close_changeval);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_display_object);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_show_cross);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_classgraph);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(help_help),
gtk_image_new_from_stock( "gtk-help", GTK_ICON_SIZE_MENU));
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
gtk_widget_add_accelerator( help_help, "activate", accel_g,
'h', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
pane = gtk_vpaned_new();
xattnav = new XAttNavGtk( (void *)this, pane, xattnav_eType_Object,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
xattnav->message_cb = &message_cb;
xattnav->change_value_cb = &change_value_cb;
xattnav->popup_menu_cb = &xatt_popup_menu_cb;
xattnav->is_authorized_cb = &xatt_is_authorized_cb;
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( "");
gtk_widget_set_size_request( msg_label, -1, 25);
cmd_prompt = gtk_label_new( "value > ");
gtk_widget_set_size_request( cmd_prompt, -1, 25);
cmd_entry = new CoWowEntryGtk( &value_recall);
cmd_input = cmd_entry->widget();
gtk_widget_set_size_request( cmd_input, -1, 25);
g_signal_connect( cmd_input, "activate",
G_CALLBACK(activate_cmd_input), this);
gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(pane), TRUE, TRUE, 0);
gtk_paned_pack1( GTK_PANED(pane), GTK_WIDGET(brow_widget), TRUE, TRUE);
gtk_paned_pack2( GTK_PANED(pane), GTK_WIDGET(statusbar), FALSE, TRUE);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
cmd_scrolled_buffer = gtk_text_buffer_new( NULL);
cmd_scrolledtextview = gtk_text_view_new_with_buffer( cmd_scrolled_buffer);
GtkWidget *viewport = gtk_viewport_new( NULL, NULL);
GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add( GTK_CONTAINER(viewport), cmd_scrolledtextview);
gtk_container_add( GTK_CONTAINER(scrolledwindow), viewport);
cmd_scrolled_ok = gtk_button_new_with_label( "Ok");
gtk_widget_set_size_request( cmd_scrolled_ok, 70, 25);
g_signal_connect( cmd_scrolled_ok, "clicked",
G_CALLBACK(activate_cmd_scrolled_ok), this);
cmd_scrolled_ca = gtk_button_new_with_label( "Cancel");
gtk_widget_set_size_request( cmd_scrolled_ca, 70, 25);
g_signal_connect( cmd_scrolled_ca, "clicked",
G_CALLBACK(activate_cmd_scrolled_ca), this);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), cmd_scrolled_ok, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hboxbuttons), cmd_scrolled_ca, FALSE, FALSE, 0);
cmd_scrolledinput = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(cmd_scrolledinput), scrolledwindow, TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(cmd_scrolledinput), hboxbuttons, FALSE, FALSE, 5);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_scrolledinput, TRUE, TRUE, 0);
gtk_widget_show_all( toplevel);
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( cmd_input, "visible", FALSE, NULL);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
int w, h;
gdk_drawable_get_size( pane->window, &w, &h);
gtk_paned_set_position( GTK_PANED(pane), h - 50);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xatt_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xatt_gtk_h
#define xtt_xatt_gtk_h
/* xtt_xatt_gtk.h -- Object attribute editor */
#ifndef xtt_xatt_h
# include "xtt_xatt.h"
#endif
#ifndef co_wow_gtk_h
# include "co_wow_gtk.h"
#endif
class XAttGtk : public XAtt {
public:
XAttGtk (
GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts);
~XAttGtk();
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;
void message( char severity, char *message);
void set_prompt( char *prompt);
void change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
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_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);
};
#endif
/*
* Proview $Id: xtt_xattnav_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* wb_xattnav.cpp -- Display object info */
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_xatt_msg.h"
#include "rt_mh_net.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "xtt_xatt.h"
#include "xtt_xattnav_gtk.h"
#include "xtt_xnav.h"
#include "xtt_xnav_brow.h"
#include "xtt_xnav_crr.h"
#include "xtt_item.h"
#include "pwr_privilege.h"
#include "co_wow_gtk.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
//
// Create the navigator widget
//
XAttNavGtk::XAttNavGtk(
void *xa_parent_ctx,
GtkWidget *xa_parent_wid,
xattnav_eType xa_type,
char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
GtkWidget **w,
pwr_tStatus *status) :
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, status),
parent_wid(xa_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new( init_brow_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
// Create the root item
*w = form_widget;
wow = new CoWowGtk( form_widget);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
XAttNavGtk::~XAttNavGtk()
{
if ( trace_started)
trace_timerid->remove();
delete trace_timerid;
delete wow;
delete brow;
gtk_widget_destroy( form_widget);
}
void XAttNavGtk::set_inputfocus()
{
if ( !displayed)
return;
gtk_widget_grab_focus( brow_widget);
}
void XAttNavGtk::popup_position( int x_event, int y_event, int *x, int *y)
{
CoWowGtk::PopupPosition( brow_widget, x_event, y_event, x, y);
}
/*
* Proview $Id: xtt_xattnav_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xattnav_gtk_h
#define xtt_xattnav_gtk_h
/* wb_xattnav_gtk.h -- */
#ifndef xtt_xattnav_h
# include "xtt_xattnav.h"
#endif
class XAttNavGtk : public XAttNav {
public:
XAttNavGtk(
void *xa_parent_ctx,
GtkWidget *xa_parent_wid,
xattnav_eType xa_type,
char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
GtkWidget **w,
pwr_tStatus *status);
~XAttNavGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
void popup_position( int x_event, int y_event, int *x, int *y);
void set_inputfocus();
};
#endif
/*
* Proview $Id: xtt_xattone_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xattone.cpp -- Display object attributes */
#if defined OS_VMS && defined __ALPHA
# pragma message disable (NOSIMPINT,EXTROUENCUNNOBJ)
#endif
#if defined OS_VMS && !defined __ALPHA
# pragma message disable (LONGEXTERN)
#endif
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_lng.h"
#include "xtt_xattone_gtk.h"
#include "xtt_xattnav.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
#include "pwr_privilege.h"
CoWowRecall XAttOneGtk::value_recall;
void XAttOneGtk::message( char severity, char *message)
{
gtk_label_set_text( GTK_LABEL(msg_label), message);
}
void XAttOneGtk::set_prompt( char *prompt)
{
if ( strcmp(prompt, "") == 0) {
g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( msg_label, "visible", TRUE, NULL);
}
else {
g_object_set( msg_label, "visible", FALSE, NULL);
g_object_set( cmd_prompt, "visible", TRUE, NULL);
}
}
int XAttOneGtk::set_value()
{
char *text;
int sts;
char buff[1024];
if ( input_open) {
if ( input_multiline) {
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
text = gtk_text_buffer_get_text( cmd_scrolled_buffer, &start_iter, &end_iter,
FALSE);
}
else {
text = gtk_editable_get_chars( GTK_EDITABLE(cmd_input), 0, -1);
}
sts = XNav::attr_string_to_value( atype, text, buff, sizeof(buff),
asize);
g_free( text);
if ( EVEN(sts)) {
message( 'E', "Input syntax error");
return sts;
}
sts = gdh_SetObjectInfoAttrref( &aref, buff, asize);
if ( EVEN(sts)) {
message( 'E', "Unable to set value");
return sts;
}
message( ' ', "");
}
return XATT__SUCCESS;
}
int XAttOneGtk::change_value( int set_focus)
{
int sts;
GtkWidget *text_w;
char *value = 0;
int input_size;
char aval[1024];
char buf[1024];
int len;
sts = gdh_GetAttributeCharAttrref( &aref, &atype, &asize, &aoffs, &aelem);
if ( EVEN(sts)) return sts;
switch ( atype) {
case pwr_eType_String:
case pwr_eType_Text:
input_size = asize;
break;
default:
input_size = 80;
}
sts = gdh_GetObjectInfoAttrref( &aref, aval, sizeof(aval));
if ( EVEN(sts)) return sts;
XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL);
value = buf;
if ( !access_rw) {
gtk_label_set_text( GTK_LABEL(cmd_label), buf);
}
else {
if ( atype == pwr_eType_Text) {
text_w = cmd_scrolledinput;
g_object_set( cmd_input, "visible", FALSE, NULL);
g_object_set( cmd_scrolledinput, "visible", TRUE, NULL);
// int w, h;
// gdk_drawable_get_size( pane->window, &w, &h);
// gtk_paned_set_position( GTK_PANED(pane), h - 170);
if ( set_focus)
gtk_widget_grab_focus( cmd_scrolledtextview);
input_multiline = 1;
#if 0
gtk_entry_set_max_length( text_w, input_size-1);
#endif
if ( value) {
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
gtk_text_buffer_delete( cmd_scrolled_buffer, &start_iter, &end_iter);
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_insert( cmd_scrolled_buffer, &start_iter, value, -1);
}
else {
GtkTextIter start_iter, end_iter;
gtk_text_buffer_get_start_iter( cmd_scrolled_buffer, &start_iter);
gtk_text_buffer_get_end_iter( cmd_scrolled_buffer, &end_iter);
gtk_text_buffer_delete( cmd_scrolled_buffer, &start_iter, &end_iter);
}
}
else {
text_w = cmd_input;
g_object_set( cmd_input, "visible", TRUE, NULL);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
if ( set_focus)
gtk_widget_grab_focus( cmd_input);
input_multiline = 0;
gtk_entry_set_max_length( GTK_ENTRY(text_w), input_size-1);
gint pos = 0;
gtk_editable_delete_text( GTK_EDITABLE(cmd_input), 0, -1);
if ( value) {
gtk_editable_insert_text( GTK_EDITABLE(text_w), value, strlen(value), &pos);
// Select the text
gtk_editable_set_position( GTK_EDITABLE(cmd_input), -1);
gtk_editable_select_region( GTK_EDITABLE(cmd_input), 0, -1);
}
}
message( ' ', "");
set_prompt( Lng::translate("value >"));
input_open = 1;
}
return XATT__SUCCESS;
}
//
// Callbackfunctions from menu entries
//
void XAttOneGtk::activate_exit( GtkWidget *w, gpointer data)
{
XAttOne *xattone = (XAttOne *)data;
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
void XAttOneGtk::activate_help( GtkWidget *w, gpointer data)
{
// Not yet implemented
}
gboolean XAttOneGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
XAttOneGtk *xattone = (XAttOneGtk *)data;
if ( xattone->input_open) {
if ( xattone->input_multiline)
gtk_widget_grab_focus( xattone->cmd_scrolledtextview);
else
gtk_widget_grab_focus( xattone->cmd_input);
}
return FALSE;
}
#if 0
void XAttOneGtk::valchanged_cmd_input( Widget w, XEvent *event)
{
XAttOne *xattone;
int sts;
Arg args[2];
XtSetArg(args[0], XmNuserData, &xattone);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)XAttOne::value_recall, sizeof(XAttOne::value_recall[0]),
sizeof( XAttOne::value_recall)/sizeof(XAttOne::value_recall[0]),
&xattone->value_current_recall);
if ( sts) {
sts = xattone->set_value();
if ( ODD(sts)) {
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
}
}
#endif
void XAttOneGtk::change_value_close()
{
set_value();
}
void XAttOneGtk::activate_cmd_input( GtkWidget *w, gpointer data)
{
activate_cmd_scrolled_ok( w, data);
}
void XAttOneGtk::activate_cmd_scrolled_ok( GtkWidget *w, gpointer data)
{
XAttOne *xattone = (XAttOne *)data;
int sts;
sts = xattone->set_value();
if ( ODD(sts)) {
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
}
void XAttOneGtk::activate_cmd_scrolled_ap( GtkWidget *w, gpointer data)
{
XAttOne *xattone = (XAttOne *)data;
xattone->set_value();
}
void XAttOneGtk::activate_cmd_scrolled_ca( GtkWidget *w, gpointer data)
{
XAttOne *xattone = (XAttOne *)data;
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
void XAttOneGtk::pop()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
XAttOneGtk::~XAttOneGtk()
{
delete cmd_entry;
gtk_widget_destroy( toplevel);
}
static gboolean delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
XAttOneGtk::activate_exit( w, data);
return TRUE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
XAttOneGtk::XAttOneGtk( GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_aref,
char *xa_title,
unsigned int xa_priv,
int *xa_sts) :
XAttOne( xa_parent_ctx, xa_aref, xa_title, xa_priv, xa_sts),
parent_wid(xa_parent_wid)
{
pwr_tAName title;
*xa_sts = gdh_AttrrefToName( &aref, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 200,
"default-width", 500,
"title", title,
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( toplevel);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), GTK_WIDGET(help_menu));
// Prompt, label, input entry
msg_label = gtk_label_new( "");
gtk_widget_set_size_request( msg_label, -1, 25);
cmd_prompt = gtk_label_new( "value > ");
gtk_widget_set_size_request( cmd_prompt, -1, 25);
cmd_label = gtk_label_new("");
gtk_widget_set_size_request( cmd_label, -1, 25);
gtk_misc_set_alignment( GTK_MISC(cmd_label), 0.0, 0.5);
cmd_entry = new CoWowEntryGtk( &value_recall);
cmd_input = cmd_entry->widget();
gtk_widget_set_size_request( cmd_input, -1, 25);
g_signal_connect( cmd_input, "activate",
G_CALLBACK(activate_cmd_input), this);
// Scrolled text input
cmd_scrolled_buffer = gtk_text_buffer_new( NULL);
cmd_scrolledtextview = gtk_text_view_new_with_buffer( cmd_scrolled_buffer);
GtkWidget *viewport = gtk_viewport_new( NULL, NULL);
GtkWidget *scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add( GTK_CONTAINER(viewport), cmd_scrolledtextview);
gtk_container_add( GTK_CONTAINER(scrolledwindow), viewport);
cmd_scrolledinput = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(cmd_scrolledinput), scrolledwindow, TRUE, TRUE, 0);
// Buttons
cmd_scrolled_ok = gtk_button_new_with_label( CoWowGtk::translate_utf8("Ok"));
gtk_widget_set_size_request( cmd_scrolled_ok, 70, 25);
g_signal_connect( cmd_scrolled_ok, "clicked",
G_CALLBACK(activate_cmd_scrolled_ok), this);
cmd_scrolled_ap = gtk_button_new_with_label( CoWowGtk::translate_utf8("Apply"));
gtk_widget_set_size_request( cmd_scrolled_ap, 70, 25);
g_signal_connect( cmd_scrolled_ap, "clicked",
G_CALLBACK(activate_cmd_scrolled_ap), this);
cmd_scrolled_ca = gtk_button_new_with_label( CoWowGtk::translate_utf8("Cancel"));
gtk_widget_set_size_request( cmd_scrolled_ca, 70, 25);
g_signal_connect( cmd_scrolled_ca, "clicked",
G_CALLBACK(activate_cmd_scrolled_ca), this);
GtkWidget *hboxbuttons = gtk_hbox_new( TRUE, 40);
gtk_box_pack_start( GTK_BOX(hboxbuttons), cmd_scrolled_ok, FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(hboxbuttons), cmd_scrolled_ap, FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(hboxbuttons), cmd_scrolled_ca, FALSE, FALSE, 0);
// Horizontal box
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(statusbar), msg_label, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_prompt, FALSE, FALSE, 15);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_label, TRUE, TRUE, 15);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_input, TRUE, TRUE, 15);
gtk_box_pack_start( GTK_BOX(statusbar), cmd_scrolledinput, TRUE, TRUE, 15);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(gtk_hseparator_new()), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(vbox), hboxbuttons, FALSE, FALSE, 5);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
if ( priv & pwr_mPrv_RtWrite || priv & pwr_mPrv_System)
access_rw = 1;
else
access_rw = 0;
if ( access_rw)
g_object_set( cmd_label, "visible", FALSE, NULL);
else {
g_object_set( cmd_input, "visible", FALSE, NULL);
g_object_set( cmd_scrolledinput, "visible", FALSE, NULL);
g_object_set( cmd_scrolled_ok, "visible", FALSE, NULL);
g_object_set( cmd_scrolled_ap, "visible", FALSE, NULL);
}
change_value( 1);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xattone_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xattone_gtk_h
#define xtt_xattone_gtk_h
/* xtt_xattone_gtk.h -- Single attribute editor */
#ifndef xtt_xattone_h
# include "xtt_xattone.h"
#endif
#ifndef co_wow_gtk_h
# include "co_wow_gtk.h"
#endif
class XAttOneGtk : public XAttOne {
public:
XAttOneGtk( GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
char *xa_title,
unsigned int xa_priv,
int *xa_sts);
~XAttOneGtk();
GtkWidget *parent_wid;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *cmd_prompt;
GtkWidget *cmd_label;
GtkWidget *cmd_input;
GtkWidget *cmd_scrolledinput;
GtkWidget *cmd_scrolledtextview;
GtkWidget *cmd_scrolled_ok;
GtkWidget *cmd_scrolled_ap;
GtkWidget *cmd_scrolled_ca;
GtkTextBuffer *cmd_scrolled_buffer;
static CoWowRecall value_recall;
CoWowEntryGtk *cmd_entry;
void message( char severity, char *message);
void set_prompt( char *prompt);
int change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
void swap( int mode);
int set_value();
static void activate_exit( 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_ap( GtkWidget *w, gpointer data);
static void activate_cmd_scrolled_ca( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: xtt_xcrr_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xcrr_gtk.cpp -- Display object crossreferences */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "xtt_xcrr_gtk.h"
#include "xtt_xattnav_gtk.h"
#include "co_lng.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
void XCrrGtk::activate_exit(GtkWidget *w, gpointer data)
{
XCrr *xcrr = (XCrr *)data;
if ( xcrr->close_cb)
(xcrr->close_cb)( xcrr->parent_ctx, (void *)xcrr);
else
delete xcrr;
}
void XCrrGtk::activate_openplc(GtkWidget *w, gpointer data)
{
XCrr *xcrr = (XCrr *)data;
xcrr->xcrrnav->start_trace();
}
void XCrrGtk::activate_help(GtkWidget *w, gpointer data)
{
// Not yet implemented
}
gboolean XCrrGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
XCrrGtk *xcrr = (XCrrGtk *)data;
if ( xcrr->focustimer.disabled()) {
return TRUE;
}
if ( xcrr->xcrrnav)
xcrr->xcrrnav->set_inputfocus();
xcrr->focustimer.disable( 400);
return FALSE;
}
void XCrrGtk::pop()
{
gtk_window_present( GTK_WINDOW(toplevel));
}
XCrrGtk::~XCrrGtk()
{
delete xcrrnav;
gtk_widget_destroy( toplevel);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
XCrrGtk *xcrr = (XCrrGtk *)data;
if ( xcrr->close_cb)
(xcrr->close_cb)( xcrr->parent_ctx, (void *)xcrr);
else
delete xcrr;
return FALSE;
}
static void destroy_event( GtkWidget *w, gpointer data)
{
}
XCrrGtk::XCrrGtk(
GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
XCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
parent_wid(xa_parent_wid)
{
int sts;
pwr_tAName title;
*xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
toplevel = (GtkWidget *) g_object_new( GTK_TYPE_WINDOW,
"default-height", 420,
"default-width", 300,
"title", title,
NULL);
g_signal_connect( toplevel, "delete_event", G_CALLBACK(delete_event), this);
g_signal_connect( toplevel, "destroy", G_CALLBACK(destroy_event), this);
g_signal_connect( toplevel, "focus-in-event", G_CALLBACK(action_inputfocus), this);
CoWowGtk::SetWindowIcon( toplevel);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0);
// Menu
// Accelerators
GtkAccelGroup *accel_g = (GtkAccelGroup *) g_object_new(GTK_TYPE_ACCEL_GROUP, NULL);
gtk_window_add_accel_group(GTK_WINDOW(toplevel), accel_g);
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), file);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), GTK_WIDGET(file_menu));
// Functions entry
GtkWidget *functions_open_plc = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("Open _Program"));
g_signal_connect( functions_open_plc, "activate",
G_CALLBACK(activate_openplc), this);
gtk_widget_add_accelerator( functions_open_plc, "activate", accel_g,
'l', GdkModifierType(GDK_CONTROL_MASK),
GTK_ACCEL_VISIBLE);
GtkMenu *func_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(func_menu), functions_open_plc);
GtkWidget *functions = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Functions"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), functions);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(functions), GTK_WIDGET(func_menu));
// Help entry
GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, accel_g);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkMenu *help_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(help_menu), help_help);
GtkWidget *help = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Help"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
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);
xcrrnav->popup_menu_cb = &xcrr_popup_menu_cb;
xcrrnav->start_trace_cb = &xcrr_start_trace_cb;
xcrrnav->close_cb = &xcrr_close_cb;
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_end( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
gtk_container_add( GTK_CONTAINER(toplevel), vbox);
gtk_widget_show_all( toplevel);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xcrr_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xcrr_gtk_h
#define xtt_xcrr_gtk_h
/* xtt_xcrr_gtk.h -- Object crossreferences */
#ifndef xtt_xcrr_h
# include "xtt_xcrr.h"
#endif
#ifndef co_wow_gtk_h
# include "co_wow_gtk.h"
#endif
class XCrrGtk : public XCrr {
public:
XCrrGtk(
GtkWidget *xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts);
~XCrrGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *xcrrnav_form;
CoWowFocusTimerGtk focustimer;
void pop();
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_openplc( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
};
#endif
/*
* Proview $Id: xtt_xnav_gtk.cpp,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xnav_gtk.cpp -- Display plant and node hierarchy */
typedef void *Widget;
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "co_nav_help.h"
#include "rt_gdh.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_msg.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "rt_trace_gtk.h"
#include "co_lng.h"
#include "co_error.h"
#include "co_xhelp.h"
#include "co_wow_gtk.h"
#include "xtt_xnav_gtk.h"
#include "xtt_item.h"
#include "xtt_menu.h"
#include "xtt_xatt_gtk.h"
#include "xtt_xcrr_gtk.h"
#include "xtt_ge_gtk.h"
#include "xtt_block_gtk.h"
#include "xtt_trend_gtk.h"
#include "xtt_fast_gtk.h"
#include "xtt_xattone_gtk.h"
#include "xtt_clog_gtk.h"
#include "xtt_ev_gtk.h"
#include "xtt_op_gtk.h"
#include "xtt_hist_gtk.h"
#include "ge_curve_gtk.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
//
// Create the navigator widget
//
XNavGtk::XNavGtk( void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
char *xn_name,
GtkWidget **w,
xnav_sStartMenu *root_menu,
char *xn_opplace_name,
pwr_tStatus *status) :
XNav( xn_parent_ctx, xn_name, root_menu, xn_opplace_name, status),
parent_wid(xn_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new(
init_brow_base_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
displayed = 1;
// Create the root item
*w = form_widget;
menu_tree_build( root_menu);
gbl.load_config( this);
for ( int i = 0; i < XNAV_LOGG_MAX; i++)
logg[i].init( i, (void *)this);
wow = new CoWowGtk( parent_wid);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
XNavGtk::~XNavGtk()
{
closing_down = 1;
if ( mcp) {
free( mcp);
mcp = 0;
}
menu_tree_free();
for ( int i = 0; i < brow_cnt; i++) {
brow_DeleteSecondaryCtx( brow_stack[i]->ctx);
brow_stack[i]->free_pixmaps();
delete brow_stack[i];
}
brow_DeleteSecondaryCtx( collect_brow->ctx);
collect_brow->free_pixmaps();
delete collect_brow;
delete brow;
#if 0
if ( op)
delete op;
#endif
gtk_widget_destroy( form_widget);
}
void XNavGtk::set_inputfocus()
{
if ( displayed) {
gtk_widget_grab_focus( brow_widget);
}
}
void XNavGtk::create_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller, unsigned int priv,
char *arg, int x, int y)
{
int x1, y1;
CoWowGtk::PopupPosition( brow_widget, x + 8, y, &x1, &y1);
get_popup_menu( attrref, item_type, caller, priv, arg, x1, y1);
}
//
// Pop xnav window
//
void XNavGtk::pop()
{
GtkWidget *parent, *top;
parent = gtk_widget_get_parent( form_widget);
while( parent) {
top = parent;
parent = gtk_widget_get_parent( parent);
}
displayed = 1;
gtk_window_present( GTK_WINDOW(top));
}
RtTrace *XNavGtk::plctrace_new( pwr_tOid oid, pwr_tStatus *sts)
{
return new RtTraceGtk( this, form_widget, oid, sts);
}
XAtt *XNavGtk::xatt_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
{
return new XAttGtk( form_widget, this, arp, advanced_user, sts);
}
XCrr *XNavGtk::xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
{
return new XCrrGtk( form_widget, this, arp, 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,
int ev_beep, pwr_tStatus *status)
{
return new EvGtk( this, parent_wid, eve_name, ala_name, blk_name,
ev_user, display_ala, display_eve, display_blk,
display_return, display_ack, ev_beep, status);
}
Hist *XNavGtk::hist_new( char *title, pwr_tOid oid, pwr_tStatus *sts)
{
return new HistGtk( this, parent_wid, title, oid, sts);
}
Block *XNavGtk::block_new( pwr_tAttrRef *arp, char *name, unsigned int priv,
pwr_tStatus *sts)
{
return new BlockGtk( this, parent_wid, arp, name, priv, sts);
}
Op *XNavGtk::op_new( char *opplace, pwr_tStatus *sts)
{
return new OpGtk( this, parent_wid, opplace, sts);
}
XttTrend *XNavGtk::xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts)
{
GtkWidget *w;
return new XttTrendGtk( this, parent_wid, name, &w, objar, plotgroup, sts);
}
XttFast *XNavGtk::xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts)
{
GtkWidget *w;
return new XttFastGtk( this, parent_wid, name, &w, objar, sts);
}
XAttOne *XNavGtk::xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts)
{
return new XAttOneGtk( parent_wid, this, objar, title, priv, sts);
}
CLog *XNavGtk::clog_new( char *name, pwr_tStatus *sts)
{
return new CLogGtk( this, parent_wid, name, sts);
}
XttGe *XNavGtk::xnav_ge_new( char *name, char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*command_cb) (XttGe *, char *),
int (*get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*is_authorized_cb) (void *, unsigned int))
{
return new XttGeGtk( parent_wid, this, name, filename, scrollbar, menu, navigator,
width, height, x, y, scan_time, object_name, use_default_access,
access, command_cb, get_current_objects_cb, is_authorized_cb);
}
GeCurve *XNavGtk::gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right)
{
return new GeCurveGtk( this, parent_wid, name, filename, data, pos_right);
}
void XNavGtk::bell( int time)
{
gdk_display_beep( gtk_widget_get_display( brow_widget));
}
void XNavGtk::get_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller,
unsigned int priv, char *arg, int x, int y)
{
int i;
GtkWidget *popup;
get_popup_menu_items( attrref, item_type, caller, priv, arg);
i = 0;
popup = build_menu( parent_wid, MENU_POPUP, "", mcp,
popup_button_cb, (void *) this,
(xmenu_sMenuItem *) mcp->ItemList, &i);
if ( !popup)
return;
popupmenu_x = x;
popupmenu_y = y;
gtk_menu_popup( GTK_MENU(popup), NULL, NULL, menu_position_func,
this, 0, gtk_get_current_event_time());
}
void XNavGtk::menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data)
{
XNavGtk *xnav = (XNavGtk *)data;
*x = xnav->popupmenu_x;
*y = xnav->popupmenu_y;
*push_in = FALSE;
}
GtkWidget *XNavGtk::build_menu( GtkWidget *Parent,
int MenuType,
char *MenuTitle,
void *MenuUserData,
void (*Callback)( GtkWidget *, gpointer),
void *CallbackData,
xmenu_sMenuItem *Items,
int *idx)
{
GtkWidget *Menu, *W;
int i;
unsigned int Level;
Menu = (GtkWidget *) g_object_new( GTK_TYPE_MENU, NULL);
g_object_set_data( (GObject *)Menu, "userdata", (gpointer)MenuUserData);
Level = Items[*idx].Level;
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
if (Items[*idx].Item == xmenu_eMenuItem_Cascade ||
Items[*idx].Item == xmenu_eMenuItem_Ref) {
if (MenuType == MENU_OPTION) {
printf("You can't have submenus from option menu items.");
return NULL;
}
else {
i = *idx;
(*idx)++;
build_menu(Menu, MENU_PULLDOWN,
Lng::translate( Items[i].Name), MenuUserData,
Callback, CallbackData, Items, idx);
(*idx)--;
}
}
else {
if (Items[*idx].Item == xmenu_eMenuItem_Separator) {
// Separator
W = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(Menu), W);
gtk_widget_show(W);
}
else {
// Pushbutton
W = gtk_menu_item_new_with_label( CoWowGtk::translate_utf8(Items[*idx].Name));
gtk_widget_set_sensitive( W, Items[*idx].Flags.f.Sensitive ? TRUE : FALSE);
g_object_set_data( (GObject *)W, "userdata", (gpointer)*idx);
if ( Callback)
g_signal_connect( W, "activate",
G_CALLBACK(Callback), CallbackData);
gtk_menu_shell_append(GTK_MENU_SHELL(Menu), W);
gtk_widget_show(W);
}
}
}
return Menu;
}
void XNavGtk::popup_button_cb( GtkWidget *w, gpointer data)
{
XNav *xnav = (XNav *)data;
int idx;
pwr_tStatus sts;
idx = (int) g_object_get_data( (GObject *)w, "userdata");
xnav->mcp->ChosenItem = idx;
//xnav->set_clock_cursor();
sts = CallMenuMethod( xnav->mcp, xnav->mcp->ChosenItem);
if (EVEN(sts))
xnav->message( 'E', XNav::get_message(sts));
//xnav->reset_cursor();
}
/*
* Proview $Id: xtt_xnav_gtk.h,v 1.1 2007-01-04 08:29:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xnav_gtk_h
#define xtt_xnav_gtk_h
/* xtt_xnav_gtk.h -- Simple navigator */
#ifndef xtt_xnav_h
# include "xtt_xnav.h"
#endif
class XNavGtk : public XNav {
public:
XNavGtk(
void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
char *xn_name,
GtkWidget **w,
xnav_sStartMenu *root_menu,
char *xn_opplace_name,
pwr_tStatus *status);
~XNavGtk();
void set_inputfocus();
void pop();
void create_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller, unsigned int priv,
char *arg, int x, int y);
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);
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,
int ev_beep, pwr_tStatus *status);
Hist *hist_new( char *title, pwr_tOid oid, pwr_tStatus *sts);
Block *block_new( pwr_tAttrRef *arp, char *name, unsigned int priv,
pwr_tStatus *sts);
Op *op_new( char *opplace, pwr_tStatus *sts);
XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts);
XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts);
XAttOne *xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts);
CLog *clog_new( char *name, pwr_tStatus *sts);
XttGe *xnav_ge_new( char *name, char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int));
GeCurve *gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right);
void bell( int time);
void get_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller,
unsigned int priv, char *arg, int x, int y);
static void menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data);
static GtkWidget *build_menu( GtkWidget *Parent,
int MenuType,
char *MenuTitle,
void *MenuUserData,
void (*Callback)( GtkWidget *, gpointer),
void *CallbackData,
xmenu_sMenuItem *Items,
int *idx);
static void popup_button_cb( GtkWidget *w, gpointer data);
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
int popupmenu_x;
int popupmenu_y;
};
#endif
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include ../../special.mk
-include ../special.mk
-include special.mk
/*
* Proview $Id: xtt_block_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_block_motif.cpp -- Alarm blocking window in xtt. */
#include "pwr_class.h"
#include "pwr_privilege.h"
#include "rt_gdh.h"
#include "rt_mh_outunit.h"
#include "co_cdh.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Xm/ToggleB.h>
#include "flow_x.h"
#include "xtt_block_motif.h"
#include "co_lng.h"
#include "co_wow_motif.h"
#include "co_msg.h"
int BlockMotif::execute()
{
mh_eEventPrio prio;
pwr_tStatus sts;
if (XmToggleButtonGetState( toggleA))
prio = mh_eEventPrio_A;
else if (XmToggleButtonGetState( toggleB))
prio = mh_eEventPrio_B;
else if (XmToggleButtonGetState( toggleC))
prio = mh_eEventPrio_C;
else if (XmToggleButtonGetState( toggleD))
prio = mh_eEventPrio_D;
else
prio = (mh_eEventPrio) 0;
sts = mh_OutunitBlock( oar.Objid, prio);
if (EVEN(sts)) {
char msg[80];
msg_GetMsg( sts, msg, sizeof(msg));
wow->DisplayError( "Block Error", msg);
}
return sts;
}
void BlockMotif::update()
{
pwr_tStatus sts;
mh_uEventInfo block_level;
sts = gdh_GetAlarmInfo( oar.Objid, NULL, NULL, (pwr_tUInt32 *) &block_level,
NULL, NULL);
switch ( block_level.Event.Prio) {
case mh_eEventPrio_A:
XmToggleButtonSetState( toggleA, 1, 1);
break;
case mh_eEventPrio_B:
XmToggleButtonSetState( toggleB, 1, 1);
break;
case mh_eEventPrio_C:
XmToggleButtonSetState( toggleC, 1, 1);
break;
case mh_eEventPrio_D:
XmToggleButtonSetState( toggleD, 1, 1);
break;
case 0:
XmToggleButtonSetState( toggleNo, 1, 1);
break;
default:
break;
}
}
void BlockMotif::create_ok( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->buttonOk = w;
}
void BlockMotif::create_apply( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->buttonApply = w;
}
void BlockMotif::create_toggleA( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->toggleA = w;
}
void BlockMotif::create_toggleB( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->toggleB = w;
}
void BlockMotif::create_toggleC( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->toggleC = w;
}
void BlockMotif::create_toggleD( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->toggleD = w;
}
void BlockMotif::create_toggleNo( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
((BlockMotif *)blk)->toggleNo = w;
}
void BlockMotif::activate_apply( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
blk->execute();
}
void BlockMotif::activate_ok( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
pwr_tStatus sts;
sts = blk->execute();
if ( ODD(sts))
delete blk;
}
void BlockMotif::activate_cancel( Widget w, Block *blk, XmAnyCallbackStruct *data)
{
delete blk;
}
BlockMotif::~BlockMotif()
{
delete wow;
XtDestroyWidget( parent_wid);
}
BlockMotif::BlockMotif( void *b_parent_ctx,
Widget b_parent_wid,
pwr_sAttrRef *b_oar,
char *name,
unsigned int priv,
pwr_tStatus *sts):
Block( b_parent_ctx, b_oar, name, priv, sts), parent_wid(b_parent_wid)
{
char uid_filename[120] = {"xtt_block.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
int msts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char title[200];
pwr_tAName aname;
static MrmRegisterArg reglist[] = {
{ "blk_ctx", 0 },
{"blk_activate_cancel",(caddr_t)activate_cancel },
{"blk_activate_ok",(caddr_t)activate_ok },
{"blk_activate_apply",(caddr_t)activate_apply },
{"blk_create_ok",(caddr_t)create_ok },
{"blk_create_apply",(caddr_t)create_apply },
{"blk_create_toggleA",(caddr_t)create_toggleA },
{"blk_create_toggleB",(caddr_t)create_toggleB },
{"blk_create_toggleC",(caddr_t)create_toggleC },
{"blk_create_toggleD",(caddr_t)create_toggleD },
{"blk_create_toggleNo",(caddr_t)create_toggleNo }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*sts = 1;
Lng::get_uid( uid_filename, uid_filename);
*sts = gdh_AttrrefToName( &oar, aname, sizeof(aname), cdh_mNName);
if ( EVEN(*sts)) return;
strcpy( title, name);
strcat( title, " ");
strcat( title, aname);
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
msts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (msts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
msts = MrmFetchWidgetOverride( s_DRMh, "blk_window", parent_wid,
name, args, 1, &toplevel, &dclass);
if (msts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
i = 0;
XtSetArg(args[i],XmNwidth,500);i++;
XtSetArg(args[i],XmNheight,200);i++;
XtSetValues( toplevel, args, i);
XtManageChild( toplevel);
XtPopup( parent_wid, XtGrabNone);
if ( !(priv & pwr_mPrv_RtEvents ||
priv & pwr_mPrv_System)) {
Arg sensitive[1];
// No access to block
// XtUnmanageChild( ok);
// XtUnmanageChild( apply);
XtSetArg( sensitive[0],XmNsensitive, 0);
XtSetValues( buttonOk, sensitive, 1);
XtSetValues( buttonApply, sensitive, 1);
XtSetValues( toggleA, sensitive, 1);
XtSetValues( toggleB, sensitive, 1);
XtSetValues( toggleC, sensitive, 1);
XtSetValues( toggleD, sensitive, 1);
XtSetValues( toggleNo, sensitive, 1);
}
wow = new CoWowMotif( parent_wid);
update();
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid,
(XtCallbackProc)activate_cancel, this);
}
/*
* Proview $Id: xtt_block_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_block_motif_h
#define xtt_block_motif_h
/* xtt_block_motif.h -- Alarm blocking window */
#ifndef xtt_block_h
# include "xtt_block.h"
#endif
class BlockMotif : public Block {
public:
BlockMotif( void *b_parent_ctx,
Widget b_parent_wid,
pwr_sAttrRef *b_oar,
char *name,
unsigned int priv,
pwr_tStatus *status);
~BlockMotif();
int execute();
void update();
Widget parent_wid;
Widget toplevel;
Widget form;
Widget toggleA;
Widget toggleB;
Widget toggleC;
Widget toggleD;
Widget toggleNo;
Widget buttonOk;
Widget buttonApply;
static void create_ok( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_apply( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_toggleA( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_toggleB( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_toggleC( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_toggleD( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void create_toggleNo( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void activate_ok( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void activate_cancel( Widget w, Block *blk, XmAnyCallbackStruct *data);
static void activate_apply( Widget w, Block *blk, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_clog_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_clog_motif.cpp -- Console log in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <Xm/ToggleB.h>
#include <Xm/List.h>
#include "flow_x.h"
#include "co_lng.h"
#include "co_wow_motif.h"
#include "xtt_clog.h"
#include "rt_xnav_msg.h"
#include "xtt_clog_motif.h"
#include "xtt_clognav_motif.h"
CLogMotif::CLogMotif( void *clog_parent_ctx,
Widget clog_parent_wid,
char *clog_name,
pwr_tStatus *status) :
CLog( clog_parent_ctx, clog_name, status), parent_wid(clog_parent_wid),
clock_cursor(0)
{
char uid_filename[120] = {"xtt_clog.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
static char clog_translations[] =
"<FocusIn>: clog_inputfocus()\n";
static XtTranslations clog_compiled_translations = NULL;
static XtActionsRec clog_actions[] =
{
{"clog_inputfocus", (XtActionProc) action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "clog_ctx", 0 },
{"clog_activate_exit",(caddr_t)activate_exit },
{"clog_activate_select_file",(caddr_t)activate_select_file },
{"clog_activate_next_file",(caddr_t)activate_next_file },
{"clog_activate_prev_file",(caddr_t)activate_prev_file },
{"clog_activate_update",(caddr_t)activate_update },
{"clog_activate_zoom_in",(caddr_t)activate_zoom_in },
{"clog_activate_zoom_out",(caddr_t)activate_zoom_out },
{"clog_activate_zoom_reset",(caddr_t)activate_zoom_reset },
{"clog_activate_filter",(caddr_t)activate_filter },
{"clog_activate_help",(caddr_t)activate_help },
{"clog_activate_helpmsg",(caddr_t)activate_helpmsg },
{"clog_create_form",(caddr_t)create_form },
{"clog_filter_tog_cr",(caddr_t)filter_tog_cr },
{"clog_filter_string_cr",(caddr_t)filter_string_cr },
{"clog_filter_act_but_cb",(caddr_t)filter_act_but_cb },
{"clog_filesel_ok_cb",(caddr_t)filesel_ok_cb },
{"clog_filesel_cancel_cb",(caddr_t)filesel_cancel_cb },
{"clog_filesel_list_cr",(caddr_t)filesel_list_cr }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*status = 1;
Lng::get_uid( uid_filename, uid_filename);
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid_clog = XtCreatePopupShell( clog_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "clog_window", parent_wid_clog,
clog_name, args, 1, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", clog_name);
sts = MrmFetchWidget(s_DRMh, "filterForm", toplevel,
&filter_form, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch filter dialog\n");
sts = MrmFetchWidget(s_DRMh, "fileselForm", toplevel,
&filesel_form, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch filesel dialog\n");
MrmCloseHierarchy(s_DRMh);
if ( clog_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel),
clog_actions, XtNumber(clog_actions));
clog_compiled_translations = XtParseTranslationTable( clog_translations);
}
XtOverrideTranslations( toplevel, clog_compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,1000);i++;
XtSetArg(args[i],XmNheight,800);i++;
XtSetValues( toplevel ,args,i);
XtManageChild( toplevel);
// Create clognav
clognav = new CLogNavMotif( this, form_clog, &clognav_widget);
XtPopup( parent_wid_clog, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid_clog,
(XtCallbackProc)activate_exit, this);
wow = new CoWowMotif( toplevel);
*status = 1;
}
//
// Delete clog
//
CLogMotif::~CLogMotif()
{
free_cursor();
XtDestroyWidget( parent_wid_clog);
delete clognav;
}
void CLogMotif::pop()
{
flow_UnmapWidget( parent_wid_clog);
flow_MapWidget( parent_wid_clog);
}
void CLogMotif::set_clock_cursor()
{
if ( !clock_cursor)
clock_cursor = XCreateFontCursor( flow_Display(toplevel), XC_watch);
XDefineCursor( flow_Display(toplevel), flow_Window(toplevel), clock_cursor);
XFlush( flow_Display(toplevel));
}
void CLogMotif::reset_cursor()
{
XUndefineCursor( flow_Display(toplevel), flow_Window(toplevel));
}
void CLogMotif::free_cursor()
{
if (clock_cursor)
XFreeCursor( flow_Display(toplevel), clock_cursor);
}
void CLogMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
CLog *clog;
XtSetArg (args[0], XmNuserData, &clog);
XtGetValues (w, args, 1);
if ( clog && clog->clog_displayed)
clog->clognav->set_input_focus();
}
void CLogMotif::activate_exit( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
if ( clog->close_cb)
(clog->close_cb)( clog->parent_ctx);
else
delete clog;
}
void CLogMotif::activate_zoom_in( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->zoom( 1.2);
}
void CLogMotif::activate_zoom_out( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->zoom( 5.0/6);
}
void CLogMotif::activate_zoom_reset( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->unzoom();
}
void CLogMotif::activate_filter( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
bool success, info, warning, error, fatal, text;
clog->clognav->get_filter( &success, &info, &warning, &error, &fatal, &text);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_success_w, success, 0);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_info_w, info, 0);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_warning_w, warning, 0);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_error_w, error, 0);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_fatal_w, fatal, 0);
XmToggleButtonSetState( ((CLogMotif *)clog)->show_text_w, text, 0);
XtManageChild( ((CLogMotif *)clog)->filter_form);
}
void CLogMotif::activate_select_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
XmString cstr;
char str[200];
char *s;
if ( !clog->filesel_loaded) {
for ( int i = 0; i < (int) clog->clognav->file_list.size(); i++) {
time_AtoAscii( &clog->clognav->file_list[i].time, time_eFormat_ComprDateAndTime,
str, sizeof(str));
str[17] = 0;
strcat( str, " ");
s = strrchr( clog->clognav->file_list[i].name, '/');
if ( s)
strcat( str, s+1);
else
strcat( str, clog->clognav->file_list[i].name);
cstr = XmStringCreateSimple( str);
XmListAddItemUnselected( ((CLogMotif *)clog)->filesel_list_w, cstr, 0);
XmStringFree(cstr);
}
clog->filesel_loaded = true;
}
XtManageChild( ((CLogMotif *)clog)->filesel_form);
}
void CLogMotif::activate_next_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->activate_next_file();
}
void CLogMotif::activate_prev_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->activate_prev_file();
}
void CLogMotif::activate_update( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->set_clock_cursor();
clog->clognav->update();
clog->reset_cursor();
}
void CLogMotif::activate_help( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->activate_help();
}
void CLogMotif::activate_helpmsg( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
}
void CLogMotif::create_form( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
((CLogMotif *)clog)->form_clog = w;
}
void CLogMotif::filter_string_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
((CLogMotif *)clog)->filter_string_w = w;
}
void CLogMotif::filter_tog_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
int key;
XtVaGetValues (w, XmNuserData, &key, NULL);
switch (key) {
case 1:
// Success
((CLogMotif *)clog)->show_success_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 2:
// Info
((CLogMotif *)clog)->show_info_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 3:
// Warning
((CLogMotif *)clog)->show_warning_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 4:
// Error
((CLogMotif *)clog)->show_error_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 5:
// Fatal
((CLogMotif *)clog)->show_fatal_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 6:
// Text
((CLogMotif *)clog)->show_text_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
default:
break;
}
}
void CLogMotif::filter_act_but_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
int key;
char *str;
bool success = XmToggleButtonGetState( ((CLogMotif *)clog)->show_success_w);
bool info = XmToggleButtonGetState( ((CLogMotif *)clog)->show_info_w);
bool warning = XmToggleButtonGetState( ((CLogMotif *)clog)->show_warning_w);
bool error = XmToggleButtonGetState( ((CLogMotif *)clog)->show_error_w);
bool fatal = XmToggleButtonGetState( ((CLogMotif *)clog)->show_fatal_w);
bool text = XmToggleButtonGetState( ((CLogMotif *)clog)->show_text_w);
str = XmTextGetString( ((CLogMotif *)clog)->filter_string_w);
XtVaGetValues(w, XmNuserData, &key, NULL);
switch (key) {
case 1 :
// Ok
XtUnmanageChild( ((CLogMotif *)clog)->filter_form);
case 2 :
// Apply
clog->set_clock_cursor();
clog->clognav->set_filter( success, info, warning, error, fatal, text, str);
clog->reset_cursor();
break;
case 3 :
// Cancel
XtUnmanageChild( ((CLogMotif *)clog)->filter_form);
break;
}
}
void CLogMotif::filesel_list_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
((CLogMotif *)clog)->filesel_list_w = w;
}
void CLogMotif::filesel_ok_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
int *pos_list, pos_cnt;
int key;
if (XmListGetSelectedPos( ((CLogMotif *)clog)->filesel_list_w, &pos_list, &pos_cnt)) {
clog->set_clock_cursor();
clog->clognav->read( pos_list, pos_cnt);
clog->reset_cursor();
}
XtVaGetValues (w, XmNuserData, &key, NULL);
switch (key) {
case 1:
XtUnmanageChild( ((CLogMotif *)clog)->filesel_form);
}
}
void CLogMotif::filesel_cancel_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
XtUnmanageChild( ((CLogMotif *)clog)->filesel_form);
}
/*
* Proview $Id: xtt_clog_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_clog_motif_h
#define xtt_clog_motif_h
/* xtt_clog_motif.h -- Alarm and event windows in xtt */
#ifndef xtt_clog_h
# include "xtt_clog.h"
#endif
class CLogMotif : public CLog {
public:
CLogMotif( void *clog_parent_ctx,
Widget clog_parent_wid,
char *clog_name,
pwr_tStatus *status);
~CLogMotif();
Widget parent_wid;
Widget parent_wid_clog;
Widget toplevel;
Widget form_clog;
Widget clognav_widget;
Widget filter_form;
Widget show_success_w;
Widget show_info_w;
Widget show_warning_w;
Widget show_error_w;
Widget show_fatal_w;
Widget show_text_w;
Widget filter_string_w;
Widget filesel_form;
Widget filesel_list_w;
int clock_cursor;
void pop();
void set_clock_cursor();
void reset_cursor();
void free_cursor();
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void activate_exit( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_select_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_next_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_prev_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_update( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_zoom_in( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_zoom_out( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_zoom_reset( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_filter( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_help( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void activate_helpmsg( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void create_form( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filter_tog_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filter_string_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filter_act_but_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filesel_list_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filesel_ok_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void filesel_cancel_cb( Widget w, CLog *clog, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_clognav_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_clognav_motif.cpp -- Console message window. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_syi.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
// Status is defined as int i xlib...
#ifdef Status
# undef Status
#endif
#include "flow_x.h"
#include "co_mrm_util.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "xtt_clognav_motif.h"
#include "xtt_menu.h"
CLogNavMotif::CLogNavMotif( void *clog_parent_ctx,
Widget clog_parent_wid,
Widget *w) :
CLogNav( clog_parent_ctx), parent_wid(clog_parent_wid)
{
form_widget = ScrolledBrowCreate( parent_wid, "CLogNav", NULL, 0,
init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
*w = form_widget;
}
//
// Delete ev
//
CLogNavMotif::~CLogNavMotif()
{
delete brow;
XtDestroyWidget( form_widget);
}
void CLogNavMotif::set_input_focus()
{
if ( flow_IsViewable( brow_widget))
XtCallAcceptFocus( brow_widget, CurrentTime);
}
/*
* Proview $Id: xtt_clognav_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_clognav_motif_h
#define xtt_clognav_motif_h
/* xtt_clognav_motif.h -- Console message window. */
// Status is defined as int i xlib...
#include <vector>
using namespace std;
#ifdef Status
# undef Status
#endif
#ifndef xtt_clognav_h
# include "xtt_clognav.h"
#endif
class CLogNavMotif : public CLogNav {
public:
CLogNavMotif( void *ev_parent_ctx,
Widget ev_parent_wid,
Widget *w);
~CLogNavMotif();
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
void set_input_focus();
};
#endif
/*
* Proview $Id: xtt_ev_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_ev_motif.cpp -- Alarm and event window in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "rt_mh_util.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow_x.h"
#include "co_lng.h"
#include "co_mrm_util.h"
#include "xtt_evlist_motif.h"
#include "xtt_ev_motif.h"
#include "rt_xnav_msg.h"
EvMotif::EvMotif( void *ev_parent_ctx,
Widget ev_parent_wid,
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,
int ev_beep,
pwr_tStatus *status) :
Ev( ev_parent_ctx, eve_name, ala_name, blk_name, ev_user, display_ala, display_eve,
display_blk, display_return, display_ack, ev_beep, status),
parent_wid(ev_parent_wid), parent_wid_eve(NULL), parent_wid_ala(NULL)
{
char uid_filename[120] = {"xtt_eve.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
int i;
pwr_sClass_User *userobject_ptr;
MrmHierarchy s_DRMh;
MrmType dclass;
static char eve_translations[] =
"<FocusIn>: eve_inputfocus()\n";
static char ala_translations[] =
"<FocusIn>: ala_inputfocus()\n";
static char blk_translations[] =
"<FocusIn>: blk_inputfocus()\n";
static XtTranslations eve_compiled_translations = NULL;
static XtTranslations ala_compiled_translations = NULL;
static XtTranslations blk_compiled_translations = NULL;
static XtActionsRec eve_actions[] =
{
{"eve_inputfocus", (XtActionProc) eve_action_inputfocus}
};
static XtActionsRec ala_actions[] =
{
{"ala_inputfocus", (XtActionProc) ala_action_inputfocus}
};
static XtActionsRec blk_actions[] =
{
{"blk_inputfocus", (XtActionProc) blk_action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "ev_ctx", 0 },
{"ev_eve_activate_exit",(caddr_t)eve_activate_exit },
{"ev_eve_activate_print",(caddr_t)eve_activate_print },
{"ev_eve_activate_ack_last",(caddr_t)eve_activate_ack_last },
{"ev_eve_activate_zoom_in",(caddr_t)eve_activate_zoom_in },
{"ev_eve_activate_zoom_out",(caddr_t)eve_activate_zoom_out },
{"ev_eve_activate_zoom_reset",(caddr_t)eve_activate_zoom_reset },
{"ev_eve_activate_open_plc",(caddr_t)eve_activate_open_plc },
{"ev_eve_activate_display_in_xnav",(caddr_t)eve_activate_display_in_xnav },
{"ev_eve_activate_disp_hundredth",(caddr_t)eve_activate_disp_hundredth },
{"ev_eve_activate_hide_object",(caddr_t)eve_activate_hide_object },
{"ev_eve_activate_hide_text",(caddr_t)eve_activate_hide_text },
{"ev_eve_activate_help",(caddr_t)eve_activate_help },
{"ev_eve_activate_helpevent",(caddr_t)eve_activate_helpevent },
{"ev_eve_create_form",(caddr_t)eve_create_form },
{"ev_ala_activate_exit",(caddr_t)ala_activate_exit },
{"ev_ala_activate_print",(caddr_t)ala_activate_print },
{"ev_ala_activate_ack_last",(caddr_t)ala_activate_ack_last },
{"ev_ala_activate_zoom_in",(caddr_t)ala_activate_zoom_in },
{"ev_ala_activate_zoom_out",(caddr_t)ala_activate_zoom_out },
{"ev_ala_activate_zoom_reset",(caddr_t)ala_activate_zoom_reset },
{"ev_ala_activate_open_plc",(caddr_t)ala_activate_open_plc },
{"ev_ala_activate_display_in_xnav",(caddr_t)ala_activate_display_in_xnav },
{"ev_ala_activate_disp_hundredth",(caddr_t)ala_activate_disp_hundredth },
{"ev_ala_activate_hide_object",(caddr_t)ala_activate_hide_object },
{"ev_ala_activate_hide_text",(caddr_t)ala_activate_hide_text },
{"ev_ala_activate_help",(caddr_t)ala_activate_help },
{"ev_ala_activate_helpevent",(caddr_t)ala_activate_helpevent },
{"ev_ala_create_form",(caddr_t)ala_create_form },
{"ev_blk_activate_exit",(caddr_t)blk_activate_exit },
{"ev_blk_activate_print",(caddr_t)blk_activate_print },
{"ev_blk_activate_zoom_in",(caddr_t)blk_activate_zoom_in },
{"ev_blk_activate_zoom_out",(caddr_t)blk_activate_zoom_out },
{"ev_blk_activate_zoom_reset",(caddr_t)blk_activate_zoom_reset },
{"ev_blk_activate_block_remove",(caddr_t)blk_activate_block_remove },
{"ev_blk_activate_open_plc",(caddr_t)blk_activate_open_plc },
{"ev_blk_activate_display_in_xnav",(caddr_t)blk_activate_display_in_xnav },
{"ev_blk_activate_help",(caddr_t)blk_activate_help },
{"ev_blk_create_form",(caddr_t)blk_create_form }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*status = 1;
Lng::get_uid( uid_filename, uid_filename);
// Check user object
if ( cdh_ObjidIsNull( user))
{
*status = XNAV__NOUSER;
return;
}
sts = gdh_ObjidToPointer ( user, (pwr_tAddress *) &userobject_ptr);
if ( EVEN(sts))
{
*status = XNAV__NOUSER;
return;
}
ala_size = userobject_ptr->MaxNoOfAlarms;
eve_size = userobject_ptr->MaxNoOfEvents;
blk_size = 0;
create_aliaslist( userobject_ptr);
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid_eve = XtCreatePopupShell( eve_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "eve_window", parent_wid_eve,
eve_name, args, 1, &toplevel_eve, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", eve_name);
parent_wid_ala = XtCreatePopupShell( ala_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "ala_window", parent_wid_ala,
ala_name, args, 1, &toplevel_ala, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", ala_name);
parent_wid_blk = XtCreatePopupShell( blk_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "blk_window", parent_wid_blk,
blk_name, args, 1, &toplevel_blk, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", blk_name);
MrmCloseHierarchy(s_DRMh);
if ( eve_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel_eve),
eve_actions, XtNumber(eve_actions));
eve_compiled_translations = XtParseTranslationTable( eve_translations);
}
XtOverrideTranslations( toplevel_eve, eve_compiled_translations);
if ( ala_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel_ala),
ala_actions, XtNumber(ala_actions));
ala_compiled_translations = XtParseTranslationTable( ala_translations);
}
XtOverrideTranslations( toplevel_ala, ala_compiled_translations);
if ( blk_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel_blk),
blk_actions, XtNumber(blk_actions));
blk_compiled_translations = XtParseTranslationTable( blk_translations);
}
XtOverrideTranslations( toplevel_blk, blk_compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,700);i++;
XtSetArg(args[i],XmNheight,600);i++;
XtSetValues( toplevel_eve ,args,i);
i = 0;
XtSetArg(args[i],XmNwidth,700);i++;
XtSetArg(args[i],XmNheight,300);i++;
XtSetValues( toplevel_ala ,args,i);
i = 0;
XtSetArg(args[i],XmNwidth,700);i++;
XtSetArg(args[i],XmNheight,300);i++;
XtSetValues( toplevel_blk ,args,i);
XtManageChild( toplevel_eve);
XtManageChild( toplevel_ala);
XtManageChild( toplevel_blk);
// Create ala and eve...
eve = new EvListMotif( this, form_eve, ev_eType_EventList, eve_size, &eve_widget);
eve->start_trace_cb = &eve_start_trace_cb;
eve->display_in_xnav_cb = &eve_display_in_xnav_cb;
eve->name_to_alias_cb = &ev_name_to_alias_cb;
eve->popup_menu_cb = &ev_popup_menu_cb;
ala = new EvListMotif( this, form_ala, ev_eType_AlarmList, ala_size, &ala_widget);
ala->start_trace_cb = &ala_start_trace_cb;
ala->display_in_xnav_cb = &ala_display_in_xnav_cb;
ala->name_to_alias_cb = &ev_name_to_alias_cb;
ala->popup_menu_cb = &ev_popup_menu_cb;
ala->sound_cb = &ev_sound_cb;
blk = new EvListMotif( this, form_blk, ev_eType_BlockList, blk_size, &blk_widget);
blk->start_trace_cb = &blk_start_trace_cb;
blk->display_in_xnav_cb = &blk_display_in_xnav_cb;
blk->popup_menu_cb = &ev_popup_menu_cb;
// blk->hide_text = 1;
// XtManageChild( form_widget);
if ( display_eve) {
XtPopup( parent_wid_eve, XtGrabNone);
eve_displayed = 1;
}
else
XtRealizeWidget( parent_wid_eve);
if ( display_ala) {
XtPopup( parent_wid_ala, XtGrabNone);
ala_displayed = 1;
}
else
XtRealizeWidget( parent_wid_ala);
if ( display_blk) {
XtPopup( parent_wid_blk, XtGrabNone);
blk_displayed = 1;
}
else
XtRealizeWidget( parent_wid_blk);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid_eve,
(XtCallbackProc)eve_activate_exit, this);
flow_AddCloseVMProtocolCb( parent_wid_ala,
(XtCallbackProc)ala_activate_exit, this);
flow_AddCloseVMProtocolCb( parent_wid_blk,
(XtCallbackProc)blk_activate_exit, this);
// Store this for the mh callbacks
ev = this;
sts = outunit_connect( user);
if ( EVEN(sts))
*status = sts;
}
//
// Delete ev
//
EvMotif::~EvMotif()
{
if ( connected)
mh_OutunitDisconnect();
if ( parent_wid_eve)
XtDestroyWidget( parent_wid_eve);
if ( parent_wid_ala)
XtDestroyWidget( parent_wid_ala);
if ( eve)
delete eve;
if ( ala)
delete ala;
ev = NULL;
}
void EvMotif::map_eve()
{
if ( !eve_displayed) {
flow_MapWidget( parent_wid_eve);
eve_displayed = 1;
}
else {
flow_UnmapWidget( parent_wid_eve);
flow_MapWidget( parent_wid_eve);
}
}
void EvMotif::map_ala()
{
if ( !ala_displayed) {
flow_MapWidget( parent_wid_ala);
ala_displayed = 1;
}
else {
flow_UnmapWidget( parent_wid_ala);
flow_MapWidget( parent_wid_ala);
}
}
void EvMotif::map_blk()
{
if ( !blk_displayed) {
flow_MapWidget( parent_wid_blk);
blk_displayed = 1;
}
else {
flow_UnmapWidget( parent_wid_blk);
flow_MapWidget( parent_wid_blk);
}
}
void EvMotif::unmap_eve()
{
if ( eve_displayed) {
flow_UnmapWidget( parent_wid_eve);
eve_displayed = 0;
}
}
void EvMotif::unmap_ala()
{
if ( ala_displayed) {
flow_UnmapWidget( parent_wid_ala);
ala_displayed = 0;
}
}
void EvMotif::unmap_blk()
{
if ( blk_displayed) {
flow_UnmapWidget( parent_wid_blk);
blk_displayed = 0;
}
}
void EvMotif::eve_action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
Ev *ev;
XtSetArg (args[0], XmNuserData, &ev);
XtGetValues (w, args, 1);
if ( mrm_IsIconicState(w))
return;
if ( ev && ev->eve_displayed) {
if ( ((EvMotif *)ev)->eve_focustimer.disabled())
return;
ev->eve->set_input_focus();
((EvMotif *)ev)->eve_focustimer.disable( ((EvMotif *)ev)->toplevel_eve, 400);
}
}
void EvMotif::ala_action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
Ev *ev;
XtSetArg (args[0], XmNuserData, &ev);
XtGetValues (w, args, 1);
if ( mrm_IsIconicState(w))
return;
if ( ev && ev->ala_displayed) {
if ( ((EvMotif *)ev)->ala_focustimer.disabled())
return;
ev->ala->set_input_focus();
((EvMotif *)ev)->ala_focustimer.disable( ((EvMotif *)ev)->toplevel_ala, 400);
}
}
void EvMotif::blk_action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
Ev *ev;
XtSetArg (args[0], XmNuserData, &ev);
XtGetValues (w, args, 1);
if ( mrm_IsIconicState(w))
return;
if ( ev && ev->blk_displayed) {
if ( ((EvMotif *)ev)->blk_focustimer.disabled())
return;
ev->blk->set_input_focus();
((EvMotif *)ev)->blk_focustimer.disable( ((EvMotif *)ev)->toplevel_blk, 400);
}
}
void EvMotif::eve_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
flow_UnmapWidget( ((EvMotif *)ev)->parent_wid_eve);
ev->eve_displayed = 0;
}
void EvMotif::ala_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
flow_UnmapWidget( ((EvMotif *)ev)->parent_wid_ala);
ev->ala_displayed = 0;
}
void EvMotif::blk_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
flow_UnmapWidget( ((EvMotif *)ev)->parent_wid_blk);
ev->blk_displayed = 0;
}
void EvMotif::eve_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve_activate_print();
}
void EvMotif::ala_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala_activate_print();
}
void EvMotif::blk_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk_activate_print();
}
void EvMotif::eve_activate_ack_last( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve_activate_ack_last();
}
void EvMotif::ala_activate_ack_last( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
eve_activate_ack_last( w, ev, data);
}
void EvMotif::eve_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve->zoom( 1.2);
}
void EvMotif::ala_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala->zoom( 1.2);
}
void EvMotif::blk_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->zoom( 1.2);
}
void EvMotif::eve_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve->zoom( 5.0/6);
}
void EvMotif::ala_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala->zoom( 5.0/6);
}
void EvMotif::blk_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->zoom( 5.0/6);
}
void EvMotif::eve_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve->unzoom();
}
void EvMotif::ala_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala->unzoom();
}
void EvMotif::blk_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->unzoom();
}
void EvMotif::blk_activate_block_remove( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->block_remove();
}
void EvMotif::eve_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve->start_trace();
}
void EvMotif::ala_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala->start_trace();
}
void EvMotif::blk_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->start_trace();
}
void EvMotif::eve_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve->display_in_xnav();
}
void EvMotif::ala_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala->display_in_xnav();
}
void EvMotif::blk_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk->display_in_xnav();
}
void EvMotif::eve_activate_disp_hundredth( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->eve->set_display_hundredth( data->set);
}
void EvMotif::ala_activate_disp_hundredth( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->ala->set_display_hundredth( data->set);
}
void EvMotif::eve_activate_hide_object( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->eve->set_hide_object( data->set);
}
void EvMotif::ala_activate_hide_object( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->ala->set_hide_object( data->set);
}
void EvMotif::eve_activate_hide_text( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->eve->set_hide_text( data->set);
}
void EvMotif::ala_activate_hide_text( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data)
{
ev->ala->set_hide_text( data->set);
}
void EvMotif::eve_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve_activate_help();
}
void EvMotif::eve_activate_helpevent( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->eve_activate_helpevent();
}
void EvMotif::ala_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala_activate_help();
}
void EvMotif::ala_activate_helpevent( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->ala_activate_helpevent();
}
void EvMotif::blk_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
ev->blk_activate_help();
}
void EvMotif::eve_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
((EvMotif *)ev)->form_eve = w;
}
void EvMotif::ala_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
((EvMotif *)ev)->form_ala = w;
}
void EvMotif::blk_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data)
{
((EvMotif *)ev)->form_blk = w;
}
/*
* Proview $Id: xtt_ev_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_ev_motif_h
#define xtt_ev_motif_h
/* xtt_ev_motif.h -- Alarm and event windows in xtt */
#ifndef xtt_ev_h
# include "xtt_ev.h"
#endif
#ifndef co_wow_motif_h
# include "co_wow_motif.h"
#endif
class EvMotif : public Ev {
public:
EvMotif(
void *ev_parent_ctx,
Widget ev_parent_wid,
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,
int ev_beep,
pwr_tStatus *status);
~EvMotif();
Widget parent_wid;
Widget parent_wid_eve;
Widget parent_wid_ala;
Widget parent_wid_blk;
Widget toplevel_ala;
Widget toplevel_eve;
Widget toplevel_blk;
Widget form_ala;
Widget form_eve;
Widget form_blk;
Widget eve_widget;
Widget ala_widget;
Widget blk_widget;
CoWowFocusTimerMotif eve_focustimer;
CoWowFocusTimerMotif ala_focustimer;
CoWowFocusTimerMotif blk_focustimer;
void map_eve();
void map_ala();
void map_blk();
void unmap_eve();
void unmap_ala();
void unmap_blk();
static void eve_action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void ala_action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void blk_action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void eve_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_exit( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_print( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_ack_last( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_ack_last( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_zoom_in( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_zoom_out( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_zoom_reset( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_block_remove( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_open_plc( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_display_in_xnav( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_disp_hundredth( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void ala_activate_disp_hundredth( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void eve_activate_hide_object( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void ala_activate_hide_object( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void eve_activate_hide_text( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void ala_activate_hide_text( Widget w, Ev *ev, XmToggleButtonCallbackStruct *data);
static void eve_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_activate_help( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_activate_helpevent( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_activate_helpevent( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void eve_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void ala_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data);
static void blk_create_form( Widget w, Ev *ev, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_evlist_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_evlist_motif.cpp -- Alarm or event list in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
// Status is defined as int i xlib...
#ifdef Status
# undef Status
#endif
#include "flow_x.h"
#include "co_wow_motif.h"
#include "co_lng.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "xtt_evlist_motif.h"
#include "xtt_menu.h"
EvListMotif::EvListMotif( void *ev_parent_ctx,
Widget ev_parent_wid,
ev_eType ev_type,
int ev_size,
Widget *w) :
EvList( ev_parent_ctx, ev_type, ev_size), parent_wid(ev_parent_wid)
{
form_widget = ScrolledBrowCreate( parent_wid, "EvList", NULL, 0,
init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
*w = form_widget;
}
//
// Delete ev
//
EvListMotif::~EvListMotif()
{
delete brow;
XtDestroyWidget( form_widget);
}
void EvListMotif::set_input_focus()
{
if ( flow_IsViewable( brow_widget))
XtCallAcceptFocus( brow_widget, CurrentTime);
}
void EvListMotif::bell()
{
flow_Bell( form_widget);
}
void EvListMotif::popup_position( int x_event, int y_event, int *x, int *y)
{
CoWowMotif::PopupPosition( brow_widget, x_event, y_event, x, y);
}
/*
* Proview $Id: xtt_evlist_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_evlist_motif_h
#define xtt_evlist_motif_h
/* xtt_evlist_motif.h -- Alarm and event windows in xtt */
// Status is defined as int i xlib...
#ifdef Status
# undef Status
#endif
#ifndef xtt_evlist_h
# include "xtt_evlist.h"
#endif
class EvListMotif : public EvList {
public:
EvListMotif(
void *ev_parent_ctx,
Widget ev_parent_wid,
ev_eType ev_type,
int ev_size,
Widget *w);
~EvListMotif();
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
void set_input_focus();
void bell();
void popup_position( int x_event, int y_event, int *x, int *y);
};
#endif
/*
* Proview $Id: xtt_fast_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_motif.h"
#include "rt_xnav_msg.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "glow_growctx.h"
#undef min
#undef max
#include "glow_growapi.h"
#include "glow_growwidget_motif.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "glow_curvewidget_motif.h"
#include "xtt_xnav.h"
#include "rt_fast.h"
#include "xtt_fast_motif.h"
#include "flow_x.h"
#include "ge_curve_motif.h"
XttFastMotif::XttFastMotif( void *parent_ctx,
Widget parent_wid,
char *name,
Widget *w,
pwr_sAttrRef *fast_arp,
int *sts) :
XttFast( parent_ctx, name, fast_arp, sts), parent_widget(parent_wid)
{
char title[250];
*sts = XNAV__SUCCESS;
curve = new GeCurveMotif( this, parent_widget, title, NULL, gcd, 0);
curve->close_cb = fast_close_cb;
curve->help_cb = fast_help_cb;
wow = new CoWowMotif( parent_widget);
timerid = wow->timer_new();
timerid->add( 1000, fast_scan, this);
}
XttFastMotif::~XttFastMotif()
{
timerid->remove();
for ( int i = 0; i < fast_cnt; i++) {
gdh_UnrefObjectInfo( new_subid);
}
delete curve;
}
/*
* Proview $Id: xtt_fast_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_fast_motif_h
#define xtt_fast_motif_h
/* xtt_fast_motif.h -- Fast curves */
#ifndef xtt_fast_h
# include "xtt_fast.h"
#endif
class XttFastMotif : public XttFast {
public:
Widget parent_widget; //!< Parent widget.
XttFastMotif ( void *xn_parent_ctx,
Widget xn_parent_wid,
char *xn_name,
Widget *w,
pwr_sAttrRef *fast_arp,
int *sts);
~XttFastMotif();
};
#endif
/*
* Proview $Id: xtt_ge_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Xm/DialogS.h>
#include <Xm/MessageB.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "glow.h"
//#include "glow_colpalctx.h"
//#include "glow_colpalapi.h"
//#include "glow_colpalwidget_motif.h"
extern "C" {
#include "flow_x.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_mrm_util.h"
}
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget_motif.h"
#include "co_lng.h"
#include "xtt_ge_motif.h"
#include "ge_graph_motif.h"
#include "xtt_xnav.h"
//
// Test program
//
//
// Static variables
void XttGeMotif::enable_set_focus( XttGeMotif *ge)
{
ge->set_focus_disabled--;
}
void XttGeMotif::disable_set_focus( XttGeMotif *ge, int time)
{
ge->set_focus_disabled++;
ge->focus_timerid = XtAppAddTimeOut(
XtWidgetToApplicationContext( ge->toplevel), time,
(XtTimerCallbackProc)enable_set_focus, ge);
}
void XttGeMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
XttGeMotif *ge;
XtSetArg (args[0], XmNuserData, &ge);
XtGetValues (w, args, 1);
if ( !ge)
return;
if ( mrm_IsIconicState(w))
return;
if ( ge->set_focus_disabled)
return;
if ( ge->graph)
ge->graph->set_inputfocus(1);
disable_set_focus( ge, 400);
}
void XttGeMotif::set_size( int width, int height)
{
short x1, x2, y1, y2;
int default_width;
int default_height;
int i;
Arg args[7];
default_width = width + 20;
default_height = height + 20;
i = 0;
XtSetArg(args[i],XmNwidth, default_width);i++;
XtSetArg(args[i],XmNheight, default_height);i++;
x1 = default_width;
y1 = default_height;
x2 = default_width;
y2 = default_height;
// This condition is due to a bug in Reflection X 11.0.5...
// if ( !((XNav *)ge->parent_ctx)->gbl.no_graph_ratio) {
XtSetArg(args[i], XmNminAspectX, x1); i++;
XtSetArg(args[i], XmNminAspectY, y1); i++;
XtSetArg(args[i], XmNmaxAspectX, x2); i++;
XtSetArg(args[i], XmNmaxAspectY, y2); i++;
XtSetValues( toplevel, args,i);
}
void XttGeMotif::ge_change_value_cb( void *ge_ctx, void *value_object, char *text)
{
Arg args[1];
XttGe *ge = (XttGe*)ge_ctx;
if ( ge->value_input_open)
{
XtUnmanageChild( ((XttGeMotif *)ge)->value_dialog);
ge->value_input_open = 0;
return;
}
XtManageChild( ((XttGeMotif *)ge)->value_dialog);
ge->message( ' ', "");
XtCallAcceptFocus( ((XttGeMotif *)ge)->value_input, CurrentTime);
// XtSetKeyboardFocus( ((XttGeMotif *)ge)->toplevel, ((XttGeMotif *)ge)->value_input);
XtSetArg(args[0],XmNvalue, text);
XtSetValues( ((XttGeMotif *)ge)->value_input, args, 1);
XmTextSetCursorPosition( ((XttGeMotif *)ge)->value_input, strlen(text));
XmTextSetSelection( ((XttGeMotif *)ge)->value_input, 0, strlen(text), CurrentTime);
ge->value_input_open = 1;
ge->current_value_object = value_object;
}
void XttGeMotif::confirm_cb( void *ge_ctx, void *confirm_object, char *text)
{
Arg args[1];
XttGe *ge = (XttGe *)ge_ctx;
if ( ge->confirm_open) {
XtUnmanageChild( ((XttGeMotif *)ge)->confirm_widget);
ge->confirm_open = 0;
return;
}
XtManageChild( ((XttGeMotif *)ge)->confirm_widget);
ge->message( ' ', "");
XtSetArg(args[0],XmNmessageString, XmStringCreateLtoR( text, "ISO8859-1"));
XtSetValues( ((XttGeMotif *)ge)->confirm_widget, args, 1);
ge->confirm_open = 1;
ge->current_confirm_object = confirm_object;
}
void XttGeMotif::message_dialog_cb( void *ge_ctx, char *text)
{
Arg args[1];
XttGe *ge = (XttGe *)ge_ctx;
XtManageChild( ((XttGeMotif *)ge)->message_dia_widget);
XtSetArg(args[0],XmNmessageString, XmStringCreateLtoR( text, "ISO8859-1"));
XtSetValues( ((XttGeMotif *)ge)->message_dia_widget, args, 1);
}
void XttGeMotif::activate_value_input( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
char *text;
text = XmTextGetString( w);
if ( ge->value_input_open)
{
ge->graph->change_value( ge->current_value_object, text);
XtUnmanageChild( ((XttGeMotif *)ge)->value_dialog);
ge->value_input_open = 0;
}
}
void XttGeMotif::activate_confirm_ok( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
XtUnmanageChild( ((XttGeMotif *)ge)->confirm_widget);
ge->confirm_open = 0;
ge->graph->confirm_ok( ge->current_confirm_object);
}
void XttGeMotif::activate_confirm_cancel( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
ge->confirm_open = 0;
XtUnmanageChild( ((XttGeMotif *)ge)->confirm_widget);
}
void XttGeMotif::activate_exit( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
delete ge;
}
void XttGeMotif::activate_zoom_in( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
ge->graph->zoom( 1.2);
}
void XttGeMotif::activate_zoom_out( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
ge->graph->zoom( 5.0/6);
}
void XttGeMotif::activate_zoom_reset( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
ge->graph->unzoom();
}
void XttGeMotif::activate_help( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
char key[80];
if ( ge->help_cb)
{
cdh_ToLower( key, ge->name);
(ge->help_cb)( ge, key);
}
}
void XttGeMotif::create_graph_form( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
((XttGeMotif *)ge)->graph_form = w;
}
void XttGeMotif::create_message_dia( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
XtUnmanageChild( XmMessageBoxGetChild( w, XmDIALOG_OK_BUTTON));
XtUnmanageChild( XmMessageBoxGetChild( w, XmDIALOG_HELP_BUTTON));
}
void XttGeMotif::create_menu( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
((XttGeMotif *)ge)->menu_widget = w;
}
void XttGeMotif::create_value_input( Widget w, XttGe *ge, XmAnyCallbackStruct *data)
{
((XttGeMotif *)ge)->value_input = w;
}
void XttGeMotif::action_resize( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
XttGe *ge;
XtSetArg (args[0], XmNuserData, &ge);
XtGetValues (w, args, 1);
if ( ge->graph && !ge->scrollbar && !ge->navigator)
ge->graph->set_default_layout();
}
XttGeMotif::~XttGeMotif()
{
if ( close_cb)
(close_cb)( this);
if ( set_focus_disabled)
XtRemoveTimeOut( focus_timerid);
delete graph;
XtDestroyWidget( toplevel);
}
void XttGeMotif::pop()
{
flow_UnmapWidget( toplevel);
flow_MapWidget( toplevel);
}
XttGeMotif::XttGeMotif( Widget xg_parent_wid, void *xg_parent_ctx, char *xg_name, char *xg_filename,
int xg_scrollbar, int xg_menu, int xg_navigator, int xg_width, int xg_height,
int x, int y, double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int)) :
XttGe( xg_parent_ctx, xg_name, xg_filename, xg_scrollbar, xg_menu, xg_navigator, xg_width,
xg_height, x, y, scan_time, object_name, use_default_access, access,
xg_command_cb, xg_get_current_objects_cb, xg_is_authorized_cb),
parent_wid(xg_parent_wid), set_focus_disabled(0), focus_timerid(0)
{
char uid_filename[120] = {"xtt_ge.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
char title[300];
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
Widget ge_widget;
char wname[] = "Proview/R Ge";
static char translations[] =
"<ConfigureNotify>: resize()\n\
<FocusIn>: ge_xtt_inputfocus()";
static XtTranslations compiled_translations = NULL;
static XtActionsRec actions[] =
{
{"ge_xtt_inputfocus", (XtActionProc) action_inputfocus},
{"resize", (XtActionProc) action_resize},
};
static MrmRegisterArg reglist[] = {
{ "ge_ctx", 0 },
{"ge_activate_exit",(caddr_t)activate_exit },
{"ge_activate_zoom_in",(caddr_t)activate_zoom_in },
{"ge_activate_zoom_out",(caddr_t)activate_zoom_out },
{"ge_activate_zoom_reset",(caddr_t)activate_zoom_reset },
{"ge_activate_help",(caddr_t)activate_help },
{"ge_create_graph_form",(caddr_t)create_graph_form },
{"ge_create_menu",(caddr_t)create_menu },
{"ge_create_value_input",(caddr_t)create_value_input },
{"ge_activate_value_input",(caddr_t)activate_value_input },
{"ge_activate_confirm_ok",(caddr_t)activate_confirm_ok },
{"ge_activate_confirm_cancel",(caddr_t)activate_confirm_cancel },
{"ge_create_message_dia",(caddr_t)create_message_dia }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
Lng::get_uid( uid_filename, uid_filename);
// Motif
MrmInitialize();
cdh_StrncpyCutOff( title, name, sizeof(title), 1);
reglist[0].value = (caddr_t) this;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i],XmNdeleteResponse, XmDO_NOTHING);i++;
toplevel = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
MrmRegisterNames(reglist, reglist_num);
sts = MrmFetchWidgetOverride( s_DRMh, "ge_window", toplevel,
wname, args, 1, &ge_widget, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", wname);
sts = MrmFetchWidget(s_DRMh, "input_dialog", toplevel,
&value_dialog, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch input dialog\n");
sts = MrmFetchWidget(s_DRMh, "confirm_dialog", toplevel,
&confirm_widget, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch confirm dialog\n");
sts = MrmFetchWidget(s_DRMh, "message_dialog", toplevel,
&message_dia_widget, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch message dialog\n");
MrmCloseHierarchy(s_DRMh);
if (compiled_translations == NULL)
XtAppAddActions( XtWidgetToApplicationContext(toplevel),
actions, XtNumber(actions));
if (compiled_translations == NULL)
compiled_translations = XtParseTranslationTable(translations);
XtOverrideTranslations( ge_widget, compiled_translations);
i = 0;
if ( width == 0 || height == 0)
{
XtSetArg(args[i],XmNwidth,600);i++;
XtSetArg(args[i],XmNheight,500);i++;
}
else
{
XtSetArg(args[i],XmNwidth,width);i++;
XtSetArg(args[i],XmNheight,height);i++;
XtSetArg(args[i], XmNminAspectX, width); i++;
XtSetArg(args[i], XmNminAspectY, height); i++;
XtSetArg(args[i], XmNmaxAspectX, width); i++;
XtSetArg(args[i], XmNmaxAspectY, height); i++;
}
if ( !(x == 0 && y == 0))
{
XtSetArg(args[i],XmNx, x);i++;
XtSetArg(args[i],XmNy, y);i++;
}
XtSetValues( toplevel, args,i);
XtManageChild( ge_widget);
if ( !menu)
XtUnmanageChild( menu_widget);
graph = new GraphMotif( this, graph_form, "Plant",
&grow_widget, &sts, "pwrp_exe:", graph_eMode_Runtime,
scrollbar, 1, object_name, use_default_access, access);
// graph->set_scantime( scan_time);
graph->message_cb = &message_cb;
graph->close_cb = &graph_close_cb;
graph->init_cb = &graph_init_cb;
graph->change_value_cb = &ge_change_value_cb;
graph->confirm_cb = &confirm_cb;
graph->message_dialog_cb = &message_dialog_cb;
graph->command_cb = &ge_command_cb;
graph->display_in_xnav_cb = &ge_display_in_xnav_cb;
graph->is_authorized_cb = &ge_is_authorized_cb;
graph->get_current_objects_cb = &ge_get_current_objects_cb;
graph->popup_menu_cb = &ge_popup_menu_cb;
graph->call_method_cb = &ge_call_method_cb;
graph->sound_cb = &ge_sound_cb;
XtPopup( toplevel, XtGrabNone);
if ( navigator)
{
// Create navigator popup
i = 0;
XtSetArg(args[i],XmNallowShellResize, TRUE); i++;
XtSetArg(args[i],XmNallowResize, TRUE); i++;
XtSetArg(args[i],XmNwidth,200);i++;
XtSetArg(args[i],XmNheight,200);i++;
XtSetArg(args[i],XmNx,500);i++;
XtSetArg(args[i],XmNy,500);i++;
XtSetArg(args[i],XmNdeleteResponse, XmDO_NOTHING);i++;
nav_shell = XmCreateDialogShell( grow_widget, "Navigator",
args, i);
XtManageChild( nav_shell);
((GraphMotif *)graph)->create_navigator( nav_shell);
// XtManageChild( nav_widget);
XtRealizeWidget( nav_shell);
graph->set_nav_background_color();
}
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( toplevel,
(XtCallbackProc)activate_exit, this);
}
/*
* Proview $Id: xtt_ge_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_ge_motif_h
#define xtt_ge_motif_h
#ifndef xtt_ge_h
# include "xtt_ge.h"
#endif
class XttGeMotif : public XttGe {
public:
Widget parent_wid;
Widget grow_widget;
Widget form_widget;
Widget toplevel;
Widget nav_shell;
Widget nav_widget;
Widget menu_widget;
Widget graph_form;
Widget value_input;
Widget value_dialog;
Widget confirm_widget;
Widget message_dia_widget;
int set_focus_disabled;
XtIntervalId focus_timerid;
XttGeMotif( Widget parent_wid, void *parent_ctx, char *name, char *filename,
int scrollbar, int menu, int navigator, int width, int height,
int x, int y, double scan_time, char *object_name, int use_default_access,
unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int));
~XttGeMotif();
void pop();
void set_size( int width, int height);
static void enable_set_focus( XttGeMotif *ge);
static void disable_set_focus( XttGeMotif *ge, int time);
static void ge_change_value_cb( void *ge_ctx, void *value_object, char *text);
static void confirm_cb( void *ge_ctx, void *confirm_object, char *text);
static void message_dialog_cb( void *ge_ctx, char *text);
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void activate_value_input( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_confirm_ok( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_confirm_cancel( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_exit( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_zoom_in( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_zoom_out( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_zoom_reset( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void activate_help( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void create_graph_form( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void create_message_dia( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void create_menu( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void create_value_input( Widget w, XttGe *ge, XmAnyCallbackStruct *data);
static void action_resize( Widget w, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_hist_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_hist_motif.cpp -- Historical event window in xtt
Author: Jonas Nylund.
Last modification: 030217
*/
#if defined OS_LINUX
using namespace std;
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
extern "C" {
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include "rt_mh_util.h"
#include "rt_elog.h"
#include "co_dcli.h"
#include <db.h>
}
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <Xm/ToggleB.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <deque>
#include <algorithm>
extern "C" {
#include "flow_x.h"
#include "co_mrm_util.h"
}
#include "co_lng.h"
#include "xtt_hist_motif.h"
#include "rt_xnav_msg.h"
#include "xtt_evlist_motif.h"
#define SENS 1
#define INSENS 0
#define DONT_SET_SENS -1
/* 24 hours in seconds */
#define ONEDAY 86400
HistMotif::HistMotif( void *hist_parent_ctx,
Widget hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status) :
Hist( hist_parent_ctx, hist_name, objid, status),
parent_wid(hist_parent_wid), parent_wid_hist(NULL)
{
char uid_filename[120] = {"xtt_hist.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
MrmType searchclass;
static char hist_translations[] =
"<FocusIn>: hist_inputfocus()\n";
static XtTranslations hist_compiled_translations = NULL;
static XtActionsRec hist_actions[] =
{
{"hist_inputfocus", (XtActionProc) action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "hist_ctx", 0 },
{"hist_activate_exit",(caddr_t)activate_exit },
{"hist_activate_print",(caddr_t)activate_print },
{"hist_activate_zoom_in",(caddr_t)activate_zoom_in },
{"hist_activate_zoom_out",(caddr_t)activate_zoom_out },
{"hist_activate_zoom_reset",(caddr_t)activate_zoom_reset },
{"hist_activate_open_plc",(caddr_t)activate_open_plc },
{"hist_activate_display_in_xnav",(caddr_t)activate_display_in_xnav },
{"hist_activate_disp_hundredth",(caddr_t)activate_disp_hundredth },
{"hist_activate_hide_object",(caddr_t)activate_hide_object },
{"hist_activate_hide_text",(caddr_t)activate_hide_text },
{"hist_activate_help",(caddr_t)activate_help },
{"hist_activate_helpevent",(caddr_t)activate_helpevent },
{"hist_create_form",(caddr_t)create_form },
{"hist_ok_btn",(caddr_t)ok_btn },
{"hist_cancel_cb",(caddr_t)cancel_cb },
{"hist_start_time_entry_cr",(caddr_t)start_time_entry_cr },
{"hist_start_time_entry_lf",(caddr_t)start_time_entry_lf },
{"hist_stop_time_entry_cr",(caddr_t)stop_time_entry_cr },
{"hist_stop_time_entry_lf",(caddr_t)stop_time_entry_lf },
{"hist_today_cb",(caddr_t)today_cb },
{"hist_yesterday_cb",(caddr_t)yesterday_cb },
{"hist_thisw_cb",(caddr_t)thisw_cb },
{"hist_lastw_cb",(caddr_t)lastw_cb },
{"hist_thism_cb",(caddr_t)thism_cb },
{"hist_lastm_cb",(caddr_t)lastm_cb },
{"hist_all_cb",(caddr_t)all_cb },
{"hist_time_cb",(caddr_t)time_cb },
{"hist_alarm_toggle_cr",(caddr_t)alarm_toggle_cr },
{"hist_info_toggle_cr",(caddr_t)info_toggle_cr },
{"hist_ack_toggle_cr",(caddr_t)ack_toggle_cr },
{"hist_ret_toggle_cr",(caddr_t)ret_toggle_cr },
{"hist_prioA_toggle_cr",(caddr_t)prioA_toggle_cr },
{"hist_prioB_toggle_cr",(caddr_t)prioB_toggle_cr },
{"hist_prioC_toggle_cr",(caddr_t)prioC_toggle_cr },
{"hist_prioD_toggle_cr",(caddr_t)prioD_toggle_cr },
{"hist_event_text_entry_cr",(caddr_t)event_text_entry_cr },
{"hist_event_text_entry_lf",(caddr_t)event_text_entry_lf },
{"hist_event_name_entry_cr",(caddr_t)event_name_entry_cr },
{"hist_event_name_entry_lf",(caddr_t)event_name_entry_lf },
{"hist_nrofevents_string_label_cr",(caddr_t)nrofevents_string_label_cr },
{"hist_search_string_label_cr",(caddr_t)search_string_label_cr },
{"hist_search_string2_label_cr",(caddr_t)search_string2_label_cr },
{"hist_search_string3_label_cr",(caddr_t)search_string3_label_cr },
{"hist_search_string4_label_cr",(caddr_t)search_string4_label_cr },
{"hist_start_time_help_label_cr",(caddr_t)start_time_help_label_cr }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*status = 1;
Lng::get_uid( uid_filename, uid_filename);
//shall be MessageHandler.EventLogSize
hist_size = 100000;
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid_hist = XtCreatePopupShell( hist_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "hist_window", parent_wid_hist,
hist_name, args, 1, &toplevel_hist, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", hist_name);
sts = MrmFetchWidgetOverride( s_DRMh, "histSearchDialog", form_hist,
"searchdialog", args, 1, &toplevel_search, &searchclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", "histSearchDialog");
MrmCloseHierarchy(s_DRMh);
if ( hist_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel_hist),
hist_actions, XtNumber(hist_actions));
hist_compiled_translations = XtParseTranslationTable( hist_translations);
}
XtOverrideTranslations( toplevel_hist, hist_compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,700);i++;
XtSetArg(args[i],XmNheight,300);i++;
XtSetValues( toplevel_search ,args,i);
XtManageChild( toplevel_search);
i = 0;
XtSetArg(args[i],XmNwidth,700);i++;
XtSetArg(args[i],XmNheight,600);i++;
XtSetValues( toplevel_hist ,args,i);
XtManageChild( toplevel_hist);
// Create hist...
hist = new EvListMotif( this, form_hist, ev_eType_HistList, hist_size, &hist_widget);
hist->start_trace_cb = &hist_start_trace_cb;
hist->display_in_xnav_cb = &hist_display_in_xnav_cb;
hist->popup_menu_cb = &hist_popup_menu_cb;
XtPopup( parent_wid_hist, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid_hist,
(XtCallbackProc)activate_exit, this);
char name_str[80];
sts = gdh_ObjidToName ( objid, name_str, sizeof(name_str), cdh_mName_pathStrict);
if (ODD(sts))
{
if(this->event_name_entry_w != NULL)
{
XmTextSetString(this->event_name_entry_w, name_str);
this->eventName_str = name_str;
this->get_hist_list();
}
}
}
//
// Delete hist
//
HistMotif::~HistMotif()
{
if ( parent_wid_hist)
XtDestroyWidget( parent_wid_hist);
if ( hist)
delete hist;
}
void HistMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
HistMotif *hist;
XtSetArg (args[0], XmNuserData, &hist);
XtGetValues (w, args, 1);
if ( mrm_IsIconicState(w))
return;
if ( hist->hist) {
if ( hist->focustimer.disabled())
return;
hist->hist->set_input_focus();
hist->focustimer.disable( hist->toplevel_hist, 4000);
}
//printf("focus\n");
//histOP->hist->set_input_focus();
//?????????????????????
//if ( ev && ev->hist_displayed)
// ev->hist->set_input_focus();
// hist->hist->set_input_focus();
}
void HistMotif::ok_btn( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
brow_DeleteAll(histOP->hist->brow->ctx);
histOP->eventType_Alarm = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->alarm_toggle_w);
histOP->eventType_Ack = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->ack_toggle_w);
histOP->eventType_Info = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->info_toggle_w);
histOP->eventType_Return = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->ret_toggle_w);
histOP->eventPrio_A = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->prioA_toggle_w);
histOP->eventPrio_B = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->prioB_toggle_w);
histOP->eventPrio_C = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->prioC_toggle_w);
histOP->eventPrio_D = (bool)XmToggleButtonGetState( ((HistMotif *)histOP)->prioD_toggle_w);
histOP->minTime_str = XmTextGetString( ((HistMotif *)histOP)->start_time_entry_w);
histOP->maxTime_str = XmTextGetString( ((HistMotif *)histOP)->stop_time_entry_w);
histOP->eventText_str = XmTextGetString( ((HistMotif *)histOP)->event_text_entry_w);
histOP->eventName_str = XmTextGetString( ((HistMotif *)histOP)->event_name_entry_w);
histOP->get_hist_list();
XtFree(histOP->minTime_str);
XtFree(histOP->maxTime_str);
XtFree(histOP->eventText_str);
XtFree(histOP->eventName_str);
}
void HistMotif::activate_exit( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->close_cb(histOP);
}
void HistMotif::activate_print( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->activate_print();
}
void HistMotif::activate_zoom_in( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->hist->zoom( 1.2);
}
void HistMotif::activate_zoom_out( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->hist->zoom( 5.0/6);
}
void HistMotif::activate_zoom_reset( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->hist->unzoom();
}
void HistMotif::activate_open_plc( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->hist->start_trace();
}
void HistMotif::activate_display_in_xnav( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->hist->display_in_xnav();
}
void HistMotif::activate_disp_hundredth( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data)
{
histOP->hist->set_display_hundredth( data->set);
}
void HistMotif::activate_hide_object( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data)
{
histOP->hist->set_hide_object( data->set);
}
void HistMotif::activate_hide_text( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data)
{
histOP->hist->set_hide_text( data->set);
}
void HistMotif::activate_help( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->activate_help();
}
void HistMotif::activate_helpevent( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->activate_helpevent();
}
void HistMotif::create_form( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->form_hist = w;
}
//callbackfunctions from the searchdialog
void HistMotif::cancel_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_cancel_cb\n");
}
void HistMotif::start_time_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->start_time_entry_w = w;
XmTextSetString( ((HistMotif *)histOP)->start_time_entry_w, "1970-05-05 00:00:00");
XtSetSensitive( ((HistMotif *)histOP)->start_time_entry_w, INSENS);
}
void HistMotif::start_time_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_start_time_entry_lf\n");
}
void HistMotif::stop_time_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->stop_time_entry_w = w;
char buf[80];
int Sts;
pwr_tTime StopTime;
pwr_tTime StartTime;
Sts = clock_gettime(CLOCK_REALTIME, &StopTime);
Sts = AdjustForDayBreak(histOP, &StopTime, &StartTime);
StopTime = StartTime;
StopTime.tv_sec += ONEDAY;
time_AtoFormAscii(&StopTime, SWE, SECOND, buf, sizeof(buf));
XmTextSetString( ((HistMotif *)histOP)->stop_time_entry_w, buf);
XtSetSensitive( ((HistMotif *)histOP)->stop_time_entry_w, INSENS);
}
void HistMotif::stop_time_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_stop_time_entry_lf\n");
}
void HistMotif::alarm_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->alarm_toggle_w = w;
//printf("hist_alarm_toggle_cr\n");
}
void HistMotif::info_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->info_toggle_w = w;
//printf("hist_info_toggle_cr\n");
}
void HistMotif::ack_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->ack_toggle_w = w;
//printf("hist_ack_toggle_cr\n");
}
void HistMotif::ret_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->ret_toggle_w = w;
//printf("hist_ret_toggle_cr\n");
}
void HistMotif::prioA_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->prioA_toggle_w = w;
//printf("hist_prioA_toggle_cr\n");
}
void HistMotif::prioB_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->prioB_toggle_w = w;
//printf("hist_prioC_toggle_cr\n");
}
void HistMotif::prioC_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->prioC_toggle_w = w;
//printf("hist_prioC_toggle_cr\n");
}
void HistMotif::prioD_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->prioD_toggle_w = w;
//printf("hist_prioD_toggle_cr\n");
}
void HistMotif::event_text_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->event_text_entry_w = w;
//printf("hist_event_text_entry_cr\n");
}
void HistMotif::event_text_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_event_text_entry_lf\n");
}
void HistMotif::event_name_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
((HistMotif *)histOP)->event_name_entry_w = w;
//printf("hist_event_name_entry_cr\n");
}
void HistMotif::event_name_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_event_name_entry_lf\n");
}
void HistMotif::nrofevents_string_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_search_string_label_cr\n");
((HistMotif *)histOP)->nrofevents_string_lbl_w = w;
}
void HistMotif::search_string_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_search_string_label_cr\n");
((HistMotif *)histOP)->search_string_lbl_w = w;
}
void HistMotif::search_string2_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_search_string_label_cr\n");
((HistMotif *)histOP)->search_string2_lbl_w = w;
}
void HistMotif::search_string3_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_search_string_label_cr\n");
((HistMotif *)histOP)->search_string3_lbl_w = w;
}
void HistMotif::search_string4_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_search_string_label_cr\n");
((HistMotif *)histOP)->search_string4_lbl_w = w;
}
void HistMotif::start_time_help_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
// printf("hist_start_time_help_label_cr\n");
((HistMotif *)histOP)->start_time_help_lbl_w = w;
char buf[40] = "Timeformat: 1970-05-05 23:30:00";
XmString str = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues( ((HistMotif *)histOP)->start_time_help_lbl_w, XmNlabelString,str,NULL);
XmStringFree(str);
}
void HistMotif::today_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->today_cb();
}
void HistMotif::yesterday_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->yesterday_cb();
}
void HistMotif::thisw_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->thisw_cb();
}
void HistMotif::lastw_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->lastw_cb();
}
void HistMotif::thism_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->thism_cb();
}
void HistMotif::lastm_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->lastm_cb();
}
void HistMotif::all_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->all_cb();
}
void HistMotif::time_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data)
{
histOP->time_cb();
}
void HistMotif::set_num_of_events( int nrOfEvents)
{
char buf[20];
sprintf(buf, " %u", nrOfEvents);
XmString str = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues(this->nrofevents_string_lbl_w, XmNlabelString,str,NULL);
XmStringFree(str);
}
void HistMotif::set_search_string( const char *s1, const char *s2,
const char *s3, const char *s4)
{
char buf[500];
strncpy(buf, s1, sizeof(buf));
XmString str = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues(this->search_string_lbl_w, XmNlabelString,str,NULL);
XmStringFree(str);
strncpy(buf, s2, sizeof(buf));
XmString str2 = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues(this->search_string2_lbl_w, XmNlabelString,str2,NULL);
XmStringFree(str2);
strncpy(buf, s3, sizeof(buf));
XmString str3 = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues(this->search_string3_lbl_w, XmNlabelString,str3,NULL);
XmStringFree(str3);
strncpy(buf, s4, sizeof(buf));
XmString str4 = XmStringCreateLtoR(buf, "tag1");
XtVaSetValues(this->search_string4_lbl_w, XmNlabelString,str4,NULL);
XmStringFree(str4);
}
/************************************************************************
*
* Name: SetListTime
*
* Type:
*
* TYPE PARAMETER IOGF DESCRIPTION
*
*
* Description: Sets the Time field for start and stop
*
*************************************************************************/
void HistMotif::SetListTime( pwr_tTime StartTime, pwr_tTime StopTime,
int Sensitive)
{
char timestr[32];
/* Show the resulting times */
time_AtoFormAscii(&StopTime,SWE, SECOND,timestr,sizeof(timestr));
XmTextSetString( stop_time_entry_w, timestr);
time_AtoFormAscii(&StartTime,SWE, SECOND,timestr,sizeof(timestr));
XmTextSetString( start_time_entry_w, timestr);
if (Sensitive != DONT_SET_SENS) {
XtSetSensitive( start_time_entry_w, Sensitive);
XtSetSensitive( stop_time_entry_w, Sensitive);
}
}/* SetListTime */
#endif
/*
* Proview $Id: xtt_hist_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_hist_motif_h
#define xtt_hist_motif_h
/* xtt_hist_motif.h -- Historical event window in xtt */
#if defined OS_LINUX
#ifndef xtt_hist_h
# include "xtt_hist.h"
#endif
#ifndef co_wow_motif_h
# include "co_wow_motif.h"
#endif
class HistMotif : public Hist {
public:
HistMotif( void *hist_parent_ctx,
Widget hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status);
~HistMotif();
Widget parent_wid;
Widget parent_wid_hist;
Widget toplevel_hist;
Widget toplevel_search;
Widget form_hist;
Widget hist_widget;
Widget start_time_help_lbl_w;
Widget start_time_entry_w;
Widget stop_time_entry_w;
Widget event_text_entry_w;
Widget event_name_entry_w;
Widget alarm_toggle_w;
Widget info_toggle_w;
Widget ack_toggle_w;
Widget ret_toggle_w;
Widget prioA_toggle_w;
Widget prioB_toggle_w;
Widget prioC_toggle_w;
Widget prioD_toggle_w;
Widget nrofevents_string_lbl_w;
Widget search_string_lbl_w;
Widget search_string2_lbl_w;
Widget search_string3_lbl_w;
Widget search_string4_lbl_w;
CoWowFocusTimerMotif focustimer;
void set_num_of_events( int nrOfEvents);
void set_search_string( const char *s1, const char *s2,
const char *s3, const char *s4);
void SetListTime( pwr_tTime StartTime, pwr_tTime StopTime,
int Sensitive);
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void activate_exit( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_print( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_zoom_in( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_zoom_out( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_zoom_reset( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_open_plc( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_display_in_xnav( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_disp_hundredth( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data);
static void activate_hide_object( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data);
static void activate_hide_text( Widget w, Hist *histOP, XmToggleButtonCallbackStruct *data);
static void activate_help( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void activate_helpevent( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void create_form( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void ok_btn( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
//callbackfunctions from the searchdialog
static void cancel_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void start_time_help_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void start_time_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void start_time_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void stop_time_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data); static void stop_time_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void today_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void yesterday_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void thisw_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void lastw_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void thism_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void lastm_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void all_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void time_cb( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void alarm_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void info_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void ack_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void ret_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void prioA_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void prioB_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void prioC_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void prioD_toggle_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void event_text_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void event_text_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void event_name_entry_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void event_name_entry_lf( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void nrofevents_string_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void search_string_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void search_string2_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void search_string3_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
static void search_string4_label_cr( Widget w, Hist *histOP, XmAnyCallbackStruct *data);
};
#else
// Dummy for other platforms then OS_LINUX
class Hist {
public:
Hist(
void *hist_parent_ctx,
Widget hist_parent_wid,
char *hist_name, pwr_tObjid objid,
pwr_tStatus *status) : parent_ctx(hist_parent_ctx) {}
void *parent_ctx;
void (*close_cb)( void *);
void (*start_trace_cb)( void *, pwr_tObjid, char *);
void (*display_in_xnav_cb)( void *, pwr_tObjid);
void (*update_info_cb)( void *);
void (*help_cb)( void *, char *);
void (*popup_menu_cb)( void *, pwr_sAttrRef, unsigned long,
unsigned long, char *, Widget * );
};
#endif
#endif
/*
* Proview $Id: xtt_hotkey_motif.c,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_hotkey.c -- <short description>
This module implements global action key definitions for Xtoolkit
based application. These global key definitions are referred to as
'hotkeys' in the rest of this document.
Using the 'hotkey' routines an Xtoolkit actionroutine can be
associated with a specific key. When the users depresses the key
the action routine is called. This is done regardless of which
window and/or application has the keyboard focus.
The hotkey definitions are read from the application X resource
database. In order to define the hotkey bindings the resource
'hotkeys' must be specified in the following way ('Class' is the
application class name) :
Example
Class*hotkeys: [hotkey_binding]...
1: Hotkey resource file translation tables
The binding between key events and hotkey actions are defined in
the application resource file by specifying the resource
'hotkeys' for the application top widget.
The syntax of the binding definition is closely related to that
of normal Xtoolkit translation tables. The syntax is defined by
the following EBNF description:
Example
hotkey_binding ::= [modifier]... "<Key>" keyname ":" action
modifier ::= "Ctrl" | "Shift" | "Alt"
keyname ::= standard_X11_key_name
action ::= action_routine_name "(" argument ")"
action_routine_name ::= normal_x11_action_routine_name
argument ::= any_text_value
Note that there are some differences between this and the normal
X11 translation table syntax. The differences are listed below:
Only the modifiers "Ctrl", "Shift" and "Alt" are allowed.
The modifiers can not be negated (i.e. ~Shift can not be used).
The 'keyname' can not be specified as a hex value (i.e. x0FF1
can not be used).
The action routine must have exactly one argument.
Below is an example of a hotkey binding:
Example:
Myprog*hotkeys: \n\
Ctrl <Key>F1: PopupAction(foo)\n\
Ctrl Shift <Key>F7: CloseValve(valve_15)\n\
<Key>F14: AcknowlegeWarning(ok)
1: Hotkey action routines.
Hotkey action routine work exactly the same way as normal
Xtoolkit action routines and must be declared in the same way (by
Calling XtAddActions or XtAppAddActions).
1: Example of using hotkeys
The following code example show one way of using the hotkey
routines. The key sequence "<Ctrl>F1" is bound to the action
routine show_win() which deiconifies and raises the window.
Example:
#include <Xm/MainW.h>
#include "TkHotkey.h"
static void show_win (Widget, void*, String*, Cardinal*);
Widget topw;
static String fbr[] = {
"*hotkeys: Ctrl<Key>F1: show_win(foo)", NULL, };
static XtActionsRec actions[] = {
{ "show_win", show_win }};
main (int argc, char* argv[])
{
XtAppContext ctx;
hotkeyHandle hk_handle;
hotkeySTATUS rs;
XEvent event;
topw = XtAppInitialize (&ctx,"Xhk",0,0,&argc,argv,fbr,0,0);
XtManageChild (XmCreateMainWindow (topw,"main",0,0));
XtAppAddActions (ctx, actions, XtNumber (actions));
rs = tkhk_initialize (topw, &hk_handle );
XtRealizeWidget (topw);
for (;;)
{
if ( XtAppPeekEvent (ctx, &event)
&& TkSUCCESS == tkhk_process (hk_handle, &event))
{
XtAppNextEvent (ctx, &event); / * remove event * /
}
else
{
XtAppNextEvent (ctx, &event);
XtDispatchEvent ( &event );
}
}
}
static void show_win (Widget w, void* arg, String* av, Cardinal* ac)
{
XMapRaised (XtDisplay (topw), XtWindow (topw));
}
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#if defined (OS_VMS)
# pragma nostandard
#endif
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/keysym.h>
#if defined (OS_VMS)
# pragma standard
#endif
#include "xtt_hotkey_motif.h"
#define CLONESTR(str) ((char*)strcpy(XtMalloc(strlen(str)+1),(str)))
#define CLONE(d,l) ((char*)memcpy(XtMalloc((l)),(d),(l)))
#define TkNhotkeys "hotkeys"
#define TkRHotkeys "Hotkeys"
/*---------------------------------------------------------------------*\
* @Structure: HkRec, *Hk
* @Abstract: hotkey storage record
* @Description:
*
* @NOSide_Effects:
* @EndStructure.
\*---------------------------------------------------------------------*/
typedef struct HkStruct {
int kcode; /* Keycode for hotkey */
unsigned int mod; /* Modified for hotkey */
void* arg; /* Callback argument */
char* action; /* `Action' procedure name */
char* args; /* `Action' procedure textual argument */
} HkRec, *Hk;
/*---------------------------------------------------------------------*\
* @Structure: CtrlRec, *Ctrl
* @Abstract: Hotkey control record
* @Description:
* TBS.
* @NOSide_Effects:
* @EndStructure.
\*---------------------------------------------------------------------*/
typedef struct CtrlStruct {
Display* xd; /* Display */
Widget wdg; /* Widget id passed to action routines */
Hk hk; /* Hotkey storage vector */
int nkeys; /* Nbr of used slots */
int hk_len; /* Allocated len of 'hk' vector */
char* bp; /* String parse pointer */
int parse_err; /* Parser error code */
char* token; /* Current parsed token */
} CtrlRec, *Ctrl;
static XtResource tkhk_resources [] = {
{ TkNhotkeys, TkRHotkeys,
XtRString, sizeof (String),
XtOffset(Ctrl,bp),
XtRImmediate, NULL },
};
/* --- PRIVATE ROUTINE FOREWARD DECLARATION --- */
static hotkeySTATUS tkhk_add_grab (Ctrl cp, Hk hk );
static int tkhk_xerr_hdlr (Display *xd, XErrorEvent* ev );
static int tkhk_xerror_flag = 0;
static hotkeySTATUS tkhk_parser (Ctrl cp);
static int TwpHotkeyStmt (Ctrl cp);
static int TwpError (Ctrl p);
static int TwpStrncmp_ncs (char* s1, char* s2, int len);
static int TwpSetToken (Ctrl p, int len);
static void TwpSkip (Ctrl p);
static int TwpCheck (Ctrl p, char* str, int len);
static int TwpMatch (Ctrl p, char* str);
static int TwpIsArg (Ctrl p);
static int TwpIsEmpty (Ctrl p);
static int TwpIsId (Ctrl p);
/*----------------------------------------------------------------------*\
* @Module: hotkey_Initialize
* @Abstract: init hotkey subsystem
* @Description:
* This routine initializes the 'hotkey' toolkit component.
*
* The application resource database is searched for a 'hotkeys'
* resource specifying a hotkey translation string. This string is
* parsed and the specified hotkeys are enabled.
*
* @Completion_Status:
* <@>TkSUCCESS -S- Successful completion
* <@>TkPARSE_ERROR -E- Syntax error in hotkey binding description.
* Some key binding where not performed.
* <@>TkNO_BINDINGS -E- Failed to locate hotkey binding resource.
* <@>TkERROR -E- Failed.
* @Side_Effects:
* If an error occurs when trying to enable a hotkey this routine
* outputs an error message to stdout.
*
* @NODesign:
* @EndModule.
\*----------------------------------------------------------------------*/
hotkeySTATUS hotkey_Initialize (
Widget w, /*@ARG:RO,VAL,Id of a widget in the */
/* application. This widget is passed */
/* to the `XtActionProc' called */
/* when a hotkey is pressed by the user.*/
hotkeyHandle* handle ) /*@ARG:WR,REF,Returned handle. This */
/* handle must be used when calling the */
/* tkhk_process() routine. */
{
Ctrl cp = (Ctrl) XtCalloc (1, sizeof (CtrlRec));
XErrorHandler xerr_hdlr;
hotkeySTATUS rs;
cp->hk_len = 10;
cp->nkeys = 0;
cp->hk = (Hk) XtCalloc (cp->hk_len, sizeof (HkRec));
cp->xd = XtDisplay (w);
cp->wdg = w;
*handle = (hotkeyHandle) cp;
XtGetApplicationResources (w, cp, tkhk_resources,1,0,0);
if (! cp->bp ) return TkNO_BINDINGS;
xerr_hdlr = XSetErrorHandler (tkhk_xerr_hdlr);
rs = tkhk_parser (cp);
XSync ( cp->xd, False );
xerr_hdlr = XSetErrorHandler (xerr_hdlr);
return rs;
}
static int tkhk_xerr_hdlr (
Display *xd,
XErrorEvent* ev )
{
printf ("TkHotkeys: failed to grab key.\n");
tkhk_xerror_flag = True;
return Success;
}
/*---------------------------------------------------------------------*\
* @Module: tkhk_process
* @Abstract: process hotkey x events
* @Description:
* This routine tests if an event is a 'hotkey' event. If it is the
* action routine associated with the key is called and TkSUCCESS is
* returned. If the event is not a 'hotkey' event this routine
* returns TkNOOP.
*
* This routine must be called in the application event dispatch
* loop. The following example shows how:
*
* @Example
* for (;;)
* {
* Xt(App)NextEvent(.. &event);
* if (TkNOOP == tk_hk_process (tk_handle, &event))
* XtDispatchEvent (&event);
* }
* @End_Example
*
* If the application does not have complete control over the event
* dispatching loop the following type of event loop can be used:
* @Example
* for (;;)
* {
* if ( XtAppPeekEvent (ctx, &event)
* && TkSUCCESS == tk_hk_process (hk, &event))
* {
* XtAppNextEvent (ctx, &event); // remove event
* }
* else
* {
* gmsWaitEvent (0);
* switch (gmsQEventPriority ())
* {
* ...
* }
* }
* }
* @End_Example
*
* @Completion_Status:
* <@>TkSUCCESS -S- Successful completion, action routine called.
* <@>TkNOOP -S- Not a hotkey event.
* <@>TkINV_ARGS -F- Invalid arguments.
* @Side_Effects:
* None.
* @NODesign:
* @EndModule.
\*---------------------------------------------------------------------*/
hotkeySTATUS hotkey_Process (
hotkeyHandle handle, /*@ARG:RO,VAL,Hotkey handle retured by */
/* tkhk_initialize() routine. */
XEvent *event ) /*@ARG:RO,REF,Address of XEvent record. */
{
Ctrl cp = (Ctrl)handle;
XKeyEvent* kev = (XKeyEvent*) event;
int i;
if (! handle || ! event) return TkINV_ARGS;
if (KeyPress == event->type )
{
for (i = 0; i < cp->nkeys; ++i )
{
if ( cp->hk[i].kcode == kev->keycode
&& cp->hk[i].mod == (kev->state & ~LockMask
& ~Mod2Mask & ~Mod3Mask & ~Mod4Mask & ~Mod5Mask)
)
{
XtCallActionProc (
cp->wdg,
cp->hk[i].action,
event,
&cp->hk[i].args,
1 );
return TkSUCCESS;
}
}
}
return TkNOOP;
}
/*---------------------------------------------------------------------*\
* @Module: tkhk_add_grab
* @Abstract: add grab for one key
* @Description:
* Add grabs for one key. The key is defined by the hotkey structure
* passed as the 2:nd argument. Both the normal 'Num-locked
* and 'caps-locked' keypress is selected.
*
* @Completion_Status:
* <@>TkSUCCESS -S- success
* <@>TkERROR -E- failed
* @Side_Effects:
* None.
* @NODesign:
* @EndModule.
\*---------------------------------------------------------------------*/
static hotkeySTATUS tkhk_add_grab (
Ctrl cp, /*@ARG:RO,REF,Address of control record */
Hk hk ) /*@ARG:RO,REF,Address of new key def */
{
int mode, i;
Window w;
if (cp->nkeys >= cp->hk_len )
{
cp->hk_len += 10;
cp->hk = (Hk) XtRealloc ((char *)cp->hk, cp->hk_len * sizeof(HkRec));
}
cp->hk[cp->nkeys++ ] = *hk;
mode = GrabModeAsync;
for (i = 0; i < ScreenCount(cp->xd); i++)
{
w = RootWindowOfScreen(ScreenOfDisplay(cp->xd, i));
XGrabKey (cp->xd, hk->kcode, hk->mod, w, 1, mode, mode );
XGrabKey (cp->xd, hk->kcode, hk->mod | LockMask, w, 1, mode,mode);
XGrabKey (cp->xd, hk->kcode, hk->mod | Mod2Mask, w, 1, mode,mode);
XGrabKey (cp->xd, hk->kcode, hk->mod | LockMask | Mod2Mask, w, 1, mode,mode);
}
return TkSUCCESS;
}
/*---------------------------------------------------------------------*\
* @Module: tkhk_parser
* @Abstract: parse hotkey binding string
* @Description:
*
* @Completion_Status:
* <@>TkSUCCESS -S- success
* <@>TkERROR -E- failed
* @Side_Effects:
* None.
* @NODesign:
* @EndModule.
\*---------------------------------------------------------------------*/
static hotkeySTATUS tkhk_parser (Ctrl cp)
{
cp->parse_err = False;
cp->token = 0;
while ( TwpHotkeyStmt ( cp ));
return cp->parse_err;
}
/*---------------------------------------------------------------------*\
* @Module: TwpHotkeyStmt
* @Abstract: parse one hotkey statement
* @Description:
* Process one hotkey binding statement.
* This code was autogenerated by the META II Bnf compiler-compiler.
* @Completion_Status:
* <@>True -S- statement successfully parsed.
* <@>False -F- Invalid syntax or reached end of binding string.
* Check the 'parse_err' flag in the CtrlRec for
* syntax errors.
* @NOSide_Effects:
* @NODesign:
* @EndModule.
\*---------------------------------------------------------------------*/
static int TwpHotkeyStmt (Ctrl cp)
{
KeySym ksym;
HkRec hkrec;
int flag = 1;
hotkeySTATUS rs;
/* printf ("\n"); */
hkrec.mod = 0x00;
if (TwpIsEmpty (cp)) return 0;
while ( flag )
{
do
{
if (TwpMatch (cp,"Ctrl"))
{
hkrec.mod |= ControlMask;
/* printf ("Ctrl "); */
break;
}
if (TwpMatch (cp,"Shift"))
{
hkrec.mod |= ShiftMask;
/* printf ("Shift "); */
break;
}
if (TwpMatch (cp,"Alt"))
{
hkrec.mod |= Mod1Mask;
/* printf ("Alt "); */
break;
}
flag=0;
} while(0);
}
if (! TwpMatch (cp,"<Key>")) return TwpError(cp);
if (! TwpIsId (cp)) return TwpError (cp);
ksym = XStringToKeysym ( cp->token );
hkrec.kcode = XKeysymToKeycode (cp->xd, ksym );
/* printf ( "%s ---> ", cp->token ); */
if (! TwpMatch(cp,":")) return TwpError(cp);
if (! TwpIsId(cp)) return TwpError(cp);
hkrec.action = CLONESTR (cp->token);
/* printf ( "%s", cp->token ); */
if (! TwpMatch(cp,"(")) return TwpError(cp);
if (! TwpIsArg(cp)) return TwpError(cp);
hkrec.args = CLONESTR (cp->token);
/* printf ( " with ARGS: %s", cp->token ); */
if (! TwpMatch(cp,")")) return TwpError(cp);
rs = tkhk_add_grab ( cp, &hkrec );
return True;
}
static int TwpError (Ctrl p)
{
p->parse_err = TkPARSE_ERROR;
return 0;
}
static int TwpStrncmp_ncs (char* s1, char* s2, int len)
{
for ( ; *s1 && *s2 && len; ++s1, ++s2, --len)
if (_tolower(*s1) != _tolower(*s2)) break;
return len * (_tolower(*s1) - _tolower(*s2));
}
static int TwpSetToken (Ctrl p, int len)
{
if (0 == len) return 0;
if (p->token) XtFree ( p->token );
p->token = CLONE (p->bp, len + 1);
p->token [len] = '\0';
p->bp = &p->bp[len];
return 1;
}
static void TwpSkip (Ctrl p)
{
while (*p->bp && (isspace (*p->bp) || *p->bp == '\n')) p->bp++;
}
static int TwpCheck (Ctrl p, char* str, int len)
{
int ok;
TwpSkip (p);
ok = (0 == TwpStrncmp_ncs (p->bp,str,len));
if (ok) p->bp = &p->bp[len];
return ok;
}
static int TwpMatch (Ctrl p, char* str)
{
if (!TwpCheck (p, str, strlen (str))) return 0;
return 1;
}
static int TwpIsArg(Ctrl p)
{
int n;
TwpSkip (p);
for (n = 0; p->bp[n] != ')' && p->bp[n] != 12 ; ++n);
return TwpSetToken (p, n);
}
static int TwpIsEmpty (Ctrl p)
{
TwpSkip (p);
return (p->bp[0] == '\0');
}
static int TwpIsId (Ctrl p)
{
int n;
TwpSkip (p);
if (! isalpha(p->bp[0])) return 0;
for(n = 0; isalnum(p->bp[n]) || '_' ==p->bp[n] || '$' ==p->bp[n]; ++n);
return TwpSetToken (p, n);
}
/* --- End of ps_utl_hotkey.c --- */
/*
* Proview $Id: xtt_hotkey_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_hotkey_motif_h
#define xtt_hotkey_motif_h
typedef int hotkeySTATUS;
#define TkSUCCESS 1
#define TkNOOP 2
#define TkERROR 3
#define TkPARSE_ERROR 4
#define TkNO_BINDINGS 5
#define TkINV_ARGS 6
typedef void* hotkeyHandle;
hotkeySTATUS hotkey_Initialize (
Widget w, /*@ARG:RO,VAL,Id of a widget in the */
/* application. This widget is passed */
/* to the `TkHotkeyActionProc' called */
/* when a hotkey is pressed by the user.*/
hotkeyHandle* handle ) /*@ARG:WR,REF,Returned handle. This */
/* handle must be used when calling the */
/* tkhk_process() routine. */
;
hotkeySTATUS hotkey_Process (
hotkeyHandle handle, /*@ARG:RO,VAL,Hotkey handle retured by */
/* tkhk_initialize() routine. */
XEvent *event ) /*@ARG:RO,REF,Address of XEvent record. */
;
#endif
/*
* Proview $Id: xtt_op_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_op_motif.cpp -- Alarm and event window in xtt */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
#include "rt_mh_outunit.h"
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Xm/PushB.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow_x.h"
#include "co_wow_motif.h"
#include "co_lng.h"
#include "xtt_op_motif.h"
#include "rt_xnav_msg.h"
#define OP_HEIGHT_MIN 80
#define OP_HEIGHT_INC 20
#define OP_HEIGHT_MAX (OP_HEIGHT_MIN + 3 * OP_HEIGHT_INC)
OpMotif::OpMotif( void *op_parent_ctx,
Widget op_parent_wid,
char *opplace,
pwr_tStatus *status) :
Op( op_parent_ctx, opplace, status), parent_wid(op_parent_wid)
{
char uid_filename[120] = {"xtt_op.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char name[20] = "Operator Window";
int width;
int decor, func;
static MrmRegisterArg reglist[] = {
{ "op_ctx", 0 },
{"op_activate_exit",(caddr_t)activate_exit },
{"op_activate_aalarm_ack",(caddr_t)activate_aalarm_ack },
{"op_activate_aalarm_incr",(caddr_t)activate_aalarm_incr },
{"op_activate_aalarm_decr",(caddr_t)activate_aalarm_decr },
{"op_create_alarmcnt_label",(caddr_t)create_alarmcnt_label },
{"op_create_aalarm_label1",(caddr_t)create_aalarm_label1 },
{"op_create_aalarm_label2",(caddr_t)create_aalarm_label2 },
{"op_create_aalarm_label3",(caddr_t)create_aalarm_label3 },
{"op_create_aalarm_label4",(caddr_t)create_aalarm_label4 },
{"op_create_aalarm_label5",(caddr_t)create_aalarm_label5 },
{"op_create_aalarm_active1",(caddr_t)create_aalarm_active1 },
{"op_create_aalarm_active2",(caddr_t)create_aalarm_active2 },
{"op_create_aalarm_active3",(caddr_t)create_aalarm_active3 },
{"op_create_aalarm_active4",(caddr_t)create_aalarm_active4 },
{"op_create_aalarm_active5",(caddr_t)create_aalarm_active5 },
{"op_activate_balarm_ack",(caddr_t)activate_balarm_ack },
{"op_activate_alarmlist",(caddr_t)activate_alarmlist },
{"op_activate_eventlist",(caddr_t)activate_eventlist },
{"op_activate_eventlog",(caddr_t)activate_eventlog },
{"op_activate_navigator",(caddr_t)activate_navigator },
{"op_activate_help",(caddr_t)activate_help },
{"op_create_balarm_label",(caddr_t)create_balarm_label },
{"op_create_balarm_mark",(caddr_t)create_balarm_mark },
{"op_create_balarm_active",(caddr_t)create_balarm_active },
{"op_create_appl_form",(caddr_t)create_appl_form }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*status = 1;
Lng::get_uid( uid_filename, uid_filename);
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
width = XWidthOfScreen(flow_Screen(op_parent_wid));
// decor = MWM_DECOR_BORDER | MWM_DECOR_RESIZEH;
// func = MWM_FUNC_RESIZE | MWM_FUNC_MOVE;
decor = MWM_DECOR_ALL | MWM_DECOR_MINIMIZE |
MWM_DECOR_MAXIMIZE | MWM_DECOR_TITLE | MWM_DECOR_MENU;
func = MWM_FUNC_ALL | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE;
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
XtSetArg(args[i],XmNmwmDecorations, decor);i++;
XtSetArg(args[i],XmNmwmFunctions, func);i++;
XtSetArg(args[i],XmNwidth, width - 20);i++;
XtSetArg(args[i],XmNheight, OP_HEIGHT_MIN);i++;
XtSetArg(args[i],XmNminHeight, OP_HEIGHT_MIN);i++;
XtSetArg(args[i],XmNmaxHeight, OP_HEIGHT_MAX);i++;
XtSetArg(args[i],XmNheightInc, OP_HEIGHT_INC);i++;
XtSetArg(args[i],XmNx, 1);i++;
XtSetArg(args[i],XmNy, 1);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid_op = XtCreatePopupShell( name,
topLevelShellWidgetClass, parent_wid, args, i);
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
sts = MrmFetchWidgetOverride( s_DRMh, "op_window", parent_wid_op,
name, args, i, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
i = 0;
/*
XtSetValues( toplevel ,args,i);
*/
XtManageChild( toplevel);
configure( opplace);
XtPopup( parent_wid_op, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid_op,
(XtCallbackProc)activate_exit, this);
if ( start_jop)
{
jop = new Jop( (void *)this);
jop->command_cb = &jop_command_cb;
}
flow_UnmapWidget( aalarm_active[0]);
flow_UnmapWidget( aalarm_active[1]);
flow_UnmapWidget( aalarm_active[2]);
flow_UnmapWidget( aalarm_active[3]);
flow_UnmapWidget( aalarm_active[4]);
flow_UnmapWidget( balarm_active);
wow = new CoWowMotif( toplevel);
wow->DisplayWarranty();
*status = sts;
}
//
// Delete op
//
OpMotif::~OpMotif()
{
if ( jop)
delete jop;
XtDestroyWidget( parent_wid_op);
}
void OpMotif::map()
{
flow_UnmapWidget( parent_wid_op);
flow_MapWidget( parent_wid_op);
}
void OpMotif::update_alarm_info()
{
evlist_sAlarmInfo info;
int sts;
Arg args[4];
XmString cstr;
int i, j;
int height, active_height;
int background;
char str[40];
char text[120];
if ( get_alarm_info_cb)
{
sts = (get_alarm_info_cb)( parent_ctx, &info);
if ( EVEN(sts)) return;
/*
printf("Info A: %s %d %d\n", info.a_alarm_text[0], info.a_alarm_active[0],
info.a_alarm_exist[0]);
printf("Info A: %s %d %d\n", info.a_alarm_text[1], info.a_alarm_active[1],
info.a_alarm_exist[1]);
printf("Info A: %s %d %d\n", info.a_alarm_text[2], info.a_alarm_active[2],
info.a_alarm_exist[2]);
printf("Info A: %s %d %d\n", info.a_alarm_text[3], info.a_alarm_active[3],
info.a_alarm_exist[3]);
printf("Info A: %s %d %d\n", info.a_alarm_text[4], info.a_alarm_active[4],
info.a_alarm_exist[4]);
printf("Info B: %s %d\n", info.b_alarm_text[0], info.b_alarm_active[0]);
printf("Info B: %s %d\n", info.b_alarm_text[1], info.b_alarm_active[1]);
*/
XtSetArg(args[j=0],XmNbackground, &background);j++;
XtGetValues( aalarm_active[0], args, j);
height = 22;
active_height = 22;
sprintf( str, "%d", info.alarms_total);
cstr=XmStringCreateLtoR( str, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( alarmcnt_label, args, j);
XmStringFree( cstr);
for ( i = 0; i < 5; i++)
{
if ( info.a_alarm_exist[i])
{
sprintf( text, "%s %s", info.a_alarm_alias[i], info.a_alarm_text[i]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( aalarm_label[i], args, j);
XmStringFree( cstr);
XtVaSetValues( aalarm_label[i], XtVaTypedArg, XmNbackground,
XmRString, "red", 4, NULL);
if ( info.a_alarm_active[i])
{
flow_MapWidget( aalarm_active[i]);
}
else
{
flow_UnmapWidget( aalarm_active[i]);
}
}
else
{
cstr=XmStringCreateLtoR( "", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetArg(args[j],XmNbackground, background);j++;
XtSetValues( aalarm_label[i], args, j);
XmStringFree( cstr);
flow_UnmapWidget( aalarm_active[i]);
}
}
if ( info.b_alarm_exist[0])
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_B;
sprintf( text, "%s %s", info.b_alarm_alias[0], info.b_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
XtVaSetValues( balarm_label, XtVaTypedArg, XmNbackground,
XmRString, "yellow", 7, NULL);
cstr=XmStringCreateLtoR( "B", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_mark, args, j);
XmStringFree( cstr);
if ( info.b_alarm_active[0])
{
flow_MapWidget( balarm_active);
}
else
{
flow_UnmapWidget( balarm_active);
}
}
else if ( info.c_alarm_exist[0])
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_C;
sprintf( text, "%s %s", info.c_alarm_alias[0], info.c_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
XtVaSetValues( balarm_label, XtVaTypedArg, XmNbackground,
XmRString, "lightblue", 7, NULL);
cstr=XmStringCreateLtoR( "C", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_mark, args, j);
XmStringFree( cstr);
if ( info.b_alarm_active[0])
{
flow_MapWidget( balarm_active);
}
else
{
flow_UnmapWidget( balarm_active);
}
}
else if ( info.d_alarm_exist[0])
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_D;
sprintf( text, "%s %s", info.d_alarm_alias[0], info.d_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
XtVaSetValues( balarm_label, XtVaTypedArg, XmNbackground,
XmRString, "violet", 7, NULL);
cstr=XmStringCreateLtoR( "D", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_mark, args, j);
XmStringFree( cstr);
if ( info.b_alarm_active[0])
{
flow_MapWidget( balarm_active);
}
else
{
flow_UnmapWidget( balarm_active);
}
}
else if ( info.i_alarm_exist[0])
{
balarm_type = evlist_eEventType_Info;
sprintf( text, "%s %s", info.i_alarm_alias[0], info.i_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
XtVaSetValues( balarm_label, XtVaTypedArg, XmNbackground,
XmRString, "green", 7, NULL);
cstr=XmStringCreateLtoR( "I", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_mark, args, j);
XmStringFree( cstr);
if ( info.b_alarm_active[0])
{
flow_MapWidget( balarm_active);
}
else
{
flow_UnmapWidget( balarm_active);
}
}
else
{
cstr=XmStringCreateLtoR( "", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetArg(args[j],XmNbackground, background);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
cstr=XmStringCreateLtoR( "", "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_mark, args, j);
XmStringFree( cstr);
flow_UnmapWidget( balarm_active);
}
for ( i = 0; i < 5; i++)
{
XtSetArg(args[j=0],XmNheight, height);j++;
XtSetValues( aalarm_label[i], args, j);
XtSetArg(args[j=0],XmNheight, active_height);j++;
XtSetValues( aalarm_active[i], args, j);
}
XtSetArg(args[j=0],XmNheight, height);j++;
XtSetValues( balarm_label, args, j);
}
}
int OpMotif::configure( char *opplace_str)
{
int sts;
int i;
pwr_tObjid opplace;
pwr_tObjid user;
pwr_sClass_OpPlace *opplace_p;
pwr_sClass_User *user_p;
pwr_sAttrRef attrref;
XmFontList fontlist;
XmFontListEntry entry;
sts = gdh_NameToObjid( opplace_str, &opplace);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( opplace, (void **) &opplace_p);
if ( EVEN(sts)) return sts;
// Fix
if ( strncmp( opplace_p->OpWinProgram, "Jop", 3) == 0)
start_jop = 1;
// Find matching user object
sts = gdh_GetClassList( pwr_cClass_User, &user);
while ( ODD (sts))
{
sts = gdh_ObjidToPointer( user, (void **) &user_p);
if ( EVEN(sts)) return sts;
if ( user_p->OpNumber == opplace_p->OpNumber)
break;
sts = gdh_GetNextObject( user, &user);
}
if ( EVEN(sts)) return sts;
// Load font
entry = XmFontListEntryCreate( "tag1", XmFONT_IS_FONT,
XLoadQueryFont( flow_Display(appl_form),
"-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1"));
fontlist = XmFontListAppendEntry( NULL, entry);
XtFree( (char *)entry);
// Examine Graph objects
button_cnt = user_p->NoFastAvail;
if ( button_cnt > 15)
button_cnt = 15;
for ( i = 0; i < button_cnt; i++)
{
if ( i >= 15)
break;
memset( &attrref, 0, sizeof(attrref));
sts = gdh_ClassAttrToAttrref( pwr_cClass_XttGraph, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
attrref = cdh_ArefAdd( &user_p->FastAvail[i], &attrref);
sts = gdh_GetObjectInfoAttrref( &attrref, (void *)button_title[i],
sizeof(button_title[0]));
if ( EVEN(sts))
strcpy( button_title[i], "");
button_objid[i] = attrref.Objid;
}
// Create the application buttons
for ( i = 0; i < button_cnt; i++)
{
Widget b[15];
switch ( i)
{
case 0:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl1, (void *)this);
break;
case 1:
case 2:
case 3:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNheight, 25,
XmNfontList, fontlist,
NULL);
if ( i == 1)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl2, (void *)this);
else if ( i == 2)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl3, (void *)this);
else
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl4, (void *)this);
break;
case 4:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNrightAttachment, XmATTACH_FORM,
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl5, (void *)this);
break;
case 5:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[0],
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl6, (void *)this);
break;
case 6:
case 7:
case 8:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[0],
XmNheight, 25,
XmNfontList, fontlist,
NULL);
if ( i == 6)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl7, (void *)this);
else if ( i == 7)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl8, (void *)this);
else
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl9, (void *)this);
break;
case 9:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[0],
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl10, (void *)this);
break;
case 10:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[5],
XmNbottomAttachment, XmATTACH_FORM,
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl11, (void *)this);
break;
case 11:
case 12:
case 13:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[5],
XmNbottomAttachment, XmATTACH_FORM,
XmNheight, 25,
XmNfontList, fontlist,
NULL);
if ( i == 11)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl12, (void *)this);
else if ( i == 12)
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl13, (void *)this);
else
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl14, (void *)this);
break;
case 14:
b[i] = XtVaCreateManagedWidget( button_title[i],
xmPushButtonWidgetClass, appl_form,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, b[i-1],
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, b[5],
XmNbottomAttachment, XmATTACH_FORM,
XmNheight, 25,
XmNfontList, fontlist,
NULL);
XtAddCallback( b[i], XmNactivateCallback,
(XtCallbackProc)activate_appl15, (void *)this);
break;
}
}
XmFontListFree( fontlist);
return XNAV__SUCCESS;
}
void OpMotif::activate_exit( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_exit();
}
void OpMotif::activate_aalarm_ack( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_aalarm_ack();
}
void OpMotif::activate_balarm_ack( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_balarm_ack();
}
void OpMotif::activate_aalarm_incr( Widget w, Op *op, XmAnyCallbackStruct *data)
{
Arg args[20];
int i;
short height;
i = 0;
XtSetArg(args[i],XmNheight, &height);i++;
XtGetValues( ((OpMotif *)op)->parent_wid_op, args, i);
if ( height >= OP_HEIGHT_MAX)
return;
height += OP_HEIGHT_INC;
i = 0;
XtSetArg(args[i],XmNheight, height);i++;
XtSetValues( ((OpMotif *)op)->parent_wid_op, args, i);
}
void OpMotif::activate_aalarm_decr( Widget w, Op *op, XmAnyCallbackStruct *data)
{
Arg args[20];
int i;
short height;
i = 0;
XtSetArg(args[i],XmNheight, &height);i++;
XtGetValues( ((OpMotif *)op)->parent_wid_op, args, i);
if ( height <= OP_HEIGHT_MIN)
return;
height -= OP_HEIGHT_INC;
i = 0;
XtSetArg(args[i],XmNheight, height);i++;
XtSetValues( ((OpMotif *)op)->parent_wid_op, args, i);
}
void OpMotif::activate_alarmlist( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_alarmlist();
}
void OpMotif::activate_eventlist( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_eventlist();
}
void OpMotif::activate_eventlog( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_eventlog();
}
void OpMotif::activate_navigator( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_navigator();
}
void OpMotif::activate_help( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->activate_help();
}
void OpMotif::activate_appl1( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(0);
}
void OpMotif::activate_appl2( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(1);
}
void OpMotif::activate_appl3( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(2);
}
void OpMotif::activate_appl4( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(3);
}
void OpMotif::activate_appl5( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(4);
}
void OpMotif::activate_appl6( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(5);
}
void OpMotif::activate_appl7( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(6);
}
void OpMotif::activate_appl8( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(7);
}
void OpMotif::activate_appl9( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(8);
}
void OpMotif::activate_appl10( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(9);
}
void OpMotif::activate_appl11( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(10);
}
void OpMotif::activate_appl12( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(11);
}
void OpMotif::activate_appl13( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(12);
}
void OpMotif::activate_appl14( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(13);
}
void OpMotif::activate_appl15( Widget w, Op *op, XmAnyCallbackStruct *data)
{
op->appl_action(14);
}
void OpMotif::create_alarmcnt_label( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->alarmcnt_label = w;
}
void OpMotif::create_aalarm_label1( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_label[0] = w;
}
void OpMotif::create_aalarm_label2( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_label[1] = w;
}
void OpMotif::create_aalarm_label3( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_label[2] = w;
}
void OpMotif::create_aalarm_label4( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_label[3] = w;
}
void OpMotif::create_aalarm_label5( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_label[4] = w;
}
void OpMotif::create_aalarm_active1( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_active[0] = w;
}
void OpMotif::create_aalarm_active2( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_active[1] = w;
}
void OpMotif::create_aalarm_active3( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_active[2] = w;
}
void OpMotif::create_aalarm_active4( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_active[3] = w;
}
void OpMotif::create_aalarm_active5( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->aalarm_active[4] = w;
}
void OpMotif::create_balarm_label( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->balarm_label = w;
}
void OpMotif::create_balarm_mark( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->balarm_mark = w;
}
void OpMotif::create_balarm_active( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->balarm_active = w;
}
void OpMotif::create_appl_form( Widget w, Op *op, XmAnyCallbackStruct *data)
{
((OpMotif *)op)->appl_form = w;
}
/*
* Proview $Id: xtt_op_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_op_motif_h
#define xtt_op_motif_h
/* xtt_op_motif.h -- Operator window in xtt */
#ifndef xtt_op_h
# include "xtt_op.h"
#endif
class OpMotif : public Op {
public:
OpMotif( void *op_parent_ctx,
Widget op_parent_wid,
char *opplace,
pwr_tStatus *status);
~OpMotif();
Widget parent_wid;
Widget parent_wid_op;
Widget toplevel;
Widget alarmcnt_label;
Widget aalarm_label[5];
Widget aalarm_active[5];
Widget balarm_label;
Widget balarm_active;
Widget balarm_mark;
Widget appl_form;
void map();
int configure( char *opplace_str);
void update_alarm_info();
static void activate_exit( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_aalarm_ack( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_balarm_ack( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_aalarm_incr( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_aalarm_decr( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_alarmlist( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_eventlist( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_eventlog( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_navigator( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_help( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl1( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl2( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl3( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl4( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl5( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl6( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl7( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl8( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl9( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl10( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl11( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl12( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl13( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl14( Widget w, Op *op, XmAnyCallbackStruct *data);
static void activate_appl15( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_alarmcnt_label( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_label1( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_label2( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_label3( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_label4( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_label5( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_active1( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_active2( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_active3( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_active4( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_aalarm_active5( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_balarm_label( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_balarm_mark( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_balarm_active( Widget w, Op *op, XmAnyCallbackStruct *data);
static void create_appl_form( Widget w, Op *op, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_trend_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_motif.h"
#include "rt_xnav_msg.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "glow_growctx.h"
#undef min
#undef max
#include "glow_growapi.h"
#include "glow_growwidget_motif.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "glow_curvewidget_motif.h"
#include "xtt_xnav.h"
#include "xtt_trend_motif.h"
#include "flow_x.h"
#include "ge_curve_motif.h"
XttTrendMotif::XttTrendMotif( void *parent_ctx,
Widget parent_wid,
char *name,
Widget *w,
pwr_sAttrRef *trend_list,
pwr_sAttrRef *plotgroup,
int *sts) :
XttTrend( parent_ctx, name, trend_list, plotgroup, sts), parent_widget(parent_wid)
{
*sts = XNAV__SUCCESS;
curve = new GeCurveMotif( this, parent_widget, name, NULL, gcd, 1);
curve->close_cb = trend_close_cb;
curve->help_cb = trend_help_cb;
wow = new CoWowMotif( parent_widget);
timerid = wow->timer_new();
timerid->add( 1000, trend_scan, this);
}
XttTrendMotif::~XttTrendMotif()
{
timerid->remove();
for ( int i = 0; i < trend_cnt; i++) {
gdh_UnrefObjectInfo( subid[i]);
}
delete curve;
}
/*
* Proview $Id: xtt_trend_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_trend_motif_h
#define xtt_trend_motif_h
/* xtt_trend_motif.h -- DsTrend curves */
#ifndef xtt_trend_h
# include "xtt_trend.h"
#endif
class XttTrendMotif : public XttTrend {
public:
Widget parent_widget;
XttTrendMotif( void *xn_parent_ctx,
Widget xn_parent_wid,
char *xn_name,
Widget *w,
pwr_sAttrRef *objid,
pwr_sAttrRef *plotgroup,
int *sts);
~XttTrendMotif();
};
#endif
/*
* Proview $Id: xtt_xatt_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xatt.cpp -- Display object attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "flow_x.h"
#include "rt_xnav_msg.h"
#include "co_mrm_util.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_lng.h"
#include "xtt_xatt_motif.h"
#include "xtt_xattnav_motif.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
// Static member elements
char XAttMotif::value_recall[30][160];
void XAttMotif::message( char severity, char *message)
{
Arg args[2];
XmString cstr;
cstr=XmStringCreateLtoR( message, "ISO8859-1");
XtSetArg(args[0],XmNlabelString, cstr);
XtSetArg(args[1],XmNheight, 20);
XtSetValues( msg_label, args, 2);
XmStringFree( cstr);
}
void XAttMotif::set_prompt( char *prompt)
{
Arg args[3];
XmString cstr;
cstr=XmStringCreateLtoR( prompt, "ISO8859-1");
XtSetArg(args[0],XmNlabelString, cstr);
XtSetArg(args[1],XmNwidth, 50);
XtSetArg(args[2],XmNheight, 30);
XtSetValues( cmd_prompt, args, 3);
XmStringFree( cstr);
}
void XAttMotif::change_value( int set_focus)
{
int sts;
Widget text_w;
int multiline;
char *value;
Arg args[5];
int input_size;
if ( input_open) {
XtUnmanageChild( cmd_input);
set_prompt( "");
input_open = 0;
return;
}
sts = xattnav->check_attr( &multiline, &input_node, input_name,
&value, &input_size);
if ( EVEN(sts)) {
if ( sts == XATT__NOATTRSEL)
message( 'E', "No attribute is selected");
else
message( 'E', XNav::get_message( sts));
return;
}
if ( multiline) {
text_w = cmd_scrolledinput;
XtManageChild( text_w);
XtManageChild( cmd_scrolled_ok);
XtManageChild( cmd_scrolled_ca);
// XtSetArg(args[0], XmNpaneMaximum, 300);
// XtSetValues( xattnav_form, args, 1);
XtSetArg(args[0], XmNmaxLength, input_size-1);
XtSetValues( text_w, args, 1);
if ( value) {
XmTextSetString( text_w, value);
// XmTextSetInsertionPosition( text_w, strlen(value));
}
else
XmTextSetString( text_w, "");
input_multiline = 1;
}
else {
text_w = cmd_input;
XtManageChild( text_w);
XtSetArg(args[0],XmNmaxLength, input_size-1);
XtSetValues( text_w, args, 1);
if ( value) {
XmTextSetString( text_w, value);
XmTextSetInsertionPosition( text_w, strlen(value));
}
else
XmTextSetString( text_w, "");
input_multiline = 0;
}
if ( value)
XtFree( value);
message( ' ', "");
if ( set_focus)
flow_SetInputFocus( text_w);
set_prompt( Lng::translate("value >"));
input_open = 1;
}
//
// Callbackfunctions from menu entries
//
void XAttMotif::activate_change_value( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->change_value(1);
}
void XAttMotif::activate_close_changeval( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->change_value_close();
}
void XAttMotif::activate_exit( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
if ( xatt->close_cb)
(xatt->close_cb)( xatt->parent_ctx, (void *)xatt);
else
delete xatt;
}
void XAttMotif::activate_display_object( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->activate_display_object();
}
void XAttMotif::activate_show_cross( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->activate_show_cross();
}
void XAttMotif::activate_open_classgraph( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->activate_open_classgraph();
}
void XAttMotif::activate_open_plc( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->activate_open_plc();
}
void XAttMotif::activate_help( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
xatt->activate_help();
}
void XAttMotif::create_msg_label( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->msg_label = w;
}
void XAttMotif::create_cmd_prompt( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->cmd_prompt = w;
}
void XAttMotif::create_cmd_input( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
Arg args[2];
XtSetArg (args[0], XmNuserData, xatt);
XtSetValues (w, args, 1);
mrm_TextInit( w, (XtActionProc) valchanged_cmd_input, mrm_eUtility_XAtt);
((XAttMotif *)xatt)->cmd_input = w;
}
void XAttMotif::create_cmd_scrolledinput( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->cmd_scrolledinput = w;
}
void XAttMotif::create_cmd_scrolled_ok( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->cmd_scrolled_ok = w;
}
void XAttMotif::create_cmd_scrolled_ca( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->cmd_scrolled_ca = w;
}
void XAttMotif::create_xattnav_form( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
((XAttMotif *)xatt)->xattnav_form = w;
}
void XAttMotif::enable_set_focus( XAttMotif *xatt)
{
xatt->set_focus_disabled--;
}
void XAttMotif::disable_set_focus( XAttMotif *xatt, int time)
{
xatt->set_focus_disabled++;
xatt->focus_timerid = XtAppAddTimeOut(
XtWidgetToApplicationContext( xatt->toplevel), time,
(XtTimerCallbackProc)enable_set_focus, xatt);
}
void XAttMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
XAttMotif *xatt;
XtSetArg (args[0], XmNuserData, &xatt);
XtGetValues (w, args, 1);
if ( !xatt)
return;
if ( mrm_IsIconicState(w))
return;
if ( xatt->set_focus_disabled)
return;
if ( flow_IsManaged( xatt->cmd_scrolledinput))
flow_SetInputFocus( xatt->cmd_scrolledinput);
else if ( flow_IsManaged( xatt->cmd_input))
flow_SetInputFocus( xatt->cmd_input);
else if ( xatt->xattnav)
xatt->xattnav->set_inputfocus();
disable_set_focus( xatt, 400);
}
void XAttMotif::valchanged_cmd_input( Widget w, XEvent *event)
{
XAttMotif *xatt;
int sts;
char *text;
Arg args[2];
XtSetArg(args[0], XmNuserData, &xatt);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)value_recall, sizeof(value_recall[0]),
sizeof(value_recall)/sizeof(value_recall[0]),
&xatt->value_current_recall);
if ( sts)
{
text = XmTextGetString( w);
if ( xatt->input_open)
{
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
XtUnmanageChild( w);
xatt->set_prompt( "");
xatt->input_open = 0;
if ( xatt->redraw_cb)
(xatt->redraw_cb)( xatt);
xatt->xattnav->set_inputfocus();
}
}
}
void XAttMotif::change_value_close()
{
char *text;
int sts;
text = XmTextGetString( cmd_scrolledinput);
if ( input_open) {
if ( input_multiline) {
sts = xattnav->set_attr_value( input_node,
input_name, text);
XtUnmanageChild( cmd_scrolledinput);
XtUnmanageChild( cmd_scrolled_ok);
XtUnmanageChild( cmd_scrolled_ca);
set_prompt( "");
input_open = 0;
xattnav->redraw();
xattnav->set_inputfocus();
}
else {
text = XmTextGetString( cmd_input);
sts = xattnav->set_attr_value( input_node,
input_name, text);
XtUnmanageChild( cmd_input);
set_prompt( "");
input_open = 0;
if ( redraw_cb)
(redraw_cb)( this);
xattnav->set_inputfocus();
}
}
}
void XAttMotif::activate_cmd_input( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
char *text;
int sts;
text = XmTextGetString( w);
if ( xatt->input_open)
{
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
XtUnmanageChild( w);
xatt->set_prompt( "");
xatt->input_open = 0;
if ( xatt->redraw_cb)
(xatt->redraw_cb)( xatt);
xatt->xattnav->set_inputfocus();
}
}
void XAttMotif::activate_cmd_scrolled_ok( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
char *text;
int sts;
text = XmTextGetString( ((XAttMotif *)xatt)->cmd_scrolledinput);
if ( xatt->input_open) {
sts = xatt->xattnav->set_attr_value( xatt->input_node,
xatt->input_name, text);
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolledinput);
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolled_ok);
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolled_ca);
xatt->set_prompt( "");
xatt->input_open = 0;
xatt->xattnav->redraw();
xatt->xattnav->set_inputfocus();
}
}
void XAttMotif::activate_cmd_scrolled_ca( Widget w, XAtt *xatt, XmAnyCallbackStruct *data)
{
if ( xatt->input_open) {
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolledinput);
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolled_ok);
XtUnmanageChild( ((XAttMotif *)xatt)->cmd_scrolled_ca);
xatt->set_prompt( "");
xatt->input_open = 0;
xatt->xattnav->set_inputfocus();
}
}
void XAttMotif::pop()
{
flow_UnmapWidget( parent_wid);
flow_MapWidget( parent_wid);
}
XAttMotif::~XAttMotif()
{
if ( set_focus_disabled)
XtRemoveTimeOut( focus_timerid);
delete (XAttNav *)xattnav;
XtDestroyWidget( parent_wid);
}
XAttMotif::XAttMotif( Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
XAtt( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
parent_wid(xa_parent_wid), set_focus_disabled(0),
value_current_recall(0)
{
char uid_filename[120] = {"xtt_xatt.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
pwr_tAName title;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char name[] = "Proview/R Navigator";
static char translations[] =
"<FocusIn>: xatt_inputfocus()\n";
static XtTranslations compiled_translations = NULL;
static XtActionsRec actions[] =
{
{"xatt_inputfocus", (XtActionProc) action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "xatt_ctx", 0 },
{"xatt_activate_exit",(caddr_t)activate_exit },
{"xatt_activate_display_object",(caddr_t)activate_display_object },
{"xatt_activate_show_cross",(caddr_t)activate_show_cross },
{"xatt_activate_open_classgraph",(caddr_t)activate_open_classgraph },
{"xatt_activate_open_plc",(caddr_t)activate_open_plc },
{"xatt_activate_change_value",(caddr_t)activate_change_value },
{"xatt_activate_close_changeval",(caddr_t)activate_close_changeval },
{"xatt_activate_help",(caddr_t)activate_help },
{"xatt_create_msg_label",(caddr_t)create_msg_label },
{"xatt_create_cmd_prompt",(caddr_t)create_cmd_prompt },
{"xatt_create_cmd_input",(caddr_t)create_cmd_input },
{"xatt_create_cmd_scrolledinput",(caddr_t)create_cmd_scrolledinput },
{"xatt_create_cmd_scrolled_ok",(caddr_t)create_cmd_scrolled_ok },
{"xatt_create_cmd_scrolled_ca",(caddr_t)create_cmd_scrolled_ca },
{"xatt_create_xattnav_form",(caddr_t)create_xattnav_form },
{"xatt_activate_cmd_scrolledinput",(caddr_t)activate_cmd_input },
{"xatt_activate_cmd_scrolled_ok",(caddr_t)activate_cmd_scrolled_ok },
{"xatt_activate_cmd_scrolled_ca",(caddr_t)activate_cmd_scrolled_ca }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
// for ( i = 0; i < int(sizeof(value_recall)/sizeof(value_recall[0])); i++)
// value_recall[i][0] = 0;
Lng::get_uid( uid_filename, uid_filename);
// Create object context
// attrctx->close_cb = close_cb;
// attrctx->redraw_cb = redraw_cb;
// Motif
MrmInitialize();
*xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
cdh_StrncpyCutOff( title, title, 100, 1);
reglist[0].value = (caddr_t) this;
// Save the context structure in the widget
i = 0;
XtSetArg (args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "xatt_window", parent_wid,
name, args, 1, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
if (compiled_translations == NULL)
XtAppAddActions( XtWidgetToApplicationContext(toplevel),
actions, XtNumber(actions));
if (compiled_translations == NULL)
compiled_translations = XtParseTranslationTable(translations);
XtOverrideTranslations( toplevel, compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,420);i++;
XtSetArg(args[i],XmNheight,600);i++;
XtSetValues( toplevel ,args,i);
XtManageChild( toplevel);
XtUnmanageChild( cmd_input);
XtUnmanageChild( cmd_scrolledinput);
XtUnmanageChild( cmd_scrolled_ok);
XtUnmanageChild( cmd_scrolled_ca);
xattnav = new XAttNavMotif( (void *)this, xattnav_form, xattnav_eType_Object,
"Plant", &objar, xa_advanced_user, &brow_widget, &sts);
xattnav->message_cb = &message_cb;
xattnav->change_value_cb = &change_value_cb;
xattnav->popup_menu_cb = &xatt_popup_menu_cb;
xattnav->is_authorized_cb = &xatt_is_authorized_cb;
XtPopup( parent_wid, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid,
(XtCallbackProc)activate_exit, this);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xatt_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xatt_motif_h
#define xtt_xatt_motif_h
/* xtt_xatt_motif.h -- Object attribute editor */
#ifndef xtt_xatt_h
# include "xtt_xatt.h"
#endif
class XAttMotif : public XAtt {
public:
XAttMotif (
Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts);
~XAttMotif();
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
Widget msg_label;
Widget cmd_prompt;
Widget cmd_input;
Widget cmd_scrolledinput;
Widget cmd_scrolled_ok;
Widget cmd_scrolled_ca;
Widget xattnav_form;
int set_focus_disabled;
XtIntervalId focus_timerid;
static char value_recall[30][160];
int value_current_recall;
void message( char severity, char *message);
void set_prompt( char *prompt);
void change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
static void activate_change_value( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_close_changeval( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_exit( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_display_object( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_show_cross( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_open_classgraph( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_open_plc( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_help( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_msg_label( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_cmd_prompt( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_cmd_input( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_cmd_scrolledinput( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_cmd_scrolled_ok( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_cmd_scrolled_ca( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void create_xattnav_form( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void enable_set_focus( XAttMotif *xatt);
static void disable_set_focus( XAttMotif *xatt, int time);
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void valchanged_cmd_input( Widget w, XEvent *event);
static void activate_cmd_input( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_cmd_scrolled_ok( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
static void activate_cmd_scrolled_ca( Widget w, XAtt *xatt, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_xattnav_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* wb_xattnav.cpp -- Display object info */
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_xatt_msg.h"
#include "rt_mh_net.h"
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "xtt_xatt.h"
#include "xtt_xattnav_motif.h"
#include "xtt_xnav.h"
#include "xtt_xnav_brow.h"
#include "xtt_xnav_crr.h"
#include "xtt_item.h"
#include "pwr_privilege.h"
#include "co_wow_motif.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
//
// Create the navigator widget
//
XAttNavMotif::XAttNavMotif(
void *xa_parent_ctx,
Widget xa_parent_wid,
xattnav_eType xa_type,
char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
Widget *w,
pwr_tStatus *status) :
XAttNav( xa_parent_ctx, xa_type, xa_name, xa_objar, xa_advanced_user, status),
parent_wid(xa_parent_wid)
{
form_widget = ScrolledBrowCreate( parent_wid, name, NULL, 0,
init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
// Create the root item
*w = form_widget;
wow = new CoWowMotif( form_widget);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
XAttNavMotif::~XAttNavMotif()
{
if ( trace_started)
trace_timerid->remove();
delete trace_timerid;
delete wow;
delete brow;
XtDestroyWidget( form_widget);
}
void XAttNavMotif::set_inputfocus()
{
// brow_SetInputFocus( brow->ctx);
if ( !displayed)
return;
XtCallAcceptFocus( brow_widget, CurrentTime);
}
void XAttNavMotif::popup_position( int x_event, int y_event, int *x, int *y)
{
CoWowMotif::PopupPosition( brow_widget, x_event, y_event, x, y);
}
/*
* Proview $Id: xtt_xattnav_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xattnav_motif_h
#define xtt_xattnav_motif_h
/* wb_xattnav_motif.h -- */
#ifndef xtt_xattnav_h
# include "xtt_xattnav.h"
#endif
class XAttNavMotif : public XAttNav {
public:
XAttNavMotif(
void *xa_parent_ctx,
Widget xa_parent_wid,
xattnav_eType xa_type,
char *xa_name,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
Widget *w,
pwr_tStatus *status);
~XAttNavMotif();
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
void popup_position( int x_event, int y_event, int *x, int *y);
void set_inputfocus();
};
#endif
/*
* Proview $Id: xtt_xattone_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xattone.cpp -- Display object attributes */
#if defined OS_VMS && defined __ALPHA
# pragma message disable (NOSIMPINT,EXTROUENCUNNOBJ)
#endif
#if defined OS_VMS && !defined __ALPHA
# pragma message disable (LONGEXTERN)
#endif
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "flow_x.h"
#include "rt_xnav_msg.h"
#include "co_mrm_util.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_lng.h"
#include "xtt_xattone_motif.h"
#include "xtt_xattnav.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
#include "pwr_privilege.h"
// Static member elements
char XAttOneMotif::value_recall[30][160];
void XAttOneMotif::message( char severity, char *message)
{
Arg args[2];
XmString cstr;
cstr=XmStringCreateLtoR( message, "ISO8859-1");
XtSetArg(args[0],XmNlabelString, cstr);
XtSetArg(args[1],XmNheight, 20);
XtSetValues( msg_label, args, 2);
XmStringFree( cstr);
}
void XAttOneMotif::set_prompt( char *prompt)
{
Arg args[3];
XmString cstr;
cstr=XmStringCreateLtoR( prompt, "ISO8859-1");
XtSetArg(args[0],XmNlabelString, cstr);
XtSetArg(args[1],XmNwidth, 50);
XtSetArg(args[2],XmNheight, 30);
XtSetValues( cmd_prompt, args, 3);
XmStringFree( cstr);
}
int XAttOneMotif::set_value()
{
char *text;
int sts;
char buff[1024];
if ( input_open) {
if ( input_multiline)
text = XmTextGetString( cmd_scrolledinput);
else
text = XmTextGetString( cmd_input);
sts = XNav::attr_string_to_value( atype, text, buff, sizeof(buff),
asize);
if ( EVEN(sts)) {
message( 'E', "Input syntax error");
return sts;
}
sts = gdh_SetObjectInfoAttrref( &aref, buff, asize);
if ( EVEN(sts)) {
message( 'E', "Unable to set value");
return sts;
}
message( ' ', "");
}
return XATT__SUCCESS;
}
int XAttOneMotif::change_value( int set_focus)
{
int sts;
Widget text_w;
char *value = 0;
Arg args[5];
int input_size;
char aval[1024];
char buf[1024];
int len;
sts = gdh_GetAttributeCharAttrref( &aref, &atype, &asize, &aoffs, &aelem);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aref, aval, sizeof(aval));
if ( EVEN(sts)) return sts;
XNav::attrvalue_to_string( atype, atype, &aval, buf, sizeof(buf), &len, NULL);
value = buf;
if ( !access_rw) {
XmString cstr;
cstr=XmStringCreateLtoR( aval, "ISO8859-1");
XtSetArg(args[0],XmNlabelString, cstr);
XtSetValues( cmd_label, args, 1);
XmStringFree( cstr);
}
else {
if ( atype == pwr_eType_Text) {
input_multiline = 1;
text_w = cmd_scrolledinput;
XtUnmanageChild( cmd_input);
XtManageChild( text_w);
XtManageChild( cmd_scrolled_ok);
XtManageChild( cmd_scrolled_ca);
// XtSetArg(args[0], XmNpaneMaximum, 300);
// XtSetValues( xattnav_form, args, 1);
XtSetArg(args[0], XmNmaxLength, input_size-1);
XtSetValues( text_w, args, 1);
if ( value) {
XmTextSetString( text_w, value);
// XmTextSetInsertionPosition( text_w, strlen(value));
}
else
XmTextSetString( text_w, "");
input_multiline = 1;
}
else {
input_multiline = 0;
text_w = cmd_input;
XtSetArg(args[0],XmNmaxLength, input_size-1);
XtSetValues( text_w, args, 1);
if ( value) {
XmTextSetString( text_w, value);
XmTextSetInsertionPosition( text_w, strlen(value));
}
else
XmTextSetString( text_w, "");
input_multiline = 0;
}
message( ' ', "");
if ( set_focus)
flow_SetInputFocus( text_w);
set_prompt( Lng::translate("value >"));
input_open = 1;
}
return XATT__SUCCESS;
}
//
// Callbackfunctions from menu entries
//
void XAttOneMotif::activate_exit( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
void XAttOneMotif::activate_help( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
// Not yet implemented
}
void XAttOneMotif::create_msg_label( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->msg_label = w;
}
void XAttOneMotif::create_cmd_prompt( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_prompt = w;
}
void XAttOneMotif::create_cmd_label( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_label = w;
}
void XAttOneMotif::create_cmd_input( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
Arg args[2];
XtSetArg (args[0], XmNuserData, xattone);
XtSetValues (w, args, 1);
((XAttOneMotif *)xattone)->cmd_input = w;
#if 0
if ( !(xattone->is_authorized_cb) ||
(!(xattone->is_authorized_cb) &&
!(xattone->is_authorized_cb( xattone->parent_ctx,
pwr_mAccess_RtWrite | pwr_mAccess_System))))
#endif
mrm_TextInit( w, (XtActionProc) valchanged_cmd_input, mrm_eUtility_XAttOne);
}
void XAttOneMotif::create_cmd_scrolledinput( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_scrolledinput = w;
}
void XAttOneMotif::create_cmd_scrolled_ok( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_scrolled_ok = w;
}
void XAttOneMotif::create_cmd_scrolled_ap( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_scrolled_ap = w;
}
void XAttOneMotif::create_cmd_scrolled_ca( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
((XAttOneMotif *)xattone)->cmd_scrolled_ca = w;
}
void XAttOneMotif::enable_set_focus( XAttOneMotif *xattone)
{
xattone->set_focus_disabled--;
}
void XAttOneMotif::disable_set_focus( XAttOneMotif *xattone, int time)
{
xattone->set_focus_disabled++;
xattone->focus_timerid = XtAppAddTimeOut(
XtWidgetToApplicationContext( xattone->toplevel), time,
(XtTimerCallbackProc)enable_set_focus, xattone);
}
void XAttOneMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
XAttOneMotif *xattone;
XtSetArg (args[0], XmNuserData, &xattone);
XtGetValues (w, args, 1);
if ( !xattone)
return;
if ( mrm_IsIconicState(w))
return;
if ( xattone->set_focus_disabled)
return;
if ( flow_IsManaged( xattone->cmd_scrolledinput))
flow_SetInputFocus( xattone->cmd_scrolledinput);
else if ( flow_IsManaged( xattone->cmd_input))
flow_SetInputFocus( xattone->cmd_input);
disable_set_focus( xattone, 400);
}
void XAttOneMotif::valchanged_cmd_input( Widget w, XEvent *event)
{
XAttOneMotif *xattone;
int sts;
Arg args[2];
XtSetArg(args[0], XmNuserData, &xattone);
XtGetValues(w, args, 1);
sts = mrm_TextInput( w, event, (char *)value_recall, sizeof(value_recall[0]),
sizeof( value_recall)/sizeof(value_recall[0]),
&xattone->value_current_recall);
if ( sts) {
sts = xattone->set_value();
if ( ODD(sts)) {
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
}
}
void XAttOneMotif::change_value_close()
{
set_value();
}
void XAttOneMotif::activate_cmd_input( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
}
void XAttOneMotif::activate_cmd_scrolled_ok( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
int sts;
sts = xattone->set_value();
if ( ODD(sts)) {
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
}
void XAttOneMotif::activate_cmd_scrolled_ap( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
xattone->set_value();
}
void XAttOneMotif::activate_cmd_scrolled_ca( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data)
{
if ( xattone->close_cb)
(xattone->close_cb)( xattone->parent_ctx, xattone);
else
delete xattone;
}
void XAttOneMotif::pop()
{
flow_UnmapWidget( parent_wid);
flow_MapWidget( parent_wid);
}
XAttOneMotif::~XAttOneMotif()
{
if ( set_focus_disabled)
XtRemoveTimeOut( focus_timerid);
XtDestroyWidget( parent_wid);
}
XAttOneMotif::XAttOneMotif( Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_aref,
char *xa_title,
unsigned int xa_priv,
int *xa_sts) :
XAttOne( xa_parent_ctx, xa_aref, xa_title, xa_priv, xa_sts),
parent_wid(xa_parent_wid), set_focus_disabled(0), value_current_recall(0)
{
char uid_filename[120] = {"xtt_xattone.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
pwr_tAName title;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char name[] = "Proview/R Navigator";
static char translations[] =
"<FocusIn>: xao_inputfocus()\n";
static XtTranslations compiled_translations = NULL;
static XtActionsRec actions[] =
{
{"xao_inputfocus", (XtActionProc) action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "xao_ctx", 0 },
{"xao_activate_exit",(caddr_t)activate_exit },
{"xao_activate_help",(caddr_t)activate_help },
{"xao_create_msg_label",(caddr_t)create_msg_label },
{"xao_create_cmd_prompt",(caddr_t)create_cmd_prompt },
{"xao_create_cmd_input",(caddr_t)create_cmd_input },
{"xao_create_cmd_label",(caddr_t)create_cmd_label },
{"xao_create_cmd_scrolledinput",(caddr_t)create_cmd_scrolledinput },
{"xao_create_cmd_scrolled_ok",(caddr_t)create_cmd_scrolled_ok },
{"xao_create_cmd_scrolled_ap",(caddr_t)create_cmd_scrolled_ap },
{"xao_create_cmd_scrolled_ca",(caddr_t)create_cmd_scrolled_ca },
{"xao_activate_cmd_scrolledinput",(caddr_t)activate_cmd_input },
{"xao_activate_cmd_scrolled_ok",(caddr_t)activate_cmd_scrolled_ok },
{"xao_activate_cmd_scrolled_ap",(caddr_t)activate_cmd_scrolled_ap },
{"xao_activate_cmd_scrolled_ca",(caddr_t)activate_cmd_scrolled_ca }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
// for ( i = 0; i < int(sizeof(value_recall)/sizeof(value_recall[0])); i++)
// value_recall[i][0] = 0;
Lng::get_uid( uid_filename, uid_filename);
// Create object context
// attrctx->close_cb = close_cb;
// attrctx->redraw_cb = redraw_cb;
// Motif
MrmInitialize();
*xa_sts = gdh_AttrrefToName( &aref, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
reglist[0].value = (caddr_t) this;
// Save the context structure in the widget
i = 0;
XtSetArg (args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "xao_window", parent_wid,
name, args, 1, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
if (compiled_translations == NULL)
XtAppAddActions( XtWidgetToApplicationContext(toplevel),
actions, XtNumber(actions));
if (compiled_translations == NULL)
compiled_translations = XtParseTranslationTable(translations);
XtOverrideTranslations( toplevel, compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,420);i++;
XtSetArg(args[i],XmNheight,120);i++;
XtSetValues( toplevel ,args,i);
if ( priv & pwr_mPrv_RtWrite || priv & pwr_mPrv_System)
access_rw = 1;
else
access_rw = 0;
XtManageChild( toplevel);
if ( access_rw)
XtUnmanageChild( cmd_label);
else {
XtUnmanageChild( cmd_input);
XtUnmanageChild( cmd_scrolled_ok);
XtUnmanageChild( cmd_scrolled_ap);
}
XtUnmanageChild( cmd_scrolledinput);
XtPopup( parent_wid, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid,
(XtCallbackProc)activate_exit, this);
change_value( 1);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xattone_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xattone_motif_h
#define xtt_xattone_motif_h
/* xtt_xattone_motif.h -- Single attribute editor */
#ifndef xtt_xattone_h
# include "xtt_xattone.h"
#endif
class XAttOneMotif : public XAttOne {
public:
XAttOneMotif( Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
char *xa_title,
unsigned int xa_priv,
int *xa_sts);
~XAttOneMotif();
Widget parent_wid;
Widget form_widget;
Widget toplevel;
Widget msg_label;
Widget cmd_prompt;
Widget cmd_label;
Widget cmd_input;
Widget cmd_scrolledinput;
Widget cmd_scrolled_ok;
Widget cmd_scrolled_ap;
Widget cmd_scrolled_ca;
int set_focus_disabled;
XtIntervalId focus_timerid;
static char value_recall[30][160];
int value_current_recall;
void message( char severity, char *message);
void set_prompt( char *prompt);
int change_value( int set_focus);
int open_changevalue( char *name);
void change_value_close();
void pop();
void swap( int mode);
int set_value();
static void activate_exit( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void activate_help( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_msg_label( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_prompt( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_label( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_input( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_scrolledinput( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_scrolled_ok( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_scrolled_ap( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void create_cmd_scrolled_ca( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void enable_set_focus( XAttOneMotif *xattone);
static void disable_set_focus( XAttOneMotif *xattone, int time);
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void valchanged_cmd_input( Widget w, XEvent *event);
static void activate_cmd_input( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void activate_cmd_scrolled_ok( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void activate_cmd_scrolled_ap( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
static void activate_cmd_scrolled_ca( Widget w, XAttOne *xattone, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_xcrr_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xcrr_motif.cpp -- Display object crossreferences */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "flow_x.h"
#include "rt_xnav_msg.h"
#include "co_mrm_util.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "xtt_xcrr_motif.h"
#include "xtt_xattnav_motif.h"
#include "co_lng.h"
#include "xtt_xnav.h"
#include "rt_xatt_msg.h"
void XCrrMotif::activate_exit( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data)
{
if ( xcrr->close_cb)
(xcrr->close_cb)( xcrr->parent_ctx, (void *)xcrr);
else
delete xcrr;
}
void XCrrMotif::activate_openplc( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data)
{
xcrr->xcrrnav->start_trace();
}
void XCrrMotif::activate_help( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data)
{
// Not yet implemented
}
void XCrrMotif::create_xcrrnav_form( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data)
{
((XCrrMotif *)xcrr)->xcrrnav_form = w;
}
void XCrrMotif::enable_set_focus( XCrrMotif *xcrr)
{
xcrr->set_focus_disabled--;
}
void XCrrMotif::disable_set_focus( XCrrMotif *xcrr, int time)
{
xcrr->set_focus_disabled++;
xcrr->focus_timerid = XtAppAddTimeOut(
XtWidgetToApplicationContext( xcrr->toplevel), time,
(XtTimerCallbackProc)enable_set_focus, xcrr);
}
void XCrrMotif::action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
XCrrMotif *xcrr;
XtSetArg (args[0], XmNuserData, &xcrr);
XtGetValues (w, args, 1);
if ( !xcrr)
return;
if ( mrm_IsIconicState(w))
return;
if ( xcrr->set_focus_disabled)
return;
if ( xcrr->xcrrnav)
xcrr->xcrrnav->set_inputfocus();
disable_set_focus( xcrr, 400);
}
void XCrrMotif::pop()
{
flow_UnmapWidget( parent_wid);
flow_MapWidget( parent_wid);
}
XCrrMotif::~XCrrMotif()
{
if ( set_focus_disabled)
XtRemoveTimeOut( focus_timerid);
delete xcrrnav;
XtDestroyWidget( parent_wid);
}
XCrrMotif::XCrrMotif(
Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
XCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
parent_wid(xa_parent_wid), set_focus_disabled(0)
{
char uid_filename[120] = {"xtt_xcrr.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
pwr_tAName title;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
char name[] = "Proview/R Navigator";
static char translations[] =
"<FocusIn>: xcrr_inputfocus()\n";
static XtTranslations compiled_translations = NULL;
static XtActionsRec actions[] =
{
{"xcrr_inputfocus", (XtActionProc) action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "xcrr_ctx", 0 },
{"xcrr_activate_exit",(caddr_t)activate_exit },
{"xcrr_activate_openplc",(caddr_t)activate_openplc },
{"xcrr_activate_help",(caddr_t)activate_help },
{"xcrr_create_xcrrnav_form",(caddr_t)create_xcrrnav_form }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
Lng::get_uid( uid_filename, uid_filename);
// Motif
MrmInitialize();
*xa_sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(*xa_sts)) return;
reglist[0].value = (caddr_t) this;
// Save the context structure in the widget
i = 0;
XtSetArg (args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg( args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid = XtCreatePopupShell( title,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "xcrr_window", parent_wid,
name, args, 1, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", name);
MrmCloseHierarchy(s_DRMh);
if (compiled_translations == NULL)
XtAppAddActions( XtWidgetToApplicationContext(toplevel),
actions, XtNumber(actions));
if (compiled_translations == NULL)
compiled_translations = XtParseTranslationTable(translations);
XtOverrideTranslations( toplevel, compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,420);i++;
XtSetArg(args[i],XmNheight,300);i++;
XtSetValues( toplevel ,args,i);
XtManageChild( toplevel);
xcrrnav = new XAttNavMotif( (void *)this, xcrrnav_form, xattnav_eType_CrossRef,
"Plant", &objar, xa_advanced_user, &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;
XtPopup( parent_wid, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid,
(XtCallbackProc)activate_exit, this);
*xa_sts = XATT__SUCCESS;
}
/*
* Proview $Id: xtt_xcrr_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xcrr_motif_h
#define xtt_xcrr_motif_h
/* xtt_xcrr_motif.h -- Object crossreferences */
#ifndef xtt_xcrr_h
# include "xtt_xcrr.h"
#endif
class XCrrMotif : public XCrr {
public:
XCrrMotif(
Widget xa_parent_wid,
void *xa_parent_ctx,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts);
~XCrrMotif();
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
Widget xcrrnav_form;
int set_focus_disabled;
XtIntervalId focus_timerid;
void pop();
static void activate_exit( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data);
static void activate_openplc( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data);
static void activate_help( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data);
static void create_xcrrnav_form( Widget w, XCrr *xcrr, XmAnyCallbackStruct *data);
static void enable_set_focus( XCrrMotif *xcrr);
static void disable_set_focus( XCrrMotif *xcrr, int time);
static void action_inputfocus( Widget w, XmAnyCallbackStruct *data);
};
#endif
/*
* Proview $Id: xtt_xnav_motif.cpp,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* xtt_xnav_motif.cpp -- Display plant and node hierarchy */
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include "co_nav_help.h"
extern "C" {
#include "pwr_privilege.h"
#include "rt_gdh.h"
#include "rt_gdb.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_api.h"
#include "co_msg.h"
#include "pwr_baseclasses.h"
#include "rt_xnav_msg.h"
}
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <Xm/CascadeBG.h>
#include <Xm/MessageB.h>
#include <Xm/PushBG.h>
#include <Xm/RowColumn.h>
#include <Xm/SelectioB.h>
#include <Xm/SeparatoG.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_motif.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "flow_x.h"
#include "rt_trace_motif.h"
#include "co_mrm_util.h"
#include "co_lng.h"
#include "co_error.h"
#include "co_xhelp.h"
#include "co_wow_motif.h"
#include "xtt_xnav_motif.h"
#include "xtt_item.h"
#include "xtt_menu.h"
#include "xtt_xatt_motif.h"
#include "xtt_xcrr_motif.h"
#include "xtt_ge_motif.h"
#include "xtt_block_motif.h"
#include "xtt_trend_motif.h"
#include "xtt_fast_motif.h"
#include "xtt_xattone_motif.h"
#include "xtt_clog_motif.h"
#include "xtt_ev_motif.h"
#include "xtt_op_motif.h"
#include "xtt_hist_motif.h"
#include "ge_curve_motif.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
//
// Create the navigator widget
//
XNavMotif::XNavMotif( void *xn_parent_ctx,
Widget xn_parent_wid,
char *xn_name,
Widget *w,
xnav_sStartMenu *root_menu,
char *xn_opplace_name,
pwr_tStatus *status) :
XNav( xn_parent_ctx, xn_name, root_menu, xn_opplace_name, status),
parent_wid(xn_parent_wid)
{
form_widget = ScrolledBrowCreate( parent_wid, name, NULL, 0,
init_brow_base_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
displayed = 1;
// Create the root item
*w = form_widget;
menu_tree_build( root_menu);
gbl.load_config( this);
for ( int i = 0; i < XNAV_LOGG_MAX; i++)
logg[i].init( i, (void *)this);
wow = new CoWowMotif( parent_wid);
trace_timerid = wow->timer_new();
*status = 1;
}
//
// Delete a nav context
//
XNavMotif::~XNavMotif()
{
closing_down = 1;
if ( mcp) {
free( mcp);
mcp = 0;
}
menu_tree_free();
for ( int i = 0; i < brow_cnt; i++) {
brow_DeleteSecondaryCtx( brow_stack[i]->ctx);
brow_stack[i]->free_pixmaps();
delete brow_stack[i];
}
brow_DeleteSecondaryCtx( collect_brow->ctx);
collect_brow->free_pixmaps();
delete collect_brow;
delete brow;
if ( op)
delete op;
XtDestroyWidget( form_widget);
}
void XNavMotif::set_inputfocus()
{
// printf( "%d XNav inputfocus %d\n", displayed, (int) brow_widget);
if ( displayed) {
XtCallAcceptFocus( brow_widget, CurrentTime);
}
// brow_SetInputFocus( brow->ctx);
}
void XNavMotif::create_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller, unsigned int priv,
char *arg, int x, int y)
{
int x1, y1;
CoWowMotif::PopupPosition( brow_widget, x + 8, y, &x1, &y1);
get_popup_menu( attrref, item_type, caller, priv, arg, x1, y1);
}
//
// Pop xnav window
//
static Boolean set_displayed( void *xnav)
{
((XNav *)xnav)->displayed = 1;
return True;
}
void XNavMotif::pop()
{
Widget parent, top;
parent = XtParent( parent_wid);
while( parent)
{
top = parent;
if ( flow_IsShell( top))
break;
parent = XtParent( parent);
}
displayed = 0;
flow_UnmapWidget( top);
flow_MapWidget( top);
// A fix to avoid a krash in setinputfocus
XtAppAddWorkProc( XtWidgetToApplicationContext(top),
(XtWorkProc)set_displayed, (XtPointer)this);
}
RtTrace *XNavMotif::plctrace_new( pwr_tOid oid, pwr_tStatus *sts)
{
return new RtTraceMotif( this, form_widget, oid, sts);
}
XAtt *XNavMotif::xatt_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
{
return new XAttMotif( form_widget, this, arp, advanced_user, sts);
}
XCrr *XNavMotif::xcrr_new( pwr_tAttrRef *arp, int advanced_user, pwr_tStatus *sts)
{
return new XCrrMotif( form_widget, this, arp, advanced_user, sts);
}
Ev *XNavMotif::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,
int ev_beep, pwr_tStatus *status)
{
return new EvMotif( this, parent_wid, eve_name, ala_name, blk_name,
ev_user, display_ala, display_eve, display_blk,
display_return, display_ack, ev_beep, status);
}
Hist *XNavMotif::hist_new( char *title, pwr_tOid oid, pwr_tStatus *sts)
{
return new HistMotif( this, parent_wid, title, oid, sts);
}
Block *XNavMotif::block_new( pwr_tAttrRef *arp, char *name, unsigned int priv,
pwr_tStatus *sts)
{
return new BlockMotif( this, parent_wid, arp, name, priv, sts);
}
Op *XNavMotif::op_new( char *opplace, pwr_tStatus *sts)
{
return new OpMotif( this, parent_wid, opplace, sts);
}
XttTrend *XNavMotif::xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts)
{
Widget w;
return new XttTrendMotif( this, parent_wid, name, &w, objar, plotgroup, sts);
}
XttFast *XNavMotif::xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts)
{
Widget w;
return new XttFastMotif( this, parent_wid, name, &w, objar, sts);
}
XAttOne *XNavMotif::xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts)
{
return new XAttOneMotif( parent_wid, this, objar, title, priv, sts);
}
CLog *XNavMotif::clog_new( char *name, pwr_tStatus *sts)
{
return new CLogMotif( this, parent_wid, name, sts);
}
XttGe *XNavMotif::xnav_ge_new( char *name, char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*command_cb) (XttGe *, char *),
int (*get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*is_authorized_cb) (void *, unsigned int))
{
return new XttGeMotif( parent_wid, this, name, filename, scrollbar, menu, navigator,
width, height, x, y, scan_time, object_name, use_default_access,
access, command_cb, get_current_objects_cb, is_authorized_cb);
}
GeCurve *XNavMotif::gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right)
{
return new GeCurveMotif( this, parent_wid, name, filename, data, pos_right);
}
void XNavMotif::bell( int time)
{
XBell( flow_Display( brow_widget), time);
}
void XNavMotif::get_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller,
unsigned int priv, char *arg, int x, int y)
{
int i;
Widget popup;
Arg args[2];
get_popup_menu_items( attrref, item_type, caller, priv, arg);
i = 0;
popup = build_menu( parent_wid, MENU_POPUP, "", mcp,
popup_button_cb, (void *) this,
(xmenu_sMenuItem *) mcp->ItemList, &i);
if (popup != NULL)
XtAddCallback( popup, XmNunmapCallback,
(XtCallbackProc)popup_unmap_cb, mcp);
XtSetArg(args[0], XmNx, x);
XtSetArg(args[1], XmNy, y);
XtSetValues( popup, args, 2);
XtManageChild(popup);
}
Widget XNavMotif::build_menu( Widget Parent,
int MenuType,
char *MenuTitle,
void *MenuUserData,
void (*Callback)( Widget, XNav *, XmAnyCallbackStruct *),
void *CallbackData,
xmenu_sMenuItem *Items,
int *idx)
{
Widget Menu, Cascade, W;
int i;
unsigned int Level;
XmString Str;
WidgetClass Class;
Arg ArgList[5];
XmFontList fontlist;
XFontStruct *font;
XmFontListEntry fontentry;
// Set default fontlist
font = XLoadQueryFont( flow_Display(Parent),
"-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
fontentry = XmFontListEntryCreate( "tag1", XmFONT_IS_FONT, font);
fontlist = XmFontListAppendEntry( NULL, fontentry);
XtFree( (char *)fontentry);
i = 0;
XtSetArg(ArgList[i], XmNuserData, MenuUserData); i++;
XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
if (MenuType == MENU_PULLDOWN || MenuType == MENU_OPTION)
Menu = XmCreatePulldownMenu(Parent, "_pulldown", ArgList, i);
else if (MenuType == MENU_POPUP)
Menu = XmCreatePopupMenu(Parent, "_popup", ArgList, i);
else {
XtWarning("Invalid menu type passed to BuildMenu().");
return NULL;
}
if (MenuType == MENU_PULLDOWN) {
Str = XmStringCreateSimple(MenuTitle);
Cascade = XtVaCreateManagedWidget(MenuTitle,
xmCascadeButtonGadgetClass, Parent,
XmNsubMenuId, Menu,
XmNlabelString, Str,
NULL);
XmStringFree(Str);
}
else if (MenuType == MENU_OPTION) {
Str = XmStringCreateSimple(MenuTitle);
XtSetArg(ArgList[0], XmNsubMenuId, Menu);
XtSetArg(ArgList[1], XmNlabelString, Str);
Cascade = XmCreateOptionMenu(Parent, MenuTitle, ArgList, 2);
XmStringFree(Str);
}
XmFontListFree( fontlist);
Level = Items[*idx].Level;
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
if (Items[*idx].Item == xmenu_eMenuItem_Cascade ||
Items[*idx].Item == xmenu_eMenuItem_Ref) {
if (MenuType == MENU_OPTION) {
XtWarning("You can't have submenus from option menu items.");
return NULL;
}
else {
i = *idx;
(*idx)++;
build_menu(Menu, MENU_PULLDOWN,
Lng::translate( Items[i].Name), MenuUserData,
Callback, CallbackData, Items, idx);
(*idx)--;
}
}
else {
if (Items[*idx].Item == xmenu_eMenuItem_Separator)
Class = xmSeparatorGadgetClass;
else
Class = xmPushButtonGadgetClass;
W = XtVaCreateManagedWidget(Lng::translate( Items[*idx].Name),
Class, Menu,
XmNuserData, *idx,
XmNsensitive, (Boolean)(Items[*idx].Flags.f.Sensitive == 1),
NULL);
if (Callback && Class == xmPushButtonGadgetClass)
XtAddCallback(W, XmNactivateCallback, (XtCallbackProc) Callback,
(XtPointer) CallbackData);
}
}
return MenuType == MENU_POPUP ? Menu : Cascade;
}
void XNavMotif::popup_unmap_cb(Widget w, xmenu_sMenuCall *ip, XmAnyCallbackStruct *data)
{
// XtFree( (char *)ip);
XtDestroyWidget(w);
}
void XNavMotif::popup_button_cb( Widget w, XNav *xnav, XmAnyCallbackStruct *data)
{
Widget menu;
int idx;
pwr_tStatus sts;
// Find the menu widget
menu = XtParent(w);
while (1) {
if (strcmp(XtName(menu), "_popup") == 0 ||
strcmp(XtName(menu), "_pulldown") == 0)
break;
menu = XtParent(menu);
}
XtVaGetValues (w, XmNuserData, &idx, NULL);
mcp->ChosenItem = idx;
// xnav->set_clock_cursor();
sts = CallMenuMethod( mcp, mcp->ChosenItem);
if (EVEN(sts))
xnav->message( 'E', XNav::get_message(sts));
// xnav->reset_cursor();
}
/*
* Proview $Id: xtt_xnav_motif.h,v 1.1 2007-01-04 08:30:03 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* 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 the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef xtt_xnav_motif_h
#define xtt_xnav_motif_h
/* xtt_xnav_motif.h -- Simple navigator */
#ifndef xtt_xnav_h
# include "xtt_xnav.h"
#endif
class XNavMotif : public XNav {
public:
XNavMotif(
void *xn_parent_ctx,
Widget xn_parent_wid,
char *xn_name,
Widget *w,
xnav_sStartMenu *root_menu,
char *xn_opplace_name,
pwr_tStatus *status);
~XNavMotif();
void set_inputfocus();
void pop();
void create_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller, unsigned int priv,
char *arg, int x, int y);
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);
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,
int ev_beep, pwr_tStatus *status);
Hist *hist_new( char *title, pwr_tOid oid, pwr_tStatus *sts);
Block *block_new( pwr_tAttrRef *arp, char *name, unsigned int priv,
pwr_tStatus *sts);
Op *op_new( char *opplace, pwr_tStatus *sts);
XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts);
XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts);
XAttOne *xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts);
CLog *clog_new( char *name, pwr_tStatus *sts);
XttGe *xnav_ge_new( char *name, char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
double scan_time, char *object_name,
int use_default_access, unsigned int access,
int (*xg_command_cb) (XttGe *, char *),
int (*xg_get_current_objects_cb) (void *, pwr_sAttrRef **, int **),
int (*xg_is_authorized_cb) (void *, unsigned int));
GeCurve *gecurve_new( char *name, char *filename, GeCurveData *data,
int pos_right);
void bell( int time);
void get_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
xmenu_mUtility caller,
unsigned int priv, char *arg, int x, int y);
static Widget build_menu( Widget Parent,
int MenuType,
char *MenuTitle,
void *MenuUserData,
void (*Callback)( Widget, XNav *, XmAnyCallbackStruct *),
void *CallbackData,
xmenu_sMenuItem *Items,
int *idx);
static void popup_button_cb( Widget w, XNav *xnav, XmAnyCallbackStruct *data);
static void popup_unmap_cb(Widget w, xmenu_sMenuCall *ip, XmAnyCallbackStruct *data);
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
};
#endif
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