Commit b7a95862 authored by Claes Sjofors's avatar Claes Sjofors

Gtk print dialog added

parent 20901257
......@@ -220,3 +220,4 @@
120821 cs cnv Xtthelp html pages generated for included helpfiles
120823 cs plc Plc, serveral processes, handling of error log and process status
120824 cs plc Plc, several plc processes, signal handling with rt_ini at start and restart
120926 cs neth Size check in subscription client message to avoid rt_neth crash at bad network
!
! 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.
!
! co_wow_msg.msg -- System information
!
! Return codes from system information routines.
!
.facility WOW,322 /prefix = WOW__ ! System information
success <successful completion> /succ
printdialogdisabled <print dialog disabled> /error
nyi <not yet implemented> /error
.end
......@@ -68,3 +68,4 @@
317 xatt
320 login
321 syi
322 wow
......@@ -314,6 +314,14 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Default printer.
!*/
Object Printer $Attribute 48
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Obsolete from V4.7.0.
!*/
Object OpNumber $Attribute 2
......
......@@ -71,6 +71,16 @@ SObject pwrb:Type
Attr Value = 2
EndBody
EndObject
!/**
! Enable Print Dialog.
!*/
Object EnablePrintDialog $Bit
Body SysBody
Attr PgmName = "EnablePrintDialog"
Attr Text = "EnablePrintDialog"
Attr Value = 4
EndBody
EndObject
EndObject
EndSObject
......
......@@ -212,4 +212,7 @@
120906 cs wb Build method for classdef to copy object graph
120906 cs wb Xtt and wb distinction
120912 cs wb wb, comment in autogenerated opt-file
120919 cs wb QCom disable auto connect between nodes in a project (refs #117)
120920 cs dist Distributor, display version info for package (refs #118)
120920 cs dist Distributor, next page, prev page and scroll events added
......@@ -204,6 +204,13 @@ void WAttGtk::activate_exit( GtkWidget *w, gpointer data)
delete watt;
}
void WAttGtk::activate_print( GtkWidget *w, gpointer data)
{
WAtt *watt = (WAtt *)data;
watt->activate_print();
}
void WAttGtk::activate_help( GtkWidget *w, gpointer data)
{
CoXHelp::dhelp( "objecteditor_refman", 0, navh_eHelpFile_Other,
......@@ -233,6 +240,14 @@ gboolean WAttGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer dat
return FALSE;
}
void WAttGtk::print( const char *title)
{
pwr_tStatus sts;
CoWowGtk::CreateBrowPrintDialogGtk( title, wattnav->brow->ctx, flow_eOrientation_Portrait,
(void *)toplevel, &sts);
}
#if 0
void WAttGtk::valchanged_cmd_input( Widget w, XEvent *event)
{
......@@ -508,7 +523,11 @@ WAttGtk::WAttGtk(
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);
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);
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");
......
......@@ -83,10 +83,12 @@ class WAttGtk : public WAtt {
int open_changevalue( char *name);
void change_value_close();
void pop();
void print( const char *title);
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_help( GtkWidget *w, gpointer data);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void valchanged_cmd_input( GtkWidget *w, gpointer data);
......
......@@ -75,6 +75,14 @@ void WdaGtk::set_prompt( const char *prompt)
}
}
void WdaGtk::print( const char *title)
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, wdanav->brow->ctx, flow_eOrientation_Portrait,
(void *)toplevel, &sts);
}
void WdaGtk::change_value( int set_focus)
{
int sts;
......@@ -186,7 +194,7 @@ void WdaGtk::activate_print( GtkWidget *w, gpointer data)
{
Wda *wda = (Wda *)data;
wda->print();
wda->activate_print();
}
void WdaGtk::activate_export_text( GtkWidget *w, gpointer data)
......
......@@ -89,6 +89,7 @@ class WdaGtk : public Wda {
void pop();
void open_class_dialog( char *hierstr, char *classstr);
void create_class_dialog();
void print( const char *title);
static void activate_change_value( GtkWidget *w, gpointer data);
static void activate_close_changeval( GtkWidget *w, gpointer data);
......
......@@ -140,6 +140,7 @@ WNavGtk::WNavGtk(
wow = new CoWowGtk( parent_wid);
toplevel = form_widget;
*status = 1;
}
......@@ -212,6 +213,14 @@ void WNavGtk::trace_scan( WNavGtk *wnav)
}
}
void WNavGtk::print( const char *title)
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, brow->ctx, flow_eOrientation_Portrait,
(void *)0, &sts);
}
int WNavGtk::get_selection( char *str, int len)
{
int sts;
......
......@@ -71,6 +71,7 @@ class WNavGtk : public WNav {
void pop();
void set_inputfocus( int focus);
void print( const char *title);
void trace_start();
void set_selection_owner();
Ge *ge_new( char *graph_name, int nojournal);
......
......@@ -105,6 +105,19 @@ void WdaMotif::set_prompt( const char *prompt)
XmStringFree( cstr);
}
void WdaMotif::print( const char *title)
{
pwr_tFileName filename = "$pwrp_tmp/wda.ps";
pwr_tCmd cmd;
int sts;
dcli_translate_filename( filename, filename);
wdanav->print(filename);
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
}
void WdaMotif::change_value( int set_focus)
{
int sts;
......
......@@ -83,6 +83,7 @@ class WdaMotif : public Wda {
void change_value_close();
void pop();
void open_class_dialog( char *hierstr, char *classstr);
void print( const char *title);
static void enable_set_focus( WdaMotif *wda);
static void disable_set_focus( WdaMotif *wda, int time);
......
......@@ -247,6 +247,20 @@ void WNavMotif::set_selection_owner()
selection_owner = 1;
}
void WNavMotif::print( const char *title)
{
char filename[80] = "pwrp_tmp:wnav.ps";
char cmd[200];
dcli_translate_filename( filename, filename);
brow_Print( brow->ctx, filename);
#if defined OS_POSIX
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
#endif
}
void WNavMotif::create_popup_menu( pwr_tAttrRef aref, int x, int y)
{
short x1, y1;
......
......@@ -70,6 +70,7 @@ class WNavMotif : public WNav {
void pop();
void set_inputfocus( int focus);
void print( const char *title);
void trace_start();
void set_selection_owner();
Ge *ge_new( char *graph_name, int nojournal);
......
......@@ -64,6 +64,20 @@ void WAtt::change_value_cb( void *watt)
((WAtt *)watt)->change_value(1);
}
void WAtt::activate_print()
{
char *namep;
pwr_tStatus sts;
int size;
pwr_tAName aname;
sts = ldh_AttrRefToName( ldhses, &aref, ldh_eName_VolPath, &namep, &size);
if ( EVEN(sts)) return;
strcpy( aname, namep);
print( aname);
}
void WAtt::set_editmode( int editmode, ldh_tSesContext ldhses)
{
this->ldhses = ldhses;
......
......@@ -90,7 +90,9 @@ class WAtt {
virtual void change_value( int set_focus) {}
virtual void change_value_close() {}
virtual void pop() {}
virtual void print( const char *title) {}
void activate_print();
void set_editmode( int editmode, ldh_tSesContext ldhses);
int open_changevalue( const char *name, int close = 0);
static void message_cb( void *watt, char severity, const char *message);
......
......@@ -74,17 +74,9 @@ void Wda::change_value_cb( void *wda)
((Wda *)wda)->change_value(1);
}
void Wda::print()
void Wda::activate_print()
{
pwr_tFileName filename = "$pwrp_tmp/wda.ps";
pwr_tCmd cmd;
int sts;
dcli_translate_filename( filename, filename);
wdanav->print(filename);
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
print( "Speadsheet Editor");
}
void Wda::print_textfile()
......
......@@ -98,6 +98,7 @@ class Wda {
virtual void change_value( int set_focus) {}
virtual void change_value_close() {}
virtual void pop() {}
virtual void print( const char *title) {}
int open_changevalue( char *name);
void set_editmode( int editmode, ldh_tSesContext ldhses);
......@@ -108,6 +109,7 @@ class Wda {
void print();
void print_textfile();
void import_textfile();
void activate_print();
static void message_cb( void *wda, char severity, const char *message);
static void change_value_cb( void *wda);
......
......@@ -643,14 +643,6 @@ WNav::~WNav()
{
}
//
// Print
//
void WNav::print( char *filename)
{
brow_Print( brow->ctx, filename);
}
//
// Get current zoom factor
//
......
......@@ -316,6 +316,7 @@ class WNav : public WUtility{
virtual void pop() {}
virtual void set_inputfocus( int focus) {}
virtual void print( const char *title) {}
virtual void trace_start() {}
virtual void set_selection_owner() {}
virtual Ge *ge_new( char *graph_name, int nojournal) { return 0;}
......@@ -353,7 +354,6 @@ class WNav : public WUtility{
int create_object_item( pwr_tObjid objid,
brow_tNode dest, flow_eDest dest_code, void **item,
int is_root);
void print( char *filename);
void zoom( double zoom_factor);
void get_zoom( double *zoom_factor);
void unzoom();
......
......@@ -956,22 +956,27 @@ int Wtt::get_wbctx( void *ctx, ldh_tWBContext *wbctx)
void Wtt::activate_print()
{
char filename[80] = "pwrp_tmp:wnav.ps";
char cmd[200];
ldh_sVolumeInfo info;
int sts;
int size;
char title[80];
if ( !ldhses)
return;
sts = ldh_GetVolumeInfo( ldh_SessionToVol( ldhses), &info);
if (EVEN(sts)) return;
strcpy( title, "PwR ");
sts = ldh_VolumeIdToName( ldh_SessionToWB( ldhses), info.Volume,
&title[4], sizeof(title)-4, &size);
if ( EVEN(sts)) return;
if ( !focused_wnav)
set_focus_default();
set_clock_cursor();
dcli_translate_filename( filename, filename);
focused_wnav->print( filename);
#if defined OS_POSIX
sprintf( cmd, "wb_gre_print.sh %s", filename);
sts = system( cmd);
#endif
focused_wnav->print( title);
reset_cursor();
}
......
......@@ -248,3 +248,6 @@
120823 cs ge Ge command 'move selected' bugfix (refs #42)
120827 cs xtt Alarm window, button to ack all alarms, and xtt command 'eventlist ack/all'
120907 cs xtt Xtt display values as hex, octal, binary etc
120912 cs xtt Xtt, alarm beep wasn't controled by OpPlace AlarmBell attribute
120919 cs xtt Xtt, bugfix in display of Do channel flags (refs #116)
120920 cs xtt Xtt bugfix, Hold and Scantime didn't work in Dv object graph
......@@ -293,6 +293,30 @@ void XttGtk::activate_print( GtkWidget *w, gpointer data)
xtt->activate_print();
}
void XttGtk::print()
{
char title[120] = "Xtt ";
char nodename[80];
pwr_tStatus sts;
syi_NodeName( &sts, nodename, sizeof(nodename));
if ( ODD(sts))
strcat( title, nodename);
wow->CreateBrowPrintDialog( title, xnav->brow->ctx, flow_eOrientation_Portrait,
(void *)toplevel, &sts);
if ( sts == WOW__PRINTDIALOGDISABLED) {
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
xnav->print( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
}
void XttGtk::activate_login( GtkWidget *w, gpointer data)
{
Xtt *xtt = (Xtt *)data;
......@@ -693,7 +717,7 @@ XttGtk::XttGtk( int argc, char *argv[], int *return_sts) :
// File Entry
GtkWidget *file_print = gtk_image_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Print"));
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(file_print),
gtk_image_new_from_stock( "gtk-print", GTK_ICON_SIZE_MENU));
gtk_image_new_from_stock( GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU));
g_signal_connect(file_print, "activate", G_CALLBACK(XttGtk::activate_print), this);
GtkWidget *file_login = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("_Login"));
......
......@@ -84,6 +84,7 @@ class XttGtk : public Xtt {
void set_prompt( const char *prompt);
void open_change_value();
void create_input_dialog();
void print();
static void close( void *ctx, int terminate);
static void set_dimension( void *ctx, int width, int height);
......
......@@ -534,6 +534,17 @@ void XttMotif::valchanged_cmd_input( Widget w, XEvent *event, XmAnyCallbackStruc
}
}
void XttMotif::print()
{
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
xnav->print( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
int main( int argc, char *argv[])
{
......
......@@ -83,6 +83,7 @@ class XttMotif : public Xtt {
void (*ok_cb)( Xtt *, char *));
void set_prompt( const char *prompt);
void open_change_value();
void print();
static void close( void *ctx, int terminate);
static void set_dimension( void *ctx, int width, int height);
......
......@@ -93,6 +93,7 @@ class Xtt {
void (*ok_cb)( Xtt *, char *)) {}
virtual void set_prompt( const char *prompt) {}
virtual void open_change_value() {}
virtual void print() {}
void list_opplace();
static void opplace_selected_cb( void *ctx, char *text);
......
......@@ -283,14 +283,7 @@ void Xtt::selection_changed( void *ctx)
//
void Xtt::activate_print()
{
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
xnav->print( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
print();
}
void Xtt::activate_find()
......@@ -815,6 +808,11 @@ Xtt::Xtt( int *argc, char **argv[], int *return_sts) :
if ( opp->AttachAudio)
attach_audio = 1;
if ( !(opp->Options & pwr_mOpPlaceOptionsMask_EnablePrintDialog))
CoWow::DisablePrintDialog();
if ( strcmp( opp->Printer, "") != 0)
CoWow::SetDefaultPrinter( opp->Printer);
}
if ( quiet)
......
......@@ -48,6 +48,8 @@
#include "co_cdh.h"
#include "co_api.h"
#include "co_lng.h"
#include "co_wow_msg.h"
#include "flow_browapi.h"
#define WOW_MAXNAMES 400
......@@ -60,6 +62,12 @@ typedef struct {
int new_main;
} wow_sSelection;
typedef struct {
char title[80];
brow_tCtx brow_ctx;
flow_eOrientation orientation;
} wow_sPrintData;
CoWowGtk::~CoWowGtk()
{
......@@ -1522,6 +1530,99 @@ void CoWowGtk::Wait( float time)
static void begin_print( GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
int pages;
brow_PrintGetPages( print_data->brow_ctx, flow_eOrientation_Portrait, &pages);
gtk_print_operation_set_n_pages( operation, pages);
}
static void end_print( GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
free( print_data);
}
static void draw_page( GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_nr,
gpointer user_data)
{
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
brow_PrintDrawPage( print_data->brow_ctx, context, print_data->title, page_nr,
flow_eOrientation_Portrait);
}
static void request_page_setup( GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_nr,
GtkPageSetup *setup,
gpointer user_data)
{
wow_sPrintData *print_data = (wow_sPrintData *)user_data;
if ( print_data->orientation == flow_eOrientation_Landscape)
gtk_page_setup_set_orientation( setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
else
gtk_page_setup_set_orientation( setup, GTK_PAGE_ORIENTATION_PORTRAIT);
}
void CoWowGtk::CreateBrowPrintDialogGtk( const char *title, void *brow_ctx, int orientation,
void *parent_widget, pwr_tStatus *sts)
{
static GtkPrintSettings *settings = 0;
GtkPrintOperation *print;
GtkPrintOperationResult result;
GtkPrintOperationAction action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
if ( m_printdialog_disable && strcmp( m_default_printer, "") == 0) {
*sts = WOW__PRINTDIALOGDISABLED;
return;
}
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;
strncpy( print_data->title, title, sizeof(print_data->title));
print = gtk_print_operation_new();
if ( settings)
gtk_print_operation_set_print_settings( print, settings);
else
settings = gtk_print_settings_new();
if ( strcmp( m_default_printer, "") != 0) {
gtk_print_settings_set_printer( settings, m_default_printer);
gtk_print_operation_set_print_settings( print, settings);
}
if ( m_printdialog_disable)
action = GTK_PRINT_OPERATION_ACTION_PRINT;
g_signal_connect( print, "begin_print", G_CALLBACK(begin_print), print_data);
g_signal_connect( print, "draw_page", G_CALLBACK(draw_page), print_data);
g_signal_connect( print, "request_page_setup", G_CALLBACK(request_page_setup), print_data);
g_signal_connect( print, "end_print", G_CALLBACK(end_print), print_data);
gtk_print_operation_set_allow_async( print, TRUE);
result = gtk_print_operation_run( print, action, GTK_WINDOW(parent_widget), 0);
if ( result == GTK_PRINT_OPERATION_RESULT_APPLY) {
if ( settings)
g_object_unref( settings);
settings = (GtkPrintSettings *)g_object_ref( gtk_print_operation_get_print_settings( print));
}
g_object_unref( print);
*sts = WOW__SUCCESS;
}
......
......@@ -148,6 +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 *parent_widget, pwr_tStatus *sts) {
CreateBrowPrintDialogGtk( title, brow_ctx, orientation, parent_widget, sts);}
static void CreateBrowPrintDialogGtk( const char *title, void *brow_ctx, int orientation,
void *parent_widget, pwr_tStatus *sts);
CoWowTimer *timer_new();
void SetParent( GtkWidget *parent) { m_parent = parent;}
void Wait( float time);
......
......@@ -45,6 +45,8 @@
#include "co_dcli.h"
bool CoWow::m_autoremove = false;
bool CoWow::m_printdialog_disable = false;
char CoWow::m_default_printer[80] = "";
CoWow::~CoWow() {}
......
......@@ -40,6 +40,7 @@
/* cow_wow -- useful windows */
#include <string.h>
#include "co_wow_msg.h"
typedef enum {
wow_eFileSelType_,
......@@ -102,6 +103,8 @@ class CoWowRecall {
class CoWow {
protected:
static bool m_autoremove;
static bool m_printdialog_disable;
static char m_default_printer[80];
public:
CoWow() {}
......@@ -150,6 +153,11 @@ class CoWow {
virtual CoWowTimer *timer_new() { return 0;}
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;}
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;}
static void SetAutoRemove( bool on) { m_autoremove = on;}
};
......
......@@ -46,6 +46,7 @@
#include "flow_draw_gtk.h"
#include "flow_msg.h"
#include "flow_widget_gtk.h"
#include "flow_printdraw_gtk.h"
#include "pwr.h"
#include "co_dcli.h"
#include "flow_browwidget_gtk.h"
......@@ -2026,3 +2027,11 @@ int FlowDrawGtk::image_load( const char *imagefile, float scale, float nav_scale
*im = (flow_tImImage *) gdk_pixbuf_scale_simple( (GdkPixbuf *)*orig_im, width, height, GDK_INTERP_NEAREST);
return 1;
}
FlowPrintDraw *FlowDrawGtk::print_draw_new( void *context, const char *title, int page,
void *flow_ctx, int page_border, int *sts)
{
FlowPrintDrawGtk *pd = new FlowPrintDrawGtk( context, title, page, flow_ctx,
page_border, sts);
return (FlowPrintDraw *)pd;
}
......@@ -206,6 +206,8 @@ class FlowDrawGtk : public FlowDraw {
int get_text_extent_pango( FlowCtx *ctx, const char *text, int len,
flow_eDrawType gc_type, int idx, double size,
int *width, int *height);
FlowPrintDraw *print_draw_new( void *context, const char *title, int page, void *flow_ctx,
int page_border, int *sts);
};
#endif
/*
* 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.
**/
#include "flow_std.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <gtk/gtk.h>
#include "flow_ctx.h"
#include "flow_printdraw_gtk.h"
FlowPrintDrawGtk::FlowPrintDrawGtk( void *context, const char *t, int p, void *flow_ctx, int page_border,
int *sts) :
print_ctx((GtkPrintContext *)context), border(page_border), ctx((FlowCtx *)flow_ctx), show_red(1), page(p)
{
strncpy( title, t, sizeof(title));
*sts = 1;
}
FlowPrintDrawGtk::~FlowPrintDrawGtk()
{
}
int FlowPrintDrawGtk::print_page( double ll_x, double ll_y, double ur_x, double ur_y)
{
PangoLayout *layout;
gdouble width, text_height;
gint layout_height, layout_width;
PangoFontDescription *desc;
char page_str[40];
if ( ur_x - ll_x > ur_y - ll_y)
ctx->print_zoom_factor = 730 / (ur_x - ll_x);
else
ctx->print_zoom_factor = 730 / (ur_y - ll_y);
ctx->print_zoom();
page_x = ll_x * ctx->print_zoom_factor;
page_y = ll_y * ctx->print_zoom_factor;
cairo = gtk_print_context_get_cairo_context (print_ctx);
width = gtk_print_context_get_width (print_ctx);
cairo_move_to( cairo, 0, 0);
cairo_line_to( cairo, width, 0);
cairo_set_source_rgb( cairo, 0, 0, 0);
cairo_set_line_width( cairo, 0.5);
cairo_stroke( cairo);
layout = gtk_print_context_create_pango_layout( print_ctx);
desc = pango_font_description_from_string( "Lucida Sans 9");
pango_layout_set_font_description( layout, desc);
pango_font_description_free( desc);
sprintf( page_str, "Page %d", page + 1);
pango_layout_set_width( layout, -1);
pango_layout_set_text( layout, page_str, -1);
pango_layout_set_alignment( layout, PANGO_ALIGN_LEFT);
pango_layout_get_size( layout, NULL, &layout_height);
text_height = (gdouble)layout_height / PANGO_SCALE;
cairo_move_to( cairo, width - 50, -text_height);
cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout);
g_object_unref( layout);
layout = gtk_print_context_create_pango_layout (print_ctx);
desc = pango_font_description_from_string( "Lucida Sans 9");
pango_layout_set_font_description( layout, desc);
pango_font_description_free( desc);
pango_layout_set_width( layout, -1);
pango_layout_set_alignment( layout, PANGO_ALIGN_CENTER);
pango_layout_set_text( layout, title, -1);
pango_layout_get_size( layout, &layout_width, &layout_height);
text_height = (gdouble)layout_height / PANGO_SCALE;
cairo_move_to (cairo, width/2 - (gdouble)layout_width/PANGO_SCALE/2, -text_height);
cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout);
g_object_unref( layout);
cairo_rectangle( cairo, 0, 0, (ur_x - ll_x) * ctx->print_zoom_factor,
(ur_y - ll_y) * ctx->print_zoom_factor);
cairo_clip( cairo);
((FlowCtx *)ctx)->current_print = this;
((FlowCtx *)ctx)->print( ll_x, ll_y, ur_x, ur_y);
cairo_reset_clip( cairo);
return 1;
}
int FlowPrintDrawGtk::rect( double x, double y, double width, double height, flow_eDrawType type,
double idx, int highlight)
{
switch( type) {
case flow_eDrawType_LineRed:
cairo_set_source_rgb( cairo, 1, 0, 0);
break;
default:
cairo_set_source_rgb( cairo, 0, 0, 0);
}
cairo_set_line_width( cairo, 0.5 * idx);
cairo_rectangle( cairo, x - page_x, y - page_y, width, height);
cairo_stroke( cairo);
return 1;
}
int FlowPrintDrawGtk::filled_rect( double x, double y, double width, double height, flow_eDrawType type,
double idx)
{
switch( type) {
case flow_eDrawType_LineRed:
cairo_set_source_rgb( cairo, 1, 0, 0);
break;
case flow_eDrawType_Green:
cairo_set_source_rgb( cairo, 0, 1, 0);
break;
case flow_eDrawType_Yellow:
cairo_set_source_rgb( cairo, 1, 1, 0);
break;
case flow_eDrawType_DarkGray:
cairo_set_source_rgb( cairo, 0.3, 0.3, 0.3);
break;
default:
cairo_set_source_rgb( cairo, 0, 0, 0);
}
cairo_rectangle( cairo, x - page_x, y - page_y, width, height);
cairo_fill( cairo);
cairo_set_source_rgb( cairo, 0, 0, 0);
cairo_set_line_width( cairo, 0.5 * idx);
cairo_rectangle( cairo, x - page_x, y - page_y, width, height);
cairo_stroke( cairo);
return 1;
}
int FlowPrintDrawGtk::arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight)
{
return 1;
}
int FlowPrintDrawGtk::line( double x1, double y1, double x2, double y2, flow_eDrawType type,
double idx, int highlight)
{
return 1;
}
int FlowPrintDrawGtk::text( double x, double y, char *text, int len, flow_eDrawType type,
double size)
{
char font[40];
PangoLayout *layout;
PangoFontDescription *desc;
int w, h;
switch( type) {
case flow_eDrawType_TextHelvetica:
sprintf( font, "Lucida Sans %3.1f", 1.0 * size);
break;
case flow_eDrawType_TextHelveticaBold:
sprintf( font, "Lucida Sans Bold %3.1f", 1.0 * size);
break;
default:
;
}
layout = gtk_print_context_create_pango_layout( print_ctx);
desc = pango_font_description_from_string( font);
pango_layout_set_font_description( layout, desc);
pango_font_description_free( desc);
char *textutf8 = g_convert( text, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
pango_layout_set_text( layout, textutf8, -1);
pango_layout_set_alignment( layout, PANGO_ALIGN_LEFT);
pango_layout_get_size( layout, &w, &h);
cairo_move_to( cairo, x - page_x, y - page_y - 0.8 / PANGO_SCALE * h);
cairo_set_source_rgb( cairo, 0, 0, 0);
pango_cairo_show_layout( cairo, layout);
g_free( textutf8);
return 1;
}
int FlowPrintDrawGtk::pixmap( double x, double y, flow_sPixmapDataElem *data,
flow_eDrawType type)
{
int stride;
cairo_surface_t *surface;
unsigned char *sdata;
unsigned char *data_p, *sdata_p;
int bit_cnt;
int i, j;
float scale = 0.7;
// Do do, set color
switch( type) {
case flow_eDrawType_LineRed:
break;
default: ;
}
stride = cairo_format_stride_for_width( CAIRO_FORMAT_A1, data->width);
sdata = (unsigned char *) calloc( 1, stride * data->height);
data_p = (unsigned char *)data->bits;
for ( i = 0; i < data->height; i++) {
bit_cnt = 0;
sdata_p = sdata + i * stride;
for ( j = 0; j < data->width; j++) {
if ( bit_cnt == 8) {
bit_cnt = 0;
data_p++;
sdata_p++;
}
if ( *data_p & ( 1 << bit_cnt))
*sdata_p |= 1 << bit_cnt;
bit_cnt++;
}
data_p++;
}
surface = cairo_image_surface_create_for_data( sdata, CAIRO_FORMAT_A1, data->width,
data->height, stride);
cairo_scale( cairo, scale, scale);
//cairo_mask_surface( cairo, surface, (x - page_x)/scale, (y - page_y)/scale);
cairo_set_source_surface( cairo, surface, (x - page_x)/scale, (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)
{
return 1;
}
/*
* 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 flow_printdraw_gtk_h
#define flow_printdraw_gtk_h
#include <stdio.h>
#include <gtk/gtk.h>
#include "flow.h"
#include "flow_printdraw.h"
class FlowPrintDrawGtk : public FlowPrintDraw {
public:
FlowPrintDrawGtk( void *context, const char *title, int page, void *flow_ctx, int page_border, int *sts);
~FlowPrintDrawGtk();
int print_page( double ll_x, double ll_y, double ur_x, double ur_y);
int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight);
int filled_rect( double x, double y, double width, double height, flow_eDrawType type, double idx);
int arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight);
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 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;}
GtkPrintContext *print_ctx;
int border;
FlowCtx *ctx;
int show_red;
cairo_t *cairo;
double page_x;
double page_y;
char title[80];
int page;
};
#endif
......@@ -123,6 +123,11 @@ typedef enum {
flow_eDirection_Down
} flow_eDirection;
typedef enum {
flow_eOrientation_Portrait,
flow_eOrientation_Landscape
} flow_eOrientation;
typedef enum {
flow_eNodeGroup_Common,
flow_eNodeGroup_Document,
......
......@@ -460,6 +460,17 @@ int brow_Print( brow_tCtx ctx, char *filename)
return ctx->print( filename);
}
void brow_PrintDrawPage( brow_tCtx ctx, void *context, const char *title, int page,
flow_eOrientation orientation)
{
ctx->print_draw_page( context, title, page, orientation);
}
void brow_PrintGetPages( brow_tCtx ctx, flow_eOrientation orientation, int *pages)
{
ctx->print_get_pages( orientation, pages);
}
void brow_GetUserData( brow_tObject object, void **user_data)
{
((FlowArrayElem *)object)->get_user_data( user_data);
......
......@@ -180,6 +180,9 @@ flow_eObjectType brow_GetObjectType( brow_tObject object);
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);
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);
......
......@@ -218,6 +218,60 @@ int BrowCtx::print( char *filename)
return 1;
}
void BrowCtx::print_draw_page( void *context, const char *title, int page,
flow_eOrientation orientation)
{
double ll_x, ll_y, ur_x, ur_y;
double width, height;
int sts;
if ( a.size() == 0)
return;
((FlowNode *)a[0])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y);
width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) {
height = 40 * ( ur_y - ll_y);
width = height / 0.70;
}
current_print = (FlowPrint *)fdraw->print_draw_new( context, title, page, this, 1, &sts);
if ( EVEN(sts)) return;
ll_y = page * height;
ur_y = ll_y + height;
ll_x = 0;
ur_x = width;
if ( ll_y > y_high)
return;
current_print->print_page( ll_x, ll_y, ur_x, ur_y);
delete current_print;
}
void BrowCtx::print_get_pages( flow_eOrientation orientation, int *pages)
{
double ll_x, ll_y, ur_x, ur_y;
double width, height;
if ( a.size() == 0) {
*pages = 0;
return;
}
((FlowNode *)a[0])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
height = 60 * (ur_y - ll_y);
width = 0.70 * height;
if ( orientation == flow_eOrientation_Landscape) {
// Portrait
height = 40 * ( ur_y - ll_y);
width = height / 0.70;
}
*pages = int(y_high / height + 1);
}
int BrowCtx::is_visible( FlowArrayElem *element, flow_eVisible type)
{
......
......@@ -64,6 +64,9 @@ class BrowCtx : public FlowCtx {
void zoom( double factor);
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);
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)
......
......@@ -40,6 +40,7 @@
#include <stdlib.h>
class FlowCtx;
class FlowPrintDraw;
class FlowDraw {
public:
......@@ -169,6 +170,8 @@ class FlowDraw {
flow_tImImage *orig_im, flow_tImImage *im,
flow_tPixmap *im_pixmap, flow_tPixmap *im_mask,
flow_tPixmap *im_nav_pixmap, flow_tPixmap *im_nav_mask) {return 0;}
virtual FlowPrintDraw *print_draw_new( void *context, const char *title, int page,
void *flow_ctx, int page_border, int *sts) {*sts = 0; return 0;}
};
......
/*
* 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 flow_printdraw_h
#define flow_printdraw_h
#include <stdio.h>
#include "flow.h"
#include "flow_print.h"
class FlowPrintDraw : public FlowPrint {
public:
FlowPrintDraw() {}
virtual ~FlowPrintDraw() {}
virtual int print_page( double ll_x, double ll_y, double ur_x, double ur_y) {return 1;}
virtual int rect( double x, double y, double width, double height, flow_eDrawType type, double idx, int highlight) {return 1;}
virtual int filled_rect( double x, double y, double width, double height, flow_eDrawType type, double idx) {return 1;}
virtual int arc( double x, double y, double width, double height, int angle1, int angle2,
flow_eDrawType type, double idx, int highlight) {return 1;}
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 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) {}
};
#endif
......@@ -44,6 +44,7 @@
#include "co_cdh.h"
#include "co_time.h"
#include "co_syi.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
......@@ -123,6 +124,10 @@ CLogGtk::CLogGtk( void *clog_parent_ctx,
'u', 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_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));
......@@ -136,6 +141,7 @@ CLogGtk::CLogGtk( void *clog_parent_ctx,
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_next_file);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_prev_file);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_update);
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"));
......@@ -381,6 +387,13 @@ void CLogGtk::activate_update( GtkWidget *w, gpointer data)
clog->reset_cursor();
}
void CLogGtk::activate_print( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
clog->activate_print();
}
void CLogGtk::activate_help( GtkWidget *w, gpointer data)
{
CLog *clog = (CLog *)data;
......@@ -508,4 +521,21 @@ void CLogGtk::create_filter_dialog()
}
void CLogGtk::print()
{
char nodename[80];
pwr_tStatus sts;
char title[80];
strcpy( title, "System Messages ");
syi_NodeName( &sts, nodename, sizeof(nodename));
if ( ODD(sts)) {
strcat( title, " ");
strcat( title, nodename);
}
wow->CreateBrowPrintDialog( title, clognav->brow->ctx, flow_eOrientation_Landscape,
parent_wid, &sts);
}
......@@ -73,6 +73,7 @@ class CLogGtk : public CLog {
void reset_cursor();
void free_cursor();
void create_filter_dialog();
void print();
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
static void activate_exit( GtkWidget*w, gpointer data);
......@@ -80,6 +81,7 @@ class CLogGtk : public CLog {
static void activate_next_file( GtkWidget*w, gpointer data);
static void activate_prev_file( GtkWidget*w, gpointer data);
static void activate_update( 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);
......
......@@ -44,6 +44,7 @@
#include "co_cdh.h"
#include "co_time.h"
#include "co_syi.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_mh.h"
......@@ -95,3 +96,21 @@ void EvListGtk::popup_position( int x_event, int y_event, int *x, int *y)
{
CoWowGtk::PopupPosition( brow_widget, x_event, y_event, x, y);
}
void EvListGtk::print( const char *title)
{
char nodename[80];
pwr_tStatus sts;
char print_title[120];
strcpy( print_title, title);
syi_NodeName( &sts, nodename, sizeof(nodename));
if ( ODD(sts)) {
strcat( print_title, " ");
strcat( print_title, nodename);
}
CoWowGtk::CreateBrowPrintDialogGtk( print_title, brow->ctx, flow_eOrientation_Landscape,
GTK_WINDOW(parent_wid), &sts);
}
......@@ -58,9 +58,11 @@ class EvListGtk : public EvList {
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
char print_title[120];
void set_input_focus();
void bell();
void print( const char *title);
void popup_position( int x_event, int y_event, int *x, int *y);
};
......
......@@ -210,6 +210,13 @@ void XColWindGtk::activate_saveas( GtkWidget *w, gpointer data)
xcolwind->activate_saveas();
}
void XColWindGtk::activate_print( GtkWidget *w, gpointer data)
{
XColWind *xcolwind = (XColWind *)data;
xcolwind->activate_print();
}
void XColWindGtk::activate_close_changeval( GtkWidget *w, gpointer data)
{
XColWind *xcolwind = (XColWind *)data;
......@@ -550,6 +557,14 @@ void XColWindGtk::get_window_size( int *w, int *h)
gtk_window_get_size( GTK_WINDOW(toplevel), w, h);
}
void XColWindGtk::print()
{
pwr_tStatus sts;
wow->CreateBrowPrintDialog( title, xattnav->brow->ctx, flow_eOrientation_Portrait,
(void *)toplevel, &sts);
}
XColWindGtk::~XColWindGtk()
{
delete (XAttNav *)xattnav;
......@@ -631,11 +646,16 @@ XColWindGtk::XColWindGtk( GtkWidget *xa_parent_wid,
g_signal_connect( file_open, "activate",
G_CALLBACK(activate_open), this);
GtkWidget *file_print = gtk_menu_item_new_with_mnemonic( CoWowGtk::translate_utf8("_Print"));
g_signal_connect( file_print, "activate",
G_CALLBACK(activate_print), this);
GtkMenu *file_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_open);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_save);
gtk_menu_shell_append(GTK_MENU_SHELL(file_menu), file_saveas);
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"));
......
......@@ -87,12 +87,14 @@ class XColWindGtk : public XColWind {
void set_title( char *title);
void set_window_size( int w, int h);
void get_window_size( int *w, int *h);
void print();
static void activate_open( GtkWidget *w, gpointer data);
static void activate_save( GtkWidget *w, gpointer data);
static void activate_saveas( GtkWidget *w, gpointer data);
static void activate_insert( GtkWidget *w, gpointer data);
static void activate_delete( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data);
static void activate_moveup( GtkWidget *w, gpointer data);
static void activate_movedown( GtkWidget *w, gpointer data);
static void activate_change_value( GtkWidget *w, gpointer data);
......
......@@ -84,6 +84,14 @@ void CLog::activate_prev_file()
reset_cursor();
}
void CLog::activate_print()
{
if ( CoWow::PrintDialogIsDisabled())
wow->DisplayError( "Disabled", "Print Dialog is disabled");
else
print();
}
void CLog::activate_help()
{
if ( help_cb)
......
......@@ -69,9 +69,11 @@ class CLog {
virtual void set_clock_cursor() {}
virtual void reset_cursor() {}
virtual void free_cursor() {}
virtual void print() {}
void activate_next_file();
void activate_prev_file();
void activate_print();
void activate_help();
};
......
......@@ -163,38 +163,50 @@ void Ev::blk_display_in_xnav_cb( void *ctx, pwr_tAttrRef *arp)
void Ev::eve_activate_print()
{
if ( CoWow::PrintDialogIsDisabled()) {
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
eve->print( filename);
eve->print_nodia( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
else
eve->print( "Event List");
}
void Ev::ala_activate_print()
{
if ( CoWow::PrintDialogIsDisabled()) {
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
ala->print( filename);
ala->print_nodia( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
else
ala->print( "Alarm List");
}
void Ev::blk_activate_print()
{
if ( CoWow::PrintDialogIsDisabled()) {
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
blk->print( filename);
blk->print_nodia( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
else
blk->print( "Block List");
}
void Ev::eve_activate_ack_last()
......
......@@ -934,7 +934,7 @@ void EvList::event_return( mh_sReturn *msg)
}
}
void EvList::print( char *filename)
void EvList::print_nodia( char *filename)
{
brow_Print( brow->ctx, filename);
}
......
......@@ -189,6 +189,7 @@ class EvList {
virtual void set_input_focus() {}
virtual void bell() {}
virtual void popup_position( int x_event, int y_event, int *x, int *y) {}
virtual void print( const char *title) {}
void event_info( mh_sMessage *msg);
void event_alarm( mh_sMessage *msg);
......@@ -218,7 +219,7 @@ class EvList {
int get_selected_event( char *eventname, ItemAlarm **item);
int get_destination( pwr_tTime time, void **dest);
void block_remove();
void print( char *filename);
void print_nodia( char *filename);
static int init_brow_cb( FlowCtx *fctx, void *client_data);
static int brow_cb( FlowCtx *ctx, flow_tEvent event);
......
......@@ -128,10 +128,14 @@ void Hist::hist_display_in_xnav_cb( void *ctx, pwr_sAttrRef *arp)
void Hist::activate_print()
{
if ( CoWow::PrintDialogIsDisabled()) {
char filename[200];
dcli_translate_filename( filename, "$pwrp_tmp/xnav.ps");
hist->print( filename);
hist->print_nodia( filename);
}
else
hist->print( "Event Log");
}
void Hist::activate_help()
......
......@@ -311,6 +311,12 @@ void XColWind::activate_movedown()
}
}
void XColWind::activate_print()
{
if ( !CoWow::PrintDialogIsDisabled())
print();
}
void XColWind::activate_help()
{
// Not yet implemented
......
......@@ -100,6 +100,7 @@ class XColWind {
virtual void set_title( char *title) {}
virtual void set_window_size( int w, int h) {}
virtual void get_window_size( int *w, int *h) {}
virtual void print() {}
int open_changevalue( char *name);
void swap( int mode);
......@@ -123,6 +124,7 @@ class XColWind {
void activate_zoomin();
void activate_zoomout();
void activate_help();
void activate_print();
static void xcolwind_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
unsigned long item_type, unsigned long utility,
......
......@@ -1330,6 +1330,17 @@ void XNav::print( char *filename)
brow_Print( brow->ctx, filename);
}
void XNav::print_draw_page( void *context, const char *title, int page,
flow_eOrientation orientation)
{
brow_PrintDrawPage( brow->ctx, context, title, page, orientation);
}
void XNav::print_get_pages( flow_eOrientation orientation, int *pages)
{
brow_PrintGetPages( brow->ctx, orientation, pages);
}
//
// Get zoom
//
......
......@@ -416,6 +416,9 @@ class XNav {
brow_tNode dest, flow_eDest dest_code, void **item,
int is_root);
void 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);
void zoom( double zoom_factor);
void get_zoom( double *zoom_factor);
void unzoom();
......
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