Commit bcd752f4 authored by Claes Sjofors's avatar Claes Sjofors

Ge graph view added

parent b7e824c3
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include "ge_subgraphs_gtk.h" #include "ge_subgraphs_gtk.h"
#include "ge_util.h" #include "ge_util.h"
#include "ge_msg.h" #include "ge_msg.h"
#include "ge_item_view_gtk.h"
#include "wb_wnav_selformat.h" #include "wb_wnav_selformat.h"
#include "cow_wow_gtk.h" #include "cow_wow_gtk.h"
#include "cow_logw_gtk.h" #include "cow_logw_gtk.h"
...@@ -1270,6 +1271,25 @@ void GeGtk::activate_view_plant(GtkWidget *w, gpointer data) ...@@ -1270,6 +1271,25 @@ void GeGtk::activate_view_plant(GtkWidget *w, gpointer data)
#endif #endif
} }
void GeGtk::activate_view_graphlist(GtkWidget *w, gpointer data)
{
Ge *ge = (Ge *)data;
int set = (int) gtk_check_menu_item_get_active( GTK_CHECK_MENU_ITEM( ((GeGtk *)ge)->view_graphlist_w));
if ( w != ((GeGtk *)ge)->view_graphlist_w) {
set = !set;
gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( ((GeGtk *)ge)->view_graphlist_w), set ? TRUE : FALSE);
}
if ( set) {
g_object_set( ((GeGtk *)ge)->graph_list, "visible", TRUE, NULL);
}
else {
g_object_set( ((GeGtk *)ge)->graph_list, "visible", FALSE, NULL);
}
ge->set_focus(0);
}
void GeGtk::activate_concorner_right(GtkWidget *w, gpointer gectx) void GeGtk::activate_concorner_right(GtkWidget *w, gpointer gectx)
{ {
...@@ -2209,6 +2229,10 @@ GeGtk::GeGtk( void *x_parent_ctx, ...@@ -2209,6 +2229,10 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_widget_add_accelerator( view_plant_w, "activate", accel_g, gtk_widget_add_accelerator( view_plant_w, "activate", accel_g,
'p', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); 'p', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
view_graphlist_w = gtk_check_menu_item_new_with_mnemonic( "Vie_w graph list");
g_signal_connect( view_graphlist_w, "activate",
G_CALLBACK(activate_view_graphlist), this);
GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL); GtkMenu *view_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_preview_start); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_preview_start);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_preview_stop); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_preview_stop);
...@@ -2216,6 +2240,7 @@ GeGtk::GeGtk( void *x_parent_ctx, ...@@ -2216,6 +2240,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_zoom_out); 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_zoom_reset);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_plant_w); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_plant_w);
gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), view_graphlist_w);
GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View"); GtkWidget *view = gtk_menu_item_new_with_mnemonic("_View");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view); gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), view);
...@@ -3003,12 +3028,19 @@ GeGtk::GeGtk( void *x_parent_ctx, ...@@ -3003,12 +3028,19 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_paned_pack2( GTK_PANED(hpaned), vpaned2, FALSE, TRUE); gtk_paned_pack2( GTK_PANED(hpaned), vpaned2, FALSE, TRUE);
gtk_widget_show( vpaned1); gtk_widget_show( vpaned1);
GeItemViewGtk *item_view = new GeItemViewGtk( this);
GtkWidget *hpaned2 = gtk_hpaned_new();
graph_list = item_view->widget();
gtk_paned_pack1( GTK_PANED(hpaned2), graph_list, FALSE, FALSE);
gtk_paned_pack2( GTK_PANED(hpaned2), hpaned, TRUE, TRUE);
gtk_widget_show( hpaned2);
GtkWidget *vbox = gtk_vbox_new( FALSE, 0); 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(menu_bar), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools3), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(tools3), 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(tools2), 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(tools), FALSE, FALSE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(hpaned), TRUE, TRUE, 0); gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(hpaned2), TRUE, TRUE, 0);
gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 0); gtk_box_pack_start( GTK_BOX(vbox), GTK_WIDGET(statusbar), FALSE, FALSE, 0);
gtk_container_add( GTK_CONTAINER(toplevel), vbox); gtk_container_add( GTK_CONTAINER(toplevel), vbox);
...@@ -3025,6 +3057,7 @@ GeGtk::GeGtk( void *x_parent_ctx, ...@@ -3025,6 +3057,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
#endif #endif
g_object_set( cmd_prompt, "visible", FALSE, NULL); g_object_set( cmd_prompt, "visible", FALSE, NULL);
g_object_set( cmd_input, "visible", FALSE, NULL); g_object_set( cmd_input, "visible", FALSE, NULL);
g_object_set( graph_list, "visible", FALSE, NULL);
subpalette->get_path( &path_cnt, &path); subpalette->get_path( &path_cnt, &path);
graph->set_subgraph_path( path_cnt, path); graph->set_subgraph_path( path_cnt, path);
......
...@@ -79,6 +79,8 @@ class GeGtk : public Ge { ...@@ -79,6 +79,8 @@ class GeGtk : public Ge {
GtkWidget *grid_size_01_w; GtkWidget *grid_size_01_w;
GtkWidget *show_grid_w; GtkWidget *show_grid_w;
GtkWidget *view_plant_w; GtkWidget *view_plant_w;
GtkWidget *view_graphlist_w;
GtkWidget *graph_list;
GdkAtom graph_atom; GdkAtom graph_atom;
CoWowRecall *text_recall; CoWowRecall *text_recall;
CoWowRecall *name_recall; CoWowRecall *name_recall;
...@@ -274,6 +276,7 @@ class GeGtk : public Ge { ...@@ -274,6 +276,7 @@ class GeGtk : public Ge {
static void activate_zoom_out( GtkWidget *w, gpointer gectx); static void activate_zoom_out( GtkWidget *w, gpointer gectx);
static void activate_zoom_reset( GtkWidget *w, gpointer gectx); static void activate_zoom_reset( GtkWidget *w, gpointer gectx);
static void activate_view_plant( GtkWidget *w, gpointer gectx); static void activate_view_plant( GtkWidget *w, gpointer gectx);
static void activate_view_graphlist( GtkWidget *w, gpointer gectx);
static void activate_concorner_right( GtkWidget *w, gpointer gectx); static void activate_concorner_right( GtkWidget *w, gpointer gectx);
static void activate_concorner_rounded( GtkWidget *w, gpointer gectx); static void activate_concorner_rounded( GtkWidget *w, gpointer gectx);
static void activate_round_amount_1( GtkWidget *w, gpointer gectx); static void activate_round_amount_1( GtkWidget *w, gpointer gectx);
......
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef ge_item_view_gtk_h
#define ge_item_view_gtk_h
#ifndef ge_h
#include "ge.h"
#endif
#include "cow_wow.h"
class GeItemViewGtk
{
private:
gpointer ge_ctx;
GtkWidget *toplevel_widget;
GtkWidget *tree_widget;
GtkWidget *autosave_button;
public:
GeItemViewGtk( gpointer gectx);
~GeItemViewGtk();
GtkWidget *widget() const;
void update();
void update( char *, int);
char *selected_text() const;
static char *selected_text( GtkWidget *);
static void activate_menu_open( GtkWidget *, gpointer);
static void activate_menu_delete( GtkWidget *, gpointer);
static void activate_tree_widget( GtkTreeView *, GtkTreePath *,
GtkTreeViewColumn *, gpointer);
static gboolean focus_out_tree_widget( GtkWidget *, GdkEvent *, gpointer);
};
#endif
...@@ -302,6 +302,7 @@ void Ge::clear_all() ...@@ -302,6 +302,7 @@ void Ge::clear_all()
graph->set_gridsize( 1); graph->set_gridsize( 1);
graph->set_grid( 0); graph->set_grid( 0);
graph->clear_all(); graph->clear_all();
graph->set_modified(0);
subpalette->get_path( &path_cnt, &path); subpalette->get_path( &path_cnt, &path);
graph->set_subgraph_path( path_cnt, path); graph->set_subgraph_path( path_cnt, path);
update(); update();
...@@ -1068,7 +1069,13 @@ void Ge::activate_print() ...@@ -1068,7 +1069,13 @@ void Ge::activate_print()
void Ge::activate_new() void Ge::activate_new()
{ {
clear_all(); if ( graph->is_modified()) {
int rv = create_modal_dialog( "New", "Graph is not saved.\nDo you want to continue?", "Yes", "Cancel", NULL, NULL);
if ( rv == wow_eModalDialogReturn_Button1)
clear_all();
}
else
clear_all();
} }
void Ge::activate_save() void Ge::activate_save()
......
...@@ -2560,6 +2560,7 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event) ...@@ -2560,6 +2560,7 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
} }
else if ( strcmp( type, ".gif") == 0 || else if ( strcmp( type, ".gif") == 0 ||
strcmp( type, ".jpg") == 0 || strcmp( type, ".jpg") == 0 ||
strcmp( type, ".svg") == 0 ||
strcmp( type, ".png") == 0) { strcmp( type, ".png") == 0) {
grow_tObject i1; grow_tObject i1;
char name[80]; char name[80];
......
...@@ -993,6 +993,8 @@ class Graph { ...@@ -993,6 +993,8 @@ class Graph {
/*! \return 1 if modified, 0 if not modified. */ /*! \return 1 if modified, 0 if not modified. */
int is_modified(); int is_modified();
void set_modified( int mod) { grow_SetModified( grow->ctx, mod);}
//! Set scantime for slow cycle. //! Set scantime for slow cycle.
/*! \param time Scantime in seconds. */ /*! \param time Scantime in seconds. */
void set_scantime( double time) { scan_time = time;}; void set_scantime( double time) { scan_time = time;};
......
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