Patch level : 2.1 nopatch
Files correlati : Ricompilazione Demo : [ ] Commento : Spostate da BA ad INCLUDE tutte le nuove classi delle Query e dei Report git-svn-id: svn://10.65.10.50/trunk@12062 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									37aa5fd6b5
								
							
						
					
					
						commit
						ccde3b0440
					
				
							
								
								
									
										1287
									
								
								include/alex.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										1287
									
								
								include/alex.cpp
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										74
									
								
								include/alex.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										74
									
								
								include/alex.h
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,74 @@
 | 
				
			|||||||
 | 
					#ifndef __ALEX_H
 | 
				
			||||||
 | 
					#define __ALEX_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __RECORDSET_H
 | 
				
			||||||
 | 
					#include <recset.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TVariant_stack : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TArray _var;
 | 
				
			||||||
 | 
					  int _sp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  int items() const { return _sp; }
 | 
				
			||||||
 | 
					  bool drop();
 | 
				
			||||||
 | 
					  TVariant& pop();
 | 
				
			||||||
 | 
					  TVariant& peek(int depth = 0);
 | 
				
			||||||
 | 
					  void roll(int depth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void push(const TVariant& var);
 | 
				
			||||||
 | 
					  void push(long n);
 | 
				
			||||||
 | 
					  void push(const real& n);
 | 
				
			||||||
 | 
					  void push(const char* str);
 | 
				
			||||||
 | 
					  void reset();
 | 
				
			||||||
 | 
					  bool overflow() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TVariant_stack() : _sp(0) { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Generic bytecode for any language
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TBytecode : public TArray
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  void set_name(const char* name) { _name = name; }
 | 
				
			||||||
 | 
					  const TString& name() const { return _name; }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ALEX = Another Language EXtension
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TAVM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TAlex_virtual_machine : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TAVM* _avm; // Chesire's cat class
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  TAVM& avm();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual size_t get_usr_words(TString_array& names) const;
 | 
				
			||||||
 | 
					  virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack);
 | 
				
			||||||
 | 
					  virtual bool get_usr_val(const TString& name, TVariant& var) const;
 | 
				
			||||||
 | 
					  virtual bool set_usr_val(const TString& name, const TVariant& var);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& get_last_error() const;
 | 
				
			||||||
 | 
					  bool compile(istream& instr, TBytecode& bc);
 | 
				
			||||||
 | 
					  bool compile(const char* cmd, TBytecode& bc);
 | 
				
			||||||
 | 
					  bool execute(const TBytecode& bc, ostream& outstr);
 | 
				
			||||||
 | 
					  bool execute(const TBytecode& bc, TString& outstr);
 | 
				
			||||||
 | 
					  bool include(const char* fname);
 | 
				
			||||||
 | 
					  void warm_restart();
 | 
				
			||||||
 | 
					  void cold_restart();
 | 
				
			||||||
 | 
					  void set_interactive(bool inter);
 | 
				
			||||||
 | 
					  bool defined(const char* name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TAlex_virtual_machine();
 | 
				
			||||||
 | 
					  virtual ~TAlex_virtual_machine();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1,13 +1,13 @@
 | 
				
			|||||||
#define __FORM_CPP
 | 
					#define __FORM_CPP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <applicat.h>
 | 
					#include <applicat.h>
 | 
				
			||||||
#include <currency.h>
 | 
					 | 
				
			||||||
#include <defmask.h>
 | 
					#include <defmask.h>
 | 
				
			||||||
#include <expr.h>
 | 
					#include <expr.h>
 | 
				
			||||||
#include <form.h>
 | 
					#include <form.h>
 | 
				
			||||||
#include <msksheet.h>
 | 
					#include <msksheet.h>
 | 
				
			||||||
#include <printer.h>
 | 
					#include <printer.h>
 | 
				
			||||||
#include <relation.h>
 | 
					#include <relation.h>
 | 
				
			||||||
 | 
					#include <recarray.h>
 | 
				
			||||||
#include <tabutil.h>
 | 
					#include <tabutil.h>
 | 
				
			||||||
#include <utility.h> 
 | 
					#include <utility.h> 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4119,19 +4119,18 @@ bool TForm::validate(TForm_item &cf, TToken_string &s)
 | 
				
			|||||||
  // dove: <tabella> nome tabella da leggere
 | 
					  // dove: <tabella> nome tabella da leggere
 | 
				
			||||||
  //       <chiave> costante stringa o riferimento a campo della form (preceduto da '#') da usare come chiave di ricerca
 | 
					  //       <chiave> costante stringa o riferimento a campo della form (preceduto da '#') da usare come chiave di ricerca
 | 
				
			||||||
  //       <campo file> identificativo del campo da leggere dalla tabella
 | 
					  //       <campo file> identificativo del campo da leggere dalla tabella
 | 
				
			||||||
    TTable tab(s.get()); // prende il nome della tabella
 | 
					    const TString4 cod = s.get(); // Codice tabella
 | 
				
			||||||
    tab.zero(); // vuota il record corrente della tabella
 | 
					    valore = s.get(); // prende il valore o il campo da usare come codice di ricerca
 | 
				
			||||||
    TString in(s.get()); // prende il valore o il campo da usare come codice di ricerca
 | 
					    if (valore[0]== '#')
 | 
				
			||||||
    if (in[0]== '#')
 | 
					 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
     in.ltrim(1);
 | 
					     valore.ltrim(1);
 | 
				
			||||||
     TForm_item &fi= cf.find_field(in);
 | 
					     TForm_item &fi= cf.find_field(valore);
 | 
				
			||||||
     in= fi.get();
 | 
					     valore = fi.get();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    tab.put("CODTAB", in); // setta la chiave nella tabella
 | 
					    const TRectype& tab = cache().get(cod, valore);
 | 
				
			||||||
    if (tab.read()== NOERR)
 | 
					    if (!tab.empty())
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      const TString &fld= s.get(); // prende il nome del campo da leggere...
 | 
					      const TString &fld = s.get(); // prende il nome del campo da leggere...
 | 
				
			||||||
      valore = tab.get(fld);
 | 
					      valore = tab.get(fld);
 | 
				
			||||||
      cf.set(valore);
 | 
					      cf.set(valore);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -4182,8 +4181,8 @@ bool TForm::validate(TForm_item &cf, TToken_string &s)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (code== "_TODAY")// Messaggio per stampare la data di oggi
 | 
					  if (code== "_TODAY")// Messaggio per stampare la data di oggi
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    TString16 dt(TDate(TODAY).string());
 | 
					    const TDate oggi(TODAY);
 | 
				
			||||||
    cf.set(dt);
 | 
					    cf.set(oggi.string());
 | 
				
			||||||
    return TRUE;
 | 
					    return TRUE;
 | 
				
			||||||
  } 
 | 
					  } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4221,17 +4220,18 @@ bool TForm::validate(TForm_item &cf, TToken_string &s)
 | 
				
			|||||||
    //       + %ANAGR (6) Anagrafica generale (indirizzo, ecc.)
 | 
					    //       + %ANAGR (6) Anagrafica generale (indirizzo, ecc.)
 | 
				
			||||||
    //          + %COMUNI (113@) Comune di residenza
 | 
					    //          + %COMUNI (113@) Comune di residenza
 | 
				
			||||||
    //          + %COMUNI (213@) Comune di residenza fiscale
 | 
					    //          + %COMUNI (213@) Comune di residenza fiscale
 | 
				
			||||||
    TLocalisamfile firm(LF_NDITTE);
 | 
					    const TRectype& firm = cache().get(LF_NDITTE, main_app().get_firm());
 | 
				
			||||||
    TLocalisamfile anag(LF_ANAG);
 | 
					    
 | 
				
			||||||
    firm.put("CODDITTA",main_app().get_firm());
 | 
					    TString16 codanag; codanag.format("%c|%ld", firm.get_char("TIPOA"), firm.get_long("CODANAGR"));
 | 
				
			||||||
    firm.read();
 | 
					    const TRectype& anag = cache().get(LF_ANAG, codanag);
 | 
				
			||||||
    anag.put("TIPOA",firm.get("TIPOA"));
 | 
					    
 | 
				
			||||||
    anag.put("CODANAGR",firm.get("CODANAGR"));
 | 
					 | 
				
			||||||
    anag.read();
 | 
					 | 
				
			||||||
    TString in(s.get());
 | 
					    TString in(s.get());
 | 
				
			||||||
    if (in[0]=='!') {
 | 
					    if (in[0]=='!') 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      in.ltrim(1);
 | 
					      in.ltrim(1);
 | 
				
			||||||
      bool _fisc= anag.get("INDRF").not_empty();
 | 
					      const bool _fisc= anag.get("INDRF").not_empty();
 | 
				
			||||||
 | 
					      if (in=="CODDITTA") 
 | 
				
			||||||
 | 
					        valore =firm.get("CODDITTA");
 | 
				
			||||||
      if (in=="RAGSOC") 
 | 
					      if (in=="RAGSOC") 
 | 
				
			||||||
        valore = anag.get("RAGSOC");
 | 
					        valore = anag.get("RAGSOC");
 | 
				
			||||||
      if (in=="IND") {
 | 
					      if (in=="IND") {
 | 
				
			||||||
@ -4285,9 +4285,11 @@ bool TForm::validate(TForm_item &cf, TToken_string &s)
 | 
				
			|||||||
        valore = _firmrel[LF_UNLOC].get("NUMCCIAA");
 | 
					        valore = _firmrel[LF_UNLOC].get("NUMCCIAA");
 | 
				
			||||||
        valore << " del " << _firmrel[LF_UNLOC].get("DATAICCIAA");
 | 
					        valore << " del " << _firmrel[LF_UNLOC].get("DATAICCIAA");
 | 
				
			||||||
      } */
 | 
					      } */
 | 
				
			||||||
    } else {
 | 
					    } 
 | 
				
			||||||
 | 
					    else 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
      TFieldref fref(s.get(), 0);
 | 
					      TFieldref fref(s.get(), 0);
 | 
				
			||||||
      valore = fref.read(anag.curr());
 | 
					      valore = fref.read(anag);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    cf.set(valore);
 | 
					    cf.set(valore);
 | 
				
			||||||
    return TRUE; 
 | 
					    return TRUE; 
 | 
				
			||||||
 | 
				
			|||||||
@ -2659,8 +2659,7 @@ KEY TFile_select::run()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (good)
 | 
					  if (good)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    const TFixed_string str(fs.name);
 | 
					    good = _filter.empty() || xvt_str_match(fs.name, _filter, false);
 | 
				
			||||||
    good = _filter.empty() || str.match(_filter);
 | 
					 | 
				
			||||||
    if (good)
 | 
					    if (good)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      TFilename path;
 | 
					      TFilename path;
 | 
				
			||||||
@ -2669,7 +2668,7 @@ KEY TFile_select::run()
 | 
				
			|||||||
      field().set(path);
 | 
					      field().set(path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
      field().error_box("Il nome del file non corrisponde alla maschera %s", _filter.get_buffer());
 | 
					      field().error_box(TR("Il nome non corrisponde a %s"), _filter.get_buffer());
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return good ? K_ENTER : K_ESC;
 | 
					  return good ? K_ENTER : K_ESC;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -2679,8 +2678,8 @@ bool TFile_select::check(CheckTime ct)
 | 
				
			|||||||
  const TFilename name = field().get();
 | 
					  const TFilename name = field().get();
 | 
				
			||||||
  if (ct != STARTING_CHECK && name.empty() && 
 | 
					  if (ct != STARTING_CHECK && name.empty() && 
 | 
				
			||||||
      field().check_type() == CHECK_REQUIRED)
 | 
					      field().check_type() == CHECK_REQUIRED)
 | 
				
			||||||
    return FALSE;
 | 
					    return false;
 | 
				
			||||||
  bool ok = _filter.empty() || name.match(_filter);
 | 
					  bool ok = _filter.empty() || xvt_str_match(name, _filter, false);
 | 
				
			||||||
  if (ok && field().roman())  // Must exist
 | 
					  if (ok && field().roman())  // Must exist
 | 
				
			||||||
    ok = name.exist();
 | 
					    ok = name.exist();
 | 
				
			||||||
  return ok;
 | 
					  return ok;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2072
									
								
								include/recset.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2072
									
								
								include/recset.cpp
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										239
									
								
								include/recset.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										239
									
								
								include/recset.h
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,239 @@
 | 
				
			|||||||
 | 
					#ifndef __RECORDSET_H
 | 
				
			||||||
 | 
					#define __RECORDSET_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __ASSOC_H
 | 
				
			||||||
 | 
					#include <assoc.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __RECTYPES_H
 | 
				
			||||||
 | 
					#include <rectypes.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __SHEET_H
 | 
				
			||||||
 | 
					#include <sheet.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct TRecordset_column_info : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _name;   // Table.Column
 | 
				
			||||||
 | 
					  int _width;
 | 
				
			||||||
 | 
					  TFieldtypes _type;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TVariant
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TVariant : public TSortable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TFieldtypes _type;
 | 
				
			||||||
 | 
					  void* _ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual TObject* dup() const { return new TVariant(*this); }
 | 
				
			||||||
 | 
					  void copy(const TVariant& var);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TFieldtypes type() const { return _type; } // Internal use only
 | 
				
			||||||
 | 
					  bool is_string() const { return _type == _alfafld; }
 | 
				
			||||||
 | 
					  bool is_empty() const;
 | 
				
			||||||
 | 
					  bool is_null() const { return _type == _nullfld; }
 | 
				
			||||||
 | 
					  bool is_zero() const;
 | 
				
			||||||
 | 
					  void set_null();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  void set(const char* str);
 | 
				
			||||||
 | 
					  void set(const real& r);
 | 
				
			||||||
 | 
					  void set(const long n);
 | 
				
			||||||
 | 
					  void set(const TDate& d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TVariant& operator=(const TVariant& var) { copy(var); return *this; }
 | 
				
			||||||
 | 
					  TVariant& operator=(const char* str) { set(str); return *this; }
 | 
				
			||||||
 | 
					  TVariant& operator=(const real& r) { set(r); return *this; }
 | 
				
			||||||
 | 
					  TVariant& operator=(const long n) { set(n); return *this; }
 | 
				
			||||||
 | 
					  TVariant& operator=(const TDate& d) { set(d); return *this; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& as_string() const;
 | 
				
			||||||
 | 
					  bool as_string(TString& str) const;
 | 
				
			||||||
 | 
					  real as_real() const;
 | 
				
			||||||
 | 
					  long as_int() const;
 | 
				
			||||||
 | 
					  TDate as_date() const;
 | 
				
			||||||
 | 
					  bool as_bool() const;
 | 
				
			||||||
 | 
					  COLOR as_color() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void convert_to(TFieldtypes ft);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual int compare(const TSortable& s) const;
 | 
				
			||||||
 | 
					  TVariant& add(const TVariant& var);
 | 
				
			||||||
 | 
					  TVariant& sub(const TVariant& var);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TVariant() : _type(_nullfld), _ptr(NULL) { }
 | 
				
			||||||
 | 
					  TVariant(const char* str) : _type(_alfafld), _ptr(new TString(str)) { }
 | 
				
			||||||
 | 
					  TVariant(const real& num) : _type(_realfld), _ptr(new real(num)) { };
 | 
				
			||||||
 | 
					  TVariant(const TDate& d) : _type(_datefld), _ptr(new TDate(d)) { };
 | 
				
			||||||
 | 
					  TVariant(long num) : _type(_longfld), _ptr((void*)num) { };
 | 
				
			||||||
 | 
					  TVariant(bool ok) : _type(_longfld), _ptr((void*)ok) { };
 | 
				
			||||||
 | 
					  TVariant(const TVariant& var) : _type(_nullfld), _ptr(NULL) { copy(var); }
 | 
				
			||||||
 | 
					  virtual ~TVariant() { set_null(); }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern const TVariant NULL_VARIANT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TRecordset
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum TRecordsetExportFormat { fmt_unknown, fmt_html, fmt_text, fmt_silk, fmt_campo };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TRecordset : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TAssoc_array _var;
 | 
				
			||||||
 | 
					  TString_array _varnames;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  bool save_as_html(const char* path);
 | 
				
			||||||
 | 
					  bool save_as_silk(const char* path);
 | 
				
			||||||
 | 
					  bool save_as_text(const char* path);
 | 
				
			||||||
 | 
					  bool save_as_campo(const char* path);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  void find_and_reset_vars();
 | 
				
			||||||
 | 
					  void parsed_text(TString& sql) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public: // Absolutely needed methods
 | 
				
			||||||
 | 
					  virtual TRecnotype items() const pure;
 | 
				
			||||||
 | 
					  virtual bool move_to(TRecnotype pos) pure;
 | 
				
			||||||
 | 
					  virtual TRecnotype current_row() const pure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual bool move_first() { return move_to(0); }
 | 
				
			||||||
 | 
					  virtual bool move_prev() { return move_to(current_row()-1); }
 | 
				
			||||||
 | 
					  virtual bool move_next() { return move_to(current_row()+1); }
 | 
				
			||||||
 | 
					  virtual bool move_last() { return move_to(items()-1); }
 | 
				
			||||||
 | 
					  virtual bool bof() const { return current_row() <= 0; }
 | 
				
			||||||
 | 
					  virtual bool eof() const { return current_row() >= items(); }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  virtual unsigned int columns() const pure;
 | 
				
			||||||
 | 
					  virtual const TRecordset_column_info& column_info(unsigned int column) const pure;
 | 
				
			||||||
 | 
					  virtual const TVariant& get(unsigned int column) const pure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual const TString_array& variables() const { return _varnames; }
 | 
				
			||||||
 | 
					  virtual const TVariant& get_var(const char* name) const;
 | 
				
			||||||
 | 
					  virtual bool set_var(const char* name, const TVariant& var, bool create = false);
 | 
				
			||||||
 | 
					  virtual bool ask_variables(bool all);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual const TString& query_text() const; 
 | 
				
			||||||
 | 
					  virtual int find_column(const char* column_name) const;
 | 
				
			||||||
 | 
					  virtual const TVariant& get(const char* column_name) const;
 | 
				
			||||||
 | 
					  virtual const TToken_string& sheet_head() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual bool save_as(const char* path, TRecordsetExportFormat fmt = fmt_unknown);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TSQL_recordset
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TSQL_recordset : public TRecordset
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _sql;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TRecnotype _first_row, _pagesize, _items, _current_row;
 | 
				
			||||||
 | 
					  TArray _column;
 | 
				
			||||||
 | 
					  TArray _page;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  void reset();
 | 
				
			||||||
 | 
					  void parsed_sql_text(TString& sql) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public: // TRecordset
 | 
				
			||||||
 | 
					  virtual TRecnotype items() const;
 | 
				
			||||||
 | 
					  virtual bool move_to(TRecnotype pos);
 | 
				
			||||||
 | 
					  virtual TRecnotype current_row() const { return _current_row; }
 | 
				
			||||||
 | 
					  virtual unsigned int columns() const;
 | 
				
			||||||
 | 
					  virtual const TRecordset_column_info& column_info(unsigned int c) const;
 | 
				
			||||||
 | 
					  virtual const TVariant& get(unsigned int column) const;
 | 
				
			||||||
 | 
					  virtual bool ask_variables(bool all);
 | 
				
			||||||
 | 
					  const TString& query_text() const { return _sql; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  void set(const char* sql);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Internal use only
 | 
				
			||||||
 | 
					  virtual int on_get_items(int argc, char** values, char** columns);
 | 
				
			||||||
 | 
					  virtual int on_get_rows(int argc, char** values, char** columns);
 | 
				
			||||||
 | 
					  const TArray* row(TRecnotype n);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TSQL_recordset(const char* sql);
 | 
				
			||||||
 | 
					  virtual ~TSQL_recordset() { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TISAM_recordset
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TISAM_recordset : public TRecordset
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _use;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  TRelation* _relation;
 | 
				
			||||||
 | 
					  TCursor* _cursor;
 | 
				
			||||||
 | 
					  TArray _column;     // Column infos
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  void reset();
 | 
				
			||||||
 | 
					  TVariant& get_tmp_var() const;
 | 
				
			||||||
 | 
					  const TVariant& get(int logic, const char* field) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  void set(const char* use);
 | 
				
			||||||
 | 
					  virtual TRecnotype items() const;
 | 
				
			||||||
 | 
					  virtual bool move_to(TRecnotype pos);
 | 
				
			||||||
 | 
					  virtual TRecnotype current_row() const;
 | 
				
			||||||
 | 
					  virtual unsigned int columns() const;
 | 
				
			||||||
 | 
					  virtual const TRecordset_column_info& column_info(unsigned int c) const;
 | 
				
			||||||
 | 
					  virtual const TVariant& get(unsigned int column) const;
 | 
				
			||||||
 | 
					  virtual const TVariant& get(const char* column_name) const;
 | 
				
			||||||
 | 
					  virtual bool ask_variables(bool all);
 | 
				
			||||||
 | 
					  virtual const TString& query_text() const { return _use; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TISAM_recordset(const char* use);
 | 
				
			||||||
 | 
					  virtual ~TISAM_recordset();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TRecordset_sheet
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TRecordset_sheet : public TSheet
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TRecordset& _query;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual void get_row(long r, TToken_string& row);
 | 
				
			||||||
 | 
					  virtual long get_items() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TRecordset_sheet(TRecordset& sql);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Utility
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TPerformance_profiler : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _desc;
 | 
				
			||||||
 | 
					  clock_t _start;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  void show() const;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  TPerformance_profiler(const char* desc = "");
 | 
				
			||||||
 | 
					  ~TPerformance_profiler();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool select_custom_file(TFilename& path, const char* ext);
 | 
				
			||||||
 | 
					const TString& logic2table(int logic_num);
 | 
				
			||||||
 | 
					int table2logic(const TString& name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -327,13 +327,13 @@ int TRelation_application::set_mode(int mode)
 | 
				
			|||||||
  switch(mode)
 | 
					  switch(mode)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
  case MODE_QUERY: 
 | 
					  case MODE_QUERY: 
 | 
				
			||||||
    t = "Ricerca"; break;
 | 
					    t = TR("Ricerca"); break;
 | 
				
			||||||
  case MODE_MOD: 
 | 
					  case MODE_MOD: 
 | 
				
			||||||
    t = "Modifica"; break;
 | 
					    t = TR("Modifica"); break;
 | 
				
			||||||
  case NO_MODE: 
 | 
					  case NO_MODE: 
 | 
				
			||||||
    t = "Ricerca/Inserimento"; break;
 | 
					    t = TR("Ricerca/Inserimento"); break;
 | 
				
			||||||
  case MODE_INS: 
 | 
					  case MODE_INS: 
 | 
				
			||||||
    t = "Inserimento"; break;
 | 
					    t = TR("Inserimento"); break;
 | 
				
			||||||
  default: 
 | 
					  default: 
 | 
				
			||||||
    break;
 | 
					    break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2265
									
								
								include/report.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2265
									
								
								include/report.cpp
									
									
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										462
									
								
								include/report.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										462
									
								
								include/report.h
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,462 @@
 | 
				
			|||||||
 | 
					#ifndef __REPORT_H
 | 
				
			||||||
 | 
					#define __REPORT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __IMAGE_H
 | 
				
			||||||
 | 
					#include <image.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __WINDOW_H
 | 
				
			||||||
 | 
					#include <window.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __XML_H
 | 
				
			||||||
 | 
					#include <xml.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __RECORDSET_H
 | 
				
			||||||
 | 
					#include <recset.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __ALEX_H
 | 
				
			||||||
 | 
					#include <alex.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TReport_font
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_font : public TSortable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  enum { DEFAULT_FONT_SIZE = 10 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TString _name;
 | 
				
			||||||
 | 
					  int _size, _cpi;
 | 
				
			||||||
 | 
					  XVT_FONT_STYLE_MASK _style;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  WINDOW _win_mapped;
 | 
				
			||||||
 | 
					  XVT_FNTID _fontid;
 | 
				
			||||||
 | 
					  int _leading, _ascent, _descent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual int compare(const TSortable& s) const;
 | 
				
			||||||
 | 
					  void copy(const TReport_font& f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  const TString& name() const { return _name; }
 | 
				
			||||||
 | 
					  int size() const { return _size; }
 | 
				
			||||||
 | 
					  XVT_FONT_STYLE_MASK style() const { return _style; }
 | 
				
			||||||
 | 
					  int cpi() const { return _cpi; } 
 | 
				
			||||||
 | 
					  XVT_FNTID get_xvt_font(const TWindow& win) const;
 | 
				
			||||||
 | 
					  void unmap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int leading() const { return _leading; }
 | 
				
			||||||
 | 
					  int ascent() const { return _ascent; }
 | 
				
			||||||
 | 
					  int descent() const { return _descent; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void save(TXmlItem& root) const;
 | 
				
			||||||
 | 
					  bool load(const TXmlItem& root);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void create(const char* name, int size, XVT_FONT_STYLE_MASK style);
 | 
				
			||||||
 | 
					  TReport_font& operator=(const TReport_font& f) { copy(f); return *this; }
 | 
				
			||||||
 | 
					  TReport_font();
 | 
				
			||||||
 | 
					  TReport_font(const TReport_font& f);
 | 
				
			||||||
 | 
					  virtual ~TReport_font();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport;
 | 
				
			||||||
 | 
					class TReport_field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Cache varie
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_expr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_expr_cache : public TCache
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TReport* _report;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual TObject* key2obj(const char* key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TReport_expr& operator[](const char* key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_report(TReport* rep) { _report = rep; }
 | 
				
			||||||
 | 
					  TReport_expr_cache() : _report(NULL) { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_image_cache : public TCache
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual TObject* key2obj(const char* key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TImage* image(const TString& name);
 | 
				
			||||||
 | 
					  TReport_image_cache();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TReport_script
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_script : public TObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TBytecode* _bc;  // Chesire's cat class
 | 
				
			||||||
 | 
					  TString _src, _desc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  void destroy();
 | 
				
			||||||
 | 
					  TString& translate_message(TReport& report) const;
 | 
				
			||||||
 | 
					  void copy(const TReport_script& rs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual bool ok() const { return !_src.blank(); }
 | 
				
			||||||
 | 
					  void set(const char* source);
 | 
				
			||||||
 | 
					  const TString& get() const { return _src; }
 | 
				
			||||||
 | 
					  void set_description(const char* d) { _desc = d; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool compile(TReport& report);
 | 
				
			||||||
 | 
					  bool execute(TReport& report, TString& output);
 | 
				
			||||||
 | 
					  bool execute(TReport_field& rf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void save(TXmlItem& root, const char* tag) const;
 | 
				
			||||||
 | 
					  bool load(const TXmlItem& root, const char* tag);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  TReport_script& operator =(const TReport_script& rs) { copy(rs); return *this; }
 | 
				
			||||||
 | 
					  TReport_script();
 | 
				
			||||||
 | 
					  TReport_script(const TReport_script& rs) { copy(rs); }
 | 
				
			||||||
 | 
					  virtual ~TReport_script();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TReport_section
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum TReport_draw_mode { rdm_edit, rdm_print, rdm_print_preview, rdm_spooler, rdm_textonly };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_section : public TArray
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TReport& _report;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  char _type;   // Head,Body,Tail
 | 
				
			||||||
 | 
					  int _level;   // 0,1,2,...
 | 
				
			||||||
 | 
					  TPoint _pos;  // Posizione assoluta in centesimi, default (0,0)
 | 
				
			||||||
 | 
					  TPoint _size; // Dimensioni in centesimi, default (0,0) 
 | 
				
			||||||
 | 
					  TString _groupby;
 | 
				
			||||||
 | 
					  bool _page_break, _hidden_if_needed, _keep_with_next;
 | 
				
			||||||
 | 
					  bool _hidden, _deactivated;
 | 
				
			||||||
 | 
					  TReport_script _prescript, _postscript;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_font* _font;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual const char* class_name() const { return "ReportSection"; }
 | 
				
			||||||
 | 
					  TReport_section* father_section() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual int add(TObject* obj);
 | 
				
			||||||
 | 
					  virtual int add(TObject& obj);
 | 
				
			||||||
 | 
					  TReport_field& field(int i) { return *(TReport_field*)objptr(i); }
 | 
				
			||||||
 | 
					  const TReport_field& field(int i) const { return *(TReport_field*)objptr(i); }
 | 
				
			||||||
 | 
					  int find_field_pos(int id);
 | 
				
			||||||
 | 
					  TReport_field* find_field(int id);
 | 
				
			||||||
 | 
					  TReport& report() { return _report; }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					  char type() const { return _type; }
 | 
				
			||||||
 | 
					  int level() const { return _level; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int width() const { return _size.x; }
 | 
				
			||||||
 | 
					  int height() const { return _size.y; }
 | 
				
			||||||
 | 
					  void set_width(short w) { _size.x = w; }
 | 
				
			||||||
 | 
					  void set_height(short h) { _size.y = h; }
 | 
				
			||||||
 | 
					  const TPoint& size() const { return _size; }
 | 
				
			||||||
 | 
					  TPoint compute_size() const;
 | 
				
			||||||
 | 
					  bool compute_rect(TRectangle& rct) const;
 | 
				
			||||||
 | 
					  const TPoint& pos() const { return _pos; }
 | 
				
			||||||
 | 
					  void set_pos(const TPoint& p) { _pos = p; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool page_break() const { return _page_break; }
 | 
				
			||||||
 | 
					  void force_page_break(bool pb) { _page_break = pb; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& grouped_by() const { return _groupby; }
 | 
				
			||||||
 | 
					  void group_by(const char* gb) { _groupby = gb; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool hidden_if_needed() const { return _hidden_if_needed; }
 | 
				
			||||||
 | 
					  void hide_if_needed(bool h) { _hidden_if_needed = h; }
 | 
				
			||||||
 | 
					  bool keep_with_next() const { return _keep_with_next; }
 | 
				
			||||||
 | 
					  void keep_with_next(bool k) { _keep_with_next = k; }
 | 
				
			||||||
 | 
					  bool hidden() const { return _hidden; }
 | 
				
			||||||
 | 
					  bool shown() const { return !hidden(); }
 | 
				
			||||||
 | 
					  void show(bool on) { _hidden = !on; }
 | 
				
			||||||
 | 
					  void hide() { show(false); }
 | 
				
			||||||
 | 
					  bool deactivated() const { return _deactivated; }
 | 
				
			||||||
 | 
					  bool active() const { return !deactivated(); }
 | 
				
			||||||
 | 
					  void activate(bool on) { _deactivated = !on; }
 | 
				
			||||||
 | 
					  void deactivate() { activate(false); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& prescript() const;
 | 
				
			||||||
 | 
					  void set_prescript(const char* src);
 | 
				
			||||||
 | 
					  const TString& postscript() const;
 | 
				
			||||||
 | 
					  void set_postscript(const char* src);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool has_font() const { return _font != NULL; }
 | 
				
			||||||
 | 
					  const TReport_font& font() const;
 | 
				
			||||||
 | 
					  void set_font(const TReport_font& f);
 | 
				
			||||||
 | 
					  void unmap_font();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool load_fields();
 | 
				
			||||||
 | 
					  bool execute_prescript();
 | 
				
			||||||
 | 
					  bool execute_postscript();
 | 
				
			||||||
 | 
					  void draw(TWindow& win, TReport_draw_mode mode) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void save(TXmlItem& report) const;
 | 
				
			||||||
 | 
					  void load(const TXmlItem& sec);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_section(TReport& r, char t, int l);
 | 
				
			||||||
 | 
					  virtual ~TReport_section();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_field : public TSortable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TReport_section* _section;
 | 
				
			||||||
 | 
					  int _id;
 | 
				
			||||||
 | 
					  char _type;   // Text, String, Numeric, Price, Valuta, Date, Line, Rectangle, Image
 | 
				
			||||||
 | 
					  TRectangle _rct, _rct_draw; // In centesimi
 | 
				
			||||||
 | 
					  COLOR _fgcolor, _bgcolor;
 | 
				
			||||||
 | 
					  short _border;
 | 
				
			||||||
 | 
					  char _halign, _valign;
 | 
				
			||||||
 | 
					  TBit_array _groups;
 | 
				
			||||||
 | 
					  TString _picture, _field, _codval, _link;
 | 
				
			||||||
 | 
					  TVariant _var;
 | 
				
			||||||
 | 
					  TReport_script _prescript, _postscript;
 | 
				
			||||||
 | 
					  TToken_string _list; // Elementi di un campo lista
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_font* _font;
 | 
				
			||||||
 | 
					  bool _hidden, _deactivated, _hide_zeroes, _selected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual const char* class_name() const { return "ReportField"; }
 | 
				
			||||||
 | 
					  virtual int compare(const TSortable& s) const;
 | 
				
			||||||
 | 
					  void copy(const TReport_field& rf);
 | 
				
			||||||
 | 
					  TFieldtypes var_type() const;
 | 
				
			||||||
 | 
					  const TString& formatted_text() const;
 | 
				
			||||||
 | 
					  void get_currency(TCurrency& cur) const;
 | 
				
			||||||
 | 
					  void compute_draw_rect() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual TObject* dup() const { return new TReport_field(*this); } 
 | 
				
			||||||
 | 
					  TReport_field& operator=(const TReport_field& rf) { copy(rf); return *this; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_section& section() const { return *_section; } 
 | 
				
			||||||
 | 
					  void set_section(TReport_section* sec) { _section = sec; } 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool has_font() const { return _font != NULL; }
 | 
				
			||||||
 | 
					  const TReport_font& font() const;
 | 
				
			||||||
 | 
					  void set_font(const TReport_font& f);
 | 
				
			||||||
 | 
					  void unmap_font();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  const TString& picture() const { return _picture; }
 | 
				
			||||||
 | 
					  void set_picture(const char* str) { _picture = str; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& field() const { return _field; }
 | 
				
			||||||
 | 
					  void set_field(const char* str) { _field = str; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TVariant& get() const { return _var; }
 | 
				
			||||||
 | 
					  void set(const char* str);
 | 
				
			||||||
 | 
					  void set(const TVariant& var);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool load_field();
 | 
				
			||||||
 | 
					  bool execute_prescript();
 | 
				
			||||||
 | 
					  bool execute_postscript();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void get_list(TString_array& list) const;
 | 
				
			||||||
 | 
					  void set_list(const TString_array& list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int id() const { return _id; }
 | 
				
			||||||
 | 
					  void set_id(int id) { _id = id; }
 | 
				
			||||||
 | 
					  char type() const { return _type; }
 | 
				
			||||||
 | 
					  const char* type_name() const;
 | 
				
			||||||
 | 
					  void set_type(char t) { _type = t; }
 | 
				
			||||||
 | 
					  void set_pos(long x, long y);
 | 
				
			||||||
 | 
					  void set_row(long y) { _rct.y = y; }
 | 
				
			||||||
 | 
					  void set_column(long x) { _rct.x = x; }
 | 
				
			||||||
 | 
					  void set_size(long w, long h);
 | 
				
			||||||
 | 
					  void set_width(long dx) { _rct.set_width(dx); }
 | 
				
			||||||
 | 
					  void set_height(long dy) { _rct.set_height(dy); }
 | 
				
			||||||
 | 
					  const TRectangle& get_rect() const { return _rct; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_draw_pos(long x, long y);
 | 
				
			||||||
 | 
					  void set_draw_size(long x, long y);
 | 
				
			||||||
 | 
					  const TRectangle& get_draw_rect() const { return _rct_draw; }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  bool hidden() const { return _hidden; }
 | 
				
			||||||
 | 
					  bool shown() const { return !hidden(); }
 | 
				
			||||||
 | 
					  void show(bool on) { _hidden = !on; }
 | 
				
			||||||
 | 
					  void hide() { show(false); }
 | 
				
			||||||
 | 
					  bool deactivated() const { return _deactivated; }
 | 
				
			||||||
 | 
					  bool active() const { return !deactivated(); }
 | 
				
			||||||
 | 
					  void activate(bool on) { _deactivated = !on; }
 | 
				
			||||||
 | 
					  void deactivate() { activate(false); }
 | 
				
			||||||
 | 
					  bool zeroes_hidden() const { return _hide_zeroes; }
 | 
				
			||||||
 | 
					  void hide_zeroes(bool hz) { _hide_zeroes = hz; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_groups(const TString& groups);
 | 
				
			||||||
 | 
					  const TString& groups() const;
 | 
				
			||||||
 | 
					  bool in_group(int group) const;
 | 
				
			||||||
 | 
					  void set_codval(const char* cod) { _codval = cod; }
 | 
				
			||||||
 | 
					  const TString& codval() const { return _codval; }
 | 
				
			||||||
 | 
					  void set_link(const char* l) { _link = l; }
 | 
				
			||||||
 | 
					  const TString& link() const { return _link; }  // TABLE.FIELD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_fore_color(COLOR c) { _fgcolor = c; }
 | 
				
			||||||
 | 
					  COLOR fore_color() const { return _fgcolor; }
 | 
				
			||||||
 | 
					  void set_back_color(COLOR c) { _bgcolor = c; }
 | 
				
			||||||
 | 
					  COLOR back_color() const { return _bgcolor; }
 | 
				
			||||||
 | 
					  COLOR link_color() const;
 | 
				
			||||||
 | 
					  void set_border(short b) { _border = b; }
 | 
				
			||||||
 | 
					  short border() const { return _border; }
 | 
				
			||||||
 | 
					  void set_horizontal_alignment(char a) { _halign = a; }
 | 
				
			||||||
 | 
					  char horizontal_alignment() const { return _halign; }
 | 
				
			||||||
 | 
					  void set_vertical_alignment(char a) { _valign = a; }
 | 
				
			||||||
 | 
					  char vertical_alignment() const { return _valign; }
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  const TString& prescript() const;
 | 
				
			||||||
 | 
					  void set_prescript(const char* src);
 | 
				
			||||||
 | 
					  const TString& postscript() const;
 | 
				
			||||||
 | 
					  void set_postscript(const char* src);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void select(bool ok = true) { _selected = ok; }
 | 
				
			||||||
 | 
					  bool selected() const { return _selected; }
 | 
				
			||||||
 | 
					  void offset(const TPoint& pt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual void draw_rect(TWindow& win) const;
 | 
				
			||||||
 | 
					  virtual void draw_text(TWindow& win, const char* text, TReport_draw_mode mode) const;
 | 
				
			||||||
 | 
					  virtual void draw(TWindow& win, TReport_draw_mode mode) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void save(TXmlItem& root) const;
 | 
				
			||||||
 | 
					  bool load(const TXmlItem& root);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_field(TReport_section* sec);
 | 
				
			||||||
 | 
					  TReport_field(const TReport_field& rf);
 | 
				
			||||||
 | 
					  virtual ~TReport_field();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_link : public TSortable
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TString _table;
 | 
				
			||||||
 | 
					  TAssoc_array _fields;
 | 
				
			||||||
 | 
					  RCT _rct;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual int compare(const TSortable& s) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  const TString& table() const { return _table; }
 | 
				
			||||||
 | 
					  void set(const char* field, const TVariant& value);
 | 
				
			||||||
 | 
					  const TVariant& get(const char* field) const;
 | 
				
			||||||
 | 
					  void add_rect(const RCT& rct); // Aggiunge un rettangolo al link
 | 
				
			||||||
 | 
					  int hit_test(const PNT& p) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TAssoc_array& fields() const { return (TAssoc_array&)_fields; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_link(const char* table);
 | 
				
			||||||
 | 
					  virtual ~TReport_link() { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Internal usage only
 | 
				
			||||||
 | 
					typedef void (*FLDMSG_FUNC)(TReport_field& rf, void* jolly);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport : public TAlex_virtual_machine
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TAssoc_array _sections;
 | 
				
			||||||
 | 
					  TFilename _path; 
 | 
				
			||||||
 | 
					  TString _description;
 | 
				
			||||||
 | 
					  TReport_font _font;
 | 
				
			||||||
 | 
					  int _lpi;  // Lines per inch
 | 
				
			||||||
 | 
					  TToken_string _include;
 | 
				
			||||||
 | 
					  TReport_script _prescript, _postscript;
 | 
				
			||||||
 | 
					  TRecordset* _recordset;
 | 
				
			||||||
 | 
					  TReport_expr_cache _expressions;
 | 
				
			||||||
 | 
					  TReport_image_cache _images;
 | 
				
			||||||
 | 
					  word _curr_page;
 | 
				
			||||||
 | 
					  TReport_field* _curr_field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual const char* class_name() const { return "Report"; }
 | 
				
			||||||
 | 
					  virtual size_t get_usr_words(TString_array& words) const;
 | 
				
			||||||
 | 
					  virtual bool execute_usr_word(unsigned int opcode, TVariant_stack& stack);
 | 
				
			||||||
 | 
					  virtual bool get_usr_val(const TString& name, TVariant& var) const;
 | 
				
			||||||
 | 
					  virtual bool set_usr_val(const TString& name, const TVariant& var);
 | 
				
			||||||
 | 
					  KEY run_form(const TString& msk);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  bool do_message(const TVariant& var, FLDMSG_FUNC msg, void* jolly);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  void build_section_key(char type, int level, TString& key) const;
 | 
				
			||||||
 | 
					  short get_num_attr(const TXmlItem& item, const char* attr, short def = 0) const;
 | 
				
			||||||
 | 
					  COLOR get_col_attr(const TXmlItem& item, const char* attr, COLOR defcol = COLOR_BLACK) const;
 | 
				
			||||||
 | 
					  void load_sections(const TXmlItem& xml);
 | 
				
			||||||
 | 
					  void save_section(const TReport_section& rs, TXmlItem& item) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool get_report_field(const TString& name, TVariant& var) const;
 | 
				
			||||||
 | 
					  bool get_record_field(const TString& name, TVariant& var) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TReport_section* find_section(char type, int level) const;
 | 
				
			||||||
 | 
					  TReport_section& section(char type, int level);
 | 
				
			||||||
 | 
					  bool kill_section(char type, int level);
 | 
				
			||||||
 | 
					  int find_max_level(char type) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual bool on_link(const TReport_link& link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TReport_font& font() const { return _font; }
 | 
				
			||||||
 | 
					  void set_font(const TReport_font& f) { _font = f; }
 | 
				
			||||||
 | 
					  void unmap_font();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int cpi() const { return _font.cpi(); }
 | 
				
			||||||
 | 
					  int lpi() const { return _lpi; }
 | 
				
			||||||
 | 
					  void set_lpi(int lpi) { _lpi= lpi; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  bool set_recordset(const TString& sql);
 | 
				
			||||||
 | 
					  bool set_recordset(TRecordset* sql);
 | 
				
			||||||
 | 
					  TRecordset* recordset() const { return _recordset; }
 | 
				
			||||||
 | 
					  bool evaluate_atom(const char* atom, TVariant& var);
 | 
				
			||||||
 | 
					  bool evaluate(const char* expr, TVariant& var, TFieldtypes force_type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TString& prescript() const;
 | 
				
			||||||
 | 
					  void set_prescript(const char* src);
 | 
				
			||||||
 | 
					  const TString& postscript() const;
 | 
				
			||||||
 | 
					  void set_postscript(const char* src);
 | 
				
			||||||
 | 
					  bool execute_prescript();
 | 
				
			||||||
 | 
					  bool execute_postscript();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_libraries(const char* inc) { _include = inc; }
 | 
				
			||||||
 | 
					  TToken_string& get_libraries() { return _include; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_description(const char* d) { _description = d; }
 | 
				
			||||||
 | 
					  const TString& description() const { return _description; }
 | 
				
			||||||
 | 
					  TImage* image(const TString& name) { return _images.image(name); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TFilename& filename() const { return _path; }
 | 
				
			||||||
 | 
					  bool save(const char* fname) const;
 | 
				
			||||||
 | 
					  bool load(const char* fname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Used by TReport_printer
 | 
				
			||||||
 | 
					  void set_curr_page(word p) { _curr_page = p; } 
 | 
				
			||||||
 | 
					  word curr_page() const { return _curr_page; }
 | 
				
			||||||
 | 
					  void set_curr_field(TReport_field* fld) { _curr_field = fld; }
 | 
				
			||||||
 | 
					  TReport_field* curr_field() const { return _curr_field; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int parse_field(const char* code, char& type, int& level, int& id) const;
 | 
				
			||||||
 | 
					  TReport_field* field(const TString& code);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					  void destroy();
 | 
				
			||||||
 | 
					  TReport();
 | 
				
			||||||
 | 
					  virtual ~TReport();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void advanced_draw_rect(TWindow& win, const RCT& r, int border, COLOR fore, COLOR back);
 | 
				
			||||||
 | 
					void advanced_draw_text(TWindow& win, const char* text, const RCT& r, 
 | 
				
			||||||
 | 
					                        char halign, char valign);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										917
									
								
								include/reprint.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										917
									
								
								include/reprint.cpp
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,917 @@
 | 
				
			|||||||
 | 
					#include <automask.h>
 | 
				
			||||||
 | 
					#include <defmask.h>
 | 
				
			||||||
 | 
					#include <diction.h>
 | 
				
			||||||
 | 
					#include <printer.h>
 | 
				
			||||||
 | 
					#include <reprint.h>
 | 
				
			||||||
 | 
					#include <statbar.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <bagn003.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool _print_aborted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TPrint_preview_window
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TPrint_preview_window : public TField_window
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPage_printer* _printer;
 | 
				
			||||||
 | 
					  word _page, _last;
 | 
				
			||||||
 | 
					  int _zoom;
 | 
				
			||||||
 | 
					  static bool _locked;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  void page_select();
 | 
				
			||||||
 | 
					  void popup_menu(EVENT* ep);
 | 
				
			||||||
 | 
					  virtual void handler(WINDOW win, EVENT* ep);
 | 
				
			||||||
 | 
					  virtual void update();
 | 
				
			||||||
 | 
					  virtual bool on_key(KEY k);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual PNT log2dev(long lx, long ly) const;
 | 
				
			||||||
 | 
					  static void lock_preview_update(bool yes) { _locked = yes; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_printer(TPage_printer* printer) { _printer = printer; }
 | 
				
			||||||
 | 
					  TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent, 
 | 
				
			||||||
 | 
					                        TWindowed_field* owner, TPage_printer* printer);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPrint_preview_window::_locked = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PNT TPrint_preview_window::log2dev(long lx, long ly) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PNT pnt;
 | 
				
			||||||
 | 
					  pnt.h = short(lx * _zoom / 1000);
 | 
				
			||||||
 | 
					  pnt.v = short(ly * _zoom / 1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TPoint orig = origin();
 | 
				
			||||||
 | 
					  pnt.h -= short(orig.x*10);
 | 
				
			||||||
 | 
					  pnt.v -= short(orig.y*10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return pnt;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPrint_preview_window::update()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (!_locked)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _printer->print_page(_page);
 | 
				
			||||||
 | 
					    TString80 str;
 | 
				
			||||||
 | 
					    str.format(FR("Pagina %u di %u"), _page, _last);
 | 
				
			||||||
 | 
					    statbar_set_title(TASK_WIN, str);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define POPUP_FIRST      20883
 | 
				
			||||||
 | 
					#define POPUP_PREV       20884
 | 
				
			||||||
 | 
					#define POPUP_NEXT       20885
 | 
				
			||||||
 | 
					#define POPUP_SEARCH     20886
 | 
				
			||||||
 | 
					#define POPUP_LAST       20887
 | 
				
			||||||
 | 
					#define POPUP_ZOOMIN     20888
 | 
				
			||||||
 | 
					#define POPUP_ZOOMOUT    20889
 | 
				
			||||||
 | 
					#define POPUP_GRID       20890
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPrint_preview_window::popup_menu(EVENT* ep)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  MENU_ITEM menu[16];  // Stiamo larghi
 | 
				
			||||||
 | 
					  memset(menu, 0, sizeof(menu));
 | 
				
			||||||
 | 
					  menu[0].tag = POPUP_FIRST;   menu[0].text = (char*)TR("Prima");    menu[0].enabled = true;
 | 
				
			||||||
 | 
					  menu[1].tag = POPUP_PREV;    menu[1].text = (char*)TR("Indietro"); menu[1].enabled = _page > 1;
 | 
				
			||||||
 | 
					  menu[2].tag = POPUP_NEXT;    menu[2].text = (char*)TR("Avanti");   menu[2].enabled = _last == 0 || _page < _last;
 | 
				
			||||||
 | 
					  menu[3].tag = POPUP_LAST;    menu[3].text = (char*)TR("Ultima");   menu[3].enabled = true;
 | 
				
			||||||
 | 
					  menu[4].tag = -1;            menu[4].separator = true;
 | 
				
			||||||
 | 
					  menu[5].tag = POPUP_ZOOMIN;  menu[5].text = (char*)TR("Zoom +");   menu[5].enabled = _zoom < 300;
 | 
				
			||||||
 | 
					  menu[6].tag = POPUP_ZOOMOUT; menu[6].text = (char*)TR("Zoom -");   menu[6].enabled = _zoom >  75;
 | 
				
			||||||
 | 
					  menu[7].tag = -1;            menu[7].separator = true;
 | 
				
			||||||
 | 
					  menu[8].tag = POPUP_GRID;    menu[8].text = (char*)TR("Griglia");  menu[8].enabled = true; 
 | 
				
			||||||
 | 
					                               menu[8].checkable = true;             menu[8].checked = _printer->show_preview_grid();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const PNT& p = ep->v.mouse.where;
 | 
				
			||||||
 | 
					  xvt_menu_popup(menu, win(), p, XVT_POPUP_CENTER, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPrint_preview_window::page_select()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TMask m("Ricerca", 1, 28, 4);
 | 
				
			||||||
 | 
					  m.add_number(101, 0, "Pagina ", 1, 1, 4,  "U").check_type(CHECK_REQUIRED);
 | 
				
			||||||
 | 
					  m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); 
 | 
				
			||||||
 | 
					  m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
 | 
				
			||||||
 | 
					  if (m.run())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _page = m.get_int(101);
 | 
				
			||||||
 | 
					    if (_last > 0 && _page > _last)
 | 
				
			||||||
 | 
					      _page = _last;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPrint_preview_window::handler(WINDOW win, EVENT* ep)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  switch (ep->type)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					  case E_MOUSE_MOVE:
 | 
				
			||||||
 | 
					    if (_printer->find_link(ep->v.mouse.where) != NULL)
 | 
				
			||||||
 | 
					      xvt_win_set_cursor(win, CURSOR_CROSS);
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      xvt_win_set_cursor(win, CURSOR_ARROW);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case E_MOUSE_DOWN:
 | 
				
			||||||
 | 
					    if (ep->v.mouse.button == 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      const TReport_link* lnk = _printer->find_link(ep->v.mouse.where);
 | 
				
			||||||
 | 
					      if (lnk != NULL)
 | 
				
			||||||
 | 
					        _printer->on_link(*lnk);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      popup_menu(ep);
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  case E_COMMAND:
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      bool processed = true;
 | 
				
			||||||
 | 
					      switch(ep->v.cmd.tag)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					      case POPUP_FIRST  : _page = 1; break;
 | 
				
			||||||
 | 
					      case POPUP_PREV   : if (_page > 1) _page--; break;
 | 
				
			||||||
 | 
					      case POPUP_SEARCH : page_select(); break;
 | 
				
			||||||
 | 
					      case POPUP_NEXT   : if (_last == 0 || _page < _last) _page++; break;
 | 
				
			||||||
 | 
					      case POPUP_LAST   : 
 | 
				
			||||||
 | 
					        if (_last == 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          _printer->print_page(9999);
 | 
				
			||||||
 | 
					          _last = _printer->last_printed_page();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        _page = _last;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      case POPUP_ZOOMIN : if (_zoom < 300) { _zoom += 25; } break;
 | 
				
			||||||
 | 
					      case POPUP_ZOOMOUT: if (_zoom >  75) { _zoom -= 25; } break;
 | 
				
			||||||
 | 
					      case POPUP_GRID   : _printer->toggle_preview_grid();  break;
 | 
				
			||||||
 | 
					      default:processed = false; break;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (processed)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        _print_aborted = false;
 | 
				
			||||||
 | 
					        force_update();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  default:
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  TField_window::handler(win, ep);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPrint_preview_window::on_key(KEY k)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  bool ok = true;
 | 
				
			||||||
 | 
					  switch (k)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					  case '+'     : dispatch_e_menu(win(), POPUP_ZOOMIN); break; 
 | 
				
			||||||
 | 
					  case '-'     : dispatch_e_menu(win(), POPUP_ZOOMOUT); break;
 | 
				
			||||||
 | 
					  case K_HOME  :
 | 
				
			||||||
 | 
					  case K_LHOME : dispatch_e_menu(win(), POPUP_FIRST); break;
 | 
				
			||||||
 | 
					  case K_LEFT  : dispatch_e_menu(win(), POPUP_PREV); break;
 | 
				
			||||||
 | 
					  case K_RIGHT : dispatch_e_menu(win(), POPUP_NEXT); break;
 | 
				
			||||||
 | 
					  case K_END:
 | 
				
			||||||
 | 
					  case K_LEND  : dispatch_e_menu(win(), POPUP_LAST); break;
 | 
				
			||||||
 | 
					  case 'G'     : 
 | 
				
			||||||
 | 
					  case 'g'     : dispatch_e_menu(win(), POPUP_GRID); break;
 | 
				
			||||||
 | 
					  default      : ok = TField_window::on_key(k); break;
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent, 
 | 
				
			||||||
 | 
					                                             TWindowed_field* owner, TPage_printer* printer)
 | 
				
			||||||
 | 
					: TField_window(x, y, dx, dy, parent, owner), _printer(printer), 
 | 
				
			||||||
 | 
					  _page(1), _last(0), _zoom(120)
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  RCT rct; xvt_vobj_get_client_rect(win(), &rct);
 | 
				
			||||||
 | 
					  set_scroll_max(rct.right, rct.bottom);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TPrint_preview_field
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TPrint_preview_field : public TWindowed_field
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPage_printer* _printer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual TField_window* create_window(int x, int y, int dx, int dy, WINDOW parent);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TPrint_preview_field(TMask* m, TPage_printer* printer) : TWindowed_field(m), _printer(printer) { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TField_window* TPrint_preview_field::create_window(int x, int y, int dx, int dy, WINDOW parent)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return new TPrint_preview_window(x, y, dx, dy, parent, this, _printer);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TPreview_mask
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TPreview_mask : public TAutomask
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPage_printer* _printer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual bool on_key(KEY k);
 | 
				
			||||||
 | 
					  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
				
			||||||
 | 
					  virtual TMask_field* parse_field(TScanner& scanner);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  TPreview_mask(TPage_printer* printer);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPreview_mask::on_key(KEY k)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  switch (k)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					  case '+'    :
 | 
				
			||||||
 | 
					  case '-'    :
 | 
				
			||||||
 | 
					  case K_HOME : 
 | 
				
			||||||
 | 
					  case K_LHOME: 
 | 
				
			||||||
 | 
					  case K_LEFT : 
 | 
				
			||||||
 | 
					  case K_RIGHT:
 | 
				
			||||||
 | 
					  case K_END  :
 | 
				
			||||||
 | 
					  case K_LEND :
 | 
				
			||||||
 | 
					  case 'G'    :
 | 
				
			||||||
 | 
					  case 'g'    :
 | 
				
			||||||
 | 
					    dispatch_e_char(_printer->win(), k);
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					  default:
 | 
				
			||||||
 | 
					    break;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return TAutomask::on_key(k);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPreview_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (e == fe_button)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    switch (o.dlg()) 
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    case DLG_FIRSTREC: dispatch_e_menu(_printer->win(), POPUP_FIRST); break;
 | 
				
			||||||
 | 
					    case DLG_PREVREC : dispatch_e_menu(_printer->win(), POPUP_PREV);  break;
 | 
				
			||||||
 | 
					    case DLG_FINDREC : dispatch_e_menu(_printer->win(), POPUP_SEARCH);break;
 | 
				
			||||||
 | 
					    case DLG_NEXTREC : dispatch_e_menu(_printer->win(), POPUP_NEXT);  break;
 | 
				
			||||||
 | 
					    case DLG_LASTREC : dispatch_e_menu(_printer->win(), POPUP_LAST);  break;
 | 
				
			||||||
 | 
					    default: break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TMask_field* TPreview_mask::parse_field(TScanner& scanner)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (scanner.token().starts_with("PR"))
 | 
				
			||||||
 | 
					    return new TPrint_preview_field(this, _printer);
 | 
				
			||||||
 | 
					  return TAutomask::parse_field(scanner);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPreview_mask::TPreview_mask(TPage_printer* printer) 
 | 
				
			||||||
 | 
					             : _printer(printer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  read_mask("ba8303", 0, -1); 
 | 
				
			||||||
 | 
					  set_handlers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int pos = id2pos(DLG_FINDREC);
 | 
				
			||||||
 | 
					  if (pos >= 0 && id2pos(DLG_FIRSTREC) >= 0) //se e' un bottone pentapartito...
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							TButton_field& f_find = (TButton_field &)fld(pos);
 | 
				
			||||||
 | 
							RCT rct_base;	f_find.get_rect(rct_base);
 | 
				
			||||||
 | 
					    const int bwidth = (rct_base.right - rct_base.left);
 | 
				
			||||||
 | 
					    const int bheight = (rct_base.bottom - rct_base.top);
 | 
				
			||||||
 | 
					    if (bwidth > 3*bheight/2) // Controllo se ho gia' ridimensionato i bottoni in precedenza
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
							  int bx = bwidth / 3;
 | 
				
			||||||
 | 
							  int by = bheight / 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      RCT r = rct_base; r.left += bx-2;  r.right -= bx-2;
 | 
				
			||||||
 | 
								f_find.set_rect(r); // Ridimensiona il bottone centrale di ricerca
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
					      bx += 5; by += 3;   // Aggiusta dimensioni bottoni sussidiari
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							  pos = id2pos(DLG_FIRSTREC);
 | 
				
			||||||
 | 
							  if (pos >= 0)
 | 
				
			||||||
 | 
							  {	
 | 
				
			||||||
 | 
								  r = rct_base; r.top = r.bottom - by;  r.right = r.left + bx;
 | 
				
			||||||
 | 
								  fld(pos).set_rect(r);
 | 
				
			||||||
 | 
							  }
 | 
				
			||||||
 | 
							  pos = id2pos(DLG_PREVREC);
 | 
				
			||||||
 | 
							  if (pos >= 0) 
 | 
				
			||||||
 | 
							  {
 | 
				
			||||||
 | 
								  r = rct_base; r.bottom = r.top + by;  r.right = r.left + bx;
 | 
				
			||||||
 | 
								  fld(pos).set_rect(r);
 | 
				
			||||||
 | 
							  }
 | 
				
			||||||
 | 
							  pos = id2pos(DLG_NEXTREC);
 | 
				
			||||||
 | 
							  if (pos >= 0) 
 | 
				
			||||||
 | 
							  {
 | 
				
			||||||
 | 
								  r = rct_base; r.bottom = r.top + by;  r.left = r.right - bx;
 | 
				
			||||||
 | 
								  fld(pos).set_rect(r);
 | 
				
			||||||
 | 
							  }
 | 
				
			||||||
 | 
							  pos = id2pos(DLG_LASTREC);
 | 
				
			||||||
 | 
							  if (pos >= 0) 
 | 
				
			||||||
 | 
							  {
 | 
				
			||||||
 | 
								  r = rct_base; r.top = r.bottom - by;  r.left = r.right - bx;
 | 
				
			||||||
 | 
								  fld(pos).set_rect(r);
 | 
				
			||||||
 | 
							  }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TPage_printer
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char* TPage_printer::form_name() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return printer().get_form_name();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char* TPage_printer::font_name() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return printer().fontname();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int TPage_printer::font_size() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return printer().get_char_size();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::ask_pages()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (_pageto <= 0)
 | 
				
			||||||
 | 
					    _pageto = pages();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TPrinter& p = printer();
 | 
				
			||||||
 | 
					  TMask msk("bagn003");
 | 
				
			||||||
 | 
					  msk.set(F_PRINTER, p.printername());
 | 
				
			||||||
 | 
					  msk.set(F_FORM, form_name());
 | 
				
			||||||
 | 
					  msk.set(F_FONT, font_name());
 | 
				
			||||||
 | 
					  msk.set(F_SIZE, font_size());
 | 
				
			||||||
 | 
					  msk.set(F_ISGRAPHICS, p.isgraphics() ? "X" : "");
 | 
				
			||||||
 | 
					  msk.set(F_FROMPAGE, _pagefrom);
 | 
				
			||||||
 | 
					  msk.set(F_TOPAGE, _pageto);
 | 
				
			||||||
 | 
					  msk.set(F_COPIES, _copies);
 | 
				
			||||||
 | 
					  const bool ok = msk.run() == K_ENTER;
 | 
				
			||||||
 | 
					  if (ok)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _copies = msk.get_int(F_COPIES);
 | 
				
			||||||
 | 
					    _pagefrom = msk.get_int(F_FROMPAGE);
 | 
				
			||||||
 | 
					    _pageto = msk.get_int(F_TOPAGE);
 | 
				
			||||||
 | 
					    if (_pageto < _pagefrom)
 | 
				
			||||||
 | 
					      _pageto = 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::main_loop()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPrinter& p = printer();
 | 
				
			||||||
 | 
					  _rcd = p.get_printrcd();
 | 
				
			||||||
 | 
					  if (!xvt_print_is_valid(_rcd))
 | 
				
			||||||
 | 
					    return false; // aborted
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  WINDOW prwin = xvt_print_create_win(_rcd, (char*)(const char*)form_name());
 | 
				
			||||||
 | 
					  if (prwin == NULL_WIN) 
 | 
				
			||||||
 | 
					    return false; // aborted
 | 
				
			||||||
 | 
					  set_win(prwin);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, _rcd, &_ph, &_pw, &_pvr, &_phr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (_pw <= 0 || _ph <= 0)
 | 
				
			||||||
 | 
					    return error_box(TR("Dimensioni pagina NULLE"));
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  bool ok = true;
 | 
				
			||||||
 | 
					  if (_pvr < 150 || _phr < 150)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ok = yesno_box(TR("Stampante obsoleta o non adeguatamente configurata:\n"
 | 
				
			||||||
 | 
					                      "Risoluzione %ldx%ld. Continuare ugualmente?"), _phr, _pvr);
 | 
				
			||||||
 | 
					    if (!ok)
 | 
				
			||||||
 | 
					      return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  _print_aborted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (word c = 0; c < _copies && ok; c++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _page = 0;
 | 
				
			||||||
 | 
					    ok = print_loop();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  _print_aborted = false;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  xvt_vobj_destroy(prwin);
 | 
				
			||||||
 | 
					  set_win(NULL_WIN);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::page_in_range() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (_page < _pagefrom)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  return _pageto < _pagefrom || _page <= _pageto;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PNT TPage_printer::log2dev(long lx, long ly) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (preview_mode())
 | 
				
			||||||
 | 
					    return _preview_window->log2dev(lx, ly);
 | 
				
			||||||
 | 
					  const PNT p = { short(ly), short(lx) };
 | 
				
			||||||
 | 
					  return p;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPoint TPage_printer::dev2log(const PNT& pnt) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  CHECK(0, "dev2log: Pure virtual funtion call");
 | 
				
			||||||
 | 
					  const TPoint p;
 | 
				
			||||||
 | 
					  return p;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::open_page()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  _page++;
 | 
				
			||||||
 | 
					  if (page_in_range())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (print_mode())
 | 
				
			||||||
 | 
					      _page_is_open = xvt_print_open_page(_rcd) != 0;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      _page_is_open = true;
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      _links.destroy(); // Distrugge elenco dei links
 | 
				
			||||||
 | 
					      _links_sorted = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    _page_is_open = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return _page_is_open;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::close_page()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const bool was_open = _page_is_open;
 | 
				
			||||||
 | 
					  if (was_open)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (print_mode())
 | 
				
			||||||
 | 
					      xvt_print_close_page(_rcd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _page_is_open = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return was_open;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPage_printer::add_link(TReport_link* link)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  _links.add(link);
 | 
				
			||||||
 | 
					  _links_sorted = false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static BOOLEAN main_loop_callback(long jolly)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPage_printer* pp = (TPage_printer*)jolly;
 | 
				
			||||||
 | 
					  return pp->main_loop();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::do_print()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  _print_aborted = true;
 | 
				
			||||||
 | 
					  bool ok = ask_pages();
 | 
				
			||||||
 | 
					  if (ok)
 | 
				
			||||||
 | 
					    ok = xvt_print_start_thread(main_loop_callback, long(this)) == FALSE;
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TPage_printer::print_page(word page)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  _pagefrom = _pageto = page;
 | 
				
			||||||
 | 
					  _page = 0;
 | 
				
			||||||
 | 
					  print_loop();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::do_preview()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  _print_aborted = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TPrinter& p = printer();
 | 
				
			||||||
 | 
					  _rcd = p.get_printrcd();
 | 
				
			||||||
 | 
					  if (!xvt_print_is_valid(_rcd))
 | 
				
			||||||
 | 
					    return error_box(TR("Stampante non valida"));
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  xvt_app_escape (XVT_ESC_GET_PRINTER_INFO, _rcd, &_ph, &_pw, &_pvr, &_phr);
 | 
				
			||||||
 | 
					  if (_pw <= 0 || _ph <= 0)
 | 
				
			||||||
 | 
					    return error_box(TR("Dimensioni pagina NULLE"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  _preview_mask = new TPreview_mask(this);
 | 
				
			||||||
 | 
					  TPrint_preview_field& pf = (TPrint_preview_field&)_preview_mask->field(DLG_USER);
 | 
				
			||||||
 | 
					  _preview_window = &pf.win();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  set_win(_preview_window->win());
 | 
				
			||||||
 | 
					  _pagefrom = _pageto = _page = 1;
 | 
				
			||||||
 | 
					  _print_aborted = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const KEY key = _preview_mask->run();
 | 
				
			||||||
 | 
					  set_win(NULL_WIN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  delete _preview_mask;
 | 
				
			||||||
 | 
					  _preview_mask = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (key == K_INS)
 | 
				
			||||||
 | 
					    print();
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const TReport_link* TPage_printer::find_link(const PNT& pnt) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (!_links_sorted)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    TPage_printer* myself = (TPage_printer*)this;
 | 
				
			||||||
 | 
					    myself->_links.sort();
 | 
				
			||||||
 | 
					    myself->_links_sorted = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int primo = 0, ultimo = _links.last();
 | 
				
			||||||
 | 
					  while (primo <= ultimo)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const int in_mezzo = (primo+ultimo)/2;
 | 
				
			||||||
 | 
					    const TReport_link* lnk = (const TReport_link*)_links.objptr(in_mezzo);
 | 
				
			||||||
 | 
					    const int cmp = lnk->hit_test(pnt);
 | 
				
			||||||
 | 
					    if (cmp == 0)
 | 
				
			||||||
 | 
					      return lnk;
 | 
				
			||||||
 | 
					    if (cmp < 0)
 | 
				
			||||||
 | 
					      ultimo = in_mezzo-1;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      primo = in_mezzo+1;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return NULL;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::on_link(const TReport_link& lnk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return false;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TPage_printer::print(bool prev_mode)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return prev_mode ? do_preview() : do_print();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPoint TPage_printer::page_size() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return TPoint(_pw, _ph);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPoint TPage_printer::page_res() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TPoint pt(_phr, _pvr);
 | 
				
			||||||
 | 
					  return pt;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPage_printer::TPage_printer() 
 | 
				
			||||||
 | 
					             : _pagefrom(1), _pageto(0), _copies(1), _preview_mask(NULL), _draw_grid(true)
 | 
				
			||||||
 | 
					{ 
 | 
				
			||||||
 | 
					  _pixmap = true; // Fondamentale!!!
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TPage_printer::~TPage_printer() 
 | 
				
			||||||
 | 
					{ }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// TReport_printer
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char* TReport_printer::form_name() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return _report.filename();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char* TReport_printer::font_name() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return _report.font().name();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int TReport_printer::font_size() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return _report.font().size();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PNT TReport_printer::log2dev(long lx, long ly) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const TPoint res = page_res();
 | 
				
			||||||
 | 
					  const double cx = (double)res.x / (double)_report.cpi();
 | 
				
			||||||
 | 
					  const double cy = (double)res.y / (double)_report.lpi();
 | 
				
			||||||
 | 
					  const long x = long((lx + _delta.x) * cx / 100.0);
 | 
				
			||||||
 | 
					  const long y = long((ly + _delta.y) * cy / 100.0);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return TPage_printer::log2dev(x, y); // Useful for preview mode
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					long TReport_printer::print_section(char type, int level)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  long h = 0;
 | 
				
			||||||
 | 
					  TReport_section* rs = _report.find_section(type, level);
 | 
				
			||||||
 | 
					  if (rs != NULL)
 | 
				
			||||||
 | 
					    h = print_section(*rs);
 | 
				
			||||||
 | 
					  return h;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TReport_printer::draw_preview_page()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  clear(COLOR_WHITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (_draw_grid)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const int max = 192;
 | 
				
			||||||
 | 
					    const int k = 100;
 | 
				
			||||||
 | 
					    for (int i = 1; i < max; i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      set_pen((i%10) ? MAKE_COLOR(232,232,232) : COLOR_LTGRAY);
 | 
				
			||||||
 | 
					      line(0, i*k, max*k, i*k);
 | 
				
			||||||
 | 
					      line(i*k, 0, i*k, max*k);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const PNT pag = log2dev(_logical_page_width, _logical_page_height);
 | 
				
			||||||
 | 
					  hide_pen();
 | 
				
			||||||
 | 
					  set_brush(COLOR_GRAY);
 | 
				
			||||||
 | 
					  RCT rct; 
 | 
				
			||||||
 | 
					  xvt_vobj_get_client_rect(win(), &rct); rct.left = pag.h;
 | 
				
			||||||
 | 
					  xvt_dwin_draw_rect(win(), &rct);
 | 
				
			||||||
 | 
					  xvt_vobj_get_client_rect(win(), &rct); rct.top = pag.v;
 | 
				
			||||||
 | 
					  xvt_dwin_draw_rect(win(), &rct);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TReport_printer::open_page()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  const bool ok = TPage_printer::open_page();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  _report.set_curr_page(_page);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  _delta.reset();
 | 
				
			||||||
 | 
					  _page_break_allowed = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (ok && preview_mode()) // Clear page needed
 | 
				
			||||||
 | 
					    draw_preview_page();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_section* page_background = _report.find_section('B', 0);
 | 
				
			||||||
 | 
					  if (page_background != NULL)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _delta = page_background->pos();
 | 
				
			||||||
 | 
					    print_section(*page_background);
 | 
				
			||||||
 | 
					    _delta.reset();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (_page == 1)
 | 
				
			||||||
 | 
					    _delta.y += print_section('H', 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_section* page_head = _report.find_section('H', 0);
 | 
				
			||||||
 | 
					  if (page_head != NULL && (_page > 1 || !page_head->hidden_if_needed()))
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    _delta += page_head->pos();
 | 
				
			||||||
 | 
					    _delta.y += print_section(*page_head);
 | 
				
			||||||
 | 
					    _delta.x = 0;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TReport_printer::close_page()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (_page_is_open)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    TReport_section* page_foot = _report.find_section('F', 0);
 | 
				
			||||||
 | 
					    if (page_foot != NULL && (!_is_last_page || !page_foot->hidden_if_needed()))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      _delta.x = page_foot->pos().x;
 | 
				
			||||||
 | 
					      _delta.y = _logical_foot_pos;
 | 
				
			||||||
 | 
					      print_section(*page_foot);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return TPage_printer::close_page();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void TReport_printer::create_links(const TReport_section& rs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TAssoc_array* links = NULL;
 | 
				
			||||||
 | 
					  for (int i = 0; i < rs.items(); i++)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const TReport_field& rf = rs.field(i);
 | 
				
			||||||
 | 
					    if (rf.link().not_empty())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if (links == NULL)
 | 
				
			||||||
 | 
					        links = new TAssoc_array;
 | 
				
			||||||
 | 
					      TToken_string tok(rf.link(), '.');
 | 
				
			||||||
 | 
					      TString table, field;
 | 
				
			||||||
 | 
					      tok.get(0, table); tok.get(1, field);
 | 
				
			||||||
 | 
					      TReport_link* rl = (TReport_link*)links->objptr(table);
 | 
				
			||||||
 | 
					      if (rl == NULL)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        rl = new TReport_link(table);
 | 
				
			||||||
 | 
					        links->add(table, rl);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      RCT rct; TWindow::log2dev(rf.get_rect(), rct); 
 | 
				
			||||||
 | 
					      rl->add_rect(rct);
 | 
				
			||||||
 | 
					      rl->set(field, rf.get());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (links != NULL)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    FOR_EACH_ASSOC_OBJECT((*links), h, key, l)
 | 
				
			||||||
 | 
					      add_link((TReport_link*)l);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					long TReport_printer::print_section(TReport_section& rs)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  if (_print_aborted)
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  rs.load_fields();
 | 
				
			||||||
 | 
					  rs.execute_prescript();
 | 
				
			||||||
 | 
					  const long height = rs.compute_size().y; // Compute size after the initilization script!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (height > 0) // Has some visible fields
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    bool page_break = _page_break_allowed && rs.page_break();
 | 
				
			||||||
 | 
					    if (!page_break)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      long h = height;
 | 
				
			||||||
 | 
					      if (rs.keep_with_next())
 | 
				
			||||||
 | 
					        h += rs.report().section('B', 1).compute_size().y;
 | 
				
			||||||
 | 
					      page_break = (_delta.y + h > _logical_foot_pos);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (page_break && rs.level() > 0) // Avoid recursion
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      close_page();
 | 
				
			||||||
 | 
					      open_page();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (_page_is_open)
 | 
				
			||||||
 | 
					      rs.draw(*this, preview_mode() ? rdm_print_preview : rdm_print);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (rs.level() > 0) // Ho stampa qualcosa che non sia lo sfondo!
 | 
				
			||||||
 | 
					      _page_break_allowed = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  rs.execute_postscript();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (_page_is_open && height > 0 && preview_mode())
 | 
				
			||||||
 | 
					    create_links(rs);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  return height;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TReport_printer::print_loop()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TRecordset* rex = _report.recordset();
 | 
				
			||||||
 | 
					  if (rex == NULL || rex->items() <= 0)
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const TPoint siz = page_size();
 | 
				
			||||||
 | 
					  const TPoint res = page_res();
 | 
				
			||||||
 | 
					  const double pollici_pagina_y = (double)siz.y / (double)res.y;
 | 
				
			||||||
 | 
					  const double righe_pagina = pollici_pagina_y * _report.lpi();
 | 
				
			||||||
 | 
					  _logical_page_height = long(righe_pagina*100.0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const double pollici_pagina_x = (double)siz.x / (double)res.x;
 | 
				
			||||||
 | 
					  const double colonne_pagina = pollici_pagina_x * _report.cpi();
 | 
				
			||||||
 | 
					  _logical_page_width = long(colonne_pagina*100.0);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  const TReport_section& footer = _report.section('F',0);
 | 
				
			||||||
 | 
					  _logical_foot_pos = footer.pos().y;
 | 
				
			||||||
 | 
					  if (_logical_foot_pos <= 0)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    const long logical_footer_height = footer.compute_size().y;
 | 
				
			||||||
 | 
					    _logical_foot_pos = _logical_page_height - logical_footer_height;  
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  _report.unmap_font(); // Gestire bene le riscalature
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TString_array oldgroup, newgroup;
 | 
				
			||||||
 | 
					  const int max_group = _report.find_max_level('H');
 | 
				
			||||||
 | 
					  if (max_group >= 2)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    for (int g = 2; g <= max_group; g++)
 | 
				
			||||||
 | 
					      oldgroup.add(EMPTY_STRING, g);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  const int max_body = _report.find_max_level('B');
 | 
				
			||||||
 | 
					  int last_body_height = 0;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  _is_last_page = false;
 | 
				
			||||||
 | 
					  open_page();
 | 
				
			||||||
 | 
					  bool aborted = false;
 | 
				
			||||||
 | 
					  for (bool ok = rex->move_to(0); ok; ok = rex->move_next())
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (_pageto >= _pagefrom && _page > _pageto || _print_aborted) // out of range
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      aborted = true;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (max_group >= 2) // Gestione raggruppamenti
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      int changed = 0;
 | 
				
			||||||
 | 
					      TVariant var;
 | 
				
			||||||
 | 
					      for (int g = 2; g <= max_group; g++)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        const TString& expr = _report.section('H', g).grouped_by();
 | 
				
			||||||
 | 
					        _report.evaluate(expr, var, _alfafld);
 | 
				
			||||||
 | 
					        const TString& grp = var.as_string();
 | 
				
			||||||
 | 
					        newgroup.add(grp, g);
 | 
				
			||||||
 | 
					        if (newgroup.row(g) != oldgroup.row(g) || rex->current_row() == 0)
 | 
				
			||||||
 | 
					          changed = g;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (changed)
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        oldgroup = newgroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (_delta.x > 0) // Devo tornare a capo!
 | 
				
			||||||
 | 
					          _delta.y += last_body_height;
 | 
				
			||||||
 | 
					        _delta.x = 0;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (rex->current_row() > 0)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          for (int g = 2; g <= changed; g++)
 | 
				
			||||||
 | 
					            _delta.y += print_section('F', g);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        for (int g = changed; g >= 2 ; g--)
 | 
				
			||||||
 | 
					          _delta.y += print_section('H', g);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (int b = 1; b <= max_body; b++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      const int dy = print_section('B', b);
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      int column_delta = 0;
 | 
				
			||||||
 | 
					      // Cerco di vedere se e' possibile la stampa etichette
 | 
				
			||||||
 | 
					      if (dy > 0) 
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        const int dx = _report.section('B', b).size().x;
 | 
				
			||||||
 | 
					        // Se dx > 0 ho una sezione a dimensione fissa
 | 
				
			||||||
 | 
					        if (dx > 0 && _delta.x+2*dx <= _logical_page_width)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					          column_delta = dx;
 | 
				
			||||||
 | 
					          last_body_height = dy;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      if (column_delta > 0)
 | 
				
			||||||
 | 
					        _delta.x += column_delta;
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        _delta.x = 0;
 | 
				
			||||||
 | 
					        _delta.y += dy;
 | 
				
			||||||
 | 
					        last_body_height = 0; // Non servirebbe strettamente
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (!aborted)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    if (max_group >= 2) // Devo stampare tutte le code dei raggrupamenti
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      for (int g = 2; g <= max_group; g++)
 | 
				
			||||||
 | 
					        _delta.y += print_section('F', g);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (rex->eof())
 | 
				
			||||||
 | 
					      print_section('F', 1);
 | 
				
			||||||
 | 
					    _is_last_page = true;
 | 
				
			||||||
 | 
					    close_page();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  _lastprinted = _page;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TReport_printer::print(bool preview_mode)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  bool ok = _report.execute_prescript();
 | 
				
			||||||
 | 
					  if (ok)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    ok = TPage_printer::print(preview_mode);
 | 
				
			||||||
 | 
					    if (ok)
 | 
				
			||||||
 | 
					      _report.execute_postscript();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return ok;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool TReport_printer::on_link(const TReport_link& lnk)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  return _report.on_link(lnk);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					// Remote control interface
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void lock_preview_update(bool yes)
 | 
				
			||||||
 | 
					{ TPrint_preview_window::lock_preview_update(yes); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void abort_printing()
 | 
				
			||||||
 | 
					{ _print_aborted = true; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										100
									
								
								include/reprint.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										100
									
								
								include/reprint.h
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,100 @@
 | 
				
			|||||||
 | 
					#ifndef __REPRINT_H
 | 
				
			||||||
 | 
					#define __REPRINT_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef __REPORT_H
 | 
				
			||||||
 | 
					#include <report.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TPage_printer : public TWindow
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  PRINT_RCD* _rcd;
 | 
				
			||||||
 | 
					  long _pw, _ph, _phr, _pvr; // Printer width, height, horizontal and vertical resolution
 | 
				
			||||||
 | 
					  TArray _links;
 | 
				
			||||||
 | 
					  bool _links_sorted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  word _copies, _pagefrom, _pageto, _page, _lastprinted;
 | 
				
			||||||
 | 
					  bool _page_is_open, _draw_grid;
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					  TMask* _preview_mask;      // owned object
 | 
				
			||||||
 | 
					  TWindow* _preview_window;  // referenced object
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual word pages() const { return 0; }
 | 
				
			||||||
 | 
					  virtual bool print_loop() pure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					  virtual TPoint dev2log(const PNT& p) const;  // Never use this!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual PNT log2dev(long lx, long ly) const; // Always override this!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual const char* form_name() const;
 | 
				
			||||||
 | 
					  virtual const char* font_name() const;
 | 
				
			||||||
 | 
					  virtual int font_size() const;
 | 
				
			||||||
 | 
					  virtual bool ask_pages();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual bool open_page();
 | 
				
			||||||
 | 
					  virtual bool close_page();
 | 
				
			||||||
 | 
					  bool page_in_range() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Called by print(bool)
 | 
				
			||||||
 | 
					  virtual bool do_print();  
 | 
				
			||||||
 | 
					  virtual bool do_preview();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  bool main_loop();          // Internal use only  
 | 
				
			||||||
 | 
					  virtual void print_page(word page);  // Inefficient default implementation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual TPoint page_size() const;
 | 
				
			||||||
 | 
					  virtual TPoint page_res() const;
 | 
				
			||||||
 | 
					  virtual word last_printed_page() { return _lastprinted; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual bool print(bool preview = false);
 | 
				
			||||||
 | 
					  bool print_mode() const { return _preview_mask == NULL; }
 | 
				
			||||||
 | 
					  bool preview_mode() const { return _preview_mask != NULL; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void toggle_preview_grid() { _draw_grid = !_draw_grid; }
 | 
				
			||||||
 | 
					  bool show_preview_grid() const { return _draw_grid; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void add_link(TReport_link* link);
 | 
				
			||||||
 | 
					  const TReport_link* find_link(const PNT& pnt) const;
 | 
				
			||||||
 | 
					  virtual bool on_link(const TReport_link& lnk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TPage_printer();
 | 
				
			||||||
 | 
					  virtual ~TPage_printer();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class TReport_printer : public TPage_printer
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  TReport& _report;
 | 
				
			||||||
 | 
					  TPoint _delta;
 | 
				
			||||||
 | 
					  long _logical_page_height, _logical_page_width;
 | 
				
			||||||
 | 
					  long _logical_foot_pos;
 | 
				
			||||||
 | 
					  bool _is_last_page, _page_break_allowed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					  virtual const char* form_name() const;
 | 
				
			||||||
 | 
					  virtual const char* font_name() const;
 | 
				
			||||||
 | 
					  virtual int font_size() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual PNT log2dev(long x, long y) const;
 | 
				
			||||||
 | 
					  virtual bool print_loop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  virtual void draw_preview_page();
 | 
				
			||||||
 | 
					  virtual bool open_page();
 | 
				
			||||||
 | 
					  virtual bool close_page();
 | 
				
			||||||
 | 
					  long print_section(TReport_section& rs);
 | 
				
			||||||
 | 
					  long print_section(char type, int level);
 | 
				
			||||||
 | 
					  void create_links(const TReport_section& rs);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					  virtual bool print(bool preview = false);
 | 
				
			||||||
 | 
					  virtual bool on_link(const TReport_link& lnk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  TReport_printer(TReport& r) : _report(r) { }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void lock_preview_update(bool yes);
 | 
				
			||||||
 | 
					void abort_printing();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class TSheet_control : public TControl
 | 
					class TSheet_control : public TControl
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  enum { FIRST_FIELD = 101, MAX_COL = 128 };
 | 
					  enum { FIRST_FIELD = 101, MAX_COL = 256 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  TSheet* _sheet;
 | 
					  TSheet* _sheet;
 | 
				
			||||||
  long _cur_rec;
 | 
					  long _cur_rec;
 | 
				
			||||||
@ -117,15 +117,14 @@ TSheet_control::TSheet_control(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  TToken_string header(head);
 | 
					  TToken_string header(head);
 | 
				
			||||||
  TToken_string new_header(256);
 | 
					  TToken_string new_header(256);
 | 
				
			||||||
  int i = 0;
 | 
					 | 
				
			||||||
  int f_width = NUMBER_WIDTH;                          // Stima larghezza colonne fisse
 | 
					  int f_width = NUMBER_WIDTH;                          // Stima larghezza colonne fisse
 | 
				
			||||||
  int max_width = f_width;                             // Stima larghezza della colonna piu' grande
 | 
					  int max_width = f_width;                             // Stima larghezza della colonna piu' grande
 | 
				
			||||||
  int lines_in_header = 1;
 | 
					  int lines_in_header = 1;
 | 
				
			||||||
  const char * h;
 | 
					  const char * h;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  for (h = header.get(); h; h = header.get(), i++)
 | 
					  int i = 0;
 | 
				
			||||||
 | 
					  for (h = header.get(); h && i < MAX_COL; h = header.get(), i++)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    CHECKD(i < MAX_COL, "Tu meni calumns in scit: ", i);
 | 
					 | 
				
			||||||
    _type[i] = ' ';
 | 
					    _type[i] = ' ';
 | 
				
			||||||
    TString testa(h);
 | 
					    TString testa(h);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -236,7 +235,7 @@ TSheet_control::TSheet_control(
 | 
				
			|||||||
  coldef->v.column->column_platform  = TRUE;
 | 
					  coldef->v.column->column_platform  = TRUE;
 | 
				
			||||||
  coldef->v.column->center_heading   = TRUE; 
 | 
					  coldef->v.column->center_heading   = TRUE; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (h = new_header.get(0), i = 0; h; h = new_header.get(), i++)
 | 
					  for (h = new_header.get(0), i = 0; h && i < MAX_COL; h = new_header.get(), i++)
 | 
				
			||||||
  {                  
 | 
					  {                  
 | 
				
			||||||
    long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY; 
 | 
					    long attr = XI_ATR_VISIBLE | XI_ATR_ENABLED | XI_ATR_AUTOSCROLL | XI_ATR_READONLY; 
 | 
				
			||||||
    if (_type[i] == 'C') 
 | 
					    if (_type[i] == 'C') 
 | 
				
			||||||
 | 
				
			|||||||
@ -66,7 +66,7 @@ public:
 | 
				
			|||||||
  bool contains(const TPoint& p) const;
 | 
					  bool contains(const TPoint& p) const;
 | 
				
			||||||
  bool intersects(const TRectangle& r) const;
 | 
					  bool intersects(const TRectangle& r) const;
 | 
				
			||||||
  void merge(const TRectangle& r);
 | 
					  void merge(const TRectangle& r);
 | 
				
			||||||
  bool is_empty() const { return _size.x > 0 && _size.y > 0; }
 | 
					  bool is_empty() const { return _size.x == 0 || _size.y == 0; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  TRectangle& operator=(const TRectangle& r) { copy(r); return *this; }
 | 
					  TRectangle& operator=(const TRectangle& r) { copy(r); return *this; }
 | 
				
			||||||
  TRectangle() : TPoint(0,0), _size(0,0) { }
 | 
					  TRectangle() : TPoint(0,0), _size(0,0) { }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user