Commit 1075fb5b authored by Claes Sjofors's avatar Claes Sjofors

Ge, menu entry to create subgraphs added

parent 682dabc9
......@@ -384,6 +384,11 @@ void GeGtk::set_prompt( const char *prompt)
//
// Callbackfunctions from menu entries
//
void GeGtk::activate_create_subgraph(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->graph->create_node_floating( 0, 0);
}
void GeGtk::activate_change_text(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_change_text();
......@@ -1734,6 +1739,12 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect( edit_polyline, "activate",
G_CALLBACK(activate_edit_polyline), this);
GtkWidget *edit_create_subgraph = gtk_menu_item_new_with_mnemonic( "_Create Subgraph");
g_signal_connect( edit_create_subgraph, "activate",
G_CALLBACK(activate_create_subgraph), this);
gtk_widget_add_accelerator( edit_create_subgraph, "activate", accel_g,
'd', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
GtkWidget *edit_change_text = gtk_menu_item_new_with_mnemonic( "Change _Text");
g_signal_connect( edit_change_text, "activate",
G_CALLBACK(activate_change_text), this);
......@@ -1759,6 +1770,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_redo);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_rotate);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_polyline);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_create_subgraph);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_change_text);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_change_name);
gtk_menu_shell_append(GTK_MENU_SHELL(edit_menu), edit_command);
......@@ -2170,7 +2182,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
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);
GtkWidget *help_help = gtk_image_menu_item_new_from_stock(GTK_STOCK_HELP, 0);
g_signal_connect(help_help, "activate", G_CALLBACK(activate_help), this);
GtkWidget *help_help_subgraph = gtk_menu_item_new_with_mnemonic( "H_elp on Subgraphs");
......
......@@ -109,6 +109,7 @@ class GeGtk : public Ge {
static void create_india_label( GtkWidget *w, gpointer gectx);
static void create_india_text( GtkWidget *w, gpointer gectx);
static void activate_create_subgraph(GtkWidget *w, gpointer gectx);
static void activate_change_text( GtkWidget *w, gpointer gectx);
static void activate_change_name( GtkWidget *w, gpointer gectx);
static void activate_preview_start( GtkWidget *w, gpointer gectx);
......
......@@ -294,6 +294,9 @@ void Graph::delete_select()
grow_tObject *sel_list;
int sel_count;
if ( grow_GetPasteActive( grow->ctx))
return;
journal_store( journal_eAction_DeleteSelect, 0);
grow_GetSelectList( grow->ctx, &sel_list, &sel_count);
......@@ -2279,6 +2282,9 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
}
break;
case glow_eEvent_MB2DoubleClick:
if ( grow_GetPasteActive( graph->grow->ctx))
break;
if ( event->object.object_type != glow_eObjectType_NoObject) {
graph->journal_store( journal_eAction_DeleteObject, event->object.object);
......@@ -4684,6 +4690,66 @@ void Graph::create_axis( grow_tObject *object, double x, double y)
grow_Redraw( grow->ctx);
}
int Graph::create_node_floating( double x, double y)
{
char sub_name[80] = "graph";
pwr_tFileName filename;
char name[80];
grow_tNodeClass nc;
grow_tNode n1;
int sts;
char dev[80], dir[80], file[80], type[32];
int version;
GeDyn *dyn;
// Create subgraph object
sts = (get_current_subgraph_cb)( parent_ctx, sub_name,
filename);
if ( EVEN(sts)) {
message( 'E', "Select a SubGraph");
return sts;
}
dcli_parse_filename( filename, dev, dir, file, type, &version);
cdh_ToLower( sub_name, file);
if ( strcmp( type, ".pwsg") == 0) {
sts = grow_FindNodeClassByName( grow->ctx, sub_name, &nc);
if ( EVEN(sts)) {
// Load the subgraph
grow_OpenSubGraph( grow->ctx, filename);
}
sts = grow_FindNodeClassByName( grow->ctx, sub_name, &nc);
if ( EVEN(sts)) {
message( 'E', "Unable to open subgraph");
return sts;
}
grow_GetUserData( nc, (void **)&dyn);
if ( !dyn) {
// Old version nodeclass without dyn, create dyn
GeDyn *dyn = new GeDyn( this);
grow_SetUserData( nc, (void *)dyn);
}
sprintf( name, "O%d", grow_IncrNextObjectNameNumber( grow->ctx));
grow_PasteClear( grow->ctx);
grow_CreatePasteNode( grow->ctx, name, nc, x, y, NULL, &n1);
if ( shadow)
grow_SetObjectShadow( n1, 1);
GeDyn *dyn = new GeDyn( this);
grow_SetUserData( n1, (void *)dyn);
if ( grow_IsSliderClass( nc))
dyn->action_type = ge_mActionType( dyn->action_type | ge_mActionType_Slider);
grow_Paste( grow->ctx);
// grow_SetSelectHighlight( grow->ctx);
}
return 1;
}
void Graph::swap( int mode)
{
......
......@@ -1250,6 +1250,8 @@ class Graph {
*/
void create_axis( grow_tObject *object, double x, double y);
int create_node_floating( double x, double y);
//! Set displayed folder in a folder object.
/*!
\param name Object name of folder object.
......
......@@ -724,10 +724,11 @@ void GlowCtx::paste_execute()
{
a.insert( a_move[i]);
}
if ( application_paste)
// if ( application_paste)
a_sel.copy_from_common_objects(a_move);
else
a_sel.copy_from(a_move);
// else
// a_sel.copy_from(a_move);
ur_x = -1e10;
ll_x = 1e10;
......
......@@ -290,6 +290,7 @@ class GlowCtx {
Copies all objects in paste list and inserts them into the context and into the move list.
*/
void paste_execute();
int get_paste_active() { return node_movement_paste_active;}
//! Cut selected objects.
/*! Clear paste list and move obejcts from select list to the pastelist. Remove them from the context. */
......
......@@ -248,7 +248,11 @@ void grow_CreatePasteNode( grow_tCtx ctx, char *name, grow_tNodeClass nc,
double x, double y, void *user_data, grow_tNode *node)
{
GlowNode *n1;
n1 = new GlowNode( ctx, name, (GlowNodeClass *)nc, x, y, 1);
if (((GlowNodeClass *)nc)->is_slider())
n1 = new GrowSlider( ctx, name, (GlowNodeClass *)nc, x, y);
else
n1 = new GrowNode( ctx, name, (GlowNodeClass *)nc, x, y, 1);
n1->set_user_data( user_data);
ctx->paste_insert( n1);
*node = (grow_tNode) n1;
......@@ -357,6 +361,12 @@ void grow_PasteClear( grow_tCtx ctx)
ctx->paste_clear();
}
int grow_GetPasteActive( grow_tCtx ctx)
{
return ctx->get_paste_active();
}
void grow_CreateRect( grow_tCtx ctx, double x, double y,
double width, double height,
glow_eDrawType draw_type, int line_width, int fix_line_width,
......
......@@ -459,6 +459,7 @@ extern "C" {
//! Clear the paste list.
/*! \param ctx Grow context. */
void grow_PasteClear( grow_tCtx ctx);
int grow_GetPasteActive( grow_tCtx ctx);
void grow_CreateRect( grow_tCtx ctx, double x, double y,
double width, double height,
......
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