Commit 2591f944 authored by claes's avatar claes

New method toolbar in xtt

parent 6cbe0f8a
/*
* Proview $Id: rt_xtt_gtk.cpp,v 1.3 2007-01-11 11:40:30 claes Exp $
* Proview $Id: rt_xtt_gtk.cpp,v 1.4 2007-01-17 06:18:10 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -53,6 +53,7 @@
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "rt_syi.h"
#include "xtt_methodtoolbar_gtk.h"
void XttGtk::hotkey_Command( char *arg, void *userdata)
{
......@@ -469,6 +470,7 @@ XttGtk::~XttGtk()
delete cmd_recall;
delete value_recall;
delete hotkey;
delete methodtoolbar;
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer xtt)
......@@ -783,6 +785,10 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
g_signal_connect(tools_zoom_reset, "clicked", G_CALLBACK(activate_zoom_reset), this);
gtk_toolbar_append_widget( tools, tools_zoom_reset,CoWowGtk::translate_utf8("Zoom reset"), "");
// Toolbar
methodtoolbar = new XttMethodToolbarGtk(0);
GtkToolbar *tools2 = (GtkToolbar *) ((XttMethodToolbarGtk *)methodtoolbar)->build();
// Statusbar and cmd input
GtkWidget *statusbar = gtk_hbox_new( FALSE, 0);
msg_label = gtk_label_new( "");
......@@ -811,11 +817,15 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
xnav->map_cb = ↦
xnav->change_value_cb = &change_value;
xnav->set_dimension_cb = &set_dimension;
xnav->selection_changed_cb = &selection_changed;
xnav->attach_audio = attach_audio;
methodtoolbar->m_xnav = xnav;
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(tools), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools2), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(brow_widget), TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 3);
......@@ -856,6 +866,7 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
gdk_display_get_default(), i));
gdk_window_add_filter( root, xtt_hotkey_filter, hotkey);
}
methodtoolbar->set_sensitive();
xtt_mainloop();
......
/*
* Proview $Id: rt_xtt_main.h,v 1.1 2007-01-04 08:40:17 claes Exp $
* Proview $Id: rt_xtt_main.h,v 1.2 2007-01-17 06:18:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -45,6 +45,7 @@
class CoWow;
class CoWowTimer;
class XttMethodToolbar;
class Xtt {
public:
......@@ -61,6 +62,7 @@ class Xtt {
pwr_tOName opplace_str;
int quiet;
int attach_audio;
XttMethodToolbar *methodtoolbar;
Xtt( int argc, char *argv[], int *return_sts);
virtual ~Xtt() {}
......@@ -83,7 +85,8 @@ class Xtt {
static void xtt_message_cb( void *ctx, char severity, char *msg);
static void close_ok( void *ctx, void *data);
static void change_value( void *ctx);
static void selection_changed( void *ctx);
void activate_print();
void activate_find();
void activate_findregex();
......@@ -99,6 +102,7 @@ class Xtt {
void activate_help();
void activate_help_project();
void activate_help_proview();
void activate_method( char *method, char *filter);
static Xtt *hot_xtt;
static xnav_sStartMenu alarm_menu[];
......
/*
* Proview $Id: xtt_main.cpp,v 1.1 2007-01-04 08:40:17 claes Exp $
* Proview $Id: xtt_main.cpp,v 1.2 2007-01-17 06:18:11 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -42,11 +42,13 @@
#include "xtt_xnav.h"
#include "xtt_item.h"
#include "xtt_url.h"
#include "xtt_methodtoolbar.h"
#include "co_lng.h"
#include "co_xhelp.h"
#include "co_wow.h"
#include "rt_xnav_msg.h"
// Static variables
Xtt *Xtt::hot_xtt = 0;
......@@ -237,6 +239,13 @@ void Xtt::change_value( void *ctx)
xtt->open_change_value();
}
void Xtt::selection_changed( void *ctx)
{
Xtt *xtt = (Xtt *) ctx;
xtt->methodtoolbar->set_sensitive();
}
//
// Callbackfunctions from menu entries
//
......@@ -397,6 +406,29 @@ void Xtt::activate_zoom_out()
xnav->zoom( 1.0 / 1.18);
}
void Xtt::activate_method( char *method, char *filter)
{
int sts;
int is_attr;
pwr_sAttrRef aref;
xmenu_eItemType menu_type;
sts = xnav->get_select( &aref, &is_attr);
if ( aref.Flags.b.Object)
menu_type = xmenu_eItemType_Object;
else if ( aref.Flags.b.ObjectAttr)
menu_type = xmenu_eItemType_AttrObject;
else
menu_type = xmenu_eItemType_Attribute;
if ( ODD(sts))
xnav->call_method( method, filter, aref,
menu_type,
xmenu_mUtility_XNav,
xnav->priv, 0);
}
void Xtt::activate_help()
{
CoXHelp::dhelp("overview", "", navh_eHelpFile_Base, NULL, 0);
......
/*
* Proview $Id: xtt_methodtoolbar_gtk.cpp,v 1.1 2007-01-17 06:18:10 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_methodtoolbar_gtk.cpp -- Display method toolbar */
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_dcli.h"
#include "co_wow_gtk.h"
#include "xtt_xnav.h"
#include "xtt_methodtoolbar_gtk.h"
XttMethodToolbarGtk::XttMethodToolbarGtk( XNav *xnav) :
XttMethodToolbar(xnav)
{
for ( int i = 0; i < m_size; i++) {
m_cb[i].mt = this;
m_cb[i].idx = i;
}
}
void XttMethodToolbarGtk::activate_button( GtkWidget *w, gpointer data)
{
XttMethodToolbarGtk *mt = ((xtt_sMethodButtonCb *)data)->mt;
int idx = ((xtt_sMethodButtonCb *)data)->idx;
int sts;
int is_attr;
pwr_sAttrRef aref;
xmenu_eItemType menu_type;
sts = mt->m_xnav->get_select( &aref, &is_attr);
if ( aref.Flags.b.Object)
menu_type = xmenu_eItemType_Object;
else if ( aref.Flags.b.ObjectAttr)
menu_type = xmenu_eItemType_AttrObject;
else
menu_type = xmenu_eItemType_Attribute;
if ( ODD(sts))
mt->m_xnav->call_method( mt->m_data[idx].method, mt->m_data[idx].filter, aref,
menu_type,
xmenu_mUtility_XNav,
mt->m_xnav->priv, 0);
}
GtkWidget *XttMethodToolbarGtk::build()
{
pwr_tFileName fname;
// Toolbar
m_toolbar_w = (GtkWidget *) g_object_new(GTK_TYPE_TOOLBAR, NULL);
for ( int i = 0; i < m_size; i++) {
m_button_w[i] = gtk_button_new();
dcli_translate_filename( fname, m_data[i].image);
gtk_container_add( GTK_CONTAINER(m_button_w[i]),
gtk_image_new_from_file( fname));
g_signal_connect( m_button_w[i], "clicked", G_CALLBACK(activate_button), &m_cb[i]);
g_object_set( m_button_w[i], "can-focus", FALSE, NULL);
gtk_toolbar_append_widget( GTK_TOOLBAR(m_toolbar_w), m_button_w[i], CoWowGtk::translate_utf8( m_data[i].tooltip), "");
}
return m_toolbar_w;
}
void XttMethodToolbarGtk::set_sensitive()
{
int is_attr;
pwr_sAttrRef aref;
xmenu_eItemType menu_type;
pwr_tStatus sts;
sts = m_xnav->get_select( &aref, &is_attr);
if ( EVEN(sts)) {
// Nothing selected
for ( int i = 0; i < m_size; i++)
gtk_widget_set_sensitive( m_button_w[i], FALSE);
}
else {
if ( aref.Flags.b.Object)
menu_type = xmenu_eItemType_Object;
else if ( aref.Flags.b.ObjectAttr)
menu_type = xmenu_eItemType_AttrObject;
else
menu_type = xmenu_eItemType_Attribute;
for ( int i = 0; i < m_size; i++) {
sts = m_xnav->check_object_methodfilter( aref, menu_type, xmenu_mUtility_XNav,
m_xnav->priv, m_data[i].name);
if ( ODD(sts))
gtk_widget_set_sensitive( m_button_w[i], TRUE);
else
gtk_widget_set_sensitive( m_button_w[i], FALSE);
}
}
}
/*
* Proview $Id: xtt_methodtoolbar_gtk.h,v 1.1 2007-01-17 06:18:10 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_methodtoolbar_gtk_h
#define xtt_methodtoolbar_gtk_h
#include "xtt_methodtoolbar.h"
class XttMethodToolbarGtk;
typedef struct {
XttMethodToolbarGtk *mt;
int idx;
} xtt_sMethodButtonCb;
class XttMethodToolbarGtk : public XttMethodToolbar {
public:
GtkWidget *m_toolbar_w;
GtkWidget *m_button_w[m_size];
xtt_sMethodButtonCb m_cb[m_size];
XttMethodToolbarGtk( XNav *xnav);
GtkWidget *build();
void set_sensitive();
static void activate_button( GtkWidget *w, gpointer data);
};
#endif
/*
* Proview $Id: xtt_menu.cpp,v 1.12 2007-01-04 08:22:47 claes Exp $
* Proview $Id: xtt_menu.cpp,v 1.13 2007-01-17 06:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -489,6 +489,8 @@ int XNav::call_method( char *method, char *filter,
strcpy( mcp->Arg, arg);
sel_cnt = 1;
if ( mcp->Selected)
free( mcp->Selected);
mcp->Selected = (pwr_sAttrRef *) calloc( sel_cnt + 1, sizeof (pwr_sAttrRef));
mcp->Selected[0] = attrref;
mcp->Selected[sel_cnt].Objid = pwr_cNObjid;
......@@ -508,6 +510,9 @@ int XNav::call_method( char *method, char *filter,
sts = (method_func) ( mcp);
if ( EVEN(sts)) return sts;
free( mcp->Selected);
mcp->Selected = 0;
return XNAV__SUCCESS;
}
......@@ -536,6 +541,8 @@ int XNav::call_object_method( pwr_sAttrRef attrref,
mcp->SelectedSet = xmenu_eMenuSet_Object;
sel_cnt = 1;
if ( mcp->Selected)
free( mcp->Selected);
mcp->Selected = (pwr_sAttrRef *) calloc( sel_cnt + 1, sizeof (pwr_sAttrRef));
mcp->Selected[0] = attrref;
mcp->Selected[sel_cnt].Objid = pwr_cNObjid;
......@@ -589,6 +596,8 @@ int XNav::check_object_methodfilter( pwr_sAttrRef attrref,
mcp->SelectedSet = xmenu_eMenuSet_Object;
sel_cnt = 1;
if ( mcp->Selected)
free( mcp->Selected);
mcp->Selected = (pwr_sAttrRef *) calloc( sel_cnt + 1, sizeof (pwr_sAttrRef));
mcp->Selected[0] = attrref;
mcp->Selected[sel_cnt].Objid = pwr_cNObjid;
......@@ -642,6 +651,8 @@ void XNav::get_popup_menu_items( pwr_sAttrRef attrref,
strcpy( mcp->Arg, arg);
sel_cnt = 1;
if ( mcp->Selected)
free( mcp->Selected);
mcp->Selected = (pwr_sAttrRef *) calloc( sel_cnt + 1, sizeof (pwr_sAttrRef));
mcp->Selected[0] = attrref;
mcp->Selected[sel_cnt].Objid = pwr_cNObjid;
......
/*
* Proview $Id: xtt_methodtoolbar.cpp,v 1.1 2007-01-17 06:19:57 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_methodtoolbar.cpp -- Display method toolbar */
#include <stdio.h>
#include <stdlib.h>
#include "xtt_methodtoolbar.h"
xtt_sMethodButton XttMethodToolbar::m_data[XttMethodToolbar::m_size] =
{{"Help", "$Object-Help", "$Object-HelpFilter", "$pwr_exe/xtt_meth_help.png", "Help"},
{"Note", "$Object-Note", "$Object-NoteFilter", "$pwr_exe/xtt_meth_note.png", "Note"},
{"Trend", "$Object-OpenTrend", "$Object-OpenTrendFilter", "$pwr_exe/xtt_meth_trend.png", "Trend"},
{"Fast", "$Object-OpenFast", "$Object-OpenFastFilter", "$pwr_exe/xtt_meth_fast.png", "Fast"},
{"Graph", "$Object-OpenGraph", "$Object-OpenGraphFilter", "$pwr_exe/xtt_meth_graph.png", "Graph"},
{"Object Graph", "$Object-OpenObjectGraph","$Object-OpenObjectGraphFilter", "$pwr_exe/xtt_meth_classgraph.png", "Object Graph"},
{"Open Plc", "$Object-OpenTrace", "$Object-OpenTraceFilter", "$pwr_exe/xtt_meth_trace.png", "Open Plc"},
{"DataSheet", "$Object-DataSheet", "$Object-DataSheetFilter", "$pwr_exe/xtt_meth_datasheet.png", "DataSheet"},
{"Hist Event...", "$Object-HistEvent", "$Object-HistEventFilter", "$pwr_exe/xtt_meth_histevent.png", "Hist Event..."},
{"Block Events...", "$Object-BlockEvents", "$Object-BlockEventsFilter", "$pwr_exe/xtt_meth_block.png", "Block Events..."},
{"Open Object", "$Object-OpenObject", "$Object-OpenObjectFilter", "$pwr_exe/xtt_meth_openobject.png", "Open Object"},
{"Crossreferences", "$Object-OpenCrossref", "$Object-OpenCrossrefFilter", "$pwr_exe/xtt_meth_crossref.png", "Crossreferences"},
{"CircuitDiagram", "$Object-CircuitDiagram", "$Object-CircuitDiagramFilter", "$pwr_exe/xtt_meth_circuitdiagram.png", "CircuitDiagram"},
{"Help Class", "$Object-HelpClass", "$Object-HelpClassFilter", "$pwr_exe/xtt_meth_classhelp.png", "Help Class"}};
/*
* Proview $Id: xtt_methodtoolbar.h,v 1.1 2007-01-17 06:19:57 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_methodtoolbar_h
#define xtt_methodtoolbar_h
class XNav;
typedef struct {
char name[80];
char method[80];
char filter[80];
char image[80];
char tooltip[80];
} xtt_sMethodButton;
class XttMethodToolbar {
public:
static const int m_size = 14;
static xtt_sMethodButton m_data[m_size];
XNav *m_xnav;
XttMethodToolbar( XNav *xnav) : m_xnav(xnav) {}
virtual ~XttMethodToolbar() {}
virtual void set_sensitive() {}
};
#endif
/*
* Proview $Id: xtt_xnav.cpp,v 1.30 2007-01-11 11:40:31 claes Exp $
* Proview $Id: xtt_xnav.cpp,v 1.31 2007-01-17 06:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -987,7 +987,7 @@ XNav::XNav(
parent_ctx(xn_parent_ctx),
brow_cnt(0), TraceList(NULL), trace_started(0),
message_cb(NULL), close_cb(NULL), map_cb(NULL), change_value_cb(NULL),
set_dimension_cb(NULL), ccm_func_registred(0), verify(0),
set_dimension_cb(NULL), selection_changed_cb(0), ccm_func_registred(0), verify(0),
menu_tree(NULL), ev(0), op(0), clog(0), closing_down(0),
base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), displayed(0),
current_logging_index(-1), search_last_found(0), search_compiled(0),
......@@ -1604,6 +1604,8 @@ int XNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_CenterObject( xnav->brow->ctx, object, 0.25);
if ( node_count)
free( node_list);
if ( xnav->selection_changed_cb)
(xnav->selection_changed_cb)( xnav->parent_ctx);
break;
}
case flow_eEvent_Key_Down:
......@@ -1639,6 +1641,8 @@ int XNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_CenterObject( xnav->brow->ctx, object, 0.75);
if ( node_count)
free( node_list);
if ( xnav->selection_changed_cb)
(xnav->selection_changed_cb)( xnav->parent_ctx);
break;
}
case flow_eEvent_Key_PageDown: {
......@@ -1905,6 +1909,8 @@ int XNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
default:
brow_SelectClear( xnav->brow->ctx);
}
if ( xnav->selection_changed_cb)
(xnav->selection_changed_cb)( xnav->parent_ctx);
break;
case flow_eEvent_Radiobutton:
{
......
/*
* Proview $Id: xtt_xnav.h,v 1.19 2007-01-04 08:22:47 claes Exp $
* Proview $Id: xtt_xnav.h,v 1.20 2007-01-17 06:19:57 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -279,6 +279,7 @@ class XNav {
void (*map_cb)( void *);
void (*change_value_cb)( void *);
void (*set_dimension_cb)( void *, int, int);
void (*selection_changed_cb)( void *);
int ccm_func_registred;
int verify;
xnav_sMenu *menu_tree;
......
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