Commit 419a26a1 authored by Claes Sjofors's avatar Claes Sjofors

Print dialog added to most windows

parent 9ad4fefc
......@@ -244,7 +244,7 @@ void WAttGtk::print( const char *title)
{
pwr_tStatus sts;
CoWowGtk::CreateBrowPrintDialogGtk( title, wattnav->brow->ctx, flow_eOrientation_Portrait,
CoWowGtk::CreateBrowPrintDialogGtk( title, wattnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
......
......@@ -79,7 +79,7 @@ void WdaGtk::print( const char *title)
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, wdanav->brow->ctx, flow_eOrientation_Portrait,
wow->CreateBrowPrintDialog( title, wdanav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
......
......@@ -217,7 +217,7 @@ void WNavGtk::print( const char *title)
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, brow->ctx, flow_eOrientation_Portrait,
wow->CreateBrowPrintDialog( title, brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)0, &sts);
}
......
......@@ -67,6 +67,13 @@ void WCrrGtk::activate_exit(GtkWidget *w, gpointer data)
delete xcrr;
}
void WCrrGtk::activate_print(GtkWidget *w, gpointer data)
{
WCrr *xcrr = (WCrr *)data;
xcrr->activate_print();
}
void WCrrGtk::activate_openplc(GtkWidget *w, gpointer data)
{
// WCrr *xcrr = (WCrr *)data;
......@@ -98,6 +105,22 @@ void WCrrGtk::pop()
gtk_window_present( GTK_WINDOW(toplevel));
}
void WCrrGtk::print()
{
pwr_tStatus sts;
char *namep;
int size;
pwr_tAName title;
sts = ldh_AttrRefToName( ldhses, &objar, cdh_mNName, &namep, &size);
if ( EVEN(sts)) return;
strncpy( title, namep, sizeof(title));
CoWowGtk::CreateBrowPrintDialogGtk( title, xcrrnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
WCrrGtk::~WCrrGtk()
{
delete xcrrnav;
......@@ -127,7 +150,7 @@ WCrrGtk::WCrrGtk(
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
WCrr( xa_parent_ctx, xa_objar, xa_advanced_user, xa_sts),
WCrr( xa_parent_ctx, xa_ldhses, xa_objar, xa_advanced_user, xa_sts),
parent_wid(xa_parent_wid)
{
int sts;
......@@ -162,10 +185,14 @@ WCrrGtk::WCrrGtk(
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
......
......@@ -69,8 +69,10 @@ class WCrrGtk : public WCrr {
CoWowFocusTimerGtk focustimer;
void pop();
void print();
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_openplc( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
......
......@@ -56,21 +56,23 @@
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "wb_ldh.h"
#include "wb_xcrr.h"
#include "wb_watt_msg.h"
#include "co_lng.h"
WCrr::~WCrr()
{
}
WCrr::WCrr(
void *xa_parent_ctx,
ldh_tSesContext xa_ldhses,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts) :
parent_ctx(xa_parent_ctx),
ldhses(xa_ldhses),
objar(*xa_objar),
input_open(0), input_multiline(0),
close_cb(0), redraw_cb(0), popup_menu_cb(0), start_trace_cb(0),
......
......@@ -49,11 +49,13 @@ class WCrr {
public:
WCrr(
void *xa_parent_ctx,
ldh_tSesContext xa_ldhses,
pwr_sAttrRef *xa_objar,
int xa_advanced_user,
int *xa_sts);
virtual ~WCrr();
void *parent_ctx;
ldh_tSesContext ldhses;
pwr_sAttrRef objar;
char name[80];
WAttNav *xcrrnav;
......@@ -71,7 +73,9 @@ class WCrr {
char input_name[80];
virtual void pop() {}
virtual void print() {}
void activate_print() {print();}
static void xcrr_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
char *arg, int x, int y);
......
......@@ -303,7 +303,7 @@ void XttGtk::print()
if ( ODD(sts))
strcat( title, nodename);
wow->CreateBrowPrintDialog( title, xnav->brow->ctx, flow_eOrientation_Portrait,
wow->CreateBrowPrintDialog( title, xnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
if ( sts == WOW__PRINTDIALOGDISABLED) {
pwr_tFileName filename;
......
......@@ -95,7 +95,11 @@ CoLogWGtk::CoLogWGtk (
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(CoLogWGtk::activate_exit), this);
GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(CoLogWGtk::activate_print), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic("_File");
......@@ -152,6 +156,14 @@ CoLogWGtk::~CoLogWGtk()
gtk_widget_destroy( toplevel);
}
void CoLogWGtk::print()
{
pwr_tStatus sts;
CoWowGtk::CreateBrowPrintDialogGtk( name, logwnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
gboolean CoLogWGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
CoLogWGtk *logw = (CoLogWGtk *)data;
......@@ -173,6 +185,13 @@ void CoLogWGtk::activate_exit( GtkWidget *w, gpointer data)
delete logw;
}
void CoLogWGtk::activate_print( GtkWidget *w, gpointer data)
{
CoLogW *logw = (CoLogW *)data;
logw->activate_print();
}
void CoLogWGtk::activate_zoom_in( GtkWidget *w, gpointer data)
{
CoLogW *logw = (CoLogW *)data;
......
......@@ -66,8 +66,11 @@ class CoLogWGtk : public CoLogW {
CoWowFocusTimerGtk focustimer;
CoWowFocusTimerGtk maptimer;
void print();
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
......
......@@ -95,6 +95,9 @@ MsgWindowGtk::MsgWindowGtk (
g_signal_connect( file_clear, "activate",
G_CALLBACK(MsgWindowGtk::activate_clear), this);
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
g_signal_connect(file_print, "activate", G_CALLBACK(MsgWindowGtk::activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
......@@ -104,6 +107,7 @@ MsgWindowGtk::MsgWindowGtk (
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_clear);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
......@@ -199,6 +203,17 @@ void MsgWindowGtk::unmap()
}
}
void MsgWindowGtk::print()
{
pwr_tStatus sts;
char title[80];
strncpy( title, CoWowGtk::translate_utf8(name), sizeof(title));
CoWowGtk::CreateBrowPrintDialogGtk( title, msgnav->brow->ctx, flow_eOrientation_Landscape, 1.4,
(void *)toplevel, &sts);
}
gboolean MsgWindowGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
MsgWindowGtk *msgw = (MsgWindowGtk *)data;
......@@ -221,6 +236,13 @@ void MsgWindowGtk::activate_exit( GtkWidget *w, gpointer data)
msgw->displayed = 0;
}
void MsgWindowGtk::activate_print( GtkWidget *w, gpointer data)
{
MsgWindow *msgw = (MsgWindow *)data;
msgw->activate_print();
}
void MsgWindowGtk::activate_clear( GtkWidget *w, gpointer data)
{
MsgWindow *msgw = (MsgWindow *)data;
......
......@@ -67,9 +67,11 @@ class MsgWindowGtk : public MsgWindow {
void map();
void unmap();
void print();
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_clear( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
......
......@@ -66,6 +66,7 @@ typedef struct {
char title[80];
brow_tCtx brow_ctx;
flow_eOrientation orientation;
double scale;
} wow_sPrintData;
......@@ -1537,7 +1538,7 @@ static void begin_print( GtkPrintOperation *operation,
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
int pages;
brow_PrintGetPages( print_data->brow_ctx, print_data->orientation, &pages);
brow_PrintGetPages( print_data->brow_ctx, print_data->orientation, print_data->scale, &pages);
gtk_print_operation_set_n_pages( operation, pages);
}
......@@ -1557,7 +1558,7 @@ static void draw_page( GtkPrintOperation *operation,
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
brow_PrintDrawPage( print_data->brow_ctx, context, print_data->title, page_nr,
print_data->orientation);
print_data->orientation, print_data->scale);
}
static void request_page_setup( GtkPrintOperation *operation,
......@@ -1576,7 +1577,7 @@ static void request_page_setup( GtkPrintOperation *operation,
void CoWowGtk::CreateBrowPrintDialogGtk( const char *title, void *brow_ctx, int orientation,
void *parent_widget, pwr_tStatus *sts)
double scale, void *parent_widget, pwr_tStatus *sts)
{
static GtkPrintSettings *settings = 0;
GtkPrintOperation *print;
......@@ -1591,6 +1592,7 @@ void CoWowGtk::CreateBrowPrintDialogGtk( const char *title, void *brow_ctx, int
wow_sPrintData *print_data = (wow_sPrintData *)calloc( 1, sizeof(wow_sPrintData));
print_data->brow_ctx = (brow_tCtx)brow_ctx;
print_data->orientation = (flow_eOrientation)orientation;
print_data->scale = scale;
strncpy( print_data->title, title, sizeof(print_data->title));
print = gtk_print_operation_new();
......
......@@ -148,11 +148,11 @@ class CoWowGtk : public CoWow {
void DisplayLicense();
pwr_tStatus CreateMenuItem( const char *name, void *menu, int pixmap, int append, void *w);
pwr_tStatus DeleteMenuItem( const char *name, void *menu);
void CreateBrowPrintDialog( const char *title, void *brow_ctx, int orientation,
void CreateBrowPrintDialog( const char *title, void *brow_ctx, int orientation, double scale,
void *parent_widget, pwr_tStatus *sts) {
CreateBrowPrintDialogGtk( title, brow_ctx, orientation, parent_widget, sts);}
CreateBrowPrintDialogGtk( title, brow_ctx, orientation, scale, parent_widget, sts);}
static void CreateBrowPrintDialogGtk( const char *title, void *brow_ctx, int orientation,
void *parent_widget, pwr_tStatus *sts);
double scale, void *parent_widget, pwr_tStatus *sts);
CoWowTimer *timer_new();
void SetParent( GtkWidget *parent) { m_parent = parent;}
void Wait( float time);
......
......@@ -83,6 +83,13 @@ void CoXHelpGtk::activate_close( GtkWidget *w, gpointer data)
// delete xhelp;
}
void CoXHelpGtk::activate_print( GtkWidget *w, gpointer data)
{
CoXHelp *xhelp = (CoXHelp *)data;
xhelp->activate_print();
}
void CoXHelpGtk::activate_back( GtkWidget *w, gpointer data)
{
CoXHelpGtk *xhelp = (CoXHelpGtk *)data;
......@@ -214,6 +221,17 @@ void CoXHelpGtk::set_dimension( int width, int height)
NULL);
}
void CoXHelpGtk::print()
{
pwr_tStatus sts;
char title[80];
strcpy( title, CoWowGtk::translate_utf8("Help"));
CoWowGtk::CreateBrowPrintDialogGtk( title, xhelpnav->brow->ctx, flow_eOrientation_Portrait, 0.7,
(void *)toplevel, &sts);
}
static gint delete_event( GtkWidget *w, GdkEvent *event, gpointer data)
{
CoXHelpGtk *xhelp = (CoXHelpGtk *)data;
......@@ -291,6 +309,10 @@ CoXHelpGtk::CoXHelpGtk(
gtk_widget_add_accelerator( file_close, "activate", accel_g,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkWidget *file_print = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
g_signal_connect( file_print, "activate",
G_CALLBACK(activate_print), this);
GtkWidget *file_home = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Home"));
g_signal_connect( file_home, "activate",
G_CALLBACK(activate_home), this);
......@@ -317,6 +339,7 @@ CoXHelpGtk::CoXHelpGtk(
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_home);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_back);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_nexttopic);
......
......@@ -66,10 +66,12 @@ class CoXHelpGtk : public CoXHelp {
void set_dimension( int width, int height);
void pop();
void print();
void open_input_dialog( const char *text, const char *title,
const char *init_text,
void (*ok_cb)( CoXHelp *, char *));
static void activate_close( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_home( GtkWidget *w, gpointer data);
static void activate_back( GtkWidget *w, gpointer data);
static void activate_nexttopic( GtkWidget *w, gpointer data);
......
......@@ -59,7 +59,9 @@ class CoLogW {
pwr_tStatus *status);
virtual ~CoLogW() {}
virtual void print() {}
void show( char categories[][20], char *item);
void activate_print() {print();}
void *parent_ctx;
char name[80];
......
......@@ -85,6 +85,7 @@ class MsgWindow {
virtual void map() {}
virtual void unmap() {}
virtual void print() {}
int is_mapped() { return displayed;};
void insert( int severity, const char *text, pwr_tOid oid = pwr_cNOid, bool is_plc = false);
......@@ -92,6 +93,7 @@ class MsgWindow {
void reset_nodraw();
void msg( int severity, const char *text, msgw_ePop pop = msgw_ePop_Default,
pwr_tOid oid = pwr_cNOid, bool is_plc = false);
void activate_print() { print();}
static void set_default( MsgWindow *msgw) { default_window = msgw;}
static void message( int severity, const char *text, msgw_ePop pop = msgw_ePop_Default,
pwr_tOid oid = pwr_cNOid, bool is_plc = false);
......
......@@ -154,7 +154,7 @@ class CoWow {
virtual pwr_tStatus CreateMenuItem( const char *name, void *menu, int pixmap, int append, void *w) { return 0;}
virtual pwr_tStatus DeleteMenuItem( const char *name, void *menu) { return 0;}
virtual void CreateBrowPrintDialog( const char *title, void *brow_ctx, int orientation,
void *parent_widget, pwr_tStatus *sts) {*sts = WOW__NYI;}
double scale, void *parent_widget, pwr_tStatus *sts) {*sts = WOW__NYI;}
static void SetDefaultPrinter( const char *printer) { strncpy( m_default_printer, printer, sizeof(m_default_printer));}
static void DisablePrintDialog() { m_printdialog_disable = true;}
static bool PrintDialogIsDisabled() { return m_printdialog_disable;}
......
......@@ -65,6 +65,7 @@ class CoXHelp {
virtual void set_dimension( int width, int height) {}
virtual void pop();
virtual void print() {}
void map();
void clear();
......@@ -75,6 +76,7 @@ class CoXHelp {
int back();
int next_topic();
int previous_topic();
void activate_print() { print();}
static void set_default( CoXHelp *xhelp) { default_xhelp = xhelp;}
static int dhelp( const char *key, const char *help_bookmark, navh_eHelpFile file_type,
const char *file_name, bool strict);
......
......@@ -244,7 +244,7 @@ int FlowPrintDrawGtk::pixmap( double x, double y, flow_sPixmapDataElem *data,
int i, j;
float scale = 0.7;
// Do do, set color
// To do, set color
switch( type) {
case flow_eDrawType_LineRed:
break;
......@@ -283,6 +283,81 @@ int FlowPrintDrawGtk::pixmap( double x, double y, flow_sPixmapDataElem *data,
return 1;
}
int FlowPrintDrawGtk::image( double x, double y, double width, double height, flow_tImImage image,
flow_eDrawType type)
{
int stride;
cairo_surface_t *surface;
unsigned char *sdata;
unsigned char *sdata_p;
float scale = 0.7;
unsigned char *rgb, *rgb_row;
int rgb_height;
int rgb_width;
int rowstride;
int n_channels;
rgb = gdk_pixbuf_get_pixels( (GdkPixbuf *)image);
rgb_height = gdk_pixbuf_get_height( (GdkPixbuf *)image);
rgb_width = gdk_pixbuf_get_width( (GdkPixbuf *)image);
rowstride = gdk_pixbuf_get_rowstride( (GdkPixbuf *)image);
n_channels = gdk_pixbuf_get_n_channels( (GdkPixbuf *)image);
stride = cairo_format_stride_for_width( CAIRO_FORMAT_ARGB32, rgb_width);
sdata = (unsigned char *) calloc( 1, 4 * stride * rgb_height);
rgb_row = rgb;
for ( int j = 0; j < rgb_height; j++) {
rgb = rgb_row;
sdata_p = sdata + j * stride;
for ( int i = 0; i < rgb_width; i++) {
switch( n_channels) {
case 1:
sdata_p[0] = rgb[0];
sdata_p[1] = rgb[0];
sdata_p[2] = rgb[0];
sdata_p[3] = 255;
break;
case 2:
sdata_p[0] = rgb[0];
sdata_p[1] = rgb[1];
sdata_p[2] = rgb[1];
sdata_p[3] = 255;
break;
case 3:
sdata_p[0] = rgb[0];
sdata_p[1] = rgb[1];
sdata_p[2] = rgb[2];
sdata_p[3] = 255;
break;
default:
sdata_p[0] = rgb[2]; // Blue
sdata_p[1] = rgb[1]; // Green
sdata_p[2] = rgb[0]; // Red
sdata_p[3] = rgb[3]; // Alpha
}
rgb += n_channels;
sdata_p += 4;
}
rgb_row += rowstride;
}
surface = cairo_image_surface_create_for_data( sdata, CAIRO_FORMAT_ARGB32, rgb_width,
rgb_height, stride);
scale = width / rgb_width;
cairo_scale( cairo, scale, scale);
//cairo_mask_surface( cairo, surface, (x - page_x)/scale, (y - page_y)/scale);
cairo_set_source_surface( cairo, surface, (print_margin_x + x - page_x)/scale, (print_margin_y + y - page_y)/scale);
cairo_paint( cairo);
cairo_scale( cairo, 1.0 / scale, 1.0 / scale);
cairo_surface_destroy( surface);
// free( sdata);
return 1;
}
int FlowPrintDrawGtk::arrow( double x1, double y1, double x2, double y2,
double x3, double y3, flow_eDrawType type, double idx)
{
......
......@@ -55,6 +55,7 @@ class FlowPrintDrawGtk : public FlowPrintDraw {
int line( double x1, double y1, double x2, double y2, flow_eDrawType type, double idx, int highlight);
int text( double x, double y, char *text, int len, flow_eDrawType type, double size);
int pixmap( double x, double y, flow_sPixmapDataElem *data, flow_eDrawType type);
int image( double x, double y, double width, double height, flow_tImImage image, flow_eDrawType type);
int arrow( double x1, double y1, double x2, double y2,
double x3, double y3, flow_eDrawType type, double idx);
void set_showred( int show) { show_red = show;}
......
......@@ -461,14 +461,14 @@ int brow_Print( brow_tCtx ctx, char *filename)
}
void brow_PrintDrawPage( brow_tCtx ctx, void *context, const char *title, int page,
flow_eOrientation orientation)
flow_eOrientation orientation, double scale)
{
ctx->print_draw_page( context, title, page, orientation);
ctx->print_draw_page( context, title, page, orientation, scale);
}
void brow_PrintGetPages( brow_tCtx ctx, flow_eOrientation orientation, int *pages)
void brow_PrintGetPages( brow_tCtx ctx, flow_eOrientation orientation, double scale, int *pages)
{
ctx->print_get_pages( orientation, pages);
ctx->print_get_pages( orientation, scale, pages);
}
void brow_GetUserData( brow_tObject object, void **user_data)
......
......@@ -181,8 +181,8 @@ void brow_MeasureNode( brow_tNode node, double *ll_x, double *ll_y,
double *ur_x, double *ur_y);
int brow_Print( brow_tCtx ctx, char *filename);
void brow_PrintDrawPage( brow_tCtx ctx, void *context, const char *title, int page,
flow_eOrientation orientation);
void brow_PrintGetPages( brow_tCtx ctx, flow_eOrientation orientation, int *pages);
flow_eOrientation orientation, double scale);
void brow_PrintGetPages( brow_tCtx ctx, flow_eOrientation orientation, double scale, int *pages);
void brow_GetUserData( brow_tObject object, void **user_data);
void brow_SetUserData( brow_tObject object, void *user_data);
void brow_GetCtxUserData( brow_tCtx ctx, void **user_data);
......
......@@ -219,7 +219,7 @@ int BrowCtx::print( char *filename)
}
void BrowCtx::print_draw_page( void *context, const char *title, int page,
flow_eOrientation orientation)
flow_eOrientation orientation, double scale)
{
double ll_x, ll_y, ur_x, ur_y;
double width, height;
......@@ -229,10 +229,10 @@ void BrowCtx::print_draw_page( void *context, const char *title, int page,
return;
((FlowNode *)a[0])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y);
height = 60 * (ur_y - ll_y) * scale;
width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) {
height = 35 * ( ur_y - ll_y);
height = 35 * ( ur_y - ll_y) * scale;
width = height / 0.70;
}
......@@ -250,7 +250,7 @@ void BrowCtx::print_draw_page( void *context, const char *title, int page,
delete current_print;
}
void BrowCtx::print_get_pages( flow_eOrientation orientation, int *pages)
void BrowCtx::print_get_pages( flow_eOrientation orientation, double scale, int *pages)
{
double ll_x, ll_y, ur_x, ur_y;
double width, height;
......@@ -261,11 +261,11 @@ void BrowCtx::print_get_pages( flow_eOrientation orientation, int *pages)
}
((FlowNode *)a[0])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y);
height = 60 * (ur_y - ll_y) * scale;
width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) {
// Portrait
height = 35 * ( ur_y - ll_y);
height = 35 * ( ur_y - ll_y) * scale;
width = height / 0.70;
}
......
......@@ -65,8 +65,8 @@ class BrowCtx : public FlowCtx {
void unzoom() { zoom( base_zoom_factor / zoom_factor);};
int print( char *filename);
void print_draw_page( void *context, const char *title, int page,
flow_eOrientation orientation);
void print_get_pages( flow_eOrientation orientation, int *pages);
flow_eOrientation orientation, double scale);
void print_get_pages( flow_eOrientation orientation, double scale, int *pages);
int get_first( FlowArrayElem **first) { return a.get_first( first);};
int get_last( FlowArrayElem **last) { return a.get_last( last);};
int get_previous( FlowArrayElem *element, FlowArrayElem **prev)
......
......@@ -104,14 +104,20 @@ void FlowImage::print( void *pos, void *node, int highlight)
{
if ( !(display_level & ctx->display_level))
return;
#if 0
if ( fix_line_width && line_width < 0)
return;
#endif
if ( draw_type == flow_eDrawType_LineErase)
return;
int idx = int( ctx->print_zoom_factor / ctx->base_zoom_factor * line_width -
1);
int idx = int( ctx->print_zoom_factor / ctx->base_zoom_factor * line_width - 1);
idx = MAX( 0, idx);
idx = MIN( idx, DRAW_TYPE_SIZE-1);
ctx->current_print->image( ll.print_z_x + ((FlowPoint *)pos)->print_z_x,
ll.print_z_y + ((FlowPoint *)pos)->print_z_y,
ur.print_z_x - ll.print_z_x, ur.print_z_y - ll.print_z_y,
image, draw_type);
#if 0
if ( !fill)
ctx->current_print->rect( ll.print_z_x + ((FlowPoint *)pos)->print_z_x,
ll.print_z_y + ((FlowPoint *)pos)->print_z_y,
......@@ -122,6 +128,7 @@ void FlowImage::print( void *pos, void *node, int highlight)
ll.print_z_y + ((FlowPoint *)pos)->print_z_y,
ur.print_z_x - ll.print_z_x, ur.print_z_y - ll.print_z_y,
draw_type, idx);
#endif
}
void FlowImage::save( ofstream& fp, flow_eSaveMode mode)
......
......@@ -53,6 +53,7 @@ class FlowPrint {
virtual int line( double x1, double y1, double x2, double y2, flow_eDrawType type, double idx, int highlight) {return 1;}
virtual int text( double x, double y, char *text, int len, flow_eDrawType type, double size) {return 1;}
virtual int pixmap( double x, double y, flow_sPixmapDataElem *data, flow_eDrawType type) {return 1;}
virtual int image( double x, double y, double width, double height, flow_tImImage image, flow_eDrawType type) {return 1;}
virtual int arrow( double x1, double y1, double x2, double y2,
double x3, double y3, flow_eDrawType type, double idx) {return 1;}
virtual void set_showred( int show) {}
......
......@@ -534,7 +534,7 @@ void CLogGtk::print()
strcat( title, nodename);
}
wow->CreateBrowPrintDialog( title, clognav->brow->ctx, flow_eOrientation_Landscape,
wow->CreateBrowPrintDialog( title, clognav->brow->ctx, flow_eOrientation_Landscape, 1.0,
parent_wid, &sts);
if ( sts == WOW__PRINTDIALOGDISABLED)
wow->DisplayError( "Disabled", "Print Dialog is disabled");
......
......@@ -112,7 +112,7 @@ void EvListGtk::print( const char *title)
strcat( print_title, nodename);
}
CoWowGtk::CreateBrowPrintDialogGtk( print_title, brow->ctx, flow_eOrientation_Landscape,
CoWowGtk::CreateBrowPrintDialogGtk( print_title, brow->ctx, flow_eOrientation_Landscape, 1.0,
0 /* GTK_WINDOW(parent_wid) */, &sts);
if ( sts == WOW__PRINTDIALOGDISABLED) {
pwr_tFileName filename;
......
......@@ -204,6 +204,13 @@ void XAttGtk::activate_exit( GtkWidget *w, gpointer data)
delete xatt;
}
void XAttGtk::activate_print( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
xatt->activate_print();
}
void XAttGtk::activate_display_object( GtkWidget *w, gpointer data)
{
XAtt *xatt = (XAtt *)data;
......@@ -427,6 +434,18 @@ void XAttGtk::pop()
gtk_window_present( GTK_WINDOW(toplevel));
}
void XAttGtk::print()
{
pwr_tStatus sts;
pwr_tAName title;
sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(sts)) return;
CoWowGtk::CreateBrowPrintDialogGtk( title, xattnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
XAttGtk::~XAttGtk()
{
delete (XAttNav *)xattnav;
......@@ -488,6 +507,9 @@ XAttGtk::XAttGtk( GtkWidget *xa_parent_wid,
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Close"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_close),
gtk_image_new_from_stock( "gtk-close", GTK_ICON_SIZE_MENU));
......@@ -496,6 +518,7 @@ XAttGtk::XAttGtk( GtkWidget *xa_parent_wid,
'w', GdkModifierType(GDK_CONTROL_MASK), GTK_ACCEL_VISIBLE);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
......
......@@ -82,10 +82,12 @@ class XAttGtk : public XAtt {
int open_changevalue( char *name);
void change_value_close();
void pop();
void print();
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_close_changeval( GtkWidget *w, gpointer data);
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_display_object( GtkWidget *w, gpointer data);
static void activate_show_cross( GtkWidget *w, gpointer data);
static void activate_open_classgraph( GtkWidget *w, gpointer data);
......
......@@ -561,7 +561,7 @@ void XColWindGtk::print()
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, xattnav->brow->ctx, flow_eOrientation_Portrait,
wow->CreateBrowPrintDialog( title, xattnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
......
......@@ -67,6 +67,13 @@ void XCrrGtk::activate_exit(GtkWidget *w, gpointer data)
delete xcrr;
}
void XCrrGtk::activate_print(GtkWidget *w, gpointer data)
{
XCrr *xcrr = (XCrr *)data;
xcrr->activate_print();
}
void XCrrGtk::activate_openplc(GtkWidget *w, gpointer data)
{
XCrr *xcrr = (XCrr *)data;
......@@ -98,6 +105,18 @@ void XCrrGtk::pop()
gtk_window_present( GTK_WINDOW(toplevel));
}
void XCrrGtk::print()
{
pwr_tStatus sts;
pwr_tAName title;
sts = gdh_AttrrefToName( &objar, title, sizeof(title), cdh_mNName);
if ( EVEN(sts)) return;
CoWowGtk::CreateBrowPrintDialogGtk( title, xcrrnav->brow->ctx, flow_eOrientation_Portrait, 1.0,
(void *)toplevel, &sts);
}
XCrrGtk::~XCrrGtk()
{
delete xcrrnav;
......@@ -157,10 +176,14 @@ XCrrGtk::XCrrGtk(
GtkMenuBar *menu_bar = (GtkMenuBar *) g_object_new(GTK_TYPE_MENU_BAR, NULL);
// File entry
GtkWidget *file_print = gtk_image_menu_item_new_from_stock(GTK_STOCK_PRINT, accel_g);
g_signal_connect(file_print, "activate", G_CALLBACK(activate_print), this);
GtkWidget *file_close = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, accel_g);
g_signal_connect(file_close, "activate", G_CALLBACK(activate_exit), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_print);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_close);
GtkWidget *file = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_File"));
......
......@@ -64,8 +64,10 @@ class XCrrGtk : public XCrr {
CoWowFocusTimerGtk focustimer;
void pop();
void print();
static void activate_exit( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_openplc( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
......
......@@ -117,6 +117,11 @@ void XAtt::activate_open_plc()
}
}
void XAtt::activate_print()
{
print();
}
void XAtt::activate_help()
{
// Not yet implemented
......
......@@ -77,6 +77,7 @@ class XAtt {
virtual void change_value( int set_focus) {}
virtual void change_value_close() {}
virtual void pop() {}
virtual void print() {}
int open_changevalue( char *name);
void swap( int mode);
......@@ -86,6 +87,7 @@ class XAtt {
void activate_open_classgraph();
void activate_open_plc();
void activate_help();
void activate_print();
static void xatt_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
......
......@@ -71,8 +71,10 @@ class XCrr {
char input_name[80];
virtual void pop() {}
virtual void print() {}
int crossref();
void activate_print() {print();}
static void xcrr_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
char *arg, int x, int y);
......
......@@ -1333,12 +1333,12 @@ void XNav::print( char *filename)
void XNav::print_draw_page( void *context, const char *title, int page,
flow_eOrientation orientation)
{
brow_PrintDrawPage( brow->ctx, context, title, page, orientation);
brow_PrintDrawPage( brow->ctx, context, title, page, orientation, 1.0);
}
void XNav::print_get_pages( flow_eOrientation orientation, int *pages)
{
brow_PrintGetPages( brow->ctx, orientation, pages);
brow_PrintGetPages( brow->ctx, orientation, 1.0, pages);
}
//
......
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