Commit 8a19126b authored by claes's avatar claes

Function for double and half scale and help popup in subpalette

parent 4684e62c
/*
* Proview $Id: ge_gtk.cpp,v 1.9 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge_gtk.cpp,v 1.10 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -138,7 +138,9 @@ void GeGtk::open_input_dialog( char *text, char *title,
void GeGtk::message( char severity, char *message)
{
gtk_label_set_text( GTK_LABEL(msg_label), message);
char *messageutf8 = g_convert( message, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
gtk_label_set_text( GTK_LABEL(msg_label), messageutf8);
g_free( messageutf8);
}
void GeGtk::status_msg( char *pos_str)
......@@ -852,6 +854,16 @@ void GeGtk::activate_scale(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_scale();
}
void GeGtk::activate_scale_double(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_scale( 2.0);
}
void GeGtk::activate_scale_half(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_scale( 0.5);
}
void GeGtk::activate_grid( GtkWidget *w, gpointer gectx)
{
int set = (int) gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(w));
......@@ -940,7 +952,7 @@ void GeGtk::activate_gridsize_3(GtkWidget *w, gpointer gectx)
void GeGtk::activate_gridsize_2(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_gridsize( 0.2);
((Ge *)gectx)->activate_gridsize( 0.25);
}
void GeGtk::activate_gridsize_1(GtkWidget *w, gpointer gectx)
......@@ -1151,6 +1163,11 @@ void GeGtk::activate_help(GtkWidget *w, gpointer gectx)
((Ge *)gectx)->activate_help();
}
void GeGtk::activate_help_subgraph(GtkWidget *w, gpointer gectx)
{
((Ge *)gectx)->activate_help_subgraph();
}
void GeGtk::activate_india_ok(GtkWidget *w, gpointer gectx)
{
char *text, *textutf8;
......@@ -1868,8 +1885,12 @@ GeGtk::GeGtk( void *x_parent_ctx,
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);
GtkWidget *help_help_subgraph = gtk_menu_item_new_with_mnemonic( "H_elp on Subgraphs");
g_signal_connect(help_help_subgraph, "activate", G_CALLBACK(activate_help_subgraph), 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_help_subgraph);
GtkWidget *help = gtk_menu_item_new_with_mnemonic("_Help");
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), help);
......@@ -2050,6 +2071,16 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect(tools_scale, "clicked", G_CALLBACK(activate_scale), this);
gtk_toolbar_append_widget( tools2, tools_scale, "Scale selected objects", "");
// Scale double button
GtkWidget *tools_scale_double = image_button( "$pwr_exe/ge_scale_double.png");
g_signal_connect(tools_scale_double, "clicked", G_CALLBACK(activate_scale_double), this);
gtk_toolbar_append_widget( tools2, tools_scale_double, "Scale selected objects to double size", "");
// Scale half button
GtkWidget *tools_scale_half = image_button( "$pwr_exe/ge_scale_half.png");
g_signal_connect(tools_scale_half, "clicked", G_CALLBACK(activate_scale_half), this);
gtk_toolbar_append_widget( tools2, tools_scale_half, "Scale selected objects to half size", "");
// Rotate 90 button
GtkWidget *tools_rotate90 = image_button( "$pwr_exe/ge_flip.png");
g_signal_connect(tools_rotate90, "clicked", G_CALLBACK(activate_rotate90), this);
......@@ -2271,7 +2302,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
g_signal_connect(tools_gridsize_4, "activate", G_CALLBACK(activate_gridsize_4), this);
GtkWidget *tools_gridsize_3 = gtk_menu_item_new_with_label( "Gridsize 0.5");
g_signal_connect(tools_gridsize_3, "activate", G_CALLBACK(activate_gridsize_3), this);
GtkWidget *tools_gridsize_2 = gtk_menu_item_new_with_label( "Gridsize 0.2");
GtkWidget *tools_gridsize_2 = gtk_menu_item_new_with_label( "Gridsize 0.25");
g_signal_connect(tools_gridsize_2, "activate", G_CALLBACK(activate_gridsize_2), this);
GtkWidget *tools_gridsize_1 = gtk_menu_item_new_with_label( "Gridsize 0.1");
g_signal_connect(tools_gridsize_1, "activate", G_CALLBACK(activate_gridsize_1), this);
......@@ -2407,6 +2438,7 @@ GeGtk::GeGtk( void *x_parent_ctx,
subpalette->message_cb = &Ge::message_cb;
subpalette->set_focus_cb = &Ge::set_focus_cb;
subpalette->traverse_focus_cb = &Ge::traverse_focus;
subpalette->help_cb = help_cb;
gtk_box_pack_start( GTK_BOX(palbox), subpalette_widget, TRUE, TRUE, 0);
gtk_widget_show( subpalette_widget);
subpalette_mapped = 1;
......
/*
* Proview $Id: ge_gtk.h,v 1.4 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge_gtk.h,v 1.5 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -184,6 +184,8 @@ class GeGtk : public Ge {
static void activate_incr_shift( GtkWidget *w, gpointer gectx);
static void activate_decr_shift( GtkWidget *w, gpointer gectx);
static void activate_scale( GtkWidget *w, gpointer gectx);
static void activate_scale_double( GtkWidget *w, gpointer gectx);
static void activate_scale_half( GtkWidget *w, gpointer gectx);
static void activate_grid( GtkWidget *w, gpointer gectx);
static void activate_linewidth_1( GtkWidget *w, gpointer gectx);
static void activate_linewidth_2( GtkWidget *w, gpointer gectx);
......@@ -240,6 +242,7 @@ class GeGtk : public Ge {
static void activate_condir_down( GtkWidget *w, gpointer gectx);
static void activate_background_color( GtkWidget *w, gpointer gectx);
static void activate_help( GtkWidget *w, gpointer gectx);
static void activate_help_subgraph( GtkWidget *w, gpointer gectx);
static void activate_india_ok( GtkWidget *w, gpointer gectx);
static void activate_india_cancel( GtkWidget *w, gpointer gectx);
static void activate_yesnodia_yes( GtkWidget *w, gpointer gectx);
......
/*
* Proview $Id: ge_subpalette_gtk.cpp,v 1.2 2007-01-12 07:58:06 claes Exp $
* Proview $Id: ge_subpalette_gtk.cpp,v 1.3 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -29,6 +29,7 @@ extern "C" {
#include "pwr_baseclasses.h"
#include "co_dcli.h"
}
#include "co_wow_gtk.h"
#include "flow.h"
#include "flow_browctx.h"
......@@ -80,3 +81,57 @@ void SubPaletteGtk::set_inputfocus( int focus)
gtk_widget_grab_focus( brow_widget);
}
void SubPaletteGtk::create_popup_menu( char *filename, int x, int y)
{
gint wind_x, wind_y;
strncpy( popup_help_filename, filename, sizeof(popup_help_filename));
CoWowGtk::PopupPosition( form_widget, x, y, &wind_x, &wind_y);
popupmenu_x = wind_x;
popupmenu_y = wind_y;
GtkMenu *menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
GtkWidget *w = gtk_menu_item_new_with_label( "Help");
g_signal_connect( w, "activate",
G_CALLBACK(activate_help), this);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), w);
gtk_widget_show(w);
//g_signal_connect( menu, "deactivate",
// G_CALLBACK(popup_unmap_cb), this);
gtk_menu_popup( menu, NULL, NULL, menu_position_func,
this, 0, gtk_get_current_event_time());
}
void SubPaletteGtk::menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data)
{
SubPaletteGtk *subpalette = (SubPaletteGtk *)data;
*x = subpalette->popupmenu_x;
*y = subpalette->popupmenu_y;
*push_in = FALSE;
}
// Callback from the menu.
void SubPaletteGtk::activate_help( GtkWidget *w, gpointer data)
{
char helpfile[80] = "$pwr_exe/man_subgraph.dat";
char topic[200];
char *s;
SubPaletteGtk *subpalette = (SubPaletteGtk *)data;
printf( "Help callback %s\n", subpalette->popup_help_filename);
if ( (s = strrchr( subpalette->popup_help_filename, '/')))
strncpy( topic, s+1, sizeof(topic));
else
strncpy( topic, subpalette->popup_help_filename, sizeof(topic));
if ( (s = strrchr( topic, '.')))
*s = 0;
if ( subpalette->help_cb)
(subpalette->help_cb)( subpalette->parent_ctx, topic, helpfile);
}
/*
* Proview $Id: ge_subpalette_gtk.h,v 1.1 2007-01-04 08:21:58 claes Exp $
* Proview $Id: ge_subpalette_gtk.h,v 1.2 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -41,8 +41,15 @@ class SubPaletteGtk : public SubPalette {
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
int popupmenu_x;
int popupmenu_y;
char popup_help_filename[200];
void set_inputfocus( int focus);
void create_popup_menu( char *filename, int x, int y);
static void menu_position_func( GtkMenu *menu, gint *x, gint *y, gboolean *push_in,
gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
};
/*@}*/
......
/*
* Proview $Id: ge.cpp,v 1.26 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge.cpp,v 1.27 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1507,6 +1507,11 @@ void Ge::activate_scale()
status_msg( this, 0, 0);
}
void Ge::activate_scale( double factor)
{
graph->scale( factor, factor);
}
void Ge::activate_grid( int set)
{
graph->set_grid( set);
......@@ -1689,6 +1694,11 @@ void Ge::activate_help()
CoXHelp::dhelp( "index", "", navh_eHelpFile_Other, "$pwr_lang/man_geref.dat", false);
}
void Ge::activate_help_subgraph()
{
CoXHelp::dhelp( "index", "", navh_eHelpFile_Other, "$pwr_exe/man_subgraph.dat", false);
}
void Ge::activate_india_ok( char *value)
{
(india_ok_cb)( this, value);
......@@ -1898,6 +1908,11 @@ void Ge::message_cb( void *ctx, char severity, char *message)
((Ge *)ctx)->message( severity, message);
}
void Ge::help_cb( void *ctx, char *topic, char *helpfile)
{
CoXHelp::dhelp( topic, "", navh_eHelpFile_Other, helpfile, false);
}
Ge::~Ge()
{
#ifdef LDH
......
/*
* Proview $Id: ge.h,v 1.8 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge.h,v 1.9 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -206,6 +206,7 @@ class Ge {
void activate_incr_shift();
void activate_decr_shift();
void activate_scale();
void activate_scale( double factor);
void activate_grid(int set);
void activate_linewidth( int width);
void activate_linetype1();
......@@ -239,6 +240,7 @@ class Ge {
void activate_condir_down();
void activate_background_color();
void activate_help();
void activate_help_subgraph();
void activate_india_ok( char *value);
void activate_india_cancel();
void activate_yesnodia_yes();
......@@ -279,6 +281,7 @@ class Ge {
static int traverse_focus( void *ctx, void *component);
static int set_focus_cb( void *ctx, void *component);
static void message_cb( void *ctx, char severity, char *message);
static void help_cb( void *ctx, char *topic, char *helpfile);
};
#endif
/*
* Proview $Id: ge_graph.cpp,v 1.39 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge_graph.cpp,v 1.40 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -221,6 +221,23 @@ void Graph::pop_select()
grow_PopSelectedObjects( grow->ctx);
}
//! Scale selected objects.
/*! \param scalex Scale factor in x direction. */
/*! \param scaley Scale factor in y direction. */
void Graph::scale( double scalex, double scaley)
{
switch ( grow_GetMoveRestrictions( grow->ctx)) {
case glow_eMoveRestriction_Horizontal:
grow_SetSelectScale( grow->ctx, scalex, 1, glow_eScaleType_UpperLeft);
break;
case glow_eMoveRestriction_Vertical:
grow_SetSelectScale( grow->ctx, 1, scaley, glow_eScaleType_UpperLeft);
break;
default:
grow_SetSelectScale( grow->ctx, scalex, scaley, glow_eScaleType_UpperLeft);
}
}
void Graph::set_move_restriction( glow_eMoveRestriction restriction)
{
grow_SetMoveRestrictions( grow->ctx, restriction, 0, 0, NULL);
......@@ -3819,6 +3836,8 @@ graph_eDatabase Graph::parse_attr_name( char *name, char *parsed_name,
if ( (s = strstr( str, "##")))
string_to_type( s + 2, (pwr_eType *)type, size, &elements);
else
*type = pwr_eType__;
if ( (s = strchr( str, '#'))) {
*s = 0;
......
/*
* Proview $Id: ge_graph.h,v 1.26 2007-05-07 14:35:03 claes Exp $
* Proview $Id: ge_graph.h,v 1.27 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -865,6 +865,8 @@ class Graph {
/*! /param object Object for thet current action execution. */
void confirm_ok( grow_tObject object);
void scale( double scalex, double scaley);
//! Restrict movement of moved objects.
/*! \param restriction Type of restriction. */
void set_move_restriction( glow_eMoveRestriction restriction);
......
/*
* Proview $Id: ge_subpalette.cpp,v 1.9 2007-06-15 11:27:56 claes Exp $
* Proview $Id: ge_subpalette.cpp,v 1.10 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <vector.h>
#include "co_cdh.h"
#include "co_time.h"
......@@ -152,6 +153,24 @@
static char null_str[] = "";
class LocalFile {
public:
pwr_tFileName name;
};
void subpalette_sort( vector<LocalFile>& fvect)
{
for ( int i = fvect.size() - 1; i > 0; i--) {
for ( int j = 0; j < i; j++) {
if ( strcmp( fvect[i].name, fvect[j].name) < 0) {
LocalFile tmp = fvect[i];
fvect[i] = fvect[j];
fvect[j] = tmp;
}
}
}
}
//
// Convert attribute string to value
//
......@@ -333,7 +352,7 @@ SubPalette::SubPalette(
parent_ctx(xn_parent_ctx),
trace_started(0),
message_cb(NULL), traverse_focus_cb(NULL), set_focus_cb(NULL),
menu_tree(NULL), path_cnt(0), displayed(0)
help_cb(NULL), menu_tree(NULL), path_cnt(0), displayed(0)
{
strcpy( name, xn_name);
*status = 1;
......@@ -533,6 +552,22 @@ static int subpalette_brow_cb( FlowCtx *ctx, flow_tEvent event)
brow_SelectClear( subpalette->brow->ctx);
}
break;
case flow_eEvent_MB3Press: {
switch ( event->object.object_type) {
case flow_eObjectType_Node:
ItemFile *item;
brow_GetUserData( event->object.object, (void **)&item);
if ( item->type != subpalette_eItemType_File)
break;
subpalette->create_popup_menu( item->filename,
event->any.x_pixel, event->any.y_pixel);
break;
default:
;
}
break;
}
case flow_eEvent_Key_Return:
case flow_eEvent_Key_Right:
{
......@@ -1054,6 +1089,8 @@ void SubPaletteBrow::brow_setup()
subpalette_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Map, flow_eEventType_CallBack,
subpalette_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_MB3Press, flow_eEventType_CallBack,
subpalette_brow_cb);
}
//
......@@ -1148,6 +1185,7 @@ int ItemLocalSubGraphs::open_children( SubPalette *subpalette, double x, double
char file_str[5][80];
int nr;
int i;
vector<LocalFile> fvect;
// Create some children
brow_SetNodraw( subpalette->brow->ctx);
......@@ -1156,41 +1194,39 @@ int ItemLocalSubGraphs::open_children( SubPalette *subpalette, double x, double
nr = dcli_parse( filename, ",", "", (char *)file_str,
sizeof( file_str) / sizeof( file_str[0]), sizeof( file_str[0]), 0);
for ( i = 0; i < nr; i++)
{
for ( i = 0; i < nr; i++) {
dcli_translate_filename( fname, file_str[i]);
sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT);
if ( ODD(sts))
{
dcli_parse_filename( found_file, dev, dir, file, type, &version);
cdh_ToLower( text, file);
text[0] = toupper( text[0]);
// Skip next pages in animations
if ( !((s = strstr( text, "__p")) && sscanf( s+3, "%d", &idx)))
{
new ItemFile( subpalette, text, found_file, 0, node, flow_eDest_IntoLast);
child_exist = 1;
}
if ( ODD(sts)) {
LocalFile f;
strcpy( f.name, found_file);
fvect.push_back( f);
}
while ( ODD(sts))
{
while ( ODD(sts)) {
sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_NEXT);
if ( ODD(sts))
{
dcli_parse_filename( found_file, dev, dir, file, type, &version);
cdh_ToLower( text, file);
text[0] = toupper( text[0]);
if ( !((s = strstr( text, "__p")) && sscanf( s+3, "%d", &idx)))
{
new ItemFile( subpalette, text, found_file, 0, node, flow_eDest_IntoLast);
child_exist = 1;
}
}
if ( ODD(sts)) {
LocalFile f;
strcpy( f.name, found_file);
fvect.push_back( f);
}
}
dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END);
}
subpalette_sort( fvect);
for ( i = 0; i < (int) fvect.size(); i++) {
dcli_parse_filename( fvect[i].name, dev, dir, file, type, &version);
cdh_ToLower( text, file);
text[0] = toupper( text[0]);
// Skip next pages in animations
if ( !((s = strstr( text, "__p")) && sscanf( s+3, "%d", &idx))) {
new ItemFile( subpalette, text, fvect[i].name, 0, node, flow_eDest_IntoLast);
child_exist = 1;
}
}
if ( child_exist)
{
brow_SetOpen( node, subpalette_mOpen_Children);
......
/*
* Proview $Id: ge_subpalette.h,v 1.9 2007-06-15 11:28:21 claes Exp $
* Proview $Id: ge_subpalette.h,v 1.10 2007-06-29 09:45:19 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -102,6 +102,7 @@ class SubPalette {
void (*message_cb)( void *, char, char *);
int (*traverse_focus_cb)( void *, void *);
int (*set_focus_cb)( void *, void *);
void (*help_cb)( void *, char *, char *);
void *root_item;
subpalette_sMenu *menu_tree;
char path[10][80];
......@@ -109,6 +110,7 @@ class SubPalette {
int displayed;
virtual void set_inputfocus( int focus) {}
virtual void create_popup_menu( char *filename, int x, int y) {}
void message( char sev, char *text);
int get_select( pwr_sAttrRef *attrref, int *is_attr);
......
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