Commit 8c476eea authored by claes's avatar claes

Print to pdf file added

parent 8c48caae
/*
* Proview $Id: wb_foe_gtk.cpp,v 1.9 2007-09-17 12:27:26 claes Exp $
* Proview $Id: wb_foe_gtk.cpp,v 1.10 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -118,6 +118,14 @@ void WFoeGtk::activate_printselect( GtkWidget *w, gpointer data)
foe->activate_printselect();
}
// Callback from the menu.
void WFoeGtk::activate_printpdf( GtkWidget *w, gpointer data)
{
WFoe *foe = (WFoe *)data;
foe->activate_printpdf();
}
// Callback from the menu.
void WFoeGtk::activate_syntax( GtkWidget *w, gpointer data)
{
......@@ -1021,11 +1029,16 @@ pwr_tStatus WFoeGtk::create_window( int x_top,
g_signal_connect( file_print_select, "activate",
G_CALLBACK(WFoeGtk::activate_printselect), this);
GtkWidget *file_print_pdf = gtk_menu_item_new_with_mnemonic( "To Pdf _File");
g_signal_connect( file_print_pdf, "activate",
G_CALLBACK(WFoeGtk::activate_printpdf), this);
GtkWidget *file_print = gtk_menu_item_new_with_mnemonic( "_Print");
GtkMenu *file_print_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_print_menu), file_print_documents);
gtk_menu_shell_append(GTK_MENU_SHELL(file_print_menu), file_print_overv);
gtk_menu_shell_append(GTK_MENU_SHELL(file_print_menu), file_print_select);
gtk_menu_shell_append(GTK_MENU_SHELL(file_print_menu), file_print_pdf);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_print),
GTK_WIDGET(file_print_menu));
......
/*
* Proview $Id: wb_foe_gtk.h,v 1.3 2007-07-17 12:44:44 claes Exp $
* Proview $Id: wb_foe_gtk.h,v 1.4 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -169,6 +169,7 @@ class WFoeGtk : public WFoe {
static void activate_print( GtkWidget *w, gpointer data);
static void activate_printoverv( GtkWidget *w, gpointer data);
static void activate_printselect( GtkWidget *w, gpointer data);
static void activate_printpdf( GtkWidget *w, gpointer data);
static void activate_syntax( GtkWidget *w, gpointer data);
static void activate_compile( GtkWidget *w, gpointer data);
static void delete_subwindow_ok_cb( void *ctx, void *data);
......
/*
* Proview $Id: wb_foe.cpp,v 1.4 2007-07-17 12:44:44 claes Exp $
* Proview $Id: wb_foe.cpp,v 1.5 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -356,6 +356,26 @@ void WFoe::activate_printoverv()
}
}
//
// Callback from the menu.
// This function finds all document objects in the window
// prints an overview of them to pdf.
//
void WFoe::activate_printpdf()
{
int sts;
vldh_t_wind wind;
wind = gre->wind;
if ( msg_label_id != 0 ) message( "");
sts = print_pdf_overview();
if ( sts == FOE__NOOBJFOUND) {
message( "No documents found");
}
}
//
// Callback from the menu.
// This function print a portion of the screen defined by the last
......@@ -3072,6 +3092,72 @@ int WFoe::print_overview()
return FOE__SUCCESS;
}
//
// Prints an overview as pdf.
//
int WFoe::print_pdf_overview()
{
unsigned long node_count;
vldh_t_node *nodelist;
vldh_t_node *node_ptr;
int i, sts;
float ll_x_min;
float ll_y_min;
float ur_x_max;
float ur_y_max;
float ll_x;
float ll_y;
float width;
float height;
int doc_count;
vldh_t_wind wind;
char file_id[80];
ll_x_min = 10000.;
ll_y_min = 10000.;
ur_x_max = -10000.;
ur_y_max = -10000.;
wind = gre->wind;
sts = vldh_get_nodes( wind, &node_count, &nodelist);
if ( EVEN(sts)) return sts;
/* Init the document objects */
// gre_init_docobjects( gre);
doc_count = 0;
node_ptr = nodelist;
for ( i = 0; i < (int)node_count; i++) {
if ( vldh_check_document( wind->hw.ldhses,
(*node_ptr)->ln.oid)) {
/* Calculate coordinates for an overview */
gre->measure_object( *node_ptr, &ll_x, &ll_y, &width, &height);
ll_x_min = co_min( ll_x_min, ll_x);
ll_y_min = co_min( ll_y_min, ll_y);
ur_x_max = co_max( ur_x_max, ll_x + width);
ur_y_max = co_max( ur_y_max, ll_y + height);
doc_count++;
}
node_ptr++;
}
if ( doc_count >= 1) {
/* Print the overview */
strcpy( file_id, vldh_IdToStr(0, wind->lw.oid));
gre->print_pdf_rectangle( ll_x_min, ll_y_min, ur_x_max,
ur_y_max, file_id);
}
if ( node_count > 0) free((char *) nodelist);
if ( doc_count <= 0)
return FOE__NOOBJFOUND;
return FOE__SUCCESS;
}
//
// Enable events and menu entris depending on the function
// in which the user works.
......
/*
* Proview $Id: wb_foe.h,v 1.13 2007-07-17 12:44:44 claes Exp $
* Proview $Id: wb_foe.h,v 1.14 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -195,6 +195,7 @@ class WFoe : public WUtility {
void activate_print();
void activate_printoverv();
void activate_printselect();
void activate_printpdf();
void activate_syntax();
void activate_compile();
void activate_delete();
......@@ -251,6 +252,7 @@ class WFoe : public WUtility {
int print_overview();
int print_document();
int print_selected_document();
int print_pdf_overview();
int change_mode( int new_mode);
int redraw_and_save();
......
/*
* Proview $Id: wb_gre.cpp,v 1.5 2007-07-18 09:27:16 claes Exp $
* Proview $Id: wb_gre.cpp,v 1.6 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -2161,6 +2161,50 @@ int WGre::print_rectangle( float ll_x, float ll_y, float ur_x, float ur_y,
return GRE__SUCCESS;
}
//
// Prints as pdf an area described by the coordinates.
//
int WGre::print_pdf_rectangle( float ll_x, float ll_y, float ur_x, float ur_y,
char *file_id)
{
pwr_tFileName filename;
vldh_t_plc plc = wind->hw.plc;
if ( plc->lp.cid == pwr_cClass_PlcTemplate) {
pwr_tOid parent;
pwr_tOName name;
pwr_tObjName vname;
int size;
pwr_tStatus sts;
sts = ldh_GetParent( wind->hw.ldhses, plc->lp.oid, &parent);
if ( EVEN(sts)) return sts;
sts = ldh_VolumeIdToName( ldh_SessionToWB( wind->hw.ldhses), parent.vid,
vname, sizeof(vname), &size);
if ( EVEN(sts)) return sts;
sts = ldh_ObjidToName( wind->hw.ldhses,
parent, ldh_eName_Object,
name, sizeof( name), &size);
if( EVEN(sts)) return sts;
if ( parent.vid >= cdh_cUserVolMin)
sprintf( filename, "$pwrp_web/%s_%s.pdf", vname, name);
else
sprintf( filename, "./%s_%s.pdf", vname, name);
cdh_ToLower( filename, filename);
}
else {
sprintf( filename, "$pwrp_tmp/pssdoc%s.pdf", file_id);
}
dcli_translate_filename( filename, filename);
printf( "Export pdf to %s\n", filename);
flow_PrintPdfRegion( flow_ctx, ll_x, ll_y, ur_x, ur_y, filename);
return GRE__SUCCESS;
}
//
// This routine is called when a paste callback is recieved.
// Initiates paste by drawing a paste rectangle in the window.
......
/*
* Proview $Id: wb_gre.h,v 1.8 2007-07-17 12:44:44 claes Exp $
* Proview $Id: wb_gre.h,v 1.9 2007-09-25 13:36:32 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -199,6 +199,8 @@ class WGre {
float *width, float *height);
int print_rectangle( float ll_x, float ll_y, float ur_x, float ur_y,
char *file_id);
int print_pdf_rectangle( float ll_x, float ll_y, float ur_x, float ur_y,
char *file_id);
void paste( float cursor_x, float cursor_y, int paste_type);
int subwindow_mark( vldh_t_node object);
pwr_tStatus node_update_points( vldh_t_node node,
......
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