124 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			124 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #ifndef __FORM_H
 | |
| #define __FORM_H
 | |
| 
 | |
| #ifndef __PRINTER_H
 | |
| #include <printer.h>
 | |
| #endif
 | |
| 
 | |
| #ifndef __SCANNER_H
 | |
| #include <scanner.h>
 | |
| #endif
 | |
| 
 | |
| #ifndef __MASK_H
 | |
| class TMask;
 | |
| #endif
 | |
| 
 | |
| #ifndef __RELATION_H
 | |
| class TRelation;
 | |
| class TCursor;
 | |
| #endif
 | |
| 
 | |
| enum pagetype { odd_page, even_page, first_page, last_page };
 | |
| 
 | |
| class TForm;
 | |
| class TForm_item;
 | |
| 
 | |
| class TPrint_section : public TArray
 | |
| {
 | |
|   static TMask* _msk;
 | |
| 
 | |
|   word _height;         // Altezza della sezione
 | |
|   int _x, _y;           // Offset di stampa   
 | |
| 
 | |
|   TForm* _form;         // Form cui appartiene alla sezione
 | |
|   TArray _item;         // Lista dei campi da stampare
 | |
|   
 | |
|   const TPrint_section& copy(const TPrint_section& ps);
 | |
|   
 | |
| protected:
 | |
|   virtual void print_on(ostream& out) const;
 | |
|   virtual TForm_item* parse_item(const TString& key);
 | |
|   TForm_item* parse_item(TScanner& scanner);
 | |
| 
 | |
| public:
 | |
|   TPrintrow& row(int num);
 | |
|   TForm& form() const { return *_form; }
 | |
|   
 | |
|   TForm_item& field(int n) const { return (TForm_item&)_item[n]; }
 | |
|   word fields() const { return _item.items(); }
 | |
|   word height() const { return _height; }
 | |
|   int offset_x() const { return _x; }
 | |
|   int offset_y() const { return _y; }
 | |
|   void offset(int& x, int& y) const;
 | |
|   
 | |
|   virtual bool ok() const { return height() > 0 || fields() > 0; }
 | |
|   
 | |
|   void reset();
 | |
|   virtual bool update();
 | |
|   bool parse(TScanner& scanner);
 | |
| 
 | |
|   bool edit(const char* title, bool all);
 | |
|   
 | |
|   const TPrint_section& operator=(const TPrint_section& ps) { return copy(ps); }
 | |
|   TPrint_section(TForm* parent);
 | |
|   TPrint_section(const TPrint_section& ps) { copy(ps); }
 | |
|   virtual ~TPrint_section();
 | |
| };
 | |
| 
 | |
| 
 | |
| class TForm : public TObject
 | |
| {                    
 | |
|   friend class TForm_editor;
 | |
| 
 | |
|   TFilename _name;       // Profile name                     
 | |
| 
 | |
|   TRelation* _relation;  // Can be NULL
 | |
|   TCursor* _cursor;      // Can be NULL
 | |
| 
 | |
|   TArray _head;          // Headers
 | |
|   TArray _body;          // Bodies
 | |
|   TArray _foot;          // Footers
 | |
|   TArray _back;          // Graphic background
 | |
|   
 | |
|   bool _lastpage;        // I am about to print the last page
 | |
| 
 | |
|   TPrint_section* exist(char s, pagetype t, bool create = FALSE);   // Can be NULL
 | |
|   
 | |
|   static void header_handler(TPrinter& p);
 | |
|   static void footer_handler(TPrinter& p);
 | |
| 
 | |
| protected:                                                
 | |
|   // H = Header, B = Body, F = Footer, R = Relation
 | |
|   TPrint_section& section(char s = 'B', word page = 1);
 | |
|   word height();         // Height of first page
 | |
|   
 | |
|   void print_section(ostream& out, char s) const;
 | |
|   virtual void print_on(ostream& out) const;
 | |
|   bool edit_relation();
 | |
| 
 | |
|   bool parse_use(TScanner&);
 | |
|   bool parse_join(TScanner&);
 | |
| 
 | |
|   word page(const TPrinter& p) const;
 | |
|   
 | |
|   virtual long records() const;
 | |
|   virtual word set_background(word p, bool u);
 | |
|   virtual word set_header(word p, bool u);
 | |
|   virtual word set_body(word p, bool u);
 | |
|   virtual word set_footer(word p, bool u);
 | |
|   
 | |
| public:
 | |
|   bool print(long from = 0L, long to = -1L);
 | |
|   
 | |
|   const TFilename& name() const { return _name; }
 | |
|   
 | |
|   TRelation* relation() const { return _relation; }
 | |
|   TCursor* cursor() const { return _cursor; }
 | |
|   virtual const char* validate(const char* cur, TToken_string& val);
 | |
| 
 | |
|   TForm(const char* form);
 | |
|   virtual ~TForm();
 | |
| };
 | |
| 
 | |
| #endif
 |